[antlr-interest] wildcard in tree grammar

Terence Parr parrt at cs.usfca.edu
Tue Dec 2 10:49:24 PST 2008


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?

Ter


More information about the antlr-interest mailing list