Avoid calling consume() at EOF

This commit is contained in:
Sam Harwell 2012-11-03 15:16:29 -05:00
parent c9890e8305
commit fbaac8194b
1 changed files with 11 additions and 3 deletions

View File

@ -265,10 +265,16 @@ public class LexerATNSimulator extends ATNSimulator {
if (target.isAcceptState) { if (target.isAcceptState) {
captureSimState(prevAccept, input, target); captureSimState(prevAccept, input, target);
if (t == IntStream.EOF) {
break;
}
}
if (t != IntStream.EOF) {
consume(input);
t = input.LA(1);
} }
consume(input);
t = input.LA(1);
s = target; // flip; current DFA target becomes new src/from state s = target; // flip; current DFA target becomes new src/from state
} }
@ -342,7 +348,9 @@ public class LexerATNSimulator extends ATNSimulator {
input.seek(index); input.seek(index);
this.line = line; this.line = line;
this.charPositionInLine = charPos; this.charPositionInLine = charPos;
consume(input); if (input.LA(1) != IntStream.EOF) {
consume(input);
}
} }
@Nullable @Nullable