[antlr-interest] EOF in a lexer rule

Mark Volkmann r.mark.volkmann at gmail.com
Mon Dec 17 08:30:41 PST 2007


All of the statements in my little language end with TERMINATOR. Below
is how that is defined.

TERMINATOR: NEWLINE | EOF;
fragment NEWLINE: ('\r'? '\n')+;

If all my statements end with a newline, including the last one,
everything parses fine. However, if the last line doesn't end in a
newline (just EOF) then I get a MismatchedTokenException. Is it clear
why this happens based on the lexer rules above? Is it legal to refer
to EOF in a lexer rule?

-- 
R. Mark Volkmann
Object Computing, Inc.


More information about the antlr-interest mailing list