summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/main.c b/main.c
index e2aca11..5c26dd3 100644
--- a/main.c
+++ b/main.c
@@ -3,6 +3,7 @@
#include "codegen.h"
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
void test_lexer(int argc, char** argv) {
struct token token;
@@ -37,15 +38,17 @@ void test_lexer(int argc, char** argv) {
}
void test_parser(int argc, char** argv) {
- struct root_node* root;
- struct root_node** p_cur = &root;
for (int i = 1; i < argc; i++) {
- *p_cur = parse(argv[i]);
- p_cur = &((*p_cur)->next);
- }
+ struct root_node* root = parse(argv[i]);
+ unsigned int fn_sz = strlen(argv[i]);
+ char outfile[fn_sz + 1];
+ strcpy(outfile, argv[i]);
+ outfile[fn_sz - 1] = 's';
+ outfile[fn_sz] = 0;
- emit_code(root, "test/simple.s");
- ast_destroy(root);
+ emit_code(root, outfile);
+ ast_destroy(root);
+ }
}
int main(int argc, char** argv) {