[antlr-interest] Recursive parenthesises in the tree.

Johannes Luber jaluber at gmx.de
Tue Feb 17 09:52:08 PST 2009


Fatih Tolga Ata schrieb:
> Johannes Luber wrote:
>> PAREXPR is a imaginary token, adding semantics to otherwise
>> indiscriminable situations or just some additional clarity like in this
>> case. The "-> ^()" is a tree rewrite operator, saying that the created
>> AST should look differently than the original input. I suppose your
>> problem with the tree walker is that it doesn't recognize all
>> possibilities created by the parser. Unless the missing alternatives are
>> somehow covered in the Identifier and literal rules, try
> I appreciated for this information.
>> primaryExpression
>>     : THIS
>>     | Identifier
>>     | literal
>>     | arrayLiteral
>>     | objectLiteral
>>     | ^( PAREXPR expression )
>>     ;
> I'm not sure, but I think, it worked! Thanks a lot. But I had to add
> "backtrack=true" options because of LL(*) conflicts. I said "I think, it
> worked", because I don't know exactly that it worked.

Look at
<http://www.antlr.org/wiki/display/ANTLR3/How+to+remove+global+backtracking+from+your+grammar>
for some tips to deal with this.

Johannes

> The treewalker
> didn't give me an error, but I didn't look at the tree yet that it is
> correct or not. Now I try to learn using the parser and the treewalker.
>> In general, look at the documentation about ASTs to learn more about
>> them.
>>
>> Johannes
> I'm studying now how the parser and tree walker works. After that I want
> to learn ANTLR grammar and the other things from the book (I haven't buy
> it, but I'll)
> 
> Thanks for helping. This gives me more desire to learn compilers and antlr.
> 
> Fatih Tolga Ata
> 



More information about the antlr-interest mailing list