improve number lexing even more
[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 typedef struct {
35         int type;
36         union {
37                 symbol_t   *symbol;
38                 long long   intvalue;
39                 long double floatvalue;
40                 const char *string;
41         } v;
42         type_t            *datatype;
43         source_position_t  source_position;
44 } token_t;
45
46 void init_tokens(void);
47 void exit_tokens(void);
48 void print_token_type(FILE *out, token_type_t token_type);
49 void print_token(FILE *out, const token_t *token);
50
51 #endif