[antlr-interest] Recursive parenthesises in the tree.

Fatih Tolga Ata fatih at diyezon.com
Tue Feb 17 06:07:33 PST 2009


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. 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