Debian Codegraph @

gcc/d/dmd/tokens.h

raw
1
2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2025 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 */
10
11 #pragma once
12
13 #include "root/dcompat.h"
14 #include "root/port.h"
15 #include "globals.h"
16
17 class Identifier;
18
19 /* Tokens:
20 ( )
21 [ ]
22 { }
23 < > <= >= == != === !==
24 << >> <<= >>= >>> >>>=
25 + - += -=
26 * / % *= /= %=
27 & | ^ &= |= ^=
28 = ! ~ @
29 ^^ ^^=
30 ++ --
31 . -> : , =>
32 ? && ||
33 */
34
35 enum class TOK : unsigned char
36 {
37 reserved,
38
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 variable,
58 slice,
59 version_,
60 module_,
61 dollar,
62 template_,
63 typeof_,
64 pragma_,
65 typeid_,
66 comment,
67
68 // Operators
69 lessThan,
70 greaterThan,
71 lessOrEqual,
72 greaterOrEqual,
73 equal,
74 notEqual,
75 identity,
76 notIdentity,
77 is_,
78
79 leftShift,
80 rightShift,
81 leftShiftAssign,
82 rightShiftAssign,
83 unsignedRightShift,
84 unsignedRightShiftAssign,
85 concatenateAssign, // ~=
86 add,
87 min,
88 addAssign,
89 minAssign,
90 mul,
91 div,
92 mod,
93 mulAssign,
94 divAssign,
95 modAssign,
96 and_,
97 or_,
98 xor_,
99 andAssign,
100 orAssign,
101 xorAssign,
102 assign,
103 not_,
104 tilde,
105 plusPlus,
106 minusMinus,
107 dot,
108 comma,
109 question,
110 andAnd,
111 orOr,
112
113 // Numeric literals
114 int32Literal,
115 uns32Literal,
116 int64Literal,
117 uns64Literal,
118 int128Literal,
119 uns128Literal,
120 float32Literal,
121 float64Literal,
122 float80Literal,
123 imaginary32Literal,
124 imaginary64Literal,
125 imaginary80Literal,
126
127 // Char constants
128 charLiteral,
129 wcharLiteral,
130 dcharLiteral,
131
132 // Leaf operators
133 identifier,
134 string_,
135 interpolated,
136 hexadecimalString,
137 this_,
138 super_,
139 error,
140
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_,
166
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_,
198
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,
224
225 // Contracts
226 invariant_,
227
228 // Testing
229 unittest_,
230
231 // Added after 1.0
232 argumentTypes,
233 ref_,
234 macro_,
235
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_,
248 at,
249 pow,
250 powAssign,
251 goesTo,
252 vector,
253 pound,
254
255 arrow, // ->
256 colonColon, // ::
257 wchar_tLiteral,
258 endOfLine, // \n, \r, \u2028, \u2029
259 whitespace,
260 rvalue,
261
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_,
281
282 // C only extended keywords
283 _assert,
284 _import,
285 cdecl_,
286 declspec,
287 stdcall,
288 thread,
289 pragma,
290 int128_,
291 attribute__,
292
293 MAX,
294 };
295
296 enum class EXP : unsigned char
297 {
298 reserved,
299
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,
337
338 // Operators
339 lessThan,
340 greaterThan,
341 lessOrEqual,
342 greaterOrEqual,
343 equal,
344 notEqual,
345 identity,
346 notIdentity,
347 index,
348 is_,
349
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,
390
391 // Leaf operators
392 identifier,
393 string_,
394 interpolated,
395 this_,
396 super_,
397 halt,
398 tuple,
399 error,
400
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_,
415
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,
427
428 voidExpression,
429 cantExpression,
430 showCtfeContext,
431 objcClassReference,
432 vectorArray,
433 compoundLiteral, // ( type-name ) { initializer-list }
434 _Generic_,
435 interval,
436
437 MAX
438 };
439
440 #define TOKwild TOKinout
441
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
447
448 struct Token
449 {
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
457 {
458 // Integers
459 sinteger_t intvalue;
460 uinteger_t unsvalue;
461
462 // Floats
463 real_t floatvalue;
464
465 struct
466 {
467 union
468 {
469 utf8_t *ustring; // UTF8 string
470 void *interpolatedSet;
471 };
472 unsigned len;
473 unsigned char postfix; // 'c', 'w', 'd'
474 };
475
476 Identifier *ident;
477 };
478
479 Token() : next(nullptr) {}
480 const char *toChars() const;
481
482 static const char *toChars(TOK value);
483 };
484
485 #if defined(__GNUC__)
486 #pragma GCC diagnostic pop
487 #endif