mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-08 21:47:33 +02:00
Added (repl)
This commit is contained in:
parent
38bb2373b6
commit
cf711ffd0f
1 changed files with 43 additions and 3 deletions
|
@ -9,9 +9,49 @@
|
||||||
(define-library (scheme repl)
|
(define-library (scheme repl)
|
||||||
(export
|
(export
|
||||||
interaction-environment
|
interaction-environment
|
||||||
)
|
repl)
|
||||||
(import (scheme eval))
|
(import (scheme base)
|
||||||
|
(scheme eval)
|
||||||
|
(scheme read)
|
||||||
|
(scheme write))
|
||||||
(begin
|
(begin
|
||||||
(define (interaction-environment)
|
(define (interaction-environment)
|
||||||
(setup-environment))
|
(setup-environment))
|
||||||
))
|
(define (repl)
|
||||||
|
(with-handler
|
||||||
|
(lambda (obj)
|
||||||
|
(display "Error: ")
|
||||||
|
(cond
|
||||||
|
((error-object? obj)
|
||||||
|
(display (error-object-message obj))
|
||||||
|
(if (not (null? (error-object-irritants obj)))
|
||||||
|
(display ": "))
|
||||||
|
(for-each
|
||||||
|
(lambda (o)
|
||||||
|
(write o)
|
||||||
|
(display " "))
|
||||||
|
(error-object-irritants obj)))
|
||||||
|
((pair? obj)
|
||||||
|
(when (string? (car obj))
|
||||||
|
(display (car obj))
|
||||||
|
(if (not (null? (cdr obj)))
|
||||||
|
(display ": "))
|
||||||
|
(set! obj (cdr obj)))
|
||||||
|
(for-each
|
||||||
|
(lambda (o)
|
||||||
|
(write o)
|
||||||
|
(display " "))
|
||||||
|
obj))
|
||||||
|
(else
|
||||||
|
(display obj)))
|
||||||
|
(newline)
|
||||||
|
(repl))
|
||||||
|
(display "cyclone> ")
|
||||||
|
(let ((c (eval (read))))
|
||||||
|
(cond
|
||||||
|
((not (eof-object? c))
|
||||||
|
(write c)
|
||||||
|
(newline)
|
||||||
|
(repl))
|
||||||
|
(else
|
||||||
|
(display "\n"))))))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue