2 * TCC - Tiny C Compiler
4 * Copyright (c) 2001-2004 Fabrice Bellard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
void save_parse_state(ParseState
*s
);
24
void restore_parse_state(ParseState
*s
);
25 void preprocess_init(TCCState
*s1
);
26 void preprocess_new(void);
27
char *get_tok_str(int v
, CValue
*cv
);
29
/* find a token and add it if not found */
30
TokenSym
*tok_alloc(const char *str
, int len
);
32
Sym
*label_find(int v
);
33 Sym
*label_push(Sym
**ptop
, int v
, int flags
);
34 /* free define stack until top reaches 'b' */
35 void free_defines(Sym
*b
);
36 void next_nomacro(void);
37 /* defines handling */
38 void define_push(int v
, int macro_type
, int *str
, Sym
*first_arg
);
39 /* parse after #define */
40 void parse_define(void);
41 static inline Sym
*define_find(int v
)
44 if ((unsigned)v
>= (unsigned)(tok_ident
- TOK_IDENT
))
46 return table_ident
[v
]->sym_define
;
48 void label_pop(Sym
**ptop
, Sym
*slast
);
49 void define_undef(Sym
*s
);
50 /* Preprocess the current file */
51 int tcc_preprocess(TCCState
*s1
);
52 /* input with '\[\r]\n' handling. Note that this function cannot
53 handle other characters after '\', so you cannot call it inside
54 strings or comments */
57 uint8_t *parse_comment(uint8_t *p
);
58 /* return the current character, handling end of block if necessary
61 /* read next char from current input file and handle end of input buffer */
62 static inline void inp(void)
64 ch
= *(++(file
->buf_ptr
));
65 /* end of buffer/file handling */
70 /* return the number of additional 'ints' necessary to store the
72 static inline int tok_ext_size(int t
)
86 error("unsupported token");
93 return LDOUBLE_SIZE
/ 4;
99 /* push back current token and set current token to 'last_tok'. Only
100 identifier case handled for labels. */
101 static inline void unget_tok(int last_tok
)
105 unget_saved_macro_ptr
= macro_ptr
;
106 unget_buffer_enabled
= 1;
107 q
= unget_saved_buffer
;
110 n
= tok_ext_size(tok
) - 1;
113 *q
= 0; /* end of token string */
117 static inline void tok_str_new(TokenString
*s
)
121 s
->allocated_len
= 0;
122 s
->last_line_num
= -1;
125 /* add the current parse token in token string 's' */
126 void tok_str_add_tok(TokenString
*s
);
127 void tok_str_add(TokenString
*s
, int t
);
128 void tok_str_free(int *str
);
130 #endif /* __TCCPP_H__ */