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