Sha256: dd6045cbcf853f810123df3c9f03c70fb4d0b2f2fcc6d0112fe94a2b11f78db4

Contents?: true

Size: 767 Bytes

Versions: 12

Compression:

Stored size: 767 Bytes

Contents

class Code
  class Parser
    class Shift < Parslet::Parser
      rule(:addition) { ::Code::Parser::Addition.new }

      rule(:right_caret) { str(">") }
      rule(:left_caret) { str("<") }

      rule(:operator) do
        (left_caret >> left_caret) | (right_caret >> right_caret)
      end

      rule(:space) { str(" ") }
      rule(:newline) { str("\n") }
      rule(:whitespace) { (space | newline).repeat(1) }
      rule(:whitespace?) { whitespace.maybe }

      rule(:shift) do
        (
          addition.as(:first) >>
            (
              whitespace? >> operator.as(:operator) >> whitespace? >>
                addition.as(:statement)
            ).repeat(1).as(:rest)
        ).as(:shift) | addition
      end

      root(:shift)
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
template-ruby-0.4.0 lib/code/parser/shift.rb
code-ruby-0.4.0 lib/code/parser/shift.rb
template-ruby-0.3.1 lib/code/parser/shift.rb
code-ruby-0.3.1 lib/code/parser/shift.rb
template-ruby-0.3.0 lib/code/parser/shift.rb
code-ruby-0.3.0 lib/code/parser/shift.rb
code-ruby-0.2.4 lib/code/parser/shift.rb
template-ruby-0.2.4 lib/code/parser/shift.rb
template-ruby-0.2.3 lib/code/parser/shift.rb
template-ruby-0.2.2 lib/code/parser/shift.rb
template-ruby-0.2.1 lib/code/parser/shift.rb
template-ruby-0.2.0 lib/code/parser/shift.rb