[antlr-interest] ANTLR not reporting error for malformed program

Dejas Ninethousand dejas9000 at gmail.com
Thu Nov 6 09:57:56 PST 2008


Strange, it found an actual error in the grammar that was not found when the
EOF was omitted.  I was referencing a terminal that did not exist.

On Thu, Nov 6, 2008 at 10:42 AM, Vitaliy <Vitaliy at dbsophic.com> wrote:

>  Did you try:
>
>
>
> superProgram
>
>                 :
>
>                 program
>
>                 EOF
>
> ;
>
>
>
> program    :
>     statement_list -> statement_list PROGRAM
>     |
>     expression ->  expression PROGRAM
>     ;
>
>
>
> *From:* antlr-interest-bounces at antlr.org [mailto:
> antlr-interest-bounces at antlr.org] *On Behalf Of *Dejas Ninethousand
> *Sent:* Thursday, November 06, 2008 18:36
> *To:* Vitaliy
> *Cc:* antlr-interest at antlr.org
> *Subject:* Re: [antlr-interest] ANTLR not reporting error for malformed
> program
>
>
>
> How do I express EOF in ANTLR?  When I add "EOF" to the production I can't
> pass grammar check anymore:
>
> program    :
>     statement_list EOF -> statement_list PROGRAM
>     |
>     expression EOF ->  expression PROGRAM
>     ;
>
> -- Matt
>
>  On Thu, Nov 6, 2008 at 10:28 AM, Vitaliy <Vitaliy at dbsophic.com> wrote:
>
> Hi Matt,
>
>
>
> Had exactly the same problem.
>
> What you need to do is
>
> "Add EOF to the end of your top-level parser rule.",
>
> As Gavin had told me.
>
>
>
> Gavin – thanks again!
>
>
>
> Enjoy,
>
> Vitaliy
>
>
>
> *From:* antlr-interest-bounces at antlr.org [mailto:
> antlr-interest-bounces at antlr.org] *On Behalf Of *Dejas Ninethousand
> *Sent:* Thursday, November 06, 2008 18:21
> *To:* antlr-interest Interest
> *Subject:* [antlr-interest] ANTLR not reporting error for malformed
> program
>
>
>
> I know I saw something about this on the ANTLR web site a while back, but I
> can't find it now for the life of me.  I have some program text that does
> not conform to my grammar.  If thought of as a long string, about the first
> half of the string conforms to the cfg but then does something blatantly
> wrong from a grammar standpoint.  When ANTLR processes the program it
> consumes and parses the valid part of the program and then stops as if only
> the first half of the program string was the entire program string.  I do
> not see tokens pass by for the 2nd half of the malformed program (and as
> consiquence, no error is generated).  Can someone point me to the part of
> the web site that discusses this issue?
>
> Thanks,
> Matt
>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 3591 (20081106) __________
>
>
>
> The message was checked by ESET NOD32 Antivirus.
>
>
>
> http://www.eset.com
>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 3591 (20081106) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus
> signature database 3591 (20081106) __________
>
>
>
> The message was checked by ESET NOD32 Antivirus.
>
>
>
> http://www.eset.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081106/4b2f3ec0/attachment.html 


More information about the antlr-interest mailing list