diff options
author | Flavian Kaufmann <flavian@flaviankaufmann.ch> | 2025-05-20 10:29:33 +0200 |
---|---|---|
committer | Flavian Kaufmann <flavian@flaviankaufmann.ch> | 2025-05-20 10:29:33 +0200 |
commit | 3829a704150a06b2767d542b39179377a592da0f (patch) | |
tree | 316a1e01f3306d717739e6d73b25f5215c2cf8f0 /src/driver.c | |
parent | cc383b7b2d89f05b724460b4d5cb385525911671 (diff) | |
download | imp-3829a704150a06b2767d542b39179377a592da0f.tar.gz imp-3829a704150a06b2767d542b39179377a592da0f.zip |
folder structure
Diffstat (limited to 'src/driver.c')
-rw-r--r-- | src/driver.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/driver.c b/src/driver.c new file mode 100644 index 0000000..90ee892 --- /dev/null +++ b/src/driver.c @@ -0,0 +1,31 @@ +#include <stdio.h> +#include <stdlib.h> +#include "interpreter.h" + +extern FILE *yyin; +extern int yyparse(void); +extern ASTNode *ast_root; + +int main(int argc, char **argv) { + if (argc > 1) { + yyin = fopen(argv[1], "r"); + if (!yyin) { + perror(argv[1]); + return EXIT_FAILURE; + } + } else { + yyin = stdin; + } + + if (yyparse() != 0) { + fprintf(stderr, "Parsing failed.\n"); + return EXIT_FAILURE; + } + + Env *env = NULL; + exec_stmt(&env, ast_root); + env_print(env); + free_ast(ast_root); + + return EXIT_SUCCESS; +} |