tisp

tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | LICENSE

commit f0fd94f1f544cc8874e40abfd0a9bec87526c751
parent 9abb2fbd9849b4513d654d8be9efc521c714af4a
Author: Ed van Bruggen <edvb@uw.edu>
Date:   Sat, 24 Mar 2018 22:36:48 -0700

Add t global constant to represent true

Diffstat:
tisp.c | 13++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/tisp.c b/tisp.c @@ -114,6 +114,7 @@ static Val tisp_eval(Hash env, Val v); char *argv0; struct Val nil; +struct Val t; #include "config.h" @@ -593,7 +594,7 @@ static Hash init_env(void) { Hash h = hash_new(64); - hash_add(h, "t", mk_sym("t")); + hash_add(h, "t", &t); hash_add(h, "car", mk_prim(prim_car)); hash_add(h, "cdr", mk_prim(prim_cdr)); hash_add(h, "cons", mk_prim(prim_cons)); @@ -641,6 +642,8 @@ main(int argc, char *argv[]) Hash env = init_env(); nil.t = NIL; + t.t = SYMBOL; + t.v.s = estrdup("t"); if (argc > 0) { if (!(fp = fopen(*argv, "r"))) @@ -658,13 +661,5 @@ main(int argc, char *argv[]) if (str) break; } - for (; env; env = env->next) { - for (int i = 0; i < env->cap; i++) - if (env->items[i].key) - val_free(env->items[i].val); - free(env->items); - free(env); - } - return 0; }