Mercurial > hg > index.cgi
comparison lwcc/cc-main.c @ 499:c3099c5d9d3e
Add very simple code generator
This very simple code generator is definitely not the final form. It is
simply a stop-gap for ongoing development.
author | William Astle <lost@l-w.ca> |
---|---|
date | Thu, 08 Aug 2019 23:48:18 -0600 |
parents | a38542cf4cc6 |
children |
comparison
equal
deleted
inserted
replaced
498:1bd2d590d734 | 499:c3099c5d9d3e |
---|---|
35 #include "tree.h" | 35 #include "tree.h" |
36 | 36 |
37 node_t *process_file(const char *); | 37 node_t *process_file(const char *); |
38 static void do_error(const char *f, ...); | 38 static void do_error(const char *f, ...); |
39 extern node_t *parse_program(struct preproc_info *pp); | 39 extern node_t *parse_program(struct preproc_info *pp); |
40 extern void generate_code(node_t *n, FILE *of); | |
40 | 41 |
41 node_t *program_tree = NULL; | 42 node_t *program_tree = NULL; |
42 | 43 |
43 /* command line option handling */ | 44 /* command line option handling */ |
44 #define PROGVER "lwcc-cc from " PACKAGE_STRING | 45 #define PROGVER "lwcc-cc from " PACKAGE_STRING |
171 lw_stringlist_destroy(includedirs); | 172 lw_stringlist_destroy(includedirs); |
172 lw_stringlist_destroy(sysincludedirs); | 173 lw_stringlist_destroy(sysincludedirs); |
173 lw_stringlist_destroy(macrolist); | 174 lw_stringlist_destroy(macrolist); |
174 | 175 |
175 node_display(program_tree, stdout); | 176 node_display(program_tree, stdout); |
177 | |
178 // generate output | |
179 generate_code(program_tree, output_fp); | |
180 | |
176 node_destroy(program_tree); | 181 node_destroy(program_tree); |
177 exit(retval); | 182 exit(retval); |
178 } | 183 } |
179 | 184 |
180 node_t *process_file(const char *fn) | 185 node_t *process_file(const char *fn) |
207 preproc_add_macro(pp, tstr); | 212 preproc_add_macro(pp, tstr); |
208 } | 213 } |
209 | 214 |
210 n = parse_program(pp); | 215 n = parse_program(pp); |
211 preproc_finish(pp); | 216 preproc_finish(pp); |
217 | |
212 return n; | 218 return n; |
213 } | 219 } |
214 | 220 |
215 static void do_error(const char *f, ...) | 221 static void do_error(const char *f, ...) |
216 { | 222 { |