From bad2751a2c9b5386475e0bb5165efb67c304f711 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Tue, 30 Oct 2012 08:46:42 -0500 Subject: [PATCH] Add edge suppression for lexer start state - required for left edge predicates --- .../antlr/v4/runtime/atn/LexerATNSimulator.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java index c32153b23..d9ef237e1 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java @@ -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());