changeset 155:cfe8ddaa770c

repl: Handle program-root scoping correctly
author Lewin Bormann <lbo@spheniscida.de>
date Tue, 03 Sep 2019 15:35:04 +0200
parents aa6847f62505
children 3cd189bd595c
files src/repl.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/repl.c	Tue Sep 03 15:34:46 2019 +0200
+++ b/src/repl.c	Tue Sep 03 15:35:04 2019 +0200
@@ -10,6 +10,7 @@
 
     yeval_state_t state;
     state.call_stack = YVEC_NEW(NULL, 16, yexpr_t);
+    yvec_t* scope_stack = NULL;
 
     while (1) {
         ystr_t input = ystr_new(NULL), output = ystr_new(NULL),
@@ -24,14 +25,16 @@
             return 0;
         }
         if (!yparse_str(&input, &stmt, &error)) {
-            fprintf(stderr, "parse error: %s\n", ystr_str(&input));
+            fprintf(stderr, "parse error: %s\n", ystr_str(&error));
             goto cleanup_continue;
         }
         if (YEXPR_LIST != stmt.typ) {
             fprintf(stderr, "bug: expression should be list!\n");
             goto cleanup_continue;
         }
-        ypreprocess(&stmt);
+        ypreprocess_resolve_builtins(&stmt);
+        ypreprocess_refs_repl(&stmt, &scope_stack);
+
         result = yeval_list_return_last(&state, &stmt.value.list, 0);
 
         if (result.typ != YEXPR_UNDEF) {