v4: Call mark() from match instead of matchATN

[git-p4: depot-paths = "//depot/code/antlr4/main/": change = 9476]
This commit is contained in:
sharwell 2011-11-27 13:45:36 -08:00
parent c0262d569b
commit fc2b4cad07
1 changed files with 19 additions and 21 deletions

View File

@ -134,6 +134,8 @@ public class LexerATNSimulator extends ATNSimulator {
public int match(@NotNull CharStream input, int mode) {
match_calls++;
this.mode = mode;
int mark = input.mark();
try {
if ( dfa[mode].s0==null ) {
return matchATN(input);
}
@ -141,6 +143,10 @@ public class LexerATNSimulator extends ATNSimulator {
return exec(input, dfa[mode].s0);
}
}
finally {
input.release(mark);
}
}
public void reset() {
dfaPrevAccept.reset();
@ -153,8 +159,6 @@ public class LexerATNSimulator extends ATNSimulator {
// only called from test code from outside
public int matchATN(@NotNull CharStream input) {
int mark = input.mark();
try {
startIndex = input.index();
ATNState startState = atn.modeToStartState.get(mode);
if ( debug ) System.out.println("mode "+ mode +" start: "+startState);
@ -165,12 +169,6 @@ public class LexerATNSimulator extends ATNSimulator {
if ( debug ) System.out.println("DFA after matchATN: "+dfa[old_mode].toLexerString());
return predict;
}
finally {
if (mark >= 0) {
input.release(mark);
}
}
}
protected int exec(@NotNull CharStream input, @NotNull DFAState s0) {
if ( dfa_debug ) System.out.println("DFA[mode "+(recog==null?0:recog.mode)+"] exec LA(1)=="+