lib/code/parser/addition.rb in code-ruby-0.4.0 vs lib/code/parser/addition.rb in code-ruby-0.5.0

- old
+ new

@@ -1,29 +1,21 @@ class Code class Parser - class Addition < Parslet::Parser - rule(:multiplication) { ::Code::Parser::Multiplication.new } + class Addition < Operation + def statement + ::Code::Parser::Multiplication + end - rule(:plus) { str("+") } - rule(:minus) { str("-") } + def plus + str("+") + end - rule(:operator) { plus | minus } - - rule(:space) { str(" ") } - rule(:newline) { str("\n") } - rule(:whitespace) { (space | newline).repeat(1) } - rule(:whitespace?) { whitespace.maybe } - - rule(:addition) do - ( - multiplication.as(:first) >> - ( - whitespace? >> operator.as(:operator) >> whitespace? >> - multiplication.as(:statement) - ).repeat(1).as(:rest) - ).as(:addition) | multiplication + def minus + str("-") end - root(:addition) + def operator + plus | minus + end end end end