d: Merge upstream dmd 3982604c5, druntime bc58b1e9, phobos 12329adb6.
[official-gcc.git] / gcc / d / dmd / tokens.h
blobf3e4411217e626926ba8b8a78149909e4586ca3e
2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2021 by The D Language Foundation, All Rights Reserved
4 * written by Walter Bright
5 * http://www.digitalmars.com
6 * Distributed under the Boost Software License, Version 1.0.
7 * http://www.boost.org/LICENSE_1_0.txt
8 * https://github.com/dlang/dmd/blob/master/src/dmd/tokens.h
9 */
11 #pragma once
13 #include "root/dcompat.h"
14 #include "root/port.h"
15 #include "globals.h"
17 class Identifier;
19 /* Tokens:
20 ( )
21 [ ]
22 { }
23 < > <= >= == != === !==
24 << >> <<= >>= >>> >>>=
25 + - += -=
26 * / % *= /= %=
27 & | ^ &= |= ^=
28 = ! ~ @
29 ^^ ^^=
30 ++ --
31 . -> : , =>
32 ? && ||
35 enum class TOK : unsigned short
37 reserved,
39 // Other
40 leftParenthesis,
41 rightParenthesis,
42 leftBracket,
43 rightBracket,
44 leftCurly,
45 rightCurly,
46 colon,
47 negate,
48 semicolon,
49 dotDotDot,
50 endOfFile,
51 cast_,
52 null_,
53 assert_,
54 true_,
55 false_,
56 array,
57 call,
58 address,
59 type,
60 throw_,
61 new_,
62 delete_,
63 star,
64 symbolOffset,
65 variable,
66 dotVariable,
67 dotIdentifier,
68 dotTemplateInstance,
69 dotType,
70 slice,
71 arrayLength,
72 version_,
73 module_,
74 dollar,
75 template_,
76 dotTemplateDeclaration,
77 declaration,
78 typeof_,
79 pragma_,
80 dSymbol,
81 typeid_,
82 uadd,
83 remove,
84 newAnonymousClass,
85 comment,
86 arrayLiteral,
87 assocArrayLiteral,
88 structLiteral,
89 classReference,
90 thrownException,
91 delegatePointer,
92 delegateFunctionPointer,
94 // Operators
95 lessThan, // 54
96 greaterThan,
97 lessOrEqual,
98 greaterOrEqual,
99 equal,
100 notEqual,
101 identity,
102 notIdentity,
103 index,
104 is_,
106 leftShift, // 64
107 rightShift,
108 leftShiftAssign,
109 rightShiftAssign,
110 unsignedRightShift,
111 unsignedRightShiftAssign,
112 concatenate,
113 concatenateAssign, // ~=
114 concatenateElemAssign,
115 concatenateDcharAssign,
116 add,
117 min,
118 addAssign,
119 minAssign,
120 mul,
121 div,
122 mod,
123 mulAssign,
124 divAssign,
125 modAssign,
126 and_,
127 or_,
128 xor_,
129 andAssign,
130 orAssign,
131 xorAssign,
132 assign,
133 not_,
134 tilde,
135 plusPlus,
136 minusMinus,
137 construct,
138 blit,
139 dot,
140 comma,
141 question,
142 andAnd,
143 orOr,
144 prePlusPlus,
145 preMinusMinus,
147 // Numeric literals
148 int32Literal, // 104,
149 uns32Literal,
150 int64Literal,
151 uns64Literal,
152 int128Literal,
153 uns128Literal,
154 float32Literal,
155 float64Literal,
156 float80Literal,
157 imaginary32Literal,
158 imaginary64Literal,
159 imaginary80Literal,
161 // Char constants
162 charLiteral, // 116,
163 wcharLiteral,
164 dcharLiteral,
166 // Leaf operators
167 identifier, // 119,
168 string_,
169 hexadecimalString,
170 this_,
171 super_,
172 halt,
173 tuple,
174 error,
176 // Basic types
177 void_, // 127
178 int8,
179 uns8,
180 int16,
181 uns16,
182 int32,
183 uns32,
184 int64,
185 uns64,
186 int128,
187 uns128,
188 float32,
189 float64,
190 float80,
191 imaginary32,
192 imaginary64,
193 imaginary80,
194 complex32,
195 complex64,
196 complex80,
197 char_,
198 wchar_,
199 dchar_,
200 bool_,
202 // Aggregates
203 struct_, // 151
204 class_,
205 interface_,
206 union_,
207 enum_,
208 import_,
209 alias_,
210 override_,
211 delegate_,
212 function_,
213 mixin_,
214 align_,
215 extern_,
216 private_,
217 protected_,
218 public_,
219 export_,
220 static_,
221 final_,
222 const_,
223 abstract_,
224 debug_,
225 deprecated_,
226 in_,
227 out_,
228 inout_,
229 lazy_,
230 auto_,
231 package_,
232 immutable_,
234 // Statements
235 if_, // 181
236 else_,
237 while_,
238 for_,
239 do_,
240 switch_,
241 case_,
242 default_,
243 break_,
244 continue_,
245 with_,
246 synchronized_,
247 return_,
248 goto_,
249 try_,
250 catch_,
251 finally_,
252 asm_,
253 foreach_,
254 foreach_reverse_,
255 scope_,
256 onScopeExit,
257 onScopeFailure,
258 onScopeSuccess,
260 // Contracts
261 invariant_, // 205
263 // Testing
264 unittest_,
266 // Added after 1.0
267 argumentTypes,
268 ref_,
269 macro_,
271 parameters, // 210
272 traits,
273 overloadSet,
274 pure_,
275 nothrow_,
276 gshared,
277 line,
278 file,
279 fileFullPath,
280 moduleString, // __MODULE__
281 functionString, // __FUNCTION__
282 prettyFunction, // __PRETTY_FUNCTION__
283 shared_,
285 pow,
286 powAssign,
287 goesTo,
288 vector,
289 pound,
291 interval, // 229
292 voidExpression,
293 cantExpression,
294 showCtfeContext,
296 objcClassReference,
297 vectorArray,
299 arrow, // ->
300 colonColon, // ::
301 wchar_tLiteral,
302 compoundLiteral, // ( type-name ) { initializer-list }
304 // C only keywords
305 inline_,
306 register_,
307 restrict_,
308 signed_,
309 sizeof_,
310 typedef_,
311 unsigned_,
312 volatile_,
313 _Alignas_,
314 _Alignof_,
315 _Atomic_,
316 _Bool_,
317 _Complex_,
318 _Generic_,
319 _Imaginary_,
320 _Noreturn_,
321 _Static_assert_,
322 _Thread_local_,
324 // C only extended keywords
325 cdecl,
326 declspec,
327 attribute__,
329 MAX,
332 enum class EXP : unsigned char
334 reserved,
336 // Other
337 negate,
338 cast_,
339 null_,
340 assert_,
341 true_,
342 false_,
343 array,
344 call,
345 address,
346 type,
347 throw_,
348 new_,
349 delete_,
350 star,
351 symbolOffset,
352 variable,
353 dotVariable,
354 dotIdentifier,
355 dotTemplateInstance,
356 dotType,
357 slice,
358 arrayLength,
359 version_,
360 dollar,
361 template_,
362 dotTemplateDeclaration,
363 declaration,
364 typeof_,
365 pragma_,
366 dSymbol,
367 typeid_,
368 uadd,
369 remove,
370 newAnonymousClass,
371 arrayLiteral,
372 assocArrayLiteral,
373 structLiteral,
374 classReference,
375 thrownException,
376 delegatePointer,
377 delegateFunctionPointer,
379 // Operators
380 lessThan,
381 greaterThan,
382 lessOrEqual,
383 greaterOrEqual,
384 equal,
385 notEqual,
386 identity,
387 notIdentity,
388 index,
389 is_,
391 leftShift,
392 rightShift,
393 leftShiftAssign,
394 rightShiftAssign,
395 unsignedRightShift,
396 unsignedRightShiftAssign,
397 concatenate,
398 concatenateAssign, // ~=
399 concatenateElemAssign,
400 concatenateDcharAssign,
401 add,
402 min,
403 addAssign,
404 minAssign,
405 mul,
406 div,
407 mod,
408 mulAssign,
409 divAssign,
410 modAssign,
411 and_,
412 or_,
413 xor_,
414 andAssign,
415 orAssign,
416 xorAssign,
417 assign,
418 not_,
419 tilde,
420 plusPlus,
421 minusMinus,
422 construct,
423 blit,
424 dot,
425 comma,
426 question,
427 andAnd,
428 orOr,
429 prePlusPlus,
430 preMinusMinus,
432 // Leaf operators
433 identifier,
434 string_,
435 this_,
436 super_,
437 halt,
438 tuple,
439 error,
441 // Basic types
442 void_,
443 int64,
444 float64,
445 complex80,
446 char_,
447 import_,
448 delegate_,
449 function_,
450 mixin_,
451 in_,
452 default_,
453 break_,
454 continue_,
455 goto_,
456 scope_,
458 traits,
459 overloadSet,
460 line,
461 file,
462 fileFullPath,
463 moduleString, // __MODULE__
464 functionString, // __FUNCTION__
465 prettyFunction, // __PRETTY_FUNCTION__
466 shared_,
467 pow,
468 powAssign,
469 vector,
471 voidExpression,
472 cantExpression,
473 showCtfeContext,
474 objcClassReference,
475 vectorArray,
476 arrow, // ->
477 compoundLiteral, // ( type-name ) { initializer-list }
478 _Generic_,
479 interval,
484 #define TOKwild TOKinout
486 // Token has an anonymous struct, which is not strict ISO C++.
487 #if defined(__GNUC__)
488 #pragma GCC diagnostic push
489 #pragma GCC diagnostic ignored "-Wpedantic"
490 #endif
492 struct Token
494 Token *next;
495 Loc loc;
496 const utf8_t *ptr; // pointer to first character of this token within buffer
497 TOK value;
498 DString blockComment; // doc comment string prior to this token
499 DString lineComment; // doc comment for previous token
500 union
502 // Integers
503 sinteger_t intvalue;
504 uinteger_t unsvalue;
506 // Floats
507 real_t floatvalue;
509 struct
510 { utf8_t *ustring; // UTF8 string
511 unsigned len;
512 unsigned char postfix; // 'c', 'w', 'd'
515 Identifier *ident;
518 void free();
520 Token() : next(NULL) {}
521 int isKeyword();
522 const char *toChars() const;
524 static const char *toChars(TOK value);
527 #if defined(__GNUC__)
528 #pragma GCC diagnostic pop
529 #endif