Class ATNConfig
- java.lang.Object
-
- org.antlr.v4.runtime.atn.ATNConfig
-
- Direct Known Subclasses:
LexerATNConfig
public class ATNConfig extends Object
A tuple: (ATN state, predicted alt, syntactic, semantic context). The syntactic context is a graph-structured stack node whose path(s) to the root is the rule invocation(s) chain used to arrive at the state. The semantic context is the tree of semantic predicates encountered before reaching an ATN state.
-
-
Field Summary
Fields Modifier and Type Field Description intaltWhat alt (or lexer rule) is predicted by this configurationPredictionContextcontextThe stack of invoking states leading to the rule/states associated with this config.intreachesIntoOuterContextWe cannot execute predicates dependent upon local context unless we know for sure we are in the correct context.SemanticContextsemanticContextATNStatestateThe ATN state associated with this configuration
-
Constructor Summary
Constructors Constructor Description ATNConfig(ATNConfig old)ATNConfig(ATNConfig c, ATNState state)ATNConfig(ATNConfig c, ATNState state, PredictionContext context)ATNConfig(ATNConfig c, ATNState state, PredictionContext context, SemanticContext semanticContext)ATNConfig(ATNConfig c, ATNState state, SemanticContext semanticContext)ATNConfig(ATNConfig c, SemanticContext semanticContext)ATNConfig(ATNState state, int alt, PredictionContext context)ATNConfig(ATNState state, int alt, PredictionContext context, SemanticContext semanticContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)An ATN configuration is equal to another if both have the same state, they predict the same alternative, and syntactic/semantic contexts are the same.booleanequals(ATNConfig other)intgetOuterContextDepth()This method gets the value of thereachesIntoOuterContextfield as it existed prior to the introduction of theisPrecedenceFilterSuppressed()method.inthashCode()booleanisPrecedenceFilterSuppressed()voidsetPrecedenceFilterSuppressed(boolean value)StringtoString()StringtoString(Recognizer<?,?> recog, boolean showAlt)
-
-
-
Field Detail
-
state
public final ATNState state
The ATN state associated with this configuration
-
alt
public final int alt
What alt (or lexer rule) is predicted by this configuration
-
context
public PredictionContext context
The stack of invoking states leading to the rule/states associated with this config. We track only those contexts pushed during execution of the ATN simulator.
-
reachesIntoOuterContext
public int reachesIntoOuterContext
We cannot execute predicates dependent upon local context unless we know for sure we are in the correct context. Because there is no way to do this efficiently, we simply cannot evaluate dependent predicates unless we are in the rule that initially invokes the ATN simulator.closure() tracks the depth of how far we dip into the outer context: depth > 0. Note that it may not be totally accurate depth since I don't ever decrement. TODO: make it a boolean then
For memory efficiency, the
isPrecedenceFilterSuppressed()method is also backed by this field. Since the field is publicly accessible, the highest bit which would not cause the value to become negative is used to store this field. This choice minimizes the risk that code which only compares this value to 0 would be affected by the new purpose of the flag. It also ensures the performance of the existingATNConfigconstructors as well as certain operations likeATNConfigSet.add(ATNConfig, DoubleKeyMap)method are completely unaffected by the change.
-
semanticContext
public final SemanticContext semanticContext
-
-
Constructor Detail
-
ATNConfig
public ATNConfig(ATNConfig old)
-
ATNConfig
public ATNConfig(ATNState state, int alt, PredictionContext context)
-
ATNConfig
public ATNConfig(ATNState state, int alt, PredictionContext context, SemanticContext semanticContext)
-
ATNConfig
public ATNConfig(ATNConfig c, ATNState state, SemanticContext semanticContext)
-
ATNConfig
public ATNConfig(ATNConfig c, SemanticContext semanticContext)
-
ATNConfig
public ATNConfig(ATNConfig c, ATNState state, PredictionContext context)
-
ATNConfig
public ATNConfig(ATNConfig c, ATNState state, PredictionContext context, SemanticContext semanticContext)
-
-
Method Detail
-
getOuterContextDepth
public final int getOuterContextDepth()
This method gets the value of thereachesIntoOuterContextfield as it existed prior to the introduction of theisPrecedenceFilterSuppressed()method.
-
isPrecedenceFilterSuppressed
public final boolean isPrecedenceFilterSuppressed()
-
setPrecedenceFilterSuppressed
public final void setPrecedenceFilterSuppressed(boolean value)
-
equals
public boolean equals(Object o)
An ATN configuration is equal to another if both have the same state, they predict the same alternative, and syntactic/semantic contexts are the same.
-
equals
public boolean equals(ATNConfig other)
-
toString
public String toString(Recognizer<?,?> recog, boolean showAlt)
-
-