[antlr-interest] Rewrite rules, again!
Shaun Bogan
smbogan at gmail.com
Thu Mar 13 15:32:55 PDT 2008
I got some great help creating the following for my grammar:
assignops :
(boolops->boolops)(firstops b2=boolops -> ^(OPERATOR ^(firstops
^(OPERAND $b2) ^(OPERAND $assignops))))*
;
To make the above clear, it is basically just:
assignops :
boolops (firstops boolops)*
;
with rewrite rules.
The problem is this creates an AST that groups items in the reverse of
how I need them. For example:
a = b = c;
will create a tree that my tree walker (doing depth first) would evaluate as:
(a = b) = c;
This is obviously wrong. It should be a = (b = c);
Essentially, my parse tree looks fine, but I can't figure out how (if
there is a way) to get my rewrite rule to write my AST like above.
Any help is greatly appreciated,
Shaun M Bogan
More information about the antlr-interest
mailing list