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