Sha256: a9656b56459179cbfcb57bad84e98001127677a8017adfb70bf31c30e49a42f0

Contents?: true

Size: 726 Bytes

Versions: 12

Compression:

Stored size: 726 Bytes

Contents

class Code
  class Parser
    class BitwiseOr < Parslet::Parser
      rule(:bitwise_and) { ::Code::Parser::BitwiseAnd.new }

      rule(:pipe) { str("|") }
      rule(:caret) { str("^") }

      rule(:operator) { pipe | caret }

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

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

      root(:bitwise_or)
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

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