1
2
3
4 #include <sngcm/cmlexer/CmajorTokens.hpp>
5 #include <map>
6
7 namespace CmajorTokens
8 {
9 std::map<std::u32string, int> tokenIdMap;
10
11 void InitTokenIdMap()
12 {
13 tokenIdMap[U"ABSTRACT"] = 40;
14 tokenIdMap[U"AMP"] = 92;
15 tokenIdMap[U"AMPAMP"] = 89;
16 tokenIdMap[U"AND"] = 77;
17 tokenIdMap[U"ARROW"] = 108;
18 tokenIdMap[U"AS"] = 28;
19 tokenIdMap[U"ASSERT"] = 1;
20 tokenIdMap[U"ASSIGN"] = 118;
21 tokenIdMap[U"AXIOM"] = 76;
22 tokenIdMap[U"BASE"] = 65;
23 tokenIdMap[U"BITOR"] = 90;
24 tokenIdMap[U"BITXOR"] = 91;
25 tokenIdMap[U"BOOL"] = 4;
26 tokenIdMap[U"BREAK"] = 55;
27 tokenIdMap[U"BYTE"] = 8;
28 tokenIdMap[U"CASE"] = 50;
29 tokenIdMap[U"CAST"] = 22;
30 tokenIdMap[U"CATCH"] = 72;
31 tokenIdMap[U"CDECL"] = 33;
32 tokenIdMap[U"CHAR"] = 17;
33 tokenIdMap[U"CHARLIT"] = 84;
34 tokenIdMap[U"CLASS"] = 45;
35 tokenIdMap[U"COLON"] = 119;
36 tokenIdMap[U"COMMA"] = 117;
37 tokenIdMap[U"COMMENT"] = 122;
38 tokenIdMap[U"CONCEPT"] = 74;
39 tokenIdMap[U"CONST"] = 61;
40 tokenIdMap[U"CONSTEXPR"] = 62;
41 tokenIdMap[U"CONSTRUCT"] = 66;
42 tokenIdMap[U"CONTINUE"] = 56;
43 tokenIdMap[U"CPL"] = 106;
44 tokenIdMap[U"DEFAULT"] = 51;
45 tokenIdMap[U"DELEGATE"] = 31;
46 tokenIdMap[U"DELETE"] = 69;
47 tokenIdMap[U"DESTROY"] = 67;
48 tokenIdMap[U"DISJUNCTION"] = 88;
49 tokenIdMap[U"DIV"] = 102;
50 tokenIdMap[U"DO"] = 53;
51 tokenIdMap[U"DOT"] = 107;
52 tokenIdMap[U"DOUBLE"] = 16;
53 tokenIdMap[U"ELIF"] = 2;
54 tokenIdMap[U"ELSE"] = 48;
55 tokenIdMap[U"ENDIF"] = 3;
56 tokenIdMap[U"ENUM"] = 21;
57 tokenIdMap[U"EQ"] = 93;
58 tokenIdMap[U"EQUIVALENCE"] = 86;
59 tokenIdMap[U"EXCLAMATION"] = 79;
60 tokenIdMap[U"EXPLICIT"] = 30;
61 tokenIdMap[U"EXTERN"] = 27;
62 tokenIdMap[U"FALSE"] = 6;
63 tokenIdMap[U"FLOAT"] = 15;
64 tokenIdMap[U"FLOATINGLIT"] = 82;
65 tokenIdMap[U"FOR"] = 54;
66 tokenIdMap[U"GEQ"] = 96;
67 tokenIdMap[U"GOTO"] = 57;
68 tokenIdMap[U"HASH"] = 121;
69 tokenIdMap[U"ID"] = 81;
70 tokenIdMap[U"IF"] = 47;
71 tokenIdMap[U"IMPLICATION"] = 87;
72 tokenIdMap[U"INLINE"] = 32;
73 tokenIdMap[U"INT"] = 11;
74 tokenIdMap[U"INTERFACE"] = 23;
75 tokenIdMap[U"INTERNAL"] = 38;
76 tokenIdMap[U"INTLIT"] = 83;
77 tokenIdMap[U"IS"] = 29;
78 tokenIdMap[U"LANGLE"] = 113;
79 tokenIdMap[U"LBRACE"] = 115;
80 tokenIdMap[U"LBRACKET"] = 109;
81 tokenIdMap[U"LEQ"] = 95;
82 tokenIdMap[U"LONG"] = 13;
83 tokenIdMap[U"LPAREN"] = 111;
84 tokenIdMap[U"MINUS"] = 100;
85 tokenIdMap[U"MINUSMINUS"] = 105;
86 tokenIdMap[U"NAMESPACE"] = 24;
87 tokenIdMap[U"NEQ"] = 94;
88 tokenIdMap[U"NEW"] = 68;
89 tokenIdMap[U"NOTHROW"] = 34;
90 tokenIdMap[U"NULLLIT"] = 63;
91 tokenIdMap[U"OPERATOR"] = 44;
92 tokenIdMap[U"OR"] = 78;
93 tokenIdMap[U"OVERRIDE"] = 41;
94 tokenIdMap[U"PLUS"] = 99;
95 tokenIdMap[U"PLUSPLUS"] = 104;
96 tokenIdMap[U"PRIVATE"] = 37;
97 tokenIdMap[U"PROTECTED"] = 36;
98 tokenIdMap[U"PUBLIC"] = 35;
99 tokenIdMap[U"RANGLE"] = 114;
100 tokenIdMap[U"RBRACE"] = 116;
101 tokenIdMap[U"RBRACKET"] = 110;
102 tokenIdMap[U"REM"] = 103;
103 tokenIdMap[U"RETURN"] = 46;
104 tokenIdMap[U"RPAREN"] = 112;
105 tokenIdMap[U"SBYTE"] = 7;
106 tokenIdMap[U"SEMICOLON"] = 120;
107 tokenIdMap[U"SHIFTLEFT"] = 97;
108 tokenIdMap[U"SHIFTRIGHT"] = 98;
109 tokenIdMap[U"SHORT"] = 9;
110 tokenIdMap[U"SIZEOF"] = 70;
111 tokenIdMap[U"STAR"] = 101;
112 tokenIdMap[U"STATIC"] = 26;
113 tokenIdMap[U"STRINGLIT"] = 85;
114 tokenIdMap[U"SUPPRESS"] = 42;
115 tokenIdMap[U"SWITCH"] = 49;
116 tokenIdMap[U"THIS"] = 64;
117 tokenIdMap[U"THROW"] = 73;
118 tokenIdMap[U"TRUE"] = 5;
119 tokenIdMap[U"TRY"] = 71;
120 tokenIdMap[U"TYPEDEF"] = 58;
121 tokenIdMap[U"TYPEID"] = 60;
122 tokenIdMap[U"TYPENAME"] = 59;
123 tokenIdMap[U"UCHAR"] = 19;
124 tokenIdMap[U"UINT"] = 12;
125 tokenIdMap[U"ULONG"] = 14;
126 tokenIdMap[U"UNIT_TEST"] = 80;
127 tokenIdMap[U"USHORT"] = 10;
128 tokenIdMap[U"USING"] = 25;
129 tokenIdMap[U"VIRTUAL"] = 39;
130 tokenIdMap[U"VOID"] = 20;
131 tokenIdMap[U"WCHAR"] = 18;
132 tokenIdMap[U"WHERE"] = 75;
133 tokenIdMap[U"WHILE"] = 52;
134 tokenIdMap[U"WINAPI"] = 43;
135 tokenIdMap[U"WS"] = 123;
136 }
137
138 int GetTokenId(const std::u32string& tokenName)
139 {
140 auto it = tokenIdMap.find(tokenName);
141 if (it != tokenIdMap.cend())
142 {
143 return it->second;
144 }
145 else
146 {
147 return -1;
148 }
149 }
150
151 const char* tokenName[] =
152 {
153 "END",
154 "ASSERT",
155 "ELIF",
156 "ENDIF",
157 "BOOL",
158 "TRUE",
159 "FALSE",
160 "SBYTE",
161 "BYTE",
162 "SHORT",
163 "USHORT",
164 "INT",
165 "UINT",
166 "LONG",
167 "ULONG",
168 "FLOAT",
169 "DOUBLE",
170 "CHAR",
171 "WCHAR",
172 "UCHAR",
173 "VOID",
174 "ENUM",
175 "CAST",
176 "INTERFACE",
177 "NAMESPACE",
178 "USING",
179 "STATIC",
180 "EXTERN",
181 "AS",
182 "IS",
183 "EXPLICIT",
184 "DELEGATE",
185 "INLINE",
186 "CDECL",
187 "NOTHROW",
188 "PUBLIC",
189 "PROTECTED",
190 "PRIVATE",
191 "INTERNAL",
192 "VIRTUAL",
193 "ABSTRACT",
194 "OVERRIDE",
195 "SUPPRESS",
196 "WINAPI",
197 "OPERATOR",
198 "CLASS",
199 "RETURN",
200 "IF",
201 "ELSE",
202 "SWITCH",
203 "CASE",
204 "DEFAULT",
205 "WHILE",
206 "DO",
207 "FOR",
208 "BREAK",
209 "CONTINUE",
210 "GOTO",
211 "TYPEDEF",
212 "TYPENAME",
213 "TYPEID",
214 "CONST",
215 "CONSTEXPR",
216 "NULLLIT",
217 "THIS",
218 "BASE",
219 "CONSTRUCT",
220 "DESTROY",
221 "NEW",
222 "DELETE",
223 "SIZEOF",
224 "TRY",
225 "CATCH",
226 "THROW",
227 "CONCEPT",
228 "WHERE",
229 "AXIOM",
230 "AND",
231 "OR",
232 "EXCLAMATION",
233 "UNIT_TEST",
234 "ID",
235 "FLOATINGLIT",
236 "INTLIT",
237 "CHARLIT",
238 "STRINGLIT",
239 "EQUIVALENCE",
240 "IMPLICATION",
241 "DISJUNCTION",
242 "AMPAMP",
243 "BITOR",
244 "BITXOR",
245 "AMP",
246 "EQ",
247 "NEQ",
248 "LEQ",
249 "GEQ",
250 "SHIFTLEFT",
251 "SHIFTRIGHT",
252 "PLUS",
253 "MINUS",
254 "STAR",
255 "DIV",
256 "REM",
257 "PLUSPLUS",
258 "MINUSMINUS",
259 "CPL",
260 "DOT",
261 "ARROW",
262 "LBRACKET",
263 "RBRACKET",
264 "LPAREN",
265 "RPAREN",
266 "LANGLE",
267 "RANGLE",
268 "LBRACE",
269 "RBRACE",
270 "COMMA",
271 "ASSIGN",
272 "COLON",
273 "SEMICOLON",
274 "HASH",
275 "COMMENT",
276 "WS"
277 };
278
279 const char* GetTokenName(int tokenId)
280 {
281 return tokenName[tokenId];
282 }
283
284 const char* tokenInfo[] =
285 {
286 "end of file",
287 "'assert'",
288 "'elif'",
289 "'endif'",
290 "'bool'",
291 "'true'",
292 "'false'",
293 "'sbyte'",
294 "'byte'",
295 "'short'",
296 "'ushort'",
297 "'int'",
298 "'uint'",
299 "'long'",
300 "'ulong'",
301 "'float'",
302 "'double'",
303 "'char'",
304 "'wchar'",
305 "'uchar'",
306 "'void'",
307 "'enum'",
308 "'cast'",
309 "'interface'",
310 "'namespace'",
311 "'using'",
312 "'static'",
313 "'extern'",
314 "'as'",
315 "'is'",
316 "'explicit'",
317 "'delegate'",
318 "'inline'",
319 "'cdecl'",
320 "'nothrow'",
321 "'public'",
322 "'protected'",
323 "'private'",
324 "'internal'",
325 "'virtual'",
326 "'abstract'",
327 "'override'",
328 "'suppress'",
329 "'winapi'",
330 "'operator'",
331 "'class'",
332 "'return'",
333 "'if'",
334 "'else'",
335 "'switch'",
336 "'case'",
337 "'default'",
338 "'while'",
339 "'do'",
340 "'for'",
341 "'break'",
342 "'continue'",
343 "'goto'",
344 "'typedef'",
345 "'typename'",
346 "'typeid'",
347 "'const'",
348 "'constexpr'",
349 "'null'",
350 "'this'",
351 "'base'",
352 "'construct'",
353 "'destroy'",
354 "'new'",
355 "'delete'",
356 "'sizeof'",
357 "'try'",
358 "'catch'",
359 "'throw'",
360 "'concept'",
361 "'where'",
362 "'axiom'",
363 "'and'",
364 "'or'",
365 "'!'",
366 "'unit_test'",
367 "identifier",
368 "floating literal",
369 "integer literal",
370 "character literal",
371 "string literal",
372 "'<=>'",
373 "'=>'",
374 "'||'",
375 "'&&'",
376 "'|'",
377 "'^'",
378 "'&'",
379 "'=='",
380 "'!='",
381 "'<='",
382 "'>='",
383 "'<<'",
384 "'>>'",
385 "'+'",
386 "'-'",
387 "'*'",
388 "'/'",
389 "'%'",
390 "'++'",
391 "'--'",
392 "'~'",
393 "'.'",
394 "'->'",
395 "'['",
396 "']'",
397 "'('",
398 "')'",
399 "'<'",
400 "'>'",
401 "'{'",
402 "'}'",
403 "','",
404 "'='",
405 "':'",
406 "';'",
407 "'#'",
408 "comment",
409 "ws"
410 };
411
412 const char* GetTokenInfo(int tokenId)
413 {
414 return tokenInfo[tokenId];
415 }
416
417 struct Initializer
418 {
419 Initializer() { InitTokenIdMap(); }
420 };
421
422 Initializer initializer;
423 }