Class ATNDeserializer

java.lang.Object
org.antlr.v4.runtime.atn.ATNDeserializer

public class ATNDeserializer extends Object
  • Field Details

    • SERIALIZED_VERSION

      public static final int SERIALIZED_VERSION
    • BASE_SERIALIZED_UUID

      private static final UUID BASE_SERIALIZED_UUID
      This is the earliest supported serialized UUID.
    • ADDED_LEXER_ACTIONS

      private static final UUID ADDED_LEXER_ACTIONS
      This UUID indicates an extension of #ADDED_PRECEDENCE_TRANSITIONS for the addition of lexer actions encoded as a sequence of LexerAction instances.
    • ADDED_UNICODE_SMP

      private static final UUID 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

      private static final List<UUID> SUPPORTED_UUIDS
      This list contains all of the currently supported UUIDs, ordered by when the feature first appeared in this branch.
    • SERIALIZED_UUID

      public static final UUID SERIALIZED_UUID
      This is the current serialized UUID.
    • deserializationOptions

      @NotNull private final ATNDeserializationOptions deserializationOptions
  • Constructor Details

  • Method Details

    • getUnicodeDeserializer

    • isFeatureSupported

      protected boolean isFeatureSupported(UUID feature, UUID actualUuid)
      Determines if a particular serialized representation of an ATN supports a particular feature, identified by the UUID used for serializing the ATN at the time the feature was first introduced.
      Parameters:
      feature - The UUID marking the first time the feature was supported in the serialized ATN.
      actualUuid - The UUID of the actual serialized ATN which is currently being deserialized.
      Returns:
      true if the actualUuid value represents a serialized ATN at or after the feature identified by feature was introduced; otherwise, false.
    • deserialize

      @NotNull public ATN deserialize(@NotNull String data)
      Deserializes an ATN from its serialized String form.

      This path is preferred for generated recognizers: String.toCharArray() produces a private buffer that is mutated in place for the historical +2 encoding shift, avoiding a second defensive clone() that the deserialize(char[]) overload must perform for caller safety.

      Parameters:
      data - the serialized ATN (tool-encoded string literal)
      Returns:
      the reconstructed ATN
    • deserialize

      @NotNull public ATN deserialize(@NotNull char[] data)
      Deserializes an ATN from a char array.

      The input array is defensively cloned before the decoding shift is applied so callers may reuse data afterward. Prefer deserialize(String) when the source is a string constant to avoid the clone.

      Parameters:
      data - the serialized ATN characters
      Returns:
      the reconstructed ATN
    • deserializeMutating

      private ATN deserializeMutating(@NotNull char[] data)
      Internal deserialize that mutates data in 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

      protected void markPrecedenceDecisions(@NotNull ATN atn)
      Analyze the StarLoopEntryState states in the specified ATN to set the StarLoopEntryState.precedenceRuleDecision field to the correct value.
      Parameters:
      atn - The ATN.
    • verifyATN

      protected void verifyATN(ATN atn)
    • checkCondition

      protected void checkCondition(boolean condition)
    • checkCondition

      protected void checkCondition(boolean condition, String message)
    • inlineSetRules

      private static int inlineSetRules(ATN atn)
    • combineChainedEpsilons

      private static int combineChainedEpsilons(ATN atn)
    • optimizeSets

      private static int optimizeSets(ATN atn, boolean preserveOrder)
    • identifyTailCalls

      private static void identifyTailCalls(ATN atn)
    • testTailCall

      private static boolean testTailCall(ATN atn, RuleTransition transition, boolean optimizedPath)
    • 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

      protected static UUID toUUID(char[] data, int offset)
    • edgeFactory

      @NotNull protected Transition edgeFactory(@NotNull ATN atn, int type, int src, int trg, int arg1, int arg2, int arg3, List<IntervalSet> sets)
    • stateFactory

      protected ATNState stateFactory(int type, int ruleIndex)
    • lexerActionFactory

      protected LexerAction lexerActionFactory(LexerActionType type, int data1, int data2)