[antlr-interest] Grammar not detecting extraneous input at end

Kevin Carroll kcarroll at signmgmt.com
Thu Jun 3 13:23:03 PDT 2010


Perhaps the lack of EOF in the start rule is Karim's problem; however, I reported a similar situation a few days ago (search for: "Missing" Tokens Do Not Cause Errors) in which I observed that the Match method does not fail, but instead inserts a missing token and does not report any error (from what I can tell).  Could there also be situations where ANTLR consumes extraneous tokens to allow the parse to proceed, but fails to report any error?

Thanks,
Kevin

-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Kirby Bohling
Sent: Thursday, June 03, 2010 1:46 PM
To: Karim Chichakly
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Grammar not detecting extraneous input at end

Channeling Jim Idle:

Remember to use antlr.markmail.org, this is a very common question,
and has been answered many times.

More then likely you don't require "EOF" at the end of whatever your
start rule is.  The token stream more then likely has a ')' and if you
tried to parse again, you'd get an error.  Use EOF to require all
input to be parsed.

Kirby



On Thu, Jun 3, 2010 at 1:38 PM, Karim Chichakly <karimc17 at gmail.com> wrote:
> Hi,
>
> I have a grammar that does not give an error (in ANTLR 3.2) if there are
> extraneous characters at the end of the input.  For example, I would expect
> "(a+b))" to generate an error, but it does not.  "(a+b)" is parsed fine and
> the extra ")" at the end is just ignored.
>
> I enclose a small sample grammar that demonstrates this problem.  I am using
> the C runtime, but the problem is not there.  The error is not detected in
> ANTLRWorks 1.4 either.
>
> Any help anyone can give me would be greatly appreciated.
>
> Thank you,
>
> Karim
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
>

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address


More information about the antlr-interest mailing list