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.
11 class ANTLR4CPP_PUBLIC ATNSerializer {
15 ATNSerializer(ATN *atn);
16 ATNSerializer(ATN *atn, const std::vector<std::string> &tokenNames);
17 virtual ~ATNSerializer();
20 /// Serialize state descriptors, edge descriptors, and decision->state map
21 /// into list of ints:
23 /// grammar-type, (ANTLRParser.LEXER, ...)
26 /// state-0-type ruleIndex, state-1-type ruleIndex, ... state-i-type
27 /// ruleIndex optional-arg ...
29 /// rule-1-start-state rule-1-args, rule-2-start-state rule-2-args, ...
30 /// (args are token type,actionIndex in lexer else 0,0)
32 /// mode-0-start-state, mode-1-start-state, ... (parser has 0 modes)
34 /// set-0-interval-count intervals, set-1-interval-count intervals, ...
36 /// src, trg, edge-type, edge arg1, optional edge arg2 (present always),
39 /// decision-0-start-state, decision-1-start-state, ...
41 /// Convenient to pack into unsigned shorts to make as Java string.
43 virtual std::vector<size_t> serialize();
45 virtual std::string decode(const std::wstring& data);
46 virtual std::string getTokenName(size_t t);
48 /// Used by Java target to encode short/int array as chars in string.
49 static std::wstring getSerializedAsString(ATN *atn);
50 static std::vector<size_t> getSerialized(ATN *atn);
52 static std::string getDecoded(ATN *atn, std::vector<std::string> &tokenNames);
55 std::vector<std::string> _tokenNames;
57 void serializeUUID(std::vector<size_t> &data, Guid uuid);