Skip to content

Instantly share code, notes, and snippets.

@michaelgpearce
Created August 18, 2012 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelgpearce/3385007 to your computer and use it in GitHub Desktop.
Save michaelgpearce/3385007 to your computer and use it in GitHub Desktop.
Left to right association with Treetop Grammar
rule expression
term (space? additive_operator space? term)* space? <Node::Expression>
end
rule term
space? factor (space? multitive_operator space? factor)* <Node::Expression>
end
rule factor
number
/
'(' expression ')' <Node::Expression>
end
rule additive_operator
addition_operator / subtraction_operator
end
rule multitive_operator
multiplication_operator / division_operator
end
rule addition_operator
'+' <Node::Operator>
end
rule subtraction_operator
'-' <Node::Operator>
end
rule multiplication_operator
'*' <Node::Operator>
end
rule division_operator
'/' <Node::Operator>
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment