[antlr-interest] Operators and rewrite rules equivalence

Aurélien LARIVE aurelien.larive at 4dconcept.fr
Mon Jan 11 08:37:30 PST 2010

Below is the message John B. Brodie sent to me :

(again tried to send a copy of this to the list, but failed)

On Mon, 2010-01-11 at 16:46 +0100, Aurélien LARIVE wrote:
> Hi,
> I successfully buit an AST using the operators notation (^) but I need 
> to customize a bit my AST construction. Could someone tell me what's the 
> rewrite rules version of the following rule ?
> andexpression
>     : notexpression ( AND^ notexpression )*
>     ;
> I found a similar example at 
> http://www.antlr.org/wiki/display/ANTLR3/Tree+construction but I failed 
> to apply this to my problem.

off the top of my head:

     : l=notexpression ( AND r=andexpression -> ^(AND $l $r) )?

but i have a vague memory that the associativity of these two are
different.  would need to look into that if associativity matters in
your application.

More information about the antlr-interest mailing list