Package org.antlr.v4.runtime.atn
Class ATNDeserializer
java.lang.Object
org.antlr.v4.runtime.atn.ATNDeserializer
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interface(package private) static enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final UUIDThis UUID indicates an extension of#ADDED_PRECEDENCE_TRANSITIONSfor the addition of lexer actions encoded as a sequence ofLexerActioninstances.private static final UUIDThis UUID indicates the serialized ATN contains two sets of IntervalSets, where the second set's values are encoded as 32-bit integers to support the full Unicode SMP range up to U+10FFFF.private static final UUIDThis is the earliest supported serialized UUID.private final ATNDeserializationOptionsstatic final UUIDThis is the current serialized UUID.static final intThis list contains all of the currently supported UUIDs, ordered by when the feature first appeared in this branch. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckCondition(boolean condition) protected voidcheckCondition(boolean condition, String message) private static intdeserialize(char[] data) Deserializes an ATN from a char array.deserialize(String data) Deserializes an ATN from its serializedStringform.private ATNdeserializeMutating(char[] data) Internal deserialize that mutatesdatain place (decoding shift).private intdeserializeSets(char[] data, int p, List<IntervalSet> sets, ATNDeserializer.UnicodeDeserializer unicodeDeserializer) protected TransitionedgeFactory(ATN atn, int type, int src, int trg, int arg1, int arg2, int arg3, List<IntervalSet> sets) (package private) static ATNDeserializer.UnicodeDeserializerprivate static voididentifyTailCalls(ATN atn) private static intinlineSetRules(ATN atn) protected booleanisFeatureSupported(UUID feature, UUID actualUuid) Determines if a particular serialized representation of an ATN supports a particular feature, identified by theUUIDused for serializing the ATN at the time the feature was first introduced.protected LexerActionlexerActionFactory(LexerActionType type, int data1, int data2) protected voidAnalyze theStarLoopEntryStatestates in the specified ATN to set theStarLoopEntryState.precedenceRuleDecisionfield to the correct value.private static intoptimizeSets(ATN atn, boolean preserveOrder) protected ATNStatestateFactory(int type, int ruleIndex) private static booleantestTailCall(ATN atn, RuleTransition transition, boolean optimizedPath) protected static inttoInt(char c) protected static inttoInt32(char[] data, int offset) protected static longtoLong(char[] data, int offset) protected static UUIDtoUUID(char[] data, int offset) protected void
-
Field Details
-
SERIALIZED_VERSION
public static final int SERIALIZED_VERSION -
BASE_SERIALIZED_UUID
This is the earliest supported serialized UUID. -
ADDED_LEXER_ACTIONS
This UUID indicates an extension of#ADDED_PRECEDENCE_TRANSITIONSfor the addition of lexer actions encoded as a sequence ofLexerActioninstances. -
ADDED_UNICODE_SMP
This UUID indicates the serialized ATN contains two sets of IntervalSets, where the second set's values are encoded as 32-bit integers to support the full Unicode SMP range up to U+10FFFF. -
SUPPORTED_UUIDS
This list contains all of the currently supported UUIDs, ordered by when the feature first appeared in this branch. -
SERIALIZED_UUID
This is the current serialized UUID. -
deserializationOptions
-
-
Constructor Details
-
ATNDeserializer
public ATNDeserializer() -
ATNDeserializer
-
-
Method Details
-
getUnicodeDeserializer
static ATNDeserializer.UnicodeDeserializer getUnicodeDeserializer(ATNDeserializer.UnicodeDeserializingMode mode) -
isFeatureSupported
Determines if a particular serialized representation of an ATN supports a particular feature, identified by theUUIDused for serializing the ATN at the time the feature was first introduced.- Parameters:
feature- TheUUIDmarking the first time the feature was supported in the serialized ATN.actualUuid- TheUUIDof the actual serialized ATN which is currently being deserialized.- Returns:
trueif theactualUuidvalue represents a serialized ATN at or after the feature identified byfeaturewas introduced; otherwise,false.
-
deserialize
Deserializes an ATN from its serializedStringform.This path is preferred for generated recognizers:
String.toCharArray()produces a private buffer that is mutated in place for the historical+2encoding shift, avoiding a second defensiveclone()that thedeserialize(char[])overload must perform for caller safety.- Parameters:
data- the serialized ATN (tool-encoded string literal)- Returns:
- the reconstructed ATN
-
deserialize
Deserializes an ATN from a char array.The input array is defensively cloned before the decoding shift is applied so callers may reuse
dataafterward. Preferdeserialize(String)when the source is a string constant to avoid the clone.- Parameters:
data- the serialized ATN characters- Returns:
- the reconstructed ATN
-
deserializeMutating
Internal deserialize that mutatesdatain place (decoding shift). Callers must pass a buffer they exclusively own. -
deserializeSets
private int deserializeSets(char[] data, int p, List<IntervalSet> sets, ATNDeserializer.UnicodeDeserializer unicodeDeserializer) -
markPrecedenceDecisions
Analyze theStarLoopEntryStatestates in the specified ATN to set theStarLoopEntryState.precedenceRuleDecisionfield to the correct value.- Parameters:
atn- The ATN.
-
verifyATN
-
checkCondition
protected void checkCondition(boolean condition) -
checkCondition
-
inlineSetRules
-
combineChainedEpsilons
-
optimizeSets
-
identifyTailCalls
-
testTailCall
-
toInt
protected static int toInt(char c) -
toInt32
protected static int toInt32(char[] data, int offset) -
toLong
protected static long toLong(char[] data, int offset) -
toUUID
-
edgeFactory
@NotNull protected Transition edgeFactory(@NotNull ATN atn, int type, int src, int trg, int arg1, int arg2, int arg3, List<IntervalSet> sets) -
stateFactory
-
lexerActionFactory
-