[antlr-interest] Tree grammar for 'zero or more' rewrite
Ted Villalba
ted.villalba at gmail.com
Thu Jul 12 15:51:08 PDT 2007
Hi Ter,
I have to apologize, I created my original tree incorrectly, and probably
steered you wrong in your help.
It should have been:
0 terms:
=
/ \
TAG VALUE
| |
to TERM
|
foo
1 term:
=
/ \
TAG VALUE
| |
to OR
/ \
TERM VALUE
| |
foo TERM
|
bar
2 terms:
=
/ \
TAG VALUE
I |
to OR
/ \
TERM VALUE
| |
foo AND |
/ \
TERM TERM
| |
bar duff
Sorry. Probably made a difference in your suggestion for the first alt
for value_.
Thanks,
Ted
On 7/12/07, Ted Villalba <ted.villalba at gmail.com> wrote:
>
> 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/7da1ad1d/attachment-0001.html
More information about the antlr-interest
mailing list