d: Merge dmd, druntime d8e3976a58, phobos 7a6e95688
[official-gcc.git] / gcc / d / dmd / tokens.h
blobf944663e43052292ed7676044854b466459a957c
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 hexadecimalString,
137 this_,
138 super_,
139 error,
141 // Basic types
142 void_,
143 int8,
144 uns8,
145 int16,
146 uns16,
147 int32,
148 uns32,
149 int64,
150 uns64,
151 int128,
152 uns128,
153 float32,
154 float64,
155 float80,
156 imaginary32,
157 imaginary64,
158 imaginary80,
159 complex32,
160 complex64,
161 complex80,
162 char_,
163 wchar_,
164 dchar_,
165 bool_,
167 // Aggregates
168 struct_,
169 class_,
170 interface_,
171 union_,
172 enum_,
173 import_,
174 alias_,
175 override_,
176 delegate_,
177 function_,
178 mixin_,
179 align_,
180 extern_,
181 private_,
182 protected_,
183 public_,
184 export_,
185 static_,
186 final_,
187 const_,
188 abstract_,
189 debug_,
190 deprecated_,
191 in_,
192 out_,
193 inout_,
194 lazy_,
195 auto_,
196 package_,
197 immutable_,
199 // Statements
200 if_,
201 else_,
202 while_,
203 for_,
204 do_,
205 switch_,
206 case_,
207 default_,
208 break_,
209 continue_,
210 with_,
211 synchronized_,
212 return_,
213 goto_,
214 try_,
215 catch_,
216 finally_,
217 asm_,
218 foreach_,
219 foreach_reverse_,
220 scope_,
221 onScopeExit,
222 onScopeFailure,
223 onScopeSuccess,
225 // Contracts
226 invariant_,
228 // Testing
229 unittest_,
231 // Added after 1.0
232 argumentTypes,
233 ref_,
234 macro_,
236 parameters,
237 traits,
238 pure_,
239 nothrow_,
240 gshared,
241 line,
242 file,
243 fileFullPath,
244 moduleString, // __MODULE__
245 functionString, // __FUNCTION__
246 prettyFunction, // __PRETTY_FUNCTION__
247 shared_,
249 pow,
250 powAssign,
251 goesTo,
252 vector,
253 pound,
255 arrow, // ->
256 colonColon, // ::
257 wchar_tLiteral,
258 endOfLine, // \n, \r, \u2028, \u2029
259 whitespace,
261 // C only keywords
262 inline_,
263 register_,
264 restrict_,
265 signed_,
266 sizeof_,
267 typedef_,
268 unsigned_,
269 volatile_,
270 _Alignas_,
271 _Alignof_,
272 _Atomic_,
273 _Bool_,
274 _Complex_,
275 _Generic_,
276 _Imaginary_,
277 _Noreturn_,
278 _Static_assert_,
279 _Thread_local_,
281 // C only extended keywords
282 _assert,
283 _import,
284 cdecl_,
285 declspec,
286 stdcall,
287 thread,
288 pragma,
289 int128_,
290 attribute__,
292 MAX,
295 enum class EXP : unsigned char
297 reserved,
299 // Other
300 negate,
301 cast_,
302 null_,
303 assert_,
304 array,
305 call,
306 address,
307 type,
308 throw_,
309 new_,
310 delete_,
311 star,
312 symbolOffset,
313 variable,
314 dotVariable,
315 dotIdentifier,
316 dotTemplateInstance,
317 dotType,
318 slice,
319 arrayLength,
320 dollar,
321 template_,
322 dotTemplateDeclaration,
323 declaration,
324 dSymbol,
325 typeid_,
326 uadd,
327 remove,
328 newAnonymousClass,
329 arrayLiteral,
330 assocArrayLiteral,
331 structLiteral,
332 classReference,
333 thrownException,
334 delegatePointer,
335 delegateFunctionPointer,
337 // Operators
338 lessThan,
339 greaterThan,
340 lessOrEqual,
341 greaterOrEqual,
342 equal,
343 notEqual,
344 identity,
345 notIdentity,
346 index,
347 is_,
349 leftShift,
350 rightShift,
351 leftShiftAssign,
352 rightShiftAssign,
353 unsignedRightShift,
354 unsignedRightShiftAssign,
355 concatenate,
356 concatenateAssign, // ~=
357 concatenateElemAssign,
358 concatenateDcharAssign,
359 add,
360 min,
361 addAssign,
362 minAssign,
363 mul,
364 div,
365 mod,
366 mulAssign,
367 divAssign,
368 modAssign,
369 and_,
370 or_,
371 xor_,
372 andAssign,
373 orAssign,
374 xorAssign,
375 assign,
376 not_,
377 tilde,
378 plusPlus,
379 minusMinus,
380 construct,
381 blit,
382 dot,
383 comma,
384 question,
385 andAnd,
386 orOr,
387 prePlusPlus,
388 preMinusMinus,
390 // Leaf operators
391 identifier,
392 string_,
393 this_,
394 super_,
395 halt,
396 tuple,
397 error,
399 // Basic types
400 void_,
401 int64,
402 float64,
403 complex80,
404 import_,
405 delegate_,
406 function_,
407 mixin_,
408 in_,
409 break_,
410 continue_,
411 goto_,
412 scope_,
414 traits,
415 overloadSet,
416 line,
417 file,
418 fileFullPath,
419 moduleString, // __MODULE__
420 functionString, // __FUNCTION__
421 prettyFunction, // __PRETTY_FUNCTION__
422 pow,
423 powAssign,
424 vector,
426 voidExpression,
427 cantExpression,
428 showCtfeContext,
429 objcClassReference,
430 vectorArray,
431 compoundLiteral, // ( type-name ) { initializer-list }
432 _Generic_,
433 interval,
438 #define TOKwild TOKinout
440 // Token has an anonymous struct, which is not strict ISO C++.
441 #if defined(__GNUC__)
442 #pragma GCC diagnostic push
443 #pragma GCC diagnostic ignored "-Wpedantic"
444 #endif
446 struct Token
448 Token *next;
449 Loc loc;
450 const utf8_t *ptr; // pointer to first character of this token within buffer
451 TOK value;
452 DString blockComment; // doc comment string prior to this token
453 DString lineComment; // doc comment for previous token
454 union
456 // Integers
457 sinteger_t intvalue;
458 uinteger_t unsvalue;
460 // Floats
461 real_t floatvalue;
463 struct
464 { utf8_t *ustring; // UTF8 string
465 unsigned len;
466 unsigned char postfix; // 'c', 'w', 'd'
469 Identifier *ident;
472 Token() : next(NULL) {}
473 const char *toChars() const;
475 static const char *toChars(TOK value);
478 #if defined(__GNUC__)
479 #pragma GCC diagnostic pop
480 #endif