[antlr-interest] Tree grammar for 'zero or more' rewrite

Ted Villalba ted.villalba at gmail.com
Thu Jul 12 09:27:38 PDT 2007


Hi,

Referring back to your instructions below, I have a couple of questions:


> > value : value_ -> ^(VALUE value_) ;
> >
> > and rename value to value_:
> >
> > value   : terms ( operator^  terms )*
> >
>      | LPAREN! value RPAREN! ( operator^ value)* // i'll ignore as i
> > don't know what you want
> >      ;
> >
> > Also don't call value recursively in first alt.  That will create the
> > wrong associativity for OR...it will do associativity you find with
> > exponents.  Now you can use simple ^ operator.
>
>
the issue with the new first alt is that it no longer accommodates  when the
second operand is surrounded by PARENs, like : ...blah blah AND ( more stuff
OR whatever).



The second question I have is:
How to define the tree grammar for rules and alts that have no rewrite
specification. For instance:
        LPAREN! value RPAREN! ( operator^ value)*

Going back to reread the book, but at the moment, when there is a rewrite
rule, it's more obvious to me, because I simply move it over to the tree
grammar. When there's not, I'm not sure how to define the tree grammar for
the alternates with inline ^ operators, or for that matter * operators.

Thanks again,
Ted
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070712/9ae1dc75/attachment.html 


More information about the antlr-interest mailing list