abouttreesummaryrefslogcommitdiff
path: root/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/atn/ATNSerializer.h
diff options
context:
space:
mode:
authorPatrick Schönberger2021-07-28 09:07:53 +0200
committerPatrick Schönberger2021-07-28 09:07:53 +0200
commit45409c781a9e35df68c43b1e2f028d30bf90c0a0 (patch)
tree0085614e19fdc136f664568e89f1686332ba8850 /antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/atn/ATNSerializer.h
downloadtoc-45409c781a9e35df68c43b1e2f028d30bf90c0a0.tar.gz
toc-45409c781a9e35df68c43b1e2f028d30bf90c0a0.zip
Initial commit
Diffstat (limited to 'antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/atn/ATNSerializer.h')
-rw-r--r--antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/atn/ATNSerializer.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/atn/ATNSerializer.h b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/atn/ATNSerializer.h
new file mode 100644
index 0000000..a6d1d69
--- /dev/null
+++ b/antlr4-cpp-runtime-4.9.2-source/install/include/antlr4-runtime/atn/ATNSerializer.h
@@ -0,0 +1,61 @@
+/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
+ * Use of this file is governed by the BSD 3-clause license that
+ * can be found in the LICENSE.txt file in the project root.
+ */
+
+#pragma once
+
+namespace antlr4 {
+namespace atn {
+
+ class ANTLR4CPP_PUBLIC ATNSerializer {
+ public:
+ ATN *atn;
+
+ ATNSerializer(ATN *atn);
+ ATNSerializer(ATN *atn, const std::vector<std::string> &tokenNames);
+ virtual ~ATNSerializer();
+
+ /// <summary>
+ /// Serialize state descriptors, edge descriptors, and decision->state map
+ /// into list of ints:
+ ///
+ /// grammar-type, (ANTLRParser.LEXER, ...)
+ /// max token type,
+ /// num states,
+ /// state-0-type ruleIndex, state-1-type ruleIndex, ... state-i-type
+ /// ruleIndex optional-arg ...
+ /// num rules,
+ /// rule-1-start-state rule-1-args, rule-2-start-state rule-2-args, ...
+ /// (args are token type,actionIndex in lexer else 0,0)
+ /// num modes,
+ /// mode-0-start-state, mode-1-start-state, ... (parser has 0 modes)
+ /// num sets
+ /// set-0-interval-count intervals, set-1-interval-count intervals, ...
+ /// num total edges,
+ /// src, trg, edge-type, edge arg1, optional edge arg2 (present always),
+ /// ...
+ /// num decisions,
+ /// decision-0-start-state, decision-1-start-state, ...
+ ///
+ /// Convenient to pack into unsigned shorts to make as Java string.
+ /// </summary>
+ virtual std::vector<size_t> serialize();
+
+ virtual std::string decode(const std::wstring& data);
+ virtual std::string getTokenName(size_t t);
+
+ /// Used by Java target to encode short/int array as chars in string.
+ static std::wstring getSerializedAsString(ATN *atn);
+ static std::vector<size_t> getSerialized(ATN *atn);
+
+ static std::string getDecoded(ATN *atn, std::vector<std::string> &tokenNames);
+
+ private:
+ std::vector<std::string> _tokenNames;
+
+ void serializeUUID(std::vector<size_t> &data, Guid uuid);
+ };
+
+} // namespace atn
+} // namespace antlr4