[antlr-interest] Tree Operators vs. Tree Rewrite Rules
Jim Idle
jimi at temporal-wave.com
Sat Oct 25 13:13:29 PDT 2008
On Sat, 2008-10-25 at 11:57 +0200, Simon wrote:
> Is it so obvious? Or is it simply not possible to achieve the same
> thing using rewrite rules?
Have you tried a few things yourself? It won't explode if you do it
wrong :-)
Try things akin to:
e
: p -> $p
(
a='.' i=id
->^($a $e $i) // Or $a $i $e
)*
;
Jim
>
> 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
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081025/35d9338f/attachment.html
More information about the antlr-interest
mailing list