From 4601553f9b9753cc5843a96dd4e8fa87671f1058 Mon Sep 17 00:00:00 2001 From: Bernd Jendrissek Date: Sun, 27 Jan 2008 20:05:22 +0000 Subject: [PATCH] Define #t and #f. --- lisp/lisp.c | 14 ++++++++++++++ lisp/test-expected | 5 +++++ lisp/test-input | 5 +++++ 3 files changed, 24 insertions(+) create mode 100644 lisp/test-expected create mode 100644 lisp/test-input diff --git a/lisp/lisp.c b/lisp/lisp.c index 88d78a6..6f6f48f 100644 --- a/lisp/lisp.c +++ b/lisp/lisp.c @@ -433,6 +433,7 @@ int main() size_t bufsize = 0; size_t formsize; union value_pointer form; + union value_pointer constant_true, constant_false; struct pair *i; struct environment top_env; @@ -455,6 +456,19 @@ int main() top_env.variables_size = 0; top_env.parent = NULL; + constant_true.vp_charseq = charseq_new(); + constant_true.vp_charseq->len = 2; + constant_true.vp_charseq->s = "#t"; + pointer_mark(&constant_true, 1); + + constant_false.vp_charseq = charseq_new(); + constant_false.vp_charseq->len = 2; + constant_false.vp_charseq->s = "#f"; + pointer_mark(&constant_false, 1); + + binding_new(&top_env, "#t", constant_true); + binding_new(&top_env, "#f", constant_false); + binding_builtin(&top_env, "car", builtin_car); binding_builtin(&top_env, "cdr", builtin_cdr); binding_builtin(&top_env, "cons", builtin_cons); diff --git a/lisp/test-expected b/lisp/test-expected new file mode 100644 index 0000000..563f587 --- /dev/null +++ b/lisp/test-expected @@ -0,0 +1,5 @@ +(+ 4 5) -> 9 +(cons 17 42) -> (17 . 42) +(car (cons 17 42)) -> 17 +#t -> #t +cons -> builtin diff --git a/lisp/test-input b/lisp/test-input new file mode 100644 index 0000000..e085116 --- /dev/null +++ b/lisp/test-input @@ -0,0 +1,5 @@ +(+ 4 5) +(cons 17 42) +(car (cons 17 42)) +#t +cons -- 2.11.4.GIT