From 98be4ba8e6050f33fd47786de066b165f74a115d Mon Sep 17 00:00:00 2001 From: Flavian Kaufmann Date: Tue, 20 May 2025 07:10:19 +0200 Subject: initial --- driver.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 driver.c (limited to 'driver.c') diff --git a/driver.c b/driver.c new file mode 100644 index 0000000..d89c412 --- /dev/null +++ b/driver.c @@ -0,0 +1,30 @@ +#include +#include +#include "ast.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; + } + + exec_stmt(ast_root); + env_print(); + free_ast(ast_root); + + return EXIT_SUCCESS; +} -- cgit v1.2.3