-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtoken_t.h
More file actions
36 lines (29 loc) · 693 Bytes
/
Copy pathtoken_t.h
File metadata and controls
36 lines (29 loc) · 693 Bytes
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
#ifndef TOKEN_T_H
#define TOKEN_T_H
#include <stdio.h>
#include "symbol.h"
#include "symbol_table.h"
typedef enum token_type_tokens_t {
T_ERROR = (unsigned)-1,
T_EOF = '\x04', // EOT
#define T(x,str,val) T_##x val,
#define TS(x,str,val) T_##x val,
#include "tokens.inc"
#undef TS
#undef T
} token_type_tokens_t;
typedef unsigned token_type_t;
typedef struct {
token_type_t type;
union {
symbol_t *symbol;
int intvalue;
const char *string;
} v;
} token_t;
void init_tokens(void);
void exit_tokens(void);
void print_token_type(FILE *out, token_type_t token_type);
void print_token(FILE *out, const token_t *token);
int register_new_token(const char *token);
#endif