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

Dave Dutcher dave at tridecap.com
Wed Jun 17 06:11:50 PDT 2009


There is a special EOF token you use to mark where the input should end.
This would probably work:
 
 
globalnumber : phonedigit (NEWLINE)* EOF;
 
 
 
Dave
 


  _____  

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Bharath R
Sent: Tuesday, June 16, 2009 11:20 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] AntLR 3 is not validating the LAST character.


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. huawei_logo 




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!

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090617/09a43ef8/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 6737 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20090617/09a43ef8/attachment.jpe 


More information about the antlr-interest mailing list