[antlr-interest] Matching Last Line in ANTLR?

consiliens at gmail.com consiliens at gmail.com
Mon Aug 17 21:08:22 PDT 2009


The last line, b., doesn't match the MC_INCORRECT token because there's 
no newline after it. Is there an easy way to match this in ANTLR?

Sample Input:
1.
*a.
b.


MC_QUESTION  : INT ('.'|')') .* NEWLINE;
MC_INCORRECT : LETTER '.' .* NEWLINE;
MC_CORRECT   : '*' MC_INCORRECT;

fragment NEWLINE : '\r'? '\n';
fragment LETTER  : ('a'..'z'|'A'..'Z');
fragment INT     : '0'..'9'+;


More information about the antlr-interest mailing list