-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoken_types.c
More file actions
49 lines (45 loc) · 1.2 KB
/
token_types.c
File metadata and controls
49 lines (45 loc) · 1.2 KB
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
#include "token_types.h"
#include "common.h"
#define UNPACK(...) __VA_ARGS__
void
print_token_data(TreePrinter * __printer, const TokenData * __token)
{
if (!__token) {
__printer->start_field(__printer);
__printer->printf(__printer, "NULL");
__printer->end_field(__printer);
return;
}
struct {
TreePrinter *printer;
const TokenData *token;
} print_token_data__locals = {
.printer = __printer,
.token = __token,
};
{
switch (print_token_data__locals.token->token_type) {
#define PRINT_FIELD(...) printer->start_field(printer); printer->printf(printer, __VA_ARGS__); printer->end_field(printer);
#define BITSTREAMOP_TOKEN(name, elements, printimpl) case TOKENTYPE_##name: { \
TreePrinter *const printer = print_token_data__locals.printer; \
const name##TokenData *const self = &print_token_data__locals.token->as_##name; \
(void) self; \
PRINT_FIELD("token_type = TOKENTYPE_%s", #name); \
UNPACK printimpl \
} break;
#include "token_types.cc"
#undef BITSTREAMOP_TOKEN
}
}
}
char *keyword_type_names[] = {
"while",
"if",
"function",
"call",
};
char *token_type_names[] = {
#define BITSTREAMOP_TOKEN(name, elements, printimpl) #name,
#include "token_types.cc"
#undef BITSTREAMOP_TOKEN
};