[antlr-interest] Alternative(s) 2 were disabled for that input
Gavin Lambert
antlr at mirality.co.nz
Fri Sep 19 23:03:59 PDT 2008
At 07:32 20/09/2008, jack zhang wrote:
>Thanks. Now the warnings are cleared. The only issue I had is
>that for the following invalid inputs, it won't report error.
>Here is the grammar.
>1) AND
>2) OR
>3) AND a
>4) OR a
[...]
>expr: orexpression*;
Your top level rule does not require anything at all to be matched
("*" is zero-or-more, and if the input isn't a valid orexpression
then it'll simply match nothing at all and succeed).
If you want to require at least one orexpression to be present,
change the * to a +. If you want to additionally ensure that the
entire input is consumed (or produce an error if not), add EOF to
the end of the rule. For example:
expr : orexpression+ EOF;
More information about the antlr-interest
mailing list