[antlr-interest] Operator tree construction in rewrite syntax

Guntis Ozols guntiso at latnet.lv
Mon Apr 14 13:33:51 PDT 2008


Citēju Guntis Ozols <guntiso at latnet.lv>:

> > i apologize...i meant there to be a zero-or-more:
> >
> > sum: something (Plus^ something)*;
>
> Right side stays the same, i.e. with '+',
> because smth smth* is the same as smth+.

I apologize... :)
I just checked out with ANTLRWorks debugger,
and ASTs are not equivalent with more than two somethings.
Which means that I do not know the answer to your question,
maybe somebody else does. That said, both ASTs are quite usable anyway
(unless there is some backwards compatibility issue).

> > > Quick question (i hope). What is the equivalent to the following using
> > > the rewrite (->) syntax:
> > >
> > > sum: something (Plus^ something);
> > >
> > > Thanks,
> > > Marko
> >
> > 1. try: something (Plus something) -> ^(Plus something+);
> >
> > 2. how about '*', did you mean: something (Plus^ something)*; ?
> >
> > 3. do not use ^ on both sides
> >
> > Guntis




More information about the antlr-interest mailing list