Converted tabs to spaces, build into build/ dir
[mcc.git] / cpp.h
blob16b65af9b7b51fbc68ac29a70fe0fd55f04ca5fb
1 #ifndef MCC_CPP_H
2 #define MCC_CPP_H
4 #include "stdio.h"
5 #include "stdbool.h"
7 // A location in a source file
8 struct sloc {
9 const char *name;
10 int line;
11 int col;
14 // A source file
15 struct incfile {
16 struct incfile *prev;
17 FILE *f;
18 int line;
19 bool must_close; // must close f after use?
20 bool eof;
21 int cond_d, cond_td; // condition depth/condition true depth
22 char name[1];
25 // A macro, or a macro argument
26 struct macro {
27 struct macro *next;
28 struct macro *args; // argument list
29 bool has_args; // if has_args && !args then it's a macro like FOO()
30 char *text; // what the macro expands to
31 struct sloc sloc; // location of definition
32 char name[1]; // macro/macro argument name
35 // Preprocessor state
36 struct cpp {
37 struct incfile *include_top;
38 struct incfile *stale_files;
39 char *line_buf;
40 struct sloc line_loc;
41 struct macro *macros; // all defined macros
42 char *include_dirs;
45 void cpp_init(struct cpp *cpp);
46 void cpp_delete(struct cpp *cpp);
47 bool cpp_open_include_file(struct cpp *cpp, const char *name);
48 void cpp_include_file(struct cpp *cpp, const char *name, FILE *f, bool must_close);
49 void cpp_read_line(struct cpp *cpp);
50 void cpp_process_line(struct cpp *cpp);
52 #endif