[antlr-interest] How-to: Tree grammar when AST rewrite rules involve parameters?

Gavin Lambert antlr at mirality.co.nz
Mon Sep 15 00:55:50 PDT 2008


At 21:11 14/09/2008, =?ISO-8859-2?Q?M._Utku_Karata=BA?= wrote:
 >Thanks Gavin, I wasn't aware of '.' notation in rewrite rules
 >(IIRC not mentioned in the ANTLR reference).

It is mentioned.  Perhaps what's confusing you is that it's *not* 
a rewrite rule.  Rewrite rules are the things to the right of a -> 
arrow, and "." is not valid over on that side.  But it's perfectly 
valid on the left side of an arrow (or where no arrow exists), as 
that's the recognition part, and it's a recognition operator.

 >For a workaround - I went with grammar refactorizations instead 
of
 >passing parameters around (which tends to get uglier and uglier 
in
 >time if you're constantly improvizing on the grammar :)).

Probably a good idea.



More information about the antlr-interest mailing list