[antlr-interest] wildcard in tree grammar

Oliver Zeigermann oliver.zeigermann at gmail.com
Mon Dec 1 10:16:45 PST 2008


2008/12/1 Terence Parr <parrt at cs.usfca.edu>:
>
> On Nov 30, 2008, at 11:15 PM, Gavin Lambert wrote:
>>
>> And then of course there's Oliver's example, where he just wanted to
>> traverse the (sub)tree regardless of structure (presumably to pretty-print
>> it or something).
>
> If you don't care about structure, one could argue why you're using a
> grammar to do that ;)

Maybe you care about structure, but only in certain sections of the
tree and still want to touch every single node of the tree (which
makes this different from the new cool partial tree matching in 3.2)

treee
       : ^(ID treee*)  { do something very different with $ID here and
maybe also something with the children}
       | ^(a=. treee* ) { do something meaningful with $a here }
       ;

Does that make sense?

Oliver


More information about the antlr-interest mailing list