introduce some builtin types
[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 #include "type.h"
8
9 typedef enum {
10 #define T(x,str,val) T_##x val,
11 #define TS(x,str,val) T_##x val,
12 #include "tokens.inc"
13 #undef TS
14 #undef T
15
16         T_EOF   = -1,
17         T_ERROR = -2
18 } token_type_t;
19
20 typedef enum {
21 #define T(x,str,val) TP_##x val,
22 #define TS(x,str,val) TP_##x val,
23 #include "tokens_preprocessor.inc"
24 #undef TS
25 #undef T
26 } preprocessor_token_type_t;
27
28 typedef struct source_position_t source_position_t;
29 struct source_position_t {
30         const char *input_name;
31         unsigned    linenr;
32 };
33
34 /* position used for "builtin" declarations/types */
35 extern source_position_t builtin_source_position;
36
37 typedef struct {
38         int type;
39         union {
40                 symbol_t   *symbol;
41                 long long   intvalue;
42                 long double floatvalue;
43                 const char *string;
44         } v;
45         type_t            *datatype;
46         source_position_t  source_position;
47 } token_t;
48
49 void init_tokens(void);
50 void exit_tokens(void);
51 void print_token_type(FILE *out, token_type_t token_type);
52 void print_token(FILE *out, const token_t *token);
53
54 #endif