Andreas Meyer schrieb:
> Robert Wentworth schrieb:
>
>> There appears to be something fundamental that I am not "getting"
>> [...]
>>
>
> I think the generated code is wrong. [...]
>
btw, when changing the gated semantic predicates:
> > cat : {input.LT(1).getText().equals("cat")}?=> WORD ;
> >
> > dog : {input.LT(1).getText().equals("dog")}?=> WORD ;
>
into plain semantic predicates
> > cat : {input.LT(1).getText().equals("cat")}? WORD ;
> >
> > dog : {input.LT(1).getText().equals("dog")}? WORD ;
>
the generated code looks good and expr can accept cat, cat when dog and
dog. Now, as the other poster already mentioned, gated semantic
predicates are there to distinguish between alternatives (that are not
syntactically ambiguous). Maybe that's where ANTLR (or the user?!) get's
confused, because cat only has one alternative (which get's effectively
disabled if the predicate fails), but the context in which it is used
has more alternatives, which effectively boil down to the same gated
predicates.
Best,
Andreas Meyer
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---