aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavian Kaufmann <flavian@flaviankaufmann.ch>2025-05-26 22:11:16 +0200
committerFlavian Kaufmann <flavian@flaviankaufmann.ch>2025-05-26 22:11:16 +0200
commitb5067e66cc320e6fbd5cf9c9af8788bcb905993d (patch)
tree4d0215e9bf41f0edefc38e43267df4f349f16a46
parent041fcfd0b17e7a6f654fc155108847aac8293144 (diff)
downloadimp-b5067e66cc320e6fbd5cf9c9af8788bcb905993d.tar.gz
imp-b5067e66cc320e6fbd5cf9c9af8788bcb905993d.zip
[bugfix] set ast_root to NULL before parsingHEADmaster
-rw-r--r--README.md2
-rw-r--r--src/ast.c2
-rw-r--r--src/driver.c2
3 files changed, 4 insertions, 2 deletions
diff --git a/README.md b/README.md
index 360c1e3..021ea3a 100644
--- a/README.md
+++ b/README.md
@@ -96,7 +96,7 @@ Control flow:
Procedures:
- `procedure <ident>(<var>, ... ; <var>, ... ) begin <stm> end` declaration, first argument list are value arguments (vars passed to procedure), second argument list are variable arguments (vars returned from procedure).
-- `<ident>(<var>, ... ; <var>, ... )` call
+- `<ident>(<aexpr>, ... ; <var>, ... )` call
**Expression**
diff --git a/src/ast.c b/src/ast.c
index 9c13d79..eced7f3 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -246,4 +246,4 @@ void imp_ast_list_destroy(IMP_ASTNodeList *list) {
imp_ast_destroy(list->node);
imp_ast_list_destroy(list->next);
free(list);
-} \ No newline at end of file
+}
diff --git a/src/driver.c b/src/driver.c
index c43b899..d8cd143 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -20,6 +20,7 @@ int imp_driver_interpret_file (IMP_InterpreterContext *context, const char *path
yyin = fopen(path, "r");
if (!yyin) return -1;
yyrestart(yyin);
+ ast_root = NULL;
if (yyparse()) {
imp_ast_destroy(ast_root);
fclose(yyin);
@@ -37,6 +38,7 @@ int imp_driver_interpret_file (IMP_InterpreterContext *context, const char *path
int imp_driver_interpret_str (IMP_InterpreterContext *context, const char *str) {
YY_BUFFER_STATE buf = yy_scan_string(str);
+ ast_root = NULL;
if (yyparse()) {
imp_ast_destroy(ast_root);
yy_delete_buffer(buf);