[antlr-interest] rewrite rule translation to tree grammar
Johannes Luber
jaluber at gmx.de
Fri Dec 14 13:09:48 PST 2007
Terence Parr schrieb:
> hi. that seems incorrect to me. You can't have a tree as a root node.
> Imagine creating $qualified_identifier as tree in first subrule then
> making root in (...)*. Probably not right.
> Ter
Having thought about your answer, it explains one of my difficulties. I
tried to mimic the following example:
expr : (INT -> INT) ('+' i=INT -> ^('+' $expr $i) )* ;
The solution seems to be that I need an equivalent for the '+'. But my
rule doesn't have a token which could be the overall root. What do you
suggest? And what would be the tree grammar equivalent?
Johannes
> On Dec 14, 2007, at 12:24 PM, Johannes Luber wrote:
>
>> Hi,
>>
>> I have the following rule:
>>
>> qualified_identifier
>> : (i1=IDENTIFIER -> ^(QUALIFIED_IDENTIFIER $i1))
>> (DOT i2=IDENTIFIER -> ^($qualified_identifier DOT $i2))*
>> ;
>>
>> But I haven't found an example in TDAR which explains the equivalent
>> rule for a tree grammar. Can someone help?
>>
>> Johannes
>
More information about the antlr-interest
mailing list