diff options
author | Himbeer <himbeer@disroot.org> | 2024-09-17 19:31:40 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-09-17 19:31:40 +0200 |
commit | 93ab996ca30a1dc9c12a34824813fdf6b3bbefa1 (patch) | |
tree | 7b516064706c784a4f2c4343f75cda22156d1902 /src | |
parent | 7ed1a6eebb852667f0a4a67e80a09ddecafb9734 (diff) |
Make main parse the token stream into an AST
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 19 |
1 files changed, 3 insertions, 16 deletions
@@ -6,6 +6,7 @@ #include <string.h> #include <sys/stat.h> #include "lex.h" +#include "parse.h" #include "util.h" int @@ -16,6 +17,7 @@ main(int argc, char *argv[]) int nsources = argc - optind; struct lexer lexer; + struct ast_unit ast; for (int i = 0; i < nsources; ++i) { FILE *in; @@ -40,22 +42,7 @@ main(int argc, char *argv[]) } lex_init(&lexer, in); - struct token token; - while (lex(&lexer, &token) != T_EOF) { - printf("%d", token.token); - if (token.token == T_COMMENT || token.token == T_NAME - || token.token == T_STRING) { - printf(" %s", token.info.str); - } else if (token.token == T_NUMBER - && token.info.num.isfloat) { - printf(" %f", token.info.num.value.floatingpt); - } else if (token.token == T_NUMBER) { - printf(" %d", token.info.num.value.integer); - } else { - printf(" %s", tokens[token.token]); - } - printf("\n"); - } + parse(&lexer, &ast); lex_finish(&lexer); } |