diff options
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -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) { |
