summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorkugwa <kugwa2000@gmail.com>2015-12-30 15:19:51 +0800
committerkugwa <kugwa2000@gmail.com>2015-12-30 15:19:51 +0800
commit0c0c7ab0850b6803c377ad7150305870d75bf3c0 (patch)
treed2bcb8109870d9d3e4254c0f8b6aade427399fa4 /src/main.c
parent9cb1a75a6772b2c4bdb895f724b40d00290ffa0d (diff)
downloadcompiler2015-0c0c7ab0850b6803c377ad7150305870d75bf3c0.tar
compiler2015-0c0c7ab0850b6803c377ad7150305870d75bf3c0.tar.gz
compiler2015-0c0c7ab0850b6803c377ad7150305870d75bf3c0.tar.bz2
compiler2015-0c0c7ab0850b6803c377ad7150305870d75bf3c0.tar.lz
compiler2015-0c0c7ab0850b6803c377ad7150305870d75bf3c0.tar.xz
compiler2015-0c0c7ab0850b6803c377ad7150305870d75bf3c0.tar.zst
compiler2015-0c0c7ab0850b6803c377ad7150305870d75bf3c0.zip
Add the code-generation phase
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 6516eab..5f6c169 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5,6 +5,7 @@
typedef void* yyscan_t;
#include "ast.h"
+#include "code-generation.h"
#include "common.h"
#include "draw.h"
#include "semantic-analysis.h"
@@ -95,6 +96,14 @@ int main (int argc, char **argv)
else
exit(1);
+ FILE *asm_output = fopen("output.s", "w");
+ if (asm_output == NULL) {
+ fprintf(stderr, "%s: output.s: %s\n", prog_name, ERR_MSG);
+ exit(1);
+ }
+ ccmmc_code_generation(state->ast, state->table, asm_output);
+ fclose(asm_output);
+
ccmmc_state_fini(state);
fclose(source_handle);
return 0;