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: [email protected] [mailto:[email protected]] On Behalf Of Bharath R Sent: Tuesday, June 16, 2009 11:20 PM To: [email protected] 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! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
<<inline: outlook_huawei_logo_en.jpg>>
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
