From 3829a704150a06b2767d542b39179377a592da0f Mon Sep 17 00:00:00 2001 From: Flavian Kaufmann Date: Tue, 20 May 2025 10:29:33 +0200 Subject: folder structure --- src/driver.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/driver.c (limited to 'src/driver.c') 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 +#include +#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; +} -- cgit v1.2.3