[antlr-interest] PEG-style "and" predicates
qwertie256 at gmail.com
Tue Jul 3 07:20:26 PDT 2007
> Nope, I don't think so. They are needed because, with a few
> exceptions, the order in which you specify alternatives *doesn't*
> actually have any impact on their precedence.
It's my understanding that if there is ambiguity, the first matching
alternative is always chosen (if applicable). The ANTLR warnings say
as much. e.g.
[07:51:33] warning(209): Foo.g:167:1: Multiple token rules can match
input such as "'f''o''o'": FOO1, FOO2
As a result, tokens(s) FOO2 were disabled for that input
Try giving ANTLR ambiguous alternatives. My experience is that it will
always choose the first.
So all one should need is a way to disable the warning and keep that behavior.
My reading of the ANTLR book (chapter 12) also suggests the predicates should be
used for prediction and not simply thrown out [if LL(*) doesn't fail
on the non-predicate input]. Could I be so bold as to suggest the
current behavior may be a big bug in ANTLR?
P.S. Sorry for the duplicate, Wincent, I'm always forgetting to "Reply all"
More information about the antlr-interest