diff options
| author | Felix Perktold <Felix.Perktold@student.uibk.ac.at> | 2026-01-22 00:23:18 +0100 |
|---|---|---|
| committer | Felix Perktold <Felix.Perktold@student.uibk.ac.at> | 2026-01-22 00:23:18 +0100 |
| commit | eaa0ad227969429b333d6ef26e4f4c9f266fbee5 (patch) | |
| tree | c5f64b2e7927783ce57fab5f1420124a4a13e3d9 /lisp.y | |
| parent | e3b8eded6cf924e2f1e532f0db1aef899b451ccf (diff) | |
changed the repl so defined values don't immediately get evaluated from REPL (important for endless lists etc)
Diffstat (limited to 'lisp.y')
| -rw-r--r-- | lisp.y | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1,6 +1,7 @@ %{ #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "lisp_api.h" #include "lisp.h" @@ -9,9 +10,14 @@ int yyerror(const char *s); void eval_and_print_REPL(value *v) { if(!v) { return; } - value *ve = eval(global_env, v); + if (v->type == VT_PAIR && car(v)->type == VT_SYMBOL && !strcmp(car(v)->as.sym, "define")) { + eval(global_env, v); + printf(";> defined "); + println_value(car(cdr(v))); + return; // Skip printing for define so infinite lists do not eval + } printf(";> "); - println_value(ve); + println_value(eval(global_env, v)); } %} |
