[antlr-interest] Evaluator bailing out early?

Brent Yates brent.yates at gmail.com
Mon Feb 18 20:22:54 PST 2008


I assume that you are testing in ANTLRWorks.  ANTLRWorks calls the
*prog*rule function which consumes tokens until it returns a match or
an error.
In this case it returns a match.  ANTLRWorks ignores any tokens after the
rule function returns (maybe a warning should be added?).  If you add an EOF
to the prog rule you should get an error as the rule will be forced to
handle ALL the tokens for a match to be made.  I often make a special rule,
for example test_rule, where I add the EOF token.  This way I am not
changing my grammar just to make testing easier.

test_rule
    : prog EOF
    ;


Brent Yates
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080218/78756a01/attachment.html 


More information about the antlr-interest mailing list