Fix ParserATNSimulator.execDFA consuming an unnecessary symbol after an accept or context-sensitive state is reached

This commit is contained in:
Sam Harwell 2012-02-15 14:02:50 -06:00
parent 79f0de4cde
commit 28919bbdc5
1 changed files with 8 additions and 2 deletions

View File

@ -364,6 +364,10 @@ public class ParserATNSimulator<Symbol> extends ATNSimulator {
// TODO: v3 dfa don't do this.
break;
}
// t is not updated if one of these states is reached
assert !s.isCtxSensitive && !s.isAcceptState;
// if no edge, pop over to ATN interpreter, update DFA and return
if ( s.edges == null || t >= s.edges.length || t < -1 || s.edges[t+1] == null ) {
if ( dfa_debug && t>=0 ) System.out.println("no edge for "+parser.getTokenNames()[t]);
@ -404,8 +408,10 @@ public class ParserATNSimulator<Symbol> extends ATNSimulator {
throw noViableAlt(input, outerContext, s.configset, startIndex);
}
s = target;
input.consume();
t = input.LA(1);
if (!s.isCtxSensitive && !s.isAcceptState) {
input.consume();
t = input.LA(1);
}
}
// if ( acceptState==null ) {
// if ( debug ) System.out.println("!!! no viable alt in dfa");