1 | /*============================================================================= |
2 | Boost.Wave: A Standard compliant C++ preprocessor library |
3 | The definition of a default set of token identifiers and related |
4 | functions. |
5 | |
6 | http://www.boost.org/ |
7 | |
8 | Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost |
9 | Software License, Version 1.0. (See accompanying file |
10 | LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
11 | =============================================================================*/ |
12 | |
13 | #define BOOST_WAVE_SOURCE 1 |
14 | |
15 | // disable stupid compiler warnings |
16 | #include <boost/config/warning_disable.hpp> |
17 | |
18 | #include <string> |
19 | #include <boost/assert.hpp> |
20 | #include <boost/static_assert.hpp> |
21 | |
22 | #include <boost/wave/wave_config.hpp> |
23 | #include <boost/wave/token_ids.hpp> |
24 | |
25 | // this must occur after all of the includes and before any code appears |
26 | #ifdef BOOST_HAS_ABI_HEADERS |
27 | #include BOOST_ABI_PREFIX |
28 | #endif |
29 | |
30 | /////////////////////////////////////////////////////////////////////////////// |
31 | namespace boost { |
32 | namespace wave { |
33 | |
34 | /////////////////////////////////////////////////////////////////////////////// |
35 | // return a token name |
36 | BOOST_WAVE_STRINGTYPE |
37 | get_token_name(token_id tokid) |
38 | { |
39 | // Table of token names |
40 | // |
41 | // Please note that the sequence of token names must match the sequence of |
42 | // token id's defined in then enum token_id above. |
43 | static char const *tok_names[] = { |
44 | /* 256 */ "AND" , |
45 | /* 257 */ "ANDAND" , |
46 | /* 258 */ "ASSIGN" , |
47 | /* 259 */ "ANDASSIGN" , |
48 | /* 260 */ "OR" , |
49 | /* 261 */ "ORASSIGN" , |
50 | /* 262 */ "XOR" , |
51 | /* 263 */ "XORASSIGN" , |
52 | /* 264 */ "COMMA" , |
53 | /* 265 */ "COLON" , |
54 | /* 266 */ "DIVIDE" , |
55 | /* 267 */ "DIVIDEASSIGN" , |
56 | /* 268 */ "DOT" , |
57 | /* 269 */ "DOTSTAR" , |
58 | /* 270 */ "ELLIPSIS" , |
59 | /* 271 */ "EQUAL" , |
60 | /* 272 */ "GREATER" , |
61 | /* 273 */ "GREATEREQUAL" , |
62 | /* 274 */ "LEFTBRACE" , |
63 | /* 275 */ "LESS" , |
64 | /* 276 */ "LESSEQUAL" , |
65 | /* 277 */ "LEFTPAREN" , |
66 | /* 278 */ "LEFTBRACKET" , |
67 | /* 279 */ "MINUS" , |
68 | /* 280 */ "MINUSASSIGN" , |
69 | /* 281 */ "MINUSMINUS" , |
70 | /* 282 */ "PERCENT" , |
71 | /* 283 */ "PERCENTASSIGN" , |
72 | /* 284 */ "NOT" , |
73 | /* 285 */ "NOTEQUAL" , |
74 | /* 286 */ "OROR" , |
75 | /* 287 */ "PLUS" , |
76 | /* 288 */ "PLUSASSIGN" , |
77 | /* 289 */ "PLUSPLUS" , |
78 | /* 290 */ "ARROW" , |
79 | /* 291 */ "ARROWSTAR" , |
80 | /* 292 */ "QUESTION_MARK" , |
81 | /* 293 */ "RIGHTBRACE" , |
82 | /* 294 */ "RIGHTPAREN" , |
83 | /* 295 */ "RIGHTBRACKET" , |
84 | /* 296 */ "COLON_COLON" , |
85 | /* 297 */ "SEMICOLON" , |
86 | /* 298 */ "SHIFTLEFT" , |
87 | /* 299 */ "SHIFTLEFTASSIGN" , |
88 | /* 300 */ "SHIFTRIGHT" , |
89 | /* 301 */ "SHIFTRIGHTASSIGN" , |
90 | /* 302 */ "STAR" , |
91 | /* 303 */ "COMPL" , |
92 | /* 304 */ "STARASSIGN" , |
93 | /* 305 */ "ASM" , |
94 | /* 306 */ "AUTO" , |
95 | /* 307 */ "BOOL" , |
96 | /* 308 */ "FALSE" , |
97 | /* 309 */ "TRUE" , |
98 | /* 310 */ "BREAK" , |
99 | /* 311 */ "CASE" , |
100 | /* 312 */ "CATCH" , |
101 | /* 313 */ "CHAR" , |
102 | /* 314 */ "CLASS" , |
103 | /* 315 */ "CONST" , |
104 | /* 316 */ "CONSTCAST" , |
105 | /* 317 */ "CONTINUE" , |
106 | /* 318 */ "DEFAULT" , |
107 | /* 319 */ "DELETE" , |
108 | /* 320 */ "DO" , |
109 | /* 321 */ "DOUBLE" , |
110 | /* 322 */ "DYNAMICCAST" , |
111 | /* 323 */ "ELSE" , |
112 | /* 324 */ "ENUM" , |
113 | /* 325 */ "EXPLICIT" , |
114 | /* 326 */ "EXPORT" , |
115 | /* 327 */ "EXTERN" , |
116 | /* 328 */ "FLOAT" , |
117 | /* 329 */ "FOR" , |
118 | /* 330 */ "FRIEND" , |
119 | /* 331 */ "GOTO" , |
120 | /* 332 */ "IF" , |
121 | /* 333 */ "INLINE" , |
122 | /* 334 */ "INT" , |
123 | /* 335 */ "LONG" , |
124 | /* 336 */ "MUTABLE" , |
125 | /* 337 */ "NAMESPACE" , |
126 | /* 338 */ "NEW" , |
127 | /* 339 */ "OPERATOR" , |
128 | /* 340 */ "PRIVATE" , |
129 | /* 341 */ "PROTECTED" , |
130 | /* 342 */ "PUBLIC" , |
131 | /* 343 */ "REGISTER" , |
132 | /* 344 */ "REINTERPRETCAST" , |
133 | /* 345 */ "RETURN" , |
134 | /* 346 */ "SHORT" , |
135 | /* 347 */ "SIGNED" , |
136 | /* 348 */ "SIZEOF" , |
137 | /* 349 */ "STATIC" , |
138 | /* 350 */ "STATICCAST" , |
139 | /* 351 */ "STRUCT" , |
140 | /* 352 */ "SWITCH" , |
141 | /* 353 */ "TEMPLATE" , |
142 | /* 354 */ "THIS" , |
143 | /* 355 */ "THROW" , |
144 | /* 356 */ "TRY" , |
145 | /* 357 */ "TYPEDEF" , |
146 | /* 358 */ "TYPEID" , |
147 | /* 359 */ "TYPENAME" , |
148 | /* 360 */ "UNION" , |
149 | /* 361 */ "UNSIGNED" , |
150 | /* 362 */ "USING" , |
151 | /* 363 */ "VIRTUAL" , |
152 | /* 364 */ "VOID" , |
153 | /* 365 */ "VOLATILE" , |
154 | /* 366 */ "WCHART" , |
155 | /* 367 */ "WHILE" , |
156 | /* 368 */ "PP_DEFINE" , |
157 | /* 369 */ "PP_IF" , |
158 | /* 370 */ "PP_IFDEF" , |
159 | /* 371 */ "PP_IFNDEF" , |
160 | /* 372 */ "PP_ELSE" , |
161 | /* 373 */ "PP_ELIF" , |
162 | /* 374 */ "PP_ENDIF" , |
163 | /* 375 */ "PP_ERROR" , |
164 | /* 376 */ "PP_LINE" , |
165 | /* 377 */ "PP_PRAGMA" , |
166 | /* 378 */ "PP_UNDEF" , |
167 | /* 379 */ "PP_WARNING" , |
168 | /* 380 */ "IDENTIFIER" , |
169 | /* 381 */ "OCTALINT" , |
170 | /* 382 */ "DECIMALINT" , |
171 | /* 383 */ "HEXAINT" , |
172 | /* 384 */ "INTLIT" , |
173 | /* 385 */ "LONGINTLIT" , |
174 | /* 386 */ "FLOATLIT" , |
175 | /* 387 */ "CCOMMENT" , |
176 | /* 388 */ "CPPCOMMENT" , |
177 | /* 389 */ "CHARLIT" , |
178 | /* 390 */ "STRINGLIT" , |
179 | /* 391 */ "CONTLINE" , |
180 | /* 392 */ "SPACE" , |
181 | /* 393 */ "SPACE2" , |
182 | /* 394 */ "NEWLINE" , |
183 | /* 395 */ "POUND_POUND" , |
184 | /* 396 */ "POUND" , |
185 | /* 397 */ "ANY" , |
186 | /* 398 */ "PP_INCLUDE" , |
187 | /* 399 */ "PP_QHEADER" , |
188 | /* 400 */ "PP_HHEADER" , |
189 | /* 401 */ "EOF" , |
190 | /* 402 */ "EOI" , |
191 | /* 403 */ "PP_NUMBER" , |
192 | |
193 | // MS extensions |
194 | /* 404 */ "MSEXT_INT8" , |
195 | /* 405 */ "MSEXT_INT16" , |
196 | /* 406 */ "MSEXT_INT32" , |
197 | /* 407 */ "MSEXT_INT64" , |
198 | /* 408 */ "MSEXT_BASED" , |
199 | /* 409 */ "MSEXT_DECLSPEC" , |
200 | /* 410 */ "MSEXT_CDECL" , |
201 | /* 411 */ "MSEXT_FASTCALL" , |
202 | /* 412 */ "MSEXT_STDCALL" , |
203 | /* 413 */ "MSEXT_TRY" , |
204 | /* 414 */ "MSEXT_EXCEPT" , |
205 | /* 415 */ "MSEXT_FINALLY" , |
206 | /* 416 */ "MSEXT_LEAVE" , |
207 | /* 417 */ "MSEXT_INLINE" , |
208 | /* 418 */ "MSEXT_ASM" , |
209 | /* 419 */ "MSEXT_REGION" , |
210 | /* 420 */ "MSEXT_ENDREGION" , |
211 | |
212 | /* 421 */ "IMPORT" , |
213 | |
214 | /* 422 */ "ALIGNAS" , |
215 | /* 423 */ "ALIGNOF" , |
216 | /* 424 */ "CHAR16_T" , |
217 | /* 425 */ "CHAR32_T" , |
218 | /* 426 */ "CONSTEXPR" , |
219 | /* 427 */ "DECLTYPE" , |
220 | /* 428 */ "NOEXCEPT" , |
221 | /* 429 */ "NULLPTR" , |
222 | /* 430 */ "STATIC_ASSERT" , |
223 | /* 431 */ "THREADLOCAL" , |
224 | /* 432 */ "RAWSTRINGLIT" , |
225 | |
226 | /* 433 */ "T_CHAR8_T" , |
227 | /* 434 */ "T_CONCEPT" , |
228 | /* 435 */ "T_CONSTEVAL" , |
229 | /* 436 */ "T_CONSTINIT" , |
230 | /* 437 */ "T_CO_AWAIT" , |
231 | /* 438 */ "T_CO_RETURN" , |
232 | /* 439 */ "T_CO_YIELD" , |
233 | /* 440 */ "T_REQUIRES" , |
234 | /* 441 */ "T_SPACESHIP" , |
235 | }; |
236 | |
237 | // make sure, I have not forgotten any commas (as I did more than once) |
238 | BOOST_STATIC_ASSERT( |
239 | sizeof(tok_names)/sizeof(tok_names[0]) == T_LAST_TOKEN-T_FIRST_TOKEN |
240 | ); |
241 | |
242 | unsigned int id = BASEID_FROM_TOKEN(tokid)-T_FIRST_TOKEN; |
243 | return (id < T_LAST_TOKEN-T_FIRST_TOKEN) ? tok_names[id] : "<UnknownToken>" ; |
244 | } |
245 | |
246 | /////////////////////////////////////////////////////////////////////////////// |
247 | // return a token name |
248 | char const * |
249 | get_token_value(token_id tokid) |
250 | { |
251 | // Table of token values |
252 | // |
253 | // Please note that the sequence of token names must match the sequence of |
254 | // token id's defined in then enum token_id above. |
255 | static char const *tok_values[] = { |
256 | /* 256 */ "&" , |
257 | /* 257 */ "&&" , |
258 | /* 258 */ "=" , |
259 | /* 259 */ "&=" , |
260 | /* 260 */ "|" , |
261 | /* 261 */ "|=" , |
262 | /* 262 */ "^" , |
263 | /* 263 */ "^=" , |
264 | /* 264 */ "," , |
265 | /* 265 */ ":" , |
266 | /* 266 */ "/" , |
267 | /* 267 */ "/=" , |
268 | /* 268 */ "." , |
269 | /* 269 */ ".*" , |
270 | /* 270 */ "..." , |
271 | /* 271 */ "==" , |
272 | /* 272 */ ">" , |
273 | /* 273 */ ">=" , |
274 | /* 274 */ "{" , |
275 | /* 275 */ "<" , |
276 | /* 276 */ "<=" , |
277 | /* 277 */ "(" , |
278 | /* 278 */ "[" , |
279 | /* 279 */ "-" , |
280 | /* 280 */ "-=" , |
281 | /* 281 */ "--" , |
282 | /* 282 */ "%" , |
283 | /* 283 */ "%=" , |
284 | /* 284 */ "!" , |
285 | /* 285 */ "!=" , |
286 | /* 286 */ "||" , |
287 | /* 287 */ "+" , |
288 | /* 288 */ "+=" , |
289 | /* 289 */ "++" , |
290 | /* 290 */ "->" , |
291 | /* 291 */ "->*" , |
292 | /* 292 */ "?" , |
293 | /* 293 */ "}" , |
294 | /* 294 */ ")" , |
295 | /* 295 */ "]" , |
296 | /* 296 */ "::" , |
297 | /* 297 */ ";" , |
298 | /* 298 */ "<<" , |
299 | /* 299 */ "<<=" , |
300 | /* 300 */ ">>" , |
301 | /* 301 */ ">>=" , |
302 | /* 302 */ "*" , |
303 | /* 303 */ "~" , |
304 | /* 304 */ "*=" , |
305 | /* 305 */ "asm" , |
306 | /* 306 */ "auto" , |
307 | /* 307 */ "bool" , |
308 | /* 308 */ "false" , |
309 | /* 309 */ "true" , |
310 | /* 310 */ "break" , |
311 | /* 311 */ "case" , |
312 | /* 312 */ "catch" , |
313 | /* 313 */ "char" , |
314 | /* 314 */ "class" , |
315 | /* 315 */ "const" , |
316 | /* 316 */ "const_cast" , |
317 | /* 317 */ "continue" , |
318 | /* 318 */ "default" , |
319 | /* 319 */ "delete" , |
320 | /* 320 */ "do" , |
321 | /* 321 */ "double" , |
322 | /* 322 */ "dynamic_cast" , |
323 | /* 323 */ "else" , |
324 | /* 324 */ "enum" , |
325 | /* 325 */ "explicit" , |
326 | /* 326 */ "export" , |
327 | /* 327 */ "extern" , |
328 | /* 328 */ "float" , |
329 | /* 329 */ "for" , |
330 | /* 330 */ "friend" , |
331 | /* 331 */ "goto" , |
332 | /* 332 */ "if" , |
333 | /* 333 */ "inline" , |
334 | /* 334 */ "int" , |
335 | /* 335 */ "long" , |
336 | /* 336 */ "mutable" , |
337 | /* 337 */ "namespace" , |
338 | /* 338 */ "new" , |
339 | /* 339 */ "operator" , |
340 | /* 340 */ "private" , |
341 | /* 341 */ "protected" , |
342 | /* 342 */ "public" , |
343 | /* 343 */ "register" , |
344 | /* 344 */ "reinterpret_cast" , |
345 | /* 345 */ "return" , |
346 | /* 346 */ "short" , |
347 | /* 347 */ "signed" , |
348 | /* 348 */ "sizeof" , |
349 | /* 349 */ "static" , |
350 | /* 350 */ "static_cast" , |
351 | /* 351 */ "struct" , |
352 | /* 352 */ "switch" , |
353 | /* 353 */ "template" , |
354 | /* 354 */ "this" , |
355 | /* 355 */ "throw" , |
356 | /* 356 */ "try" , |
357 | /* 357 */ "typedef" , |
358 | /* 358 */ "typeid" , |
359 | /* 359 */ "typename" , |
360 | /* 360 */ "union" , |
361 | /* 361 */ "unsigned" , |
362 | /* 362 */ "using" , |
363 | /* 363 */ "virtual" , |
364 | /* 364 */ "void" , |
365 | /* 365 */ "volatile" , |
366 | /* 366 */ "wchar_t" , |
367 | /* 367 */ "while" , |
368 | /* 368 */ "#define" , |
369 | /* 369 */ "#if" , |
370 | /* 370 */ "#ifdef" , |
371 | /* 371 */ "#ifndef" , |
372 | /* 372 */ "#else" , |
373 | /* 373 */ "#elif" , |
374 | /* 374 */ "#endif" , |
375 | /* 375 */ "#error" , |
376 | /* 376 */ "#line" , |
377 | /* 377 */ "#pragma" , |
378 | /* 378 */ "#undef" , |
379 | /* 379 */ "#warning" , |
380 | /* 380 */ "" , // identifier |
381 | /* 381 */ "" , // octalint |
382 | /* 382 */ "" , // decimalint |
383 | /* 383 */ "" , // hexlit |
384 | /* 384 */ "" , // intlit |
385 | /* 385 */ "" , // longintlit |
386 | /* 386 */ "" , // floatlit |
387 | /* 387 */ "" , // ccomment |
388 | /* 388 */ "" , // cppcomment |
389 | /* 389 */ "" , // charlit |
390 | /* 390 */ "" , // stringlit |
391 | /* 391 */ "" , // contline |
392 | /* 392 */ "" , // space |
393 | /* 393 */ "" , // space2 |
394 | /* 394 */ "\n" , |
395 | /* 395 */ "##" , |
396 | /* 396 */ "#" , |
397 | /* 397 */ "" , // any |
398 | /* 398 */ "#include" , |
399 | /* 399 */ "#include" , |
400 | /* 400 */ "#include" , |
401 | /* 401 */ "" , // eof |
402 | /* 402 */ "" , // eoi |
403 | /* 403 */ "" , // pp-number |
404 | |
405 | // MS extensions |
406 | /* 404 */ "__int8" , |
407 | /* 405 */ "__int16" , |
408 | /* 406 */ "__int32" , |
409 | /* 407 */ "__int64" , |
410 | /* 408 */ "__based" , |
411 | /* 409 */ "__declspec" , |
412 | /* 410 */ "__cdecl" , |
413 | /* 411 */ "__fastcall" , |
414 | /* 412 */ "__stdcall" , |
415 | /* 413 */ "__try" , |
416 | /* 414 */ "__except" , |
417 | /* 415 */ "__finally" , |
418 | /* 416 */ "__leave" , |
419 | /* 417 */ "__inline" , |
420 | /* 418 */ "__asm" , |
421 | /* 419 */ "#region" , |
422 | /* 420 */ "#endregion" , |
423 | |
424 | /* 421 */ "import" , |
425 | |
426 | /* 422 */ "alignas" , |
427 | /* 423 */ "alignof" , |
428 | /* 424 */ "char16_t" , |
429 | /* 425 */ "char32_t" , |
430 | /* 426 */ "constexpr" , |
431 | /* 427 */ "decltype" , |
432 | /* 428 */ "noexcept" , |
433 | /* 429 */ "nullptr" , |
434 | /* 430 */ "static_assert" , |
435 | /* 431 */ "thread_local" , |
436 | /* 432 */ "" , // extrawstringlit |
437 | |
438 | /* 433 */ "char8_t" , |
439 | /* 434 */ "concept" , |
440 | /* 435 */ "consteval" , |
441 | /* 436 */ "constinit" , |
442 | /* 437 */ "co_await" , |
443 | /* 438 */ "co_return" , |
444 | /* 439 */ "co_yield" , |
445 | /* 440 */ "requires" , |
446 | /* 441 */ "<=>" , |
447 | }; |
448 | |
449 | // make sure, I have not forgotten any commas (as I did more than once) |
450 | BOOST_STATIC_ASSERT( |
451 | sizeof(tok_values)/sizeof(tok_values[0]) == T_LAST_TOKEN-T_FIRST_TOKEN |
452 | ); |
453 | |
454 | unsigned int id = BASEID_FROM_TOKEN(tokid)-T_FIRST_TOKEN; |
455 | return (id < T_LAST_TOKEN-T_FIRST_TOKEN) ? tok_values[id] : "<UnknownToken>" ; |
456 | } |
457 | |
458 | /////////////////////////////////////////////////////////////////////////////// |
459 | } // namespace wave |
460 | } // namespace boost |
461 | |
462 | // the suffix header occurs after all of the code |
463 | #ifdef BOOST_HAS_ABI_HEADERS |
464 | #include BOOST_ABI_SUFFIX |
465 | #endif |
466 | |