From 9432bfb74691bf5940005d234c41a3e0a7f39610 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Thu, 9 Jan 2014 06:52:13 -0600 Subject: [PATCH] Do not cache the results of a failed predicate evaluation in the DFA (fixes #398) --- .../src/org/antlr/v4/runtime/atn/LexerATNSimulator.java | 9 ++++++--- 1 file changed, 6 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 70f715353..804e07349 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/LexerATNSimulator.java @@ -290,9 +290,12 @@ public class LexerATNSimulator extends ATNSimulator { getReachableConfigSet(input, s.configs, reach, t); if ( reach.isEmpty() ) { // we got nowhere on t from s - // we got nowhere on t, don't throw out this knowledge; it'd - // cause a failover from DFA later. - addDFAEdge(s, t, ERROR); + if (!reach.hasSemanticContext) { + // we got nowhere on t, don't throw out this knowledge; it'd + // cause a failover from DFA later. + addDFAEdge(s, t, ERROR); + } + // stop when we can't match any more char return ERROR; }