[antlr-interest] Shortcircuiting the tree parser

Terence Parr parrt at cs.usfca.edu
Sun Jan 25 13:47:53 PST 2009


Also see upcoming release's ideas:

http://www.antlr.org/wiki/display/~admin/2008/11/29/Woohoo%21+Tree 
+pattern+matching%2C+rewriting+a+reality

Ter
On Jan 25, 2009, at 1:43 PM, Oliver Zeigermann wrote:

> 2009/1/25 Johannes Luber <jaluber at gmx.de>:
>> Carter Cheng schrieb:
>>> Thanks everyone for the replies to my previous post. I have been  
>>> wondering about one additional point
>>> when it comes to tree parsers. For alot of AST's when doing semantic
>> analysis you tend to have alot
>>> of separable distinct tasks which only need parts of the constructed
>> tree. I am curious if there is
>>> a way to underspecify the tree grammar and tell it explicitly not to
>> descend certain portions of the
>>> AST and only focus on certain parts. I apologize if this has been
>> addressed before.
>>>
>>> Thanks in advance,
>>>
>>> Carter.
>>>
>> Well, you could use the . to mark certain nodes and subtrees as "just
>> have to be here".
>>
>
> Which isn't that easy as the wildcard '.' does not work for tree
> roots. Additionally, nodes matched by wildcards do not seem to get
> copied to the output tree automatically.
>
> What you could do is to have simple Java code that scans (and copies
> if desired) the tree until it finds - say - an expression an calls a
> tree parser with this sub tree. You can take BaseTreeAdaptor#dupTree
> for inspiration how to traverse a random tree.
>
> - Oliver
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list