First iteration in adding wide string literal support. No input encoding handling...
[cparser] / token_t.h
1 #ifndef TOKEN_T_H
2 #define TOKEN_T_H
3
4 #include <stdio.h>
5 #include "string_rep.h"
6 #include "symbol.h"
7 #include "symbol_table.h"
8 #include "type.h"
9
10 typedef enum {
11 #define T(x,str,val) T_##x val,
12 #define TS(x,str,val) T_##x val,
13 #include "tokens.inc"
14 #undef TS
15 #undef T
16
17         T_EOF   = -1,
18         T_ERROR = -2
19 } token_type_t;
20
21 typedef enum {
22 #define T(x,str,val) TP_##x val,
23 #define TS(x,str,val) TP_##x val,
24 #include "tokens_preprocessor.inc"
25 #undef TS
26 #undef T
27 } preprocessor_token_type_t;
28
29 typedef struct source_position_t source_position_t;
30 struct source_position_t {
31         const char *input_name;
32         unsigned    linenr;
33 };
34
35 /* position used for "builtin" declarations/types */
36 extern source_position_t builtin_source_position;
37
38 typedef struct {
39         int type;
40         union {
41                 symbol_t      *symbol;
42                 long long      intvalue;
43                 long double    floatvalue;
44                 const char    *string;
45                 wide_string_t  wide_string;
46         } v;
47         type_t            *datatype;
48         source_position_t  source_position;
49 } token_t;
50
51 void init_tokens(void);
52 void exit_tokens(void);
53 void print_token_type(FILE *out, token_type_t token_type);
54 void print_token(FILE *out, const token_t *token);
55
56 #endif