[antlr-interest] Tree Operators vs. Tree Rewrite Rules
Simon
cocoa at gmx.ch
Sat Oct 25 02:57:02 PDT 2008
Is it so obvious? Or is it simply not possible to achieve the same
thing using rewrite rules?
On Oct 22, 2008, at 3:07 PM, cocoa at gmx.ch wrote:
> Hi
>
> I try to build an AST for the following sentences:
>
> a.b.c;
>
> or
>
> a.b.c.d.e;
>
> The grammar is shown below. The expected tree (for the first
> example) is
>
> ^('.' ^('.' 'a' 'b') 'c')
>
> It works as expected with tree operators:
>
> prog
> : expr ';'!
> ;
>
> expr
> : primary ('.'^ ID )*
> ;
>
> primary
> : ID
> ;
>
> However, I can't get the same tree using tree rewrite rules. Is it
> possible at all? If so, could somebody please show me how?
>
> Thanks
> Simon
>
> PS: ultimately, I want to build an AST for a Java like language
> (method calls, field access, ...)
> --
> GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit
> Pastry Passion!
> http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196
>
> 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