[antlr-interest] "Missing" Tokens Do Not Cause Errors

Kevin Carroll kcarroll at signmgmt.com
Fri May 28 18:39:24 PDT 2010


Jim,

Actually, I'm using the C# 3.2 beta with the parser and lexer files being generated using the stand-alone windows exe from Sam Harwell.

When you say "they are reported", how and to whom/what are they reported?

Thanks,
Kevin

-----Original Message-----
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Jim Idle
Sent: Friday, May 28, 2010 3:32 PM
To: antlr-interest at antlr.org
Subject: Re: [antlr-interest] "Missing" Tokens Do Not Cause Errors

Sounds like you are using ANTLRWorks? They are reported, but they don't thrown exceptions.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Kevin Carroll
> Sent: Friday, May 28, 2010 12:49 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] "Missing" Tokens Do Not Cause Errors
>
> Here are a couple of simple rules extracted from a combined grammar I
> have:
>
> RETURNS                             :               ('R'|'r')'eturns'
> { $text = "RETURNS"; } ;
>
> returnsStatement
>                 :               RETURNS ':' type ';'          ->
> ^(RETURNS type)
>                 ;
>
> (type's definition is, I think, irrelevant.  It matches the typical
> things - int, double, etc.).
>
> Note that the rule uses the rewrite syntax and omits the ':' and ';'
> tokens in the AST.
>
> I am observing that my parser accepts inputs even when these tokens are
> missing.
>
> For example, the line:    "returns double" is accepted (note, no ':' or
> ';').  In stepping through the parse, the Match() method calls that
> should match the ':' and ';' return '<missing ':'>' and '<missing
> ';'>', respectively, yet do not fail.  I understand that a feature of
> ANTLR is that missing tokens are sometimes automatically inserted to
> allow the parse to proceed, but shouldn't the erroneous line(s) be
> reported?
>
> Is this behavior correct and/or expected?  If not, does anyone have any
> clues as to what might be going wrong?
>
> Thanks,
> Kevin Carroll
>
>
> 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