(module repl mzscheme
(require "reader.ss"
(lib "util.ss" "planet"))
(define prim-eval (current-eval))
(define prim-namespace
(let ((src (current-namespace)))
(parameterize ((current-namespace (make-namespace 'empty)))
(namespace-attach-module src 'mzscheme)
(namespace-require
'mzscheme '(only mzscheme #%app #%top #%datum
quote lambda begin define let if set!
values
null? pair? list? cons car cdr
map list apply append
and > vector? = >= ))
(namespace-require
'(planet "expander.ss" ("dvanhorn" "r6rs-expander-vantonder.plt" 2 5)))
(current-namespace))))
(define library-path
(let-values (((base name must-be-dir?)
(split-path
(resolve-planet-path
'(planet "expander.ss" ("dvanhorn" "r6rs-expander-vantonder.plt" 2 5))))))
(build-path base "lib/")))
(parameterize ((read-curly-brace-as-paren #f) (read-accept-box #f)
(read-accept-compiled #f)
(read-accept-graph #f)
(read-accept-dot #t)
(read-accept-infix-dot #f)
(read-accept-quasiquote #t)
(read-accept-reader #f)
(current-readtable readtable) (current-prompt-read
(λ () (printf "R6RS> ")
(let ((x (read)))
(if (mzprim? x)
(namespace-require (mzprim-quoted-require x))
x))))
(current-eval
(λ (x)
(parameterize ((current-eval prim-eval)
(current-namespace prim-namespace))
(eval `(ex:repl '(,(if (and (pair? x)
(eq? '#%top-interaction (car x)))
(cdr x)
x))))))))
(parameterize ((current-directory library-path)
(current-load
(λ (path expected-module-name)
(let ((p (open-input-file path)))
(let loop ((x (read p)))
(cond
((eof-object? x) (close-input-port p) (values))
(else (eval x) (loop (read p)))))))))
(for-each load (list
"core.ss"
"core/define-values.ss"
"core/vector-types.ss"
"rnrs/eval.ss"
"rnrs/io/simple.ss"
"rnrs/unicode.ss"
"rnrs/eval.ss"
"rnrs/control.ss"
"rnrs/base.ss"
"rnrs/lists.ss" "rnrs/r5rs.ss" "rnrs.ss"
"rnrs/records/private/core.ss" "rnrs/records/procedural.ss" "rnrs/records/inspection.ss"
"rnrs/arithmetic/bitwise.ss"
"rnrs/composite.ss"
"ubik/define-values.ss" "slib/record.ss" "srfi/n9.ss" "srfi/n26.ss" "srfi/n42.ss" "srfi/n60.ss" "srfi/n63.ss" "srfi/n66.ss" "srfi/n69.ss" "srfi/n74.ss" "srfi/n78.ss" "srfi/n95.ss" "rnrs/sorting.ss" "srfi/n42/tests.ss"
"ubik/explicit-renaming.ss" "ubik/include.ss"
))
(read-eval-print-loop)))
(newline)
(exit)
)