forked from jasder/antlr
Fix ParserATNSimulator.execDFA consuming an unnecessary symbol after an accept or context-sensitive state is reached
This commit is contained in:
parent
79f0de4cde
commit
28919bbdc5
|
@ -364,6 +364,10 @@ public class ParserATNSimulator<Symbol> extends ATNSimulator {
|
||||||
// TODO: v3 dfa don't do this.
|
// TODO: v3 dfa don't do this.
|
||||||
break;
|
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 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 ( 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]);
|
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);
|
throw noViableAlt(input, outerContext, s.configset, startIndex);
|
||||||
}
|
}
|
||||||
s = target;
|
s = target;
|
||||||
input.consume();
|
if (!s.isCtxSensitive && !s.isAcceptState) {
|
||||||
t = input.LA(1);
|
input.consume();
|
||||||
|
t = input.LA(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// if ( acceptState==null ) {
|
// if ( acceptState==null ) {
|
||||||
// if ( debug ) System.out.println("!!! no viable alt in dfa");
|
// if ( debug ) System.out.println("!!! no viable alt in dfa");
|
||||||
|
|
Loading…
Reference in New Issue