[antlr-interest] How to write the rewrite rule for AST if I want to place an imaginary node as its root

chain one chainone at gmail.com
Tue Nov 25 04:28:56 PST 2008


The rule is simple_expression:  term  (  add_like_op  term  )*
If it doesn't need to place an imaginary as its root, I can simply write
this rule like that: simple_expression:  term  (  add_like_op^  term  )*

How about if I wanna put an imaginary node on top of it ?

simple_expression:  term  (  add_like_op  term  )*  -> ^(SIMPLE_EXPRESSION[]
?????????)

I don't know how to write the ????? part.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081125/ba88e6f7/attachment.html 


More information about the antlr-interest mailing list