[antlr-interest] wildcard in tree grammar

Oliver Zeigermann oliver.zeigermann at gmail.com
Tue Dec 2 12:54:38 PST 2008


2008/12/2 Terence Parr <parrt at cs.usfca.edu>:
>
> On Dec 2, 2008, at 2:58 AM, Oliver Zeigermann wrote:
>>
>> 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).
>
> You are looking at the tree as a node stream, which is fine. A simple tree
> visitor does that. A grammar specify structure; don't use a grammar to
> serialize a tree. The new tree pattern matching is what you want. Just list
> all of the special nodes and given action or a rewrite. Will that work for
> you?

It will work and it does work with the new tree pattern matching. My
problem is already solved.

But more generally: Why not using a grammar to serialize a tree (given
there are some structure sensitive exceptions?).

Is it really that hard to implement that root wildcard? Maybe just for
the sake of completeness?

Anyway, I won't bother any more.

Oliver


More information about the antlr-interest mailing list