[repl] support multiple line input
This commit is contained in:
parent
9fefa80466
commit
a290bb0b04
|
@ -23,30 +23,34 @@
|
||||||
(define-readline)
|
(define-readline)
|
||||||
|
|
||||||
(define (repl)
|
(define (repl)
|
||||||
(let ((line (readline "> ")))
|
(let loop ((buf ""))
|
||||||
(if (eof-object? line)
|
(let ((line (readline (if (equal? buf "") "> " "* "))))
|
||||||
(newline) ; exit
|
(if (eof-object? line)
|
||||||
(begin
|
(newline) ; exit
|
||||||
(add-history line)
|
(let ((str (string-append buf line "\n")))
|
||||||
(call/cc
|
(add-history line)
|
||||||
(lambda (exit)
|
(call/cc
|
||||||
(with-exception-handler
|
(lambda (exit)
|
||||||
(lambda (condition)
|
(with-exception-handler
|
||||||
(display (error-object-message condition) (current-error-port))
|
(lambda (condition)
|
||||||
(newline)
|
(unless (equal? (error-object-message condition) "unexpected EOF")
|
||||||
(exit))
|
(display (error-object-message condition) (current-error-port))
|
||||||
(lambda ()
|
(newline)
|
||||||
;; FIXME
|
(set! str ""))
|
||||||
;; non-local exception jump from inside call-with-port
|
(exit))
|
||||||
;; fails with segv, though i don't know why...
|
(lambda ()
|
||||||
(let ((port (open-input-string line)))
|
;; FIXME
|
||||||
(let loop ((expr (read port)))
|
;; non-local exception jump from inside call-with-port
|
||||||
(unless (eof-object? expr)
|
;; fails with segv, though i don't know why...
|
||||||
(write (eval expr '(picrin user)))
|
(let ((port (open-input-string str)))
|
||||||
(newline)
|
(let next ((expr (read port)))
|
||||||
(loop (read port))))
|
(unless (eof-object? expr)
|
||||||
(close-port port))))))
|
(write (eval expr '(picrin user)))
|
||||||
(repl)))))
|
(newline)
|
||||||
|
(set! str "")
|
||||||
|
(next (read port))))
|
||||||
|
(close-port port))))))
|
||||||
|
(loop str))))))
|
||||||
|
|
||||||
(export repl))
|
(export repl))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue