[antlr-interest] Cannot understand why parser accepts input...

G R relationalalgebra at gmail.com
Fri Dec 7 04:26:24 PST 2007


Try using this lexer rule at the end of your grammar :

OtherChar :.;

This will define every character, and if you don't mention in your grammar
that you want a "OtherChar", then, an exception will be raised.
Hope, this helps you.

G.R.

2007/12/7, Bern.McCarty at bentley.com <Bern.McCarty at bentley.com>:
>
> ...but when I enter a clearly invalid input into the interpreter such as
> simply "3" or "B=3C the console contains no errors or warnings at all.
>
> How could a mode that allows incorrect input without even issuing a
> complaint/warning possibly be helpful? Is there a way to turn it off?
>
> Thanks,
> -Bern
>
>
>
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org
> [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Gavin Lambert
> Sent: Friday, December 07, 2007 3:23 AM
> To: Bern McCarty; antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Cannot understand why parser accepts
> input...
>
> At 17:45 7/12/2007, Bern.McCarty at bentley.com wrote:
>
> >Why does the below grammer successfully parse the input " B ==3C"
> >When there are no numerals allowed anywhere in the grammer?
>
> It's an automatic error-recovery thing.  When ANTLRv3 encounters a
> character it can't figure out, it prints an error to the console
> (by default), drops the character, and then tries again.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071207/93044e95/attachment-0001.html 


More information about the antlr-interest mailing list