Add edge suppression for lexer start state - required for left edge predicates

This commit is contained in:
Sam Harwell 2012-10-30 08:46:42 -05:00
parent 1e5cfb4a1e
commit bad2751a2c
1 changed files with 11 additions and 3 deletions

View File

@ -199,10 +199,18 @@ public class LexerATNSimulator extends ATNSimulator {
System.out.format("matchATN mode %d start: %s\n", mode, startState);
}
ATNConfigSet s0_closure = computeStartState(input, startState);
int old_mode = mode;
decisionToDFA[mode].s0 = addDFAState(s0_closure);
int predict = execATN(input, s0_closure, decisionToDFA[mode].s0);
ATNConfigSet s0_closure = computeStartState(input, startState);
boolean suppressEdge = s0_closure.hasSemanticContext;
s0_closure.hasSemanticContext = false;
DFAState next = addDFAState(s0_closure);
if (!suppressEdge) {
decisionToDFA[mode].s0 = next;
}
int predict = execATN(input, s0_closure, next);
if ( debug ) {
System.out.format("DFA after matchATN: %s\n", decisionToDFA[old_mode].toLexerString());