aboutsummaryrefslogtreecommitdiff
path: root/src/as_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/as_main.c')
-rw-r--r--src/as_main.c42
1 files changed, 0 insertions, 42 deletions
diff --git a/src/as_main.c b/src/as_main.c
deleted file mode 100644
index cd9251b..0000000
--- a/src/as_main.c
+++ /dev/null
@@ -1,42 +0,0 @@
-#include <stdio.h>
-
-#include "as_tokenizer.h"
-#include "as_analyzer.h"
-#include "as_parser.h"
-#include "as_codegen.h"
-#include "utils.h"
-
-result main_impl(int argc, char** argv) {
- if (argc != 3) {
- return err("usage: fvm-as <input_file> <output_file>");
- }
- struct allocator * alct = new_allocator();
- FILE *fp = fopen(argv[1], "r");
- token_stream * ts = new_token_stream(alct, fp);
- prog* prog = unwrap(parse_prog(alct, ts));
- sym_table symtbl = analyze_prog(alct, prog);
- bytearray* output = unwrap(codegen(alct, prog, symtbl));
- fclose(fp);
-
- fp = fopen(argv[2], "wb");
- if (fp == NULL) {
- return err("open output file failed.");
- }
- int ret =fwrite(output->buf, 1, output->len, fp);
- if (ret != output->len) {
- return err("write output file failed.");
- }
- fclose(fp);
-
- delete_allocator(alct);
- return ok(NULL);
-}
-
-int main(int argc, char** argv) {
- result result = main_impl(argc, argv);
- if (result.errmsg != NULL) {
- fprintf(stderr, "%s\n", result.errmsg);
- return -1;
- }
- return 0;
-}