[antlr-interest] expression tree question
thomas.rolfs at cox.net
Thu Jan 13 22:21:46 PST 2005
This is a very simplified version of my expression grammar.
: atmo ((EQUALS^|NOT_EQUALS^|GT^|GTE^|LESS^|LTE^) atom)*
: relationalExpression ((AND^|OR^) relationalExpression)*
1 and 2 and 3 and 4
creates the tree:
<and <and < and 1 2 > 3 > 4 >
but I would like to have:
< and 1 < and 2 < and 3 < and 4>>>>
What is the best way to do this?
I can get the desired tree by changing the rule to:
: relationalExpression ((AND^|OR^) expression)*
but I'm guessing that operator precedence will be broken.
Thanks in advance.
More information about the antlr-interest