Package org.antlr.v4.runtime.atn
Class PredictionContext
java.lang.Object
org.antlr.v4.runtime.atn.PredictionContext
- Direct Known Subclasses:
ArrayPredictionContext,EmptyPredictionContext,SingletonPredictionContext
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intStores the computed hash code of thisPredictionContext.static final PredictionContextstatic final intstatic final PredictionContextstatic final intprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract PredictionContextprivate static PredictionContextaddEmptyContext(PredictionContext context) appendContext(int returnContext, PredictionContextCache contextCache) abstract PredictionContextappendContext(PredictionContext suffix, PredictionContextCache contextCache) protected static intprotected static intcalculateHashCode(PredictionContext[] parents, int[] returnStates) protected static intcalculateHashCode(PredictionContext parent, int returnState) abstract booleanabstract intfindReturnState(int returnState) static PredictionContextfromRuleContext(ATN atn, RuleContext outerContext) static PredictionContextfromRuleContext(ATN atn, RuleContext outerContext, boolean fullContext) static PredictionContextgetCachedContext(PredictionContext context, ConcurrentMap<PredictionContext, PredictionContext> contextCache, PredictionContext.IdentityHashMap visited) getChild(int returnState) abstract PredictionContextgetParent(int index) abstract intgetReturnState(int index) abstract booleanhasEmpty()final inthashCode()abstract booleanisEmpty()static booleanisEmptyLocal(PredictionContext context) static PredictionContextjoin(PredictionContext context0, PredictionContext context1) (package private) static PredictionContextjoin(PredictionContext context0, PredictionContext context1, PredictionContextCache contextCache) protected abstract PredictionContextprivate static PredictionContextremoveEmptyContext(PredictionContext context) abstract intsize()String[]toStrings(Recognizer<?, ?> recognizer, int currentState) String[]toStrings(Recognizer<?, ?> recognizer, PredictionContext stop, int currentState)
-
Field Details
-
EMPTY_LOCAL
-
EMPTY_FULL
-
EMPTY_LOCAL_STATE_KEY
public static final int EMPTY_LOCAL_STATE_KEY- See Also:
-
EMPTY_FULL_STATE_KEY
public static final int EMPTY_FULL_STATE_KEY- See Also:
-
INITIAL_HASH
private static final int INITIAL_HASH- See Also:
-
cachedHashCode
private final int cachedHashCodeStores the computed hash code of thisPredictionContext. The hash code is computed in parts to match the following reference algorithm.private int referenceHashCode() { int hash =MurmurHash.initialize(INITIAL_HASH); for (int i = 0; i <size(); i++) { hash =MurmurHash.update(hash,getParent(i)); } for (int i = 0; i <size(); i++) { hash =MurmurHash.update(hash,getReturnState(i)); } hash =MurmurHash.finish(hash, 2 *size()); return hash; }
-
-
Constructor Details
-
PredictionContext
protected PredictionContext(int cachedHashCode)
-
-
Method Details
-
calculateEmptyHashCode
protected static int calculateEmptyHashCode() -
calculateHashCode
-
calculateHashCode
-
size
public abstract int size() -
getReturnState
public abstract int getReturnState(int index) -
findReturnState
public abstract int findReturnState(int returnState) -
getParent
-
addEmptyContext
-
removeEmptyContext
-
fromRuleContext
public static PredictionContext fromRuleContext(@NotNull ATN atn, @NotNull RuleContext outerContext) -
fromRuleContext
public static PredictionContext fromRuleContext(@NotNull ATN atn, @NotNull RuleContext outerContext, boolean fullContext) -
addEmptyContext
-
removeEmptyContext
-
join
-
join
static PredictionContext join(@NotNull PredictionContext context0, @NotNull PredictionContext context1, @NotNull PredictionContextCache contextCache) -
isEmptyLocal
-
getCachedContext
public static PredictionContext getCachedContext(@NotNull PredictionContext context, @NotNull ConcurrentMap<PredictionContext, PredictionContext> contextCache, @NotNull PredictionContext.IdentityHashMap visited) -
appendContext
-
appendContext
public abstract PredictionContext appendContext(PredictionContext suffix, PredictionContextCache contextCache) -
getChild
-
isEmpty
public abstract boolean isEmpty() -
hasEmpty
public abstract boolean hasEmpty() -
hashCode
public final int hashCode() -
equals
-
toStrings
-
toStrings
-