I've a simple ANTLR4 grammar :
grammar Test;
preprocessing_file: oneline+;
oneline: IDENTIFIER? new_line;
new_line: EOF|CRLF
;
WS: [ \t\f]+ -> channel(2);
CRLF: '\r'? '\n';
IDENTIFIER: (NONDIGIT | DIGIT )+
;
fragment DIGIT: [0-9];
fragment NONDIGIT: [_a-zA-Z] ;
I was testing how to use a newline rule that allows the last line not being terminated by a CRLF. I tested the grammar with ANTLR v4.1 and v4.5.3.
An input file of a few lines of text caused ANTLR4 to freeze and OutOfMemoryException after a while. It looks like ANTLR4 entered some infinite loop. Is it a bug with ANTLR4? Did I do anything wrong? Also, if I remove the EOF
in new_line
rule, everything works fine.