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

G R relationalalgebra at gmail.com
Fri Dec 7 05:02:42 PST 2007


Try using the debugger and take a look at the output section.

G.R.

2007/12/7, Bern.McCarty at bentley.com <Bern.McCarty at bentley.com>:
>
>  Yes that is a big help.  Thanks. At least now I see a
> NoViableAltException in the interpreter output "diagram".  However, there is
> still no indication of anything being amiss at all in the console window.
> Shouldn't the console window have something to say about an exception that
> has caused parsing to fail?
>
>
>
> -Bern
>
>
>
> *From:* antlr-interest-bounces at antlr.org [mailto:
> antlr-interest-bounces at antlr.org] *On Behalf Of *G R
> *Sent:* Friday, December 07, 2007 7:26 AM
> *To:* antlr at mirality.co.nz; antlr-interest at antlr.org
> *Subject:* Re: [antlr-interest] Cannot understand why parser accepts
> input...
>
>
>
> 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/923df298/attachment.html 


More information about the antlr-interest mailing list