1 /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
2 * Use of this file is governed by the BSD 3-clause license that
3 * can be found in the LICENSE.txt file in the project root.
8 #include "atn/LexerAction.h"
9 #include "atn/ATNDeserializationOptions.h"
14 class ANTLR4CPP_PUBLIC ATNDeserializer {
16 #if __cplusplus >= 201703L
17 static constexpr size_t SERIALIZED_VERSION = 3;
20 SERIALIZED_VERSION = 3,
24 /// This is the current serialized UUID.
25 // ml: defined as function to avoid the “static initialization order fiasco”.
26 static Guid SERIALIZED_UUID();
29 ATNDeserializer(const ATNDeserializationOptions& dso);
30 virtual ~ATNDeserializer();
32 static Guid toUUID(const unsigned short *data, size_t offset);
34 virtual ATN deserialize(const std::vector<uint16_t> &input);
35 virtual void verifyATN(const ATN &atn);
37 static void checkCondition(bool condition);
38 static void checkCondition(bool condition, const std::string &message);
40 static Transition *edgeFactory(const ATN &atn, size_t type, size_t src, size_t trg, size_t arg1, size_t arg2,
41 size_t arg3, const std::vector<misc::IntervalSet> &sets);
43 static ATNState *stateFactory(size_t type, size_t ruleIndex);
46 /// Determines if a particular serialized representation of an ATN supports
47 /// a particular feature, identified by the <seealso cref="UUID"/> used for serializing
48 /// the ATN at the time the feature was first introduced.
50 /// <param name="feature"> The <seealso cref="UUID"/> marking the first time the feature was
51 /// supported in the serialized ATN. </param>
52 /// <param name="actualUuid"> The <seealso cref="UUID"/> of the actual serialized ATN which is
53 /// currently being deserialized. </param>
54 /// <returns> {@code true} if the {@code actualUuid} value represents a
55 /// serialized ATN at or after the feature identified by {@code feature} was
56 /// introduced; otherwise, {@code false}. </returns>
57 virtual bool isFeatureSupported(const Guid &feature, const Guid &actualUuid);
58 void markPrecedenceDecisions(const ATN &atn);
59 Ref<LexerAction> lexerActionFactory(LexerActionType type, int data1, int data2);
62 /// This is the earliest supported serialized UUID.
63 static Guid BASE_SERIALIZED_UUID();
65 /// This UUID indicates an extension of <seealso cref="BASE_SERIALIZED_UUID"/> for the
66 /// addition of precedence predicates.
67 static Guid ADDED_PRECEDENCE_TRANSITIONS();
70 * This UUID indicates an extension of ADDED_PRECEDENCE_TRANSITIONS
71 * for the addition of lexer actions encoded as a sequence of
72 * LexerAction instances.
74 static Guid ADDED_LEXER_ACTIONS();
77 * This UUID indicates the serialized ATN contains two sets of
78 * IntervalSets, where the second set's values are encoded as
79 * 32-bit integers to support the full Unicode SMP range up to U+10FFFF.
81 static Guid ADDED_UNICODE_SMP();
83 /// This list contains all of the currently supported UUIDs, ordered by when
84 /// the feature first appeared in this branch.
85 static std::vector<Guid>& SUPPORTED_UUIDS();
87 ATNDeserializationOptions deserializationOptions;