From 1259c178373aa959a7bd0b7037b6ded11c46c47e Mon Sep 17 00:00:00 2001 From: JeffBezanson Date: Thu, 23 Apr 2009 00:55:03 +0000 Subject: [PATCH] updating interpreter to work better for bootstrapping adding program mkboot0, which can be run in the interpreter to compile source files into a stage-0 boot image. --- femtolisp/mkboot0.lsp | 19 +++++++++++++++++++ femtolisp/read.c | 10 ++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 femtolisp/mkboot0.lsp diff --git a/femtolisp/mkboot0.lsp b/femtolisp/mkboot0.lsp new file mode 100644 index 0000000..9dd989e --- /dev/null +++ b/femtolisp/mkboot0.lsp @@ -0,0 +1,19 @@ +; -*- scheme -*- + +(if (not (bound? 'top-level-value)) (set! top-level-value %eval)) +(if (not (bound? 'set-top-level-value!)) (set! set-top-level-value! set)) + +(load "compiler.lsp") + +(define (compile-file inf) + (let ((in (file inf :read))) + (let next ((E (read in))) + (if (not (io.eof? in)) + (begin (print (compile-thunk (expand E))) + (princ "\n") + (next (read in))))) + (io.close in))) + +(for-each (lambda (file) + (compile-file file)) + (cdr *argv*)) diff --git a/femtolisp/read.c b/femtolisp/read.c index 4b08336..f5acb4a 100644 --- a/femtolisp/read.c +++ b/femtolisp/read.c @@ -575,8 +575,14 @@ static value_t do_read_sexpr(value_t label) // cannot see pending labels. in other words: // (... #2=#.#0# ... ) OK // (... #2=#.(#2#) ... ) DO NOT WANT - v = do_read_sexpr(UNBOUND); - return toplevel_eval(v); + sym = do_read_sexpr(UNBOUND); + if (issymbol(sym)) { + v = symbol_value(sym); + if (v == UNBOUND) + raise(list2(UnboundError, sym)); + return v; + } + return toplevel_eval(sym); case TOK_LABEL: // create backreference label if (ptrhash_has(&readstate->backrefs, (void*)tokval))