[antlr-interest] ANTLR3 AST construction with optionsandalternatives
Robert Hill
rob.hill at blueyonder.co.uk
Mon Nov 13 11:57:05 PST 2006
>
> On Mon, Nov 13, 2006 at 05:26:12PM +0000, Foolish Ewe wrote:
> > a: b=b (c+=C)?->^(A $b $c+); // Doesn't seem to work if C is not scanned
I think the rule you're looking for would be...
a: b (C+)? -> ^(A b (C+)?)
Where A is a Token you've defined.
You don't need the $ signs on a re-write rule, unless you're in an action
between {}'s
Also, the ? needs to go outside the parens - C+? won't work.
There's a good description of the terminology used in the antlr manual,and
ISTR there's a page on tree re-write rules on the V3 wiki. The example
source , especially mantra , is invaluable for showing stuff that's not
described anywhere else.
/2ob
More information about the antlr-interest
mailing list