Add error edges to DFA

This commit is contained in:
Sam Harwell 2013-04-18 13:01:01 -05:00
parent 64354e5740
commit 9206a263b7
1 changed files with 6 additions and 0 deletions

View File

@ -590,6 +590,8 @@ public class ParserATNSimulator extends ATNSimulator {
// return w/o altering DFA
return alt;
}
addDFAEdge(dfa, previousD, t, ERROR);
throw noViableAlt(input, outerContext, previousD.configs, startIndex);
}
@ -1590,6 +1592,10 @@ public class ParserATNSimulator extends ATNSimulator {
/** Add D if not there and return D. Return previous if already present. */
protected DFAState addDFAState(@NotNull DFA dfa, @NotNull DFAState D) {
if (D == ERROR) {
return D;
}
synchronized (dfa.states) {
DFAState existing = dfa.states.get(D);
if ( existing!=null ) return existing;