[antlr-interest] Q re syntax for relative root for TreePatternMatcher

Gerald Rosenberg gerald at certiv.net
Thu Mar 11 10:45:57 PST 2010


On 3/11/2010 10:27 AM, Terence Parr wrote:
> On Mar 11, 2010, at 9:56 AM, Gerald Rosenberg wrote:
>
>    
>> Given an actual AST structure of
>>
>>          ^(ROOT ^(PACKAGE ^(PACKAGENAME ID+)))
>>
>> this tree pattern rule works as expected
>>
>>          package : ^(PACKAGE ^(PACKAGENAME id+=ID+)) ;
>>
>> and this works
>>
>>          package : PACKAGE ;
>>      
> that would only work as start rule i think.
>    
Well, it does work as a non-start rule, even if not intended.
>> However, this rule does not
>>
>>          package : PACKAGE ^(PACKAGENAME id+=ID+) ;
>>
>> Seems that it generates code that expects a flat structure:
>>      
> that is a flat structure :)
>
> A B is flat A=PACKAGE B=^(...)
>    
 From that perspective, but the code gets confused on the DOWN token.  
It is looking for

A=PACKAGE B=PACKAGENAME

but is actually finding

A=PACKAGE B=DOWN



More information about the antlr-interest mailing list