shithub: femtolisp

ref: ee58f398fec62d3096b0e01da51a3969ed37a32d
dir: /mkboot0.lsp/

View raw version
; -*- 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))
(if (not (bound? 'eof-object?)) (set! eof-object? (lambda (x) #f)))

(define update-compiler
   (let ((C ()))
     (with-bindings
       ((eval (lambda (x) (set! C (cons (compile-thunk (expand x)) C)))))
       (begin
         (load "instructions.lsp")
         (load "compiler.lsp")))
     (lambda () (begin
                  (for-each (lambda (x) (x)) (reverse! C))
                  (set! update-compiler (lambda () ()))))))

(define (compile-file inf)
  (update-compiler)
  (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*))