[antlr-interest] Alternative(s) 2 were disabled for that input

jack zhang jackgzhang2 at yahoo.com
Sun Sep 21 13:43:35 PDT 2008


Thanks. That explains it.


--- On Fri, 9/19/08, Gavin Lambert <antlr at mirality.co.nz> wrote:
From: Gavin Lambert <antlr at mirality.co.nz>
Subject: Re: [antlr-interest] Alternative(s) 2 were disabled for that  input
To: jackgzhang2 at yahoo.com, antlr-interest at antlr.org
Date: Friday, September 19, 2008, 11:03 PM

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;





      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080921/4dbbdca3/attachment.html 


More information about the antlr-interest mailing list