-
Notifications
You must be signed in to change notification settings - Fork 0
/
lex.c
778 lines (671 loc) · 21.3 KB
/
lex.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
#include "lex.h"
#include "alloc.h"
#include "log.h"
#include "util.h"
#include <ctype.h>
struct lexer {
struct program *program;
struct arena_allocator *arena;
const char *text;
size_t len;
struct text_pos pos;
const char **associated_texts;
};
enum lex_create_result lexer_create(struct preprocessed_program *program,
struct lexer **lexer) {
info("beginning lex stage");
struct arena_allocator *arena;
arena_allocator_create(&arena);
struct lexer *l = nonnull_malloc(sizeof(*l));
l->arena = arena;
l->text = arena_alloc_strcpy(arena, program->text);
l->len = strlen(l->text);
l->pos.idx = 0;
l->pos.line = 0;
l->pos.col = 0;
*lexer = l;
return LEX_CREATE_RESULT_SUCCESS;
}
void lexer_free(struct lexer **lexer) {
arena_allocator_free(&(*lexer)->arena);
(*lexer)->arena = NULL;
free(*lexer);
*lexer = NULL;
}
static bool valid_identifier_char(char c) {
return isalpha(c) || isdigit(c) || c == '_';
}
/* Identifiers cannot start with digits */
static bool valid_first_identifier_char(char c) {
return !isdigit(c) && valid_identifier_char(c);
}
/* The lexer parses identifiers, but these could be identifiers, typedef-names,
or keywords. This function converts identifiers into their "real" type */
static enum lex_token_ty refine_ty(struct lexer *lexer, struct text_pos start,
struct text_pos end) {
struct keyword {
const char *str;
size_t len;
enum lex_token_ty ty;
};
size_t len = text_pos_len(start, end);
#define KEYWORD(kw, ty) \
{ \
kw, sizeof(kw) - 1, ty \
}
// TODO: hashify
static struct keyword keywords[] = {
KEYWORD("goto", LEX_TOKEN_TY_KW_GOTO),
KEYWORD("break", LEX_TOKEN_TY_KW_BREAK),
KEYWORD("continue", LEX_TOKEN_TY_KW_CONTINUE),
KEYWORD("do", LEX_TOKEN_TY_KW_DO),
KEYWORD("for", LEX_TOKEN_TY_KW_FOR),
KEYWORD("while", LEX_TOKEN_TY_KW_WHILE),
KEYWORD("switch", LEX_TOKEN_TY_KW_SWITCH),
KEYWORD("default", LEX_TOKEN_TY_KW_DEFAULT),
KEYWORD("case", LEX_TOKEN_TY_KW_CASE),
KEYWORD("if", LEX_TOKEN_TY_KW_IF),
KEYWORD("else", LEX_TOKEN_TY_KW_ELSE),
KEYWORD("return", LEX_TOKEN_TY_KW_RETURN),
KEYWORD("typedef", LEX_TOKEN_TY_KW_TYPEDEF),
KEYWORD("static", LEX_TOKEN_TY_KW_STATIC),
KEYWORD("auto", LEX_TOKEN_TY_KW_AUTO),
KEYWORD("extern", LEX_TOKEN_TY_KW_EXTERN),
KEYWORD("register", LEX_TOKEN_TY_KW_REGISTER),
KEYWORD("inline", LEX_TOKEN_TY_KW_INLINE),
KEYWORD("const", LEX_TOKEN_TY_KW_CONST),
KEYWORD("volatile", LEX_TOKEN_TY_KW_VOLATILE),
KEYWORD("void", LEX_TOKEN_TY_KW_VOID),
KEYWORD("__fp16", LEX_TOKEN_TY_KW_HALF),
KEYWORD("_Float16", LEX_TOKEN_TY_KW_HALF),
KEYWORD("float", LEX_TOKEN_TY_KW_FLOAT),
KEYWORD("double", LEX_TOKEN_TY_KW_DOUBLE),
KEYWORD("char", LEX_TOKEN_TY_KW_CHAR),
KEYWORD("short", LEX_TOKEN_TY_KW_SHORT),
KEYWORD("int", LEX_TOKEN_TY_KW_INT),
KEYWORD("long", LEX_TOKEN_TY_KW_LONG),
KEYWORD("unsigned", LEX_TOKEN_TY_KW_UNSIGNED),
KEYWORD("signed", LEX_TOKEN_TY_KW_SIGNED),
KEYWORD("enum", LEX_TOKEN_TY_KW_ENUM),
KEYWORD("struct", LEX_TOKEN_TY_KW_STRUCT),
KEYWORD("union", LEX_TOKEN_TY_KW_UNION),
KEYWORD("sizeof", LEX_TOKEN_TY_KW_SIZEOF),
KEYWORD("alignof", LEX_TOKEN_TY_KW_ALIGNOF),
KEYWORD("_Alignof", LEX_TOKEN_TY_KW_ALIGNOF),
KEYWORD("alignas", LEX_TOKEN_TY_KW_ALIGNAS),
KEYWORD("_Alignas", LEX_TOKEN_TY_KW_ALIGNAS),
};
#undef KEYWORD
for (size_t i = 0; i < ARR_LENGTH(keywords); i++) {
if (len == keywords[i].len &&
memcmp(&lexer->text[start.idx], keywords[i].str, len) == 0) {
return keywords[i].ty;
}
}
return LEX_TOKEN_TY_IDENTIFIER;
}
struct text_pos get_position(struct lexer *lexer) { return lexer->pos; }
void backtrack(struct lexer *lexer, struct text_pos position) {
lexer->pos = position;
}
void consume_token(struct lexer *lexer, struct token token) {
lexer->pos = token.span.end;
}
static const char *process_raw_string(const struct lexer *lexer,
const struct token *token, size_t *str_len) {
// TODO: this i think will wrongly accept multilines
// FIXME: definitely wrong for wide strings
size_t max_str_len = token->span.end.idx - token->span.start.idx;
char *buff = arena_alloc(lexer->arena, max_str_len - 1);
char end_char = (token->ty == LEX_TOKEN_TY_ASCII_WIDE_CHAR_LITERAL ||
token->ty == LEX_TOKEN_TY_ASCII_CHAR_LITERAL)
? '\''
: '"';
size_t str_start = (token->ty == LEX_TOKEN_TY_ASCII_WIDE_CHAR_LITERAL ||
token->ty == LEX_TOKEN_TY_ASCII_WIDE_STR_LITERAL)
? token->span.start.idx + 2
: token->span.start.idx + 1;
*str_len = 0;
bool char_escaped = false;
for (size_t i = str_start; i <= token->span.end.idx &&
!(!char_escaped && lexer->text[i] == end_char);
i++) {
if (char_escaped) {
#define ADD_ESCAPED(ch, esc) \
case ch: \
buff[(*str_len)++] = esc; \
break;
switch (lexer->text[i]) {
ADD_ESCAPED('0', '\0')
ADD_ESCAPED('a', '\a')
ADD_ESCAPED('b', '\b')
// non-standard so not included for now
// ADD_ESCAPED('e', '\e')
ADD_ESCAPED('f', '\f')
ADD_ESCAPED('n', '\n')
ADD_ESCAPED('r', '\r')
ADD_ESCAPED('t', '\t')
ADD_ESCAPED('v', '\v')
ADD_ESCAPED('\\', '\\')
ADD_ESCAPED('\'', '\'')
ADD_ESCAPED('"', '"')
ADD_ESCAPED('?', '\?')
default:
todo("\\x \\u \\U and \\octal escapes");
// either octal escape, or invalid
}
#undef ADD_ESCAPED
} else if (lexer->text[i] != '\\') {
buff[(*str_len)++] = lexer->text[i];
}
// next char is escaped if this char is a non-escaped backslash
char_escaped = !char_escaped && lexer->text[i] == '\\';
}
buff[*str_len] = 0;
return buff;
}
/* Attempts to consume and move forward the position if it finds char `c` */
static bool try_consume(struct lexer *lexer, struct text_pos *pos, char c) {
debug_assert(
lexer->pos.idx != pos->idx,
"calling `try_consume` with `pos` the same as lexer makes no sense");
if (pos->idx < lexer->len && lexer->text[pos->idx] == c) {
if (c == '\n') {
next_line(pos);
} else {
next_col(pos);
}
return true;
}
return false;
}
bool lexer_at_eof(struct lexer *lexer) {
// needed to skip whitespace
struct token token;
peek_token(lexer, &token);
return lexer->pos.idx >= lexer->len;
}
void peek_token(struct lexer *lexer, struct token *token) {
while (lexer->pos.idx < lexer->len && isspace(lexer->text[lexer->pos.idx])) {
if (lexer->text[lexer->pos.idx] == '\n') {
// skip newlines, adjust position
next_line(&lexer->pos);
} else {
// just adjust position
next_col(&lexer->pos);
}
}
struct text_pos start = lexer->pos;
struct text_pos end = start;
if (end.idx >= lexer->len) {
token->ty = LEX_TOKEN_TY_EOF;
token->span.start = start;
token->span.end = end;
return;
}
char c = lexer->text[start.idx];
// trace("lexing char '%c'", c);
// size_t context = MIN(lexer->len - start.idx, 25);
// trace("on '%.*s'\n", context, &lexer->text[start.idx]);
enum lex_token_ty ty;
switch (c) {
case '?':
ty = LEX_TOKEN_TY_QMARK;
next_col(&end);
break;
case '(':
ty = LEX_TOKEN_TY_OPEN_BRACKET;
next_col(&end);
break;
case ')':
ty = LEX_TOKEN_TY_CLOSE_BRACKET;
next_col(&end);
break;
case '[':
ty = LEX_TOKEN_TY_OPEN_SQUARE_BRACKET;
next_col(&end);
break;
case ']':
ty = LEX_TOKEN_TY_CLOSE_SQUARE_BRACKET;
next_col(&end);
break;
case '{':
ty = LEX_TOKEN_TY_OPEN_BRACE;
next_col(&end);
break;
case '}':
ty = LEX_TOKEN_TY_CLOSE_BRACE;
next_col(&end);
break;
case ':':
ty = LEX_TOKEN_TY_COLON;
next_col(&end);
break;
case ';':
ty = LEX_TOKEN_TY_SEMICOLON;
next_col(&end);
break;
case ',':
ty = LEX_TOKEN_TY_COMMA;
next_col(&end);
break;
case '.':
next_col(&end);
if (try_consume(lexer, &end, '.')) {
if (try_consume(lexer, &end, '.')) {
ty = LEX_TOKEN_TY_ELLIPSIS;
} else {
ty = LEX_TOKEN_TY_UNKNOWN;
}
} else {
// NOTE: `.75` is a valid float
// grammar requires a digit after `.` to be valid so we check for that
if (end.idx < lexer->len && isdigit(lexer->text[end.idx])) {
goto number_literal;
}
ty = LEX_TOKEN_TY_DOT;
}
break;
case '>':
next_col(&end);
if (try_consume(lexer, &end, '=')) {
ty = LEX_TOKEN_TY_OP_GTEQ;
} else if (try_consume(lexer, &end, '>')) {
if (try_consume(lexer, &end, '=')) {
ty = LEX_TOKEN_TY_OP_RSHIFT_ASSG;
} else {
ty = LEX_TOKEN_TY_OP_RSHIFT;
}
} else {
ty = LEX_TOKEN_TY_OP_GT;
}
break;
case '<':
next_col(&end);
if (try_consume(lexer, &end, '=')) {
ty = LEX_TOKEN_TY_OP_LTEQ;
} else if (try_consume(lexer, &end, '<')) {
if (try_consume(lexer, &end, '=')) {
ty = LEX_TOKEN_TY_OP_LSHIFT_ASSG;
} else {
ty = LEX_TOKEN_TY_OP_LSHIFT;
}
} else {
ty = LEX_TOKEN_TY_OP_LT;
}
break;
case '~':
next_col(&end);
ty = LEX_TOKEN_TY_OP_NOT;
break;
case '!':
next_col(&end);
if (try_consume(lexer, &end, '=')) {
ty = LEX_TOKEN_TY_OP_NEQ;
} else {
ty = LEX_TOKEN_TY_OP_LOGICAL_NOT;
}
break;
case '=':
next_col(&end);
if (try_consume(lexer, &end, '=')) {
ty = LEX_TOKEN_TY_OP_EQ;
} else {
ty = LEX_TOKEN_TY_OP_ASSG;
}
break;
case '&':
next_col(&end);
if (try_consume(lexer, &end, '=')) {
ty = LEX_TOKEN_TY_OP_AND_ASSG;
} else if (try_consume(lexer, &end, '&')) {
ty = LEX_TOKEN_TY_OP_LOGICAL_AND;
} else {
ty = LEX_TOKEN_TY_OP_AND;
}
break;
case '|':
next_col(&end);
if (try_consume(lexer, &end, '=')) {
ty = LEX_TOKEN_TY_OP_OR_ASSG;
} else if (try_consume(lexer, &end, '|')) {
ty = LEX_TOKEN_TY_OP_LOGICAL_OR;
} else {
ty = LEX_TOKEN_TY_OP_OR;
}
break;
case '^':
next_col(&end);
if (try_consume(lexer, &end, '=')) {
ty = LEX_TOKEN_TY_OP_XOR_ASSG;
} else {
ty = LEX_TOKEN_TY_OP_XOR;
}
break;
case '+':
next_col(&end);
if (try_consume(lexer, &end, '+')) {
ty = LEX_TOKEN_TY_OP_INC;
} else if (try_consume(lexer, &end, '=')) {
ty = LEX_TOKEN_TY_OP_ADD_ASSG;
} else {
ty = LEX_TOKEN_TY_OP_ADD;
}
break;
case '-':
next_col(&end);
if (try_consume(lexer, &end, '-')) {
ty = LEX_TOKEN_TY_OP_DEC;
} else if (try_consume(lexer, &end, '=')) {
ty = LEX_TOKEN_TY_OP_SUB_ASSG;
} else if (try_consume(lexer, &end, '>')) {
ty = LEX_TOKEN_TY_ARROW;
} else {
ty = LEX_TOKEN_TY_OP_SUB;
}
break;
case '*':
next_col(&end);
if (try_consume(lexer, &end, '=')) {
ty = LEX_TOKEN_TY_OP_MUL_ASSG;
} else {
ty = LEX_TOKEN_TY_OP_MUL;
}
break;
case '/':
next_col(&end);
if (try_consume(lexer, &end, '=')) {
ty = LEX_TOKEN_TY_OP_DIV_ASSG;
} else {
ty = LEX_TOKEN_TY_OP_DIV;
}
break;
case '%':
next_col(&end);
if (try_consume(lexer, &end, '=')) {
ty = LEX_TOKEN_TY_OP_QUOT_ASSG;
} else {
ty = LEX_TOKEN_TY_OP_QUOT;
}
break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
number_literal: {
// all integers must begin with a digit
// any digit for decimal, `0` for hex/octal
// floats can be digit or `.`
bool is_float = c == '.';
next_col(&end);
// remove hex prefix
bool is_hex = try_consume(lexer, &end, 'x');
// this is generous and will allow 0BE for example, when only 0xBE is valid
// that's okay, let parser handle it
for (; end.idx < lexer->len; next_col(&end)) {
if (lexer->text[end.idx] == '.') {
is_float = true;
continue;
}
if (!is_hex &&
(lexer->text[end.idx] == 'E' || lexer->text[end.idx] == 'e')) {
is_float = true;
next_col(&end);
if (end.idx < lexer->len &&
(lexer->text[end.idx] == '+' || lexer->text[end.idx] == '-')) {
next_col(&end);
}
// skip the sign after exponent
continue;
}
if ((is_float && !isdigit(lexer->text[end.idx])) ||
(!is_float && !isxdigit(lexer->text[end.idx]))) {
break;
}
}
bool is_unsigned = false;
ty = is_float ? LEX_TOKEN_TY_DOUBLE_LITERAL
: LEX_TOKEN_TY_SIGNED_INT_LITERAL;
while (end.idx < lexer->len) {
switch (tolower(lexer->text[end.idx])) {
case 'u':
is_unsigned = true;
next_col(&end);
continue;
case 'f':
ty = LEX_TOKEN_TY_FLOAT_LITERAL;
next_col(&end);
continue;
case 'l':
if (!is_float && end.idx + 2 < lexer->len &&
tolower(lexer->text[end.idx + 1]) == 'l') {
ty = LEX_TOKEN_TY_SIGNED_LONG_LONG_LITERAL;
} else if (is_float) {
ty = LEX_TOKEN_TY_LONG_DOUBLE_LITERAL;
} else {
ty = LEX_TOKEN_TY_SIGNED_LONG_LITERAL;
}
next_col(&end);
continue;
default:
break;
}
break;
}
if (is_unsigned) {
invariant_assert(!is_float, "can't be unsigned and float");
ty++;
}
break;
}
default: {
if (c == '\'' || (c == 'L' && end.idx < lexer->len &&
lexer->text[end.idx + 1] == '\'')) {
ty = LEX_TOKEN_TY_ASCII_CHAR_LITERAL;
// skip first single-quote
if (c == 'L') {
next_col(&end);
ty = LEX_TOKEN_TY_ASCII_WIDE_CHAR_LITERAL;
}
next_col(&end);
// move forward while
bool char_escaped = false;
for (size_t i = end.idx;
i < lexer->len && !(!char_escaped && lexer->text[i] == '\''); i++) {
// next char is escaped if this char is a non-escaped backslash
char_escaped = !char_escaped && lexer->text[i] == '\\';
next_col(&end);
}
// skip final single-quote
next_col(&end);
} else if (c == '"' || (c == 'L' && end.idx < lexer->len &&
lexer->text[end.idx + 1] == '"')) {
// TODO: logic is same as for char, could dedupe
ty = LEX_TOKEN_TY_ASCII_STR_LITERAL;
// skip first double-quote
if (c == 'L') {
next_col(&end);
ty = LEX_TOKEN_TY_ASCII_WIDE_STR_LITERAL;
}
next_col(&end);
// move forward while
bool char_escaped = false;
for (size_t i = end.idx;
i < lexer->len && !(!char_escaped && lexer->text[i] == '"'); i++) {
// next char is escaped if this char is a non-escaped backslash
char_escaped = !char_escaped && lexer->text[i] == '\\';
next_col(&end);
}
// skip final double-quote
next_col(&end);
} else if (valid_first_identifier_char(c)) {
ty = LEX_TOKEN_TY_IDENTIFIER;
for (size_t i = end.idx;
i < lexer->len && valid_identifier_char(lexer->text[i]); i++) {
next_col(&end);
}
// slightly hacky solution - retroactively determine if identifier
// is a keyword
ty = refine_ty(lexer, start, end);
} else {
bug("lexer hit an unknown token! line=%zu, col=%zu, value=%u", start.line,
start.col, c);
}
}
}
token->ty = ty;
token->span.start = start;
token->span.end = end;
// debug("parse token %s\n", token_name(lexecr, token));
}
const char *strlike_associated_text(const struct lexer *lexer,
const struct token *token,
size_t *str_len) {
return process_raw_string(lexer, token, str_len);
}
const char *associated_text(const struct lexer *lexer,
const struct token *token) {
switch (token->ty) {
case LEX_TOKEN_TY_ASCII_STR_LITERAL:
case LEX_TOKEN_TY_ASCII_WIDE_STR_LITERAL:
case LEX_TOKEN_TY_ASCII_CHAR_LITERAL:
case LEX_TOKEN_TY_ASCII_WIDE_CHAR_LITERAL:
bug("use `strlike_associated_text` instead");
case LEX_TOKEN_TY_IDENTIFIER:
case LEX_TOKEN_TY_FLOAT_LITERAL:
case LEX_TOKEN_TY_DOUBLE_LITERAL:
case LEX_TOKEN_TY_LONG_DOUBLE_LITERAL:
case LEX_TOKEN_TY_SIGNED_INT_LITERAL:
case LEX_TOKEN_TY_UNSIGNED_INT_LITERAL:
case LEX_TOKEN_TY_SIGNED_LONG_LITERAL:
case LEX_TOKEN_TY_UNSIGNED_LONG_LITERAL:
case LEX_TOKEN_TY_SIGNED_LONG_LONG_LITERAL:
case LEX_TOKEN_TY_UNSIGNED_LONG_LONG_LITERAL: {
size_t len = text_span_len(&token->span);
char *p = arena_alloc(lexer->arena, len + 1);
memcpy(p, &lexer->text[token->span.start.idx], len);
p[len] = '\0';
return p;
}
case LEX_TOKEN_TY_ELLIPSIS:
return "...";
default:
bug("associated text did not make sense for token '%s'",
token_name(lexer, token));
}
}
const char *token_name(UNUSED_ARG(const struct lexer *lexer), const struct token *token) {
#define CASE_RET(name) \
case name: \
return #name;
switch (token->ty) {
CASE_RET(LEX_TOKEN_TY_UNKNOWN)
CASE_RET(LEX_TOKEN_TY_EOF)
CASE_RET(LEX_TOKEN_TY_WHITESPACE)
CASE_RET(LEX_TOKEN_TY_INLINE_CO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KW_HALF)
CASE_RET(LEX_TOKEN_TY_KW_FLOAT)
CASE_RET(LEX_TOKEN_TY_KW_DOUBLE)
CASE_RET(LEX_TOKEN_TY_KW_CHAR)
CASE_RET(LEX_TOKEN_TY_KW_SHORT)
CASE_RET(LEX_TOKEN_TY_KW_INT)
CASE_RET(LEX_TOKEN_TY_KW_LONG)
CASE_RET(LEX_TOKEN_TY_KW_SIGNED)
CASE_RET(LEX_TOKEN_TY_KW_UNSIGNED)
CASE_RET(LEX_TOKEN_TY_OPEN_SQUARE_BRACKET)
CASE_RET(LEX_TOKEN_TY_CLOSE_SQUARE_BRACKET)
CASE_RET(LEX_TOKEN_TY_OPEN_BRACKET)
CASE_RET(LEX_TOKEN_TY_CLOSE_BRACKET)
CASE_RET(LEX_TOKEN_TY_OPEN_BRACE)
CASE_RET(LEX_TOKEN_TY_CLOSE_BRACE)
CASE_RET(LEX_TOKEN_TY_IDENTIFIER)
CASE_RET(LEX_TOKEN_TY_ASCII_STR_LITERAL)
CASE_RET(LEX_TOKEN_TY_ASCII_WIDE_STR_LITERAL)
CASE_RET(LEX_TOKEN_TY_ASCII_CHAR_LITERAL)
CASE_RET(LEX_TOKEN_TY_ASCII_WIDE_CHAR_LITERAL)
CASE_RET(LEX_TOKEN_TY_FLOAT_LITERAL)
CASE_RET(LEX_TOKEN_TY_DOUBLE_LITERAL)
CASE_RET(LEX_TOKEN_TY_LONG_DOUBLE_LITERAL)
CASE_RET(LEX_TOKEN_TY_SIGNED_INT_LITERAL)
CASE_RET(LEX_TOKEN_TY_UNSIGNED_INT_LITERAL)
CASE_RET(LEX_TOKEN_TY_SIGNED_LONG_LITERAL)
CASE_RET(LEX_TOKEN_TY_UNSIGNED_LONG_LITERAL)
CASE_RET(LEX_TOKEN_TY_SIGNED_LONG_LONG_LITERAL)
CASE_RET(LEX_TOKEN_TY_UNSIGNED_LONG_LONG_LITERAL)
}
#undef CASE_RET
}