CTRL-C while in the repl now throws back into the repl no matter

where an exception occurs.
This commit is contained in:
Abdulaziz Ghuloum 2008-12-08 02:13:40 -05:00
parent 75d2756bd2
commit 6041597a27
2 changed files with 61 additions and 53 deletions

View File

@ -62,60 +62,57 @@ description:
(reset-input-port! (console-input-port)) (reset-input-port! (console-input-port))
(k)) (k))
(define wait (define wait1
(lambda (eval-proc escape-k) (lambda (eval-proc k escape-k)
(call/cc (display-prompt 0)
(lambda (k) (let ([x (with-exception-handler
(display-prompt 0) (lambda (ex)
(let ([x (with-exception-handler (cond
(lambda (ex) [(lexical-violation? ex)
(cond (print-ex ex)
[(lexical-violation? ex) (reset k)]
(print-ex ex) [(interrupted-condition? ex)
(reset k)] (flush-output-port (console-output-port))
[(interrupted-condition? ex) (newline (console-output-port))
(flush-output-port (console-output-port)) (reset k)]
(newline (console-output-port)) [else (raise-continuable ex)]))
(reset k)] (lambda ()
[else (raise-continuable ex)])) (read (console-input-port))))])
(lambda () (cond
(read (console-input-port))))]) [(eof-object? x)
(cond (newline (console-output-port))
[(eof-object? x) (escape-k (void))]
(newline (console-output-port)) [else
(escape-k (void))] (call-with-values
[else (lambda ()
(call-with-values (with-exception-handler
(lambda () (lambda (ex)
(if (non-continuable-violation? ex)
(reset k)
(raise-continuable ex)))
(lambda ()
(with-exception-handler (with-exception-handler
(lambda (ex) (lambda (ex)
(if (non-continuable-violation? ex) (print-ex ex)
(reset k) (when (serious-condition? ex)
(raise-continuable ex))) (reset k)))
(lambda () (lambda ()
(with-exception-handler (eval-proc x))))))
(lambda (ex) (lambda v*
(print-ex ex) (unless (andmap (lambda (v) (eq? v (void))) v*)
(when (serious-condition? ex) (with-exception-handler
(reset k))) (lambda (ex)
(lambda () (cond
(eval-proc x)))))) [(interrupted-condition? ex)
(lambda v* (flush-output-port (console-output-port))
(unless (andmap (lambda (v) (eq? v (void))) v*) (newline (console-output-port))
(with-exception-handler (reset k)]
(lambda (ex) [else (raise-continuable ex)]))
(cond (lambda ()
[(interrupted-condition? ex) (for-each
(flush-output-port (console-output-port)) (lambda (v)
(newline (console-output-port)) (pretty-print v (console-output-port)))
(reset k)] v*))))))]))))
[else (raise-continuable ex)]))
(lambda ()
(for-each
(lambda (v)
(pretty-print v (console-output-port)))
v*))))))]))))
(wait eval-proc escape-k)))
(define do-new-cafe (define do-new-cafe
(lambda (eval-proc) (lambda (eval-proc)
@ -124,7 +121,18 @@ description:
(lambda () (lambda ()
(call/cc (call/cc
(lambda (k) (lambda (k)
(wait eval-proc k)))) (let loop ()
(call/cc
(lambda (k1)
(with-exception-handler
(lambda (ex)
(with-exception-handler k1
(lambda ()
(flush-output-port (console-output-port))
(newline (console-output-port))
(reset k1))))
(lambda () (wait1 eval-proc k1 k)))))
(loop)))))
(lambda () (set! eval-depth (fxsub1 eval-depth)))))) (lambda () (set! eval-depth (fxsub1 eval-depth))))))
(define default-cafe-eval (define default-cafe-eval

View File

@ -1 +1 @@
1702 1703