diff --git a/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java b/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java index 1e47b197d..a6a9533e0 100755 --- a/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java +++ b/runtime/Java/src/org/antlr/v4/runtime/atn/ParserATNSimulator.java @@ -282,12 +282,6 @@ public class ParserATNSimulator extends ATNSimulator { if ( dfa_debug ) System.out.println("DFA state "+s.stateNumber+" LA(1)=="+getLookaheadName(input)); if ( s.isCtxSensitive && !SLL ) { if ( dfa_debug ) System.out.println("ctx sensitive state "+outerContext+" in "+s); - PredictionContext predictionCtx = PredictionContext.fromRuleContext(outerContext); - predictionCtx = getCachedContext(predictionCtx); - Integer predI = s.contextToPredictedAlt.get(predictionCtx); - if ( predI!=null ) { - return predI; // ha! quick exit :) - } boolean loopsSimulateTailRecursion = true; boolean fullCtx = true; ATNConfigSet s0_closure = @@ -301,7 +295,6 @@ public class ParserATNSimulator extends ATNSimulator { outerContext, ATN.INVALID_ALT_NUMBER, greedy); - s.contextToPredictedAlt.put(predictionCtx, fullCtxSet.uniqueAlt); return fullCtxSet.uniqueAlt; } if ( s.isAcceptState ) { @@ -540,13 +533,9 @@ public class ParserATNSimulator extends ATNSimulator { D.configs.conflictingAlts.getMinElement(), greedy); // not accept state: isCtxSensitive - PredictionContext predictionCtx = PredictionContext.fromRuleContext(outerContext); - predictionCtx = getCachedContext(predictionCtx); D.isCtxSensitive = true; // always force DFA to ATN simulate predictedAlt = fullCtxSet.uniqueAlt; D.prediction = ATN.INVALID_ALT_NUMBER; - // TODO: have to cache pred list to test also - D.contextToPredictedAlt.put(predictionCtx, predictedAlt); // CACHE addDFAEdge(dfa, previousD, t, D); return predictedAlt; // all done with preds, etc... } @@ -810,7 +799,7 @@ public class ParserATNSimulator extends ATNSimulator { } int nPredAlts = 0; - for (int i = 0; i < n; i++) { + for (int i = 1; i < n; i++) { if (altToPred[i] == null) { altToPred[i] = SemanticContext.NONE; } diff --git a/runtime/Java/src/org/antlr/v4/runtime/dfa/DFAState.java b/runtime/Java/src/org/antlr/v4/runtime/dfa/DFAState.java index e60cb20ce..5d07fd31f 100644 --- a/runtime/Java/src/org/antlr/v4/runtime/dfa/DFAState.java +++ b/runtime/Java/src/org/antlr/v4/runtime/dfa/DFAState.java @@ -31,15 +31,11 @@ package org.antlr.v4.runtime.dfa; import org.antlr.v4.runtime.atn.ATNConfig; import org.antlr.v4.runtime.atn.ATNConfigSet; -import org.antlr.v4.runtime.atn.PredictionContext; import org.antlr.v4.runtime.atn.SemanticContext; import org.antlr.v4.runtime.misc.Nullable; -import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Set; /** A DFA state represents a set of possible ATN configurations. @@ -110,9 +106,6 @@ public class DFAState { @Nullable public List predicates; - public Map contextToPredictedAlt = - Collections.synchronizedMap(new HashMap()); - /** Map a predicate to a predicted alternative */ public static class PredPrediction { public SemanticContext pred; // never null; at least SemanticContext.NONE