[antlr-interest] wildcard in tree grammar
Oliver Zeigermann
oliver.zeigermann at gmail.com
Tue Dec 2 02:58:25 PST 2008
2008/12/1 Terence Parr <parrt at cs.usfca.edu>:
>
> On Dec 1, 2008, at 10:16 AM, Oliver Zeigermann wrote:
>
>> 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?
>
> It seems to me like you're saying "do x on ID or y on any other node".
> remember that once you match a node, you can ask for child list or even
> parent.
Here is what I want to do:
>>Traverse a *full tree* (i.e. from tree root down to each and every leaf), having access to each and every single node and handle certain nodes differently.<<
How would you do that? My grammar above would do the job (I know as it
used to work in ANTLR 2).
Oliver
More information about the antlr-interest
mailing list