forked from jasder/antlr
slow again since i had to remove full LL context->alt cache (wasn't correct). But, threaded now makes bigger diff than before.
This commit is contained in:
parent
754e6eb593
commit
06d7c150fd
|
@ -282,12 +282,6 @@ public class ParserATNSimulator<Symbol extends Token> 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<Symbol extends Token> 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<Symbol extends Token> 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<Symbol extends Token> 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;
|
||||
}
|
||||
|
|
|
@ -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<PredPrediction> predicates;
|
||||
|
||||
public Map<PredictionContext,Integer> contextToPredictedAlt =
|
||||
Collections.synchronizedMap(new HashMap<PredictionContext, Integer>());
|
||||
|
||||
/** Map a predicate to a predicted alternative */
|
||||
public static class PredPrediction {
|
||||
public SemanticContext pred; // never null; at least SemanticContext.NONE
|
||||
|
|
Loading…
Reference in New Issue