[antlr-interest] Re: Syntactic predicates and ()+ rules
Eric Mahurin
eric_mahurin at yahoo.com
Sat Aug 21 10:13:12 PDT 2004
Try this instead:
expr: exp1 ( (OP ~(NL|SPC)) => OP exp1 )* ;
antlr complains that the syntactic predicate is redundant, but this
warning is a bug. Ignore it and you should be good. If you look back
in this yahoo group you'll find some of my postings on the topic and a
little wrapper around antlr to remove these bogus messages.
Eric
--- In antlr-interest at yahoogroups.com, Joan Pujol <joanpujol at g...> wrote:
> Hi,
>
> After a lot of time I have found my problems with indeterminism and
> syntactic predicates ;)
> But I have a question:
>
> I have a grammar like
>
> inst: instx (NL|SPC);
> instX: ... expr OP;
>
> expr: exp1
> (
> (OP ~(NL|SPC)) => OP exp1
> |
> )
>
> And it works well and it has no indeterminism. I'm lucky because the
> OP can't be associated in form exp1 OP exp1 OP exp1 OP (is a
> comparison operator)
>
> But my question is If I suppose that exp1 OP exp1 OP exp1 is valid
> and then I need to do:
>
> expr: exp1
> (
> (OP ~(NL|SPC)) => (OP exp1)+
> |
> )
>
> This doesn't work, because the syntactic predicate is only evaluated
> once and when I enter in the ()+ block I don't solve the
> indeterminism.
> My question how can I manage this If sometimes i need a grammar like
> this. I tried to refactor, but with no exit.
>
> A lot of thanks,
>
>
> --
> Joan Jesús Pujol Espinar
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list