2 * This file is part of cparser.
3 * Copyright (C) 2007-2009 Matthias Braun <matze@braunis.de>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 #include "string_rep.h"
26 #include "symbol_table.h"
29 typedef enum token_kind_t {
31 T_EOF = '\x04', // EOT
32 #define T(mode,x,str,val) T_##x val,
33 #define TS(x,str,val) T_##x val,
40 typedef enum preprocessor_token_kind_t {
43 #define T(mode,x,str,val) TP_##x val,
44 #define TS(x,str,val) TP_##x val,
45 #include "tokens_preprocessor.inc"
49 } preprocessor_token_kind_t;
51 typedef struct source_position_t source_position_t;
52 struct source_position_t {
53 const char *input_name;
56 unsigned is_system_header : 1;
59 /* position used for "builtin" declarations/types */
60 extern const source_position_t builtin_source_position;
62 typedef struct token_base_t token_base_t;
63 typedef struct string_literal_t string_literal_t;
64 typedef struct number_literal_t number_literal_t;
65 typedef union token_t token_t;
69 source_position_t source_position;
73 struct string_literal_t {
78 struct number_literal_t {
87 string_literal_t string;
88 number_literal_t number;
91 void init_tokens(void);
92 void exit_tokens(void);
93 void print_token_kind(FILE *out, token_kind_t token_kind);
94 void print_token(FILE *out, const token_t *token);
96 void print_pp_token_kind(FILE *out, int kind);
97 void print_pp_token(FILE *out, const token_t *token);
100 * returns true if pasting 2 preprocessing tokens next to each other
101 * without a space in between would generate (an)other preprocessing token(s)
103 bool tokens_would_paste(preprocessor_token_kind_t token1,
104 preprocessor_token_kind_t token2);