[antlr-interest] AntLR 3 is not validating the LAST character.

Jim Idle jimi at temporal-wave.com
Wed Jun 17 06:10:28 PDT 2009


You need to add EOF token as last element of your start rule.

Jim

On Jun 16, 2009, at 11:20 PM, Bharath R <r.bharath at huawei.com> wrote:

> Hi All
>
> I am facing an issue while parsing the last character of my input.
>
> Even if i give an invalid character at the last the parser is not  
> throwing the exception.
>
> The below is my grammar :-
>
> // ***************************
> grammar test;
>
> globalnumber : phonedigit (NEWLINE)* ;
>
> phonedigit : (DIGIT)* ;
>
> NEWLINE : '\n' ;
>
> DIGIT : (0-9)
>
> ALPHA : ('a'-'z') | ('A'-'Z');
>
> // ***************************
>
> Here if we notice that the NEWLINE is an optional rule. , when I  
> give the input as " 12345a " for the rule "globalnumber" then the  
> parser is not throwing
> any exception. i checked the parser code its just consuming those  
> tokens .  :-(
>
> When I make the NEWLINE as mandatory then its working fine. but i  
> dont want that to be a mandatory RULE.
>
> Thanx a lot for reading this query expecting your response.
>
> Regards
> Bharath R
> HUAWEI TECHNOLOGIES CO.,LTD. <outlook_huawei_logo_en.jpg>
>
> Address: Huawei Industrial Base
> Bantian Longgang
> Shenzhen 518129, P.R.China
> www.huawei.com
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> --- 
> ----------------------------------------------------------------------
> This e-mail and its attachments contain confidential information  
> from HUAWEI, which
> is intended only for the person or entity whose address is listed  
> above. Any use of the
> information contained herein in any way (including, but not limited  
> to, total or partial
> disclosure, reproduction, or dissemination) by persons other than  
> the intended
> recipient(s) is prohibited. If you receive this e-mail in error,  
> please notify the sender by
> phone or email immediately and delete it!
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090617/d7eac573/attachment.html 


More information about the antlr-interest mailing list