mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
By recreating a fresh global environment after all imports have been processed, and passing this to eval, all modules loaded by icyc are available to eval.
52 lines
1.1 KiB
Scheme
52 lines
1.1 KiB
Scheme
;; Cyclone Scheme
|
|
;; Copyright (c) 2014, Justin Ethier
|
|
;; All rights reserved.
|
|
;;
|
|
;; This module contains a simple Read-Eval-Print Loop
|
|
;;
|
|
(import (scheme cyclone common)
|
|
(scheme base)
|
|
(scheme char)
|
|
(scheme load)
|
|
(scheme read)
|
|
(scheme write)
|
|
(scheme eval))
|
|
(cond-expand
|
|
(cyclone
|
|
(display *Cyc-version-banner*))
|
|
(else #f))
|
|
|
|
(define *icyc-env* (setup-environment))
|
|
(define (repl:next-line)
|
|
(call/cc
|
|
(lambda (k)
|
|
(with-exception-handler
|
|
(lambda (obj)
|
|
(display "Error: ")
|
|
(cond
|
|
((pair? obj)
|
|
(for-each
|
|
(lambda (o)
|
|
(display o)
|
|
(display " "))
|
|
obj))
|
|
(else
|
|
(display obj)))
|
|
(display "\n")
|
|
(k #t))
|
|
(lambda ()
|
|
(repl)))))
|
|
(repl:next-line))
|
|
|
|
(define (repl)
|
|
(display "cyclone> ")
|
|
(let ((c (eval (read) *icyc-env*)))
|
|
(cond
|
|
((not (eof-object? c))
|
|
(write c)
|
|
(repl:next-line))
|
|
(else
|
|
(display "\n")
|
|
(exit 0)))))
|
|
|
|
(repl:next-line)
|