Initial import of c parser
[cparser] / token_t.h
1 #ifndef TOKEN_T_H
2 #define TOKEN_T_H
3
4 #include <stdio.h>
5 #include "symbol.h"
6 #include "symbol_table.h"
7
8 typedef enum {
9 #define T(x,str,val) T_##x val,
10 #define TS(x,str,val) T_##x val,
11 #include "tokens.inc"
12 #undef TS
13 #undef T
14
15         T_EOF   = -1,
16         T_ERROR = -2
17 } token_type_t;
18
19 typedef enum {
20 #define T(x,str,val) TP_##x val,
21 #define TS(x,str,val) TP_##x val,
22 #include "tokens.inc"
23 #undef TS
24 #undef T
25
26         TP_EOF   = T_EOF,
27         TP_ERROR = T_ERROR
28 } preprocessor_token_type_t;
29
30 typedef struct {
31         int type;
32         union {
33                 symbol_t   *symbol;
34                 int         intvalue;
35                 const char *string;
36         } v;
37 } token_t;
38
39 void init_tokens(void);
40 void exit_tokens(void);
41 void print_token_type(FILE *out, token_type_t token_type);
42 void print_token(FILE *out, const token_t *token);
43
44 #endif