shithub: femtolisp

ref: 22ae0e366f8678ac2df9104ba37c2e2ab9c0190d
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? (λ (x) #f)))

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

(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)))

(define (do-boot0)
  (for-each (λ (file)
              (compile-file file))
              (cdr *argv*)))

(update-compiler)
(do-boot0)