]> gitweb.ps.run Git - toc/blob - antlr4-cpp-runtime-4.9.2-source/runtime/src/tree/xpath/XPathLexer.cpp
add antlr source code and ReadMe
[toc] / antlr4-cpp-runtime-4.9.2-source / runtime / src / tree / xpath / XPathLexer.cpp
1 #include "XPathLexer.h"
2
3
4 using namespace antlr4;
5
6
7 XPathLexer::XPathLexer(CharStream *input) : Lexer(input) {
8   _interpreter = new atn::LexerATNSimulator(this, _atn, _decisionToDFA, _sharedContextCache);
9 }
10
11 XPathLexer::~XPathLexer() {
12   delete _interpreter;
13 }
14
15 std::string XPathLexer::getGrammarFileName() const {
16   return "XPathLexer.g4";
17 }
18
19 const std::vector<std::string>& XPathLexer::getRuleNames() const {
20   return _ruleNames;
21 }
22
23 const std::vector<std::string>& XPathLexer::getChannelNames() const {
24   return _channelNames;
25 }
26
27 const std::vector<std::string>& XPathLexer::getModeNames() const {
28   return _modeNames;
29 }
30
31 const std::vector<std::string>& XPathLexer::getTokenNames() const {
32   return _tokenNames;
33 }
34
35 dfa::Vocabulary& XPathLexer::getVocabulary() const {
36   return _vocabulary;
37 }
38
39 const std::vector<uint16_t> XPathLexer::getSerializedATN() const {
40   return _serializedATN;
41 }
42
43 const atn::ATN& XPathLexer::getATN() const {
44   return _atn;
45 }
46
47
48 void XPathLexer::action(RuleContext *context, size_t ruleIndex, size_t actionIndex) {
49   switch (ruleIndex) {
50     case 4: IDAction(dynamic_cast<antlr4::RuleContext *>(context), actionIndex); break;
51
52   default:
53     break;
54   }
55 }
56
57 void XPathLexer::IDAction(antlr4::RuleContext * /*context*/, size_t actionIndex) {
58   switch (actionIndex) {
59     case 0: 
60                                 if (isupper(getText()[0]))
61                                   setType(TOKEN_REF);
62                                 else
63                                   setType(RULE_REF);
64                                  break;
65
66   default:
67     break;
68   }
69 }
70
71
72
73 // Static vars and initialization.
74 std::vector<dfa::DFA> XPathLexer::_decisionToDFA;
75 atn::PredictionContextCache XPathLexer::_sharedContextCache;
76
77 // We own the ATN which in turn owns the ATN states.
78 atn::ATN XPathLexer::_atn;
79 std::vector<uint16_t> XPathLexer::_serializedATN;
80
81 std::vector<std::string> XPathLexer::_ruleNames = {
82   "ANYWHERE", "ROOT", "WILDCARD", "BANG", "ID", "NameChar", "NameStartChar", 
83   "STRING"
84 };
85
86 std::vector<std::string> XPathLexer::_channelNames = {
87   "DEFAULT_TOKEN_CHANNEL", "HIDDEN"
88 };
89
90 std::vector<std::string> XPathLexer::_modeNames = {
91   "DEFAULT_MODE"
92 };
93
94 std::vector<std::string> XPathLexer::_literalNames = {
95   "", "", "", "'//'", "'/'", "'*'", "'!'"
96 };
97
98 std::vector<std::string> XPathLexer::_symbolicNames = {
99   "", "TOKEN_REF", "RULE_REF", "ANYWHERE", "ROOT", "WILDCARD", "BANG", "ID", 
100   "STRING"
101 };
102
103 dfa::Vocabulary XPathLexer::_vocabulary(_literalNames, _symbolicNames);
104
105 std::vector<std::string> XPathLexer::_tokenNames;
106
107 XPathLexer::Initializer::Initializer() {
108   // This code could be in a static initializer lambda, but VS doesn't allow access to private class members from there.
109         for (size_t i = 0; i < _symbolicNames.size(); ++i) {
110                 std::string name = _vocabulary.getLiteralName(i);
111                 if (name.empty()) {
112                         name = _vocabulary.getSymbolicName(i);
113                 }
114
115                 if (name.empty()) {
116                         _tokenNames.push_back("<INVALID>");
117                 } else {
118       _tokenNames.push_back(name);
119     }
120         }
121
122   _serializedATN = {
123     0x3, 0x430, 0xd6d1, 0x8206, 0xad2d, 0x4417, 0xaef1, 0x8d80, 0xaadd, 
124     0x2, 0xa, 0x34, 0x8, 0x1, 0x4, 0x2, 0x9, 0x2, 0x4, 0x3, 0x9, 0x3, 0x4, 
125     0x4, 0x9, 0x4, 0x4, 0x5, 0x9, 0x5, 0x4, 0x6, 0x9, 0x6, 0x4, 0x7, 0x9, 
126     0x7, 0x4, 0x8, 0x9, 0x8, 0x4, 0x9, 0x9, 0x9, 0x3, 0x2, 0x3, 0x2, 0x3, 
127     0x2, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x4, 0x3, 0x5, 0x3, 0x5, 0x3, 
128     0x6, 0x3, 0x6, 0x7, 0x6, 0x1f, 0xa, 0x6, 0xc, 0x6, 0xe, 0x6, 0x22, 0xb, 
129     0x6, 0x3, 0x6, 0x3, 0x6, 0x3, 0x7, 0x3, 0x7, 0x5, 0x7, 0x28, 0xa, 0x7, 
130     0x3, 0x8, 0x3, 0x8, 0x3, 0x9, 0x3, 0x9, 0x7, 0x9, 0x2e, 0xa, 0x9, 0xc, 
131     0x9, 0xe, 0x9, 0x31, 0xb, 0x9, 0x3, 0x9, 0x3, 0x9, 0x3, 0x2f, 0x2, 0xa, 
132     0x3, 0x5, 0x5, 0x6, 0x7, 0x7, 0x9, 0x8, 0xb, 0x9, 0xd, 0x2, 0xf, 0x2, 
133     0x11, 0xa, 0x3, 0x2, 0x4, 0x7, 0x2, 0x32, 0x3b, 0x61, 0x61, 0xb9, 0xb9, 
134     0x302, 0x371, 0x2041, 0x2042, 0xf, 0x2, 0x43, 0x5c, 0x63, 0x7c, 0xc2, 
135     0xd8, 0xda, 0xf8, 0xfa, 0x301, 0x372, 0x37f, 0x381, 0x2001, 0x200e, 
136     0x200f, 0x2072, 0x2191, 0x2c02, 0x2ff1, 0x3003, 0xd801, 0xf902, 0xfdd1, 
137     0xfdf2, 0x1, 0x34, 0x2, 0x3, 0x3, 0x2, 0x2, 0x2, 0x2, 0x5, 0x3, 0x2, 
138     0x2, 0x2, 0x2, 0x7, 0x3, 0x2, 0x2, 0x2, 0x2, 0x9, 0x3, 0x2, 0x2, 0x2, 
139     0x2, 0xb, 0x3, 0x2, 0x2, 0x2, 0x2, 0x11, 0x3, 0x2, 0x2, 0x2, 0x3, 0x13, 
140     0x3, 0x2, 0x2, 0x2, 0x5, 0x16, 0x3, 0x2, 0x2, 0x2, 0x7, 0x18, 0x3, 0x2, 
141     0x2, 0x2, 0x9, 0x1a, 0x3, 0x2, 0x2, 0x2, 0xb, 0x1c, 0x3, 0x2, 0x2, 0x2, 
142     0xd, 0x27, 0x3, 0x2, 0x2, 0x2, 0xf, 0x29, 0x3, 0x2, 0x2, 0x2, 0x11, 
143     0x2b, 0x3, 0x2, 0x2, 0x2, 0x13, 0x14, 0x7, 0x31, 0x2, 0x2, 0x14, 0x15, 
144     0x7, 0x31, 0x2, 0x2, 0x15, 0x4, 0x3, 0x2, 0x2, 0x2, 0x16, 0x17, 0x7, 
145     0x31, 0x2, 0x2, 0x17, 0x6, 0x3, 0x2, 0x2, 0x2, 0x18, 0x19, 0x7, 0x2c, 
146     0x2, 0x2, 0x19, 0x8, 0x3, 0x2, 0x2, 0x2, 0x1a, 0x1b, 0x7, 0x23, 0x2, 
147     0x2, 0x1b, 0xa, 0x3, 0x2, 0x2, 0x2, 0x1c, 0x20, 0x5, 0xf, 0x8, 0x2, 
148     0x1d, 0x1f, 0x5, 0xd, 0x7, 0x2, 0x1e, 0x1d, 0x3, 0x2, 0x2, 0x2, 0x1f, 
149     0x22, 0x3, 0x2, 0x2, 0x2, 0x20, 0x1e, 0x3, 0x2, 0x2, 0x2, 0x20, 0x21, 
150     0x3, 0x2, 0x2, 0x2, 0x21, 0x23, 0x3, 0x2, 0x2, 0x2, 0x22, 0x20, 0x3, 
151     0x2, 0x2, 0x2, 0x23, 0x24, 0x8, 0x6, 0x2, 0x2, 0x24, 0xc, 0x3, 0x2, 
152     0x2, 0x2, 0x25, 0x28, 0x5, 0xf, 0x8, 0x2, 0x26, 0x28, 0x9, 0x2, 0x2, 
153     0x2, 0x27, 0x25, 0x3, 0x2, 0x2, 0x2, 0x27, 0x26, 0x3, 0x2, 0x2, 0x2, 
154     0x28, 0xe, 0x3, 0x2, 0x2, 0x2, 0x29, 0x2a, 0x9, 0x3, 0x2, 0x2, 0x2a, 
155     0x10, 0x3, 0x2, 0x2, 0x2, 0x2b, 0x2f, 0x7, 0x29, 0x2, 0x2, 0x2c, 0x2e, 
156     0xb, 0x2, 0x2, 0x2, 0x2d, 0x2c, 0x3, 0x2, 0x2, 0x2, 0x2e, 0x31, 0x3, 
157     0x2, 0x2, 0x2, 0x2f, 0x30, 0x3, 0x2, 0x2, 0x2, 0x2f, 0x2d, 0x3, 0x2, 
158     0x2, 0x2, 0x30, 0x32, 0x3, 0x2, 0x2, 0x2, 0x31, 0x2f, 0x3, 0x2, 0x2, 
159     0x2, 0x32, 0x33, 0x7, 0x29, 0x2, 0x2, 0x33, 0x12, 0x3, 0x2, 0x2, 0x2, 
160     0x6, 0x2, 0x20, 0x27, 0x2f, 0x3, 0x3, 0x6, 0x2, 
161   };
162
163   atn::ATNDeserializer deserializer;
164   _atn = deserializer.deserialize(_serializedATN);
165
166   size_t count = _atn.getNumberOfDecisions();
167   _decisionToDFA.reserve(count);
168   for (size_t i = 0; i < count; i++) { 
169     _decisionToDFA.emplace_back(_atn.getDecisionState(i), i);
170   }
171 }
172
173 XPathLexer::Initializer XPathLexer::_init;