At 17:03 27/01/2009, Meena Vinod wrote: >On the ANTLRWorks, when I give a junk input say 'zee zee', the >ANTLRWorks does not generate any proper output and does not evn >throw an exception. >Also, the C code generated hangs when given this input.
The grammar you provided in the email shouldn't have either behaviour (unless you generated the code with -debug, for the hanging problem). However variations on some of your rules could cause both of them. 1. If your top-level rule permits nothing to be matched (eg. by using *), then ANTLR will quite happily match nothing and report success, when given invalid input. ANTLR will not complain about having "extra" unconsumed input; it assumes that you're going to do something else with it (such as passing it to a different lexer). If you want ANTLR to complain about not matching all the input, then your top-level rule should end with EOF, thereby explicitly trying to match "end of file/input". 2. If a top-level lexer rule permits nothing to be matched (again, eg. by using *), then it will get into an infinite loop, as it can always successfully match nothing. Make sure you don't do that. 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 [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 -~----------~----~----~----~------~----~------~--~---
