Hi,You could use the EOF token to match the whole input test: exp EOF; -shibin
On Tue, Jun 30, 2009 at 5:29 AM, Gyanit Singh <gya...@gmail.com> wrote: > Hi all, > > I have a simple grammar > ---------------------- > grammar test; > test : exp; > exp : ONE ('+' ONE)* ; > ONE : '1'; > ----------------------- > > if you try to parse "1+11" the parser matches test and expr to "1+1" and > ignores the last "1". Is there a way to throw an exception when this > happens. > > More abstractly, when the rule is kleene closure (or plus) and it ends > leading to the end of the main rule (for the above example rule "test") and > still there are tokens remaining then how to throw and exception instead of > partial match. In other words, after the parsing is done how to check > whether the token stream has ended or not? > > thanks, > gyanit. > > List: http://www.antlr.org/mailman/listinfo/antlr-interest > Unsubscribe: > http://www.antlr.org/mailman/options/antlr-interest/your-email-address > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to il-antlr-interest@googlegroups.com To unsubscribe from this group, send email to il-antlr-interest+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address