adds basic math operators, thanks to kasper associative and prioritised

This commit is contained in:
Torsten Ruger
2014-05-10 21:41:46 +03:00
parent 6378209f33
commit 2d389d2e00
7 changed files with 108 additions and 5 deletions

View File

@@ -41,6 +41,11 @@ module Parser
rule(:asignee => simple(:left) , :asigned => simple(:right) ) do
Ast::AssignmentExpression.new(left , right )
end
rule(l: simple(:l), o: simple(:o) , r: simple(:r)) do
Ast::OperatorExpression.new( o.to_s.strip , l ,r)
end
#shortcut to get the ast tree for a given string
# optional second arguement specifies a rule that will be parsed (mainly for testing)
def self.ast string , rule = :root