repl: Use exception handling.
* module/mes/repl.mes (repl): Use catch to prevent exit upon error.
This commit is contained in:
parent
cb1fa49767
commit
1f9476aeca
|
@ -159,23 +159,29 @@ along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
|||
(force-output)
|
||||
(let ((sexp (read-env a)))
|
||||
(when (not (eq? sexp '()))
|
||||
(when print-sexp?
|
||||
(display "[sexp=")
|
||||
(display sexp)
|
||||
(display "]")
|
||||
(newline))
|
||||
(cond ((and (pair? sexp) (eq? (car sexp) (string->symbol "unquote")))
|
||||
(let ((r (meta (cadr sexp) a)))
|
||||
(if (pair? r) (loop (append r a))
|
||||
(loop a))))
|
||||
((and (pair? sexp) (eq? (car sexp) 'mes-use-module))
|
||||
(loop (mes-load-module-env (cadr sexp) a)))
|
||||
(else (let ((e (eval sexp a)))
|
||||
(if (eq? e *unspecified*) (loop a)
|
||||
(let ((id (string->symbol (string-append "$" (number->string count)))))
|
||||
(set! count (+ count 1))
|
||||
(display id)
|
||||
(display " = ")
|
||||
(display e)
|
||||
(newline)
|
||||
(loop (acons id e a))))))))))))
|
||||
(catch #t
|
||||
(lambda ()
|
||||
(when print-sexp?
|
||||
(display "[sexp=")
|
||||
(display sexp)
|
||||
(display "]")
|
||||
(newline))
|
||||
(cond ((and (pair? sexp) (eq? (car sexp) (string->symbol "unquote")))
|
||||
(let ((r (meta (cadr sexp) a)))
|
||||
(if (pair? r) (loop (append r a))
|
||||
(loop a))))
|
||||
((and (pair? sexp) (eq? (car sexp) 'mes-use-module))
|
||||
(loop (mes-load-module-env (cadr sexp) a)))
|
||||
(else
|
||||
(let ((e (eval sexp a)))
|
||||
(if (eq? e *unspecified*) (loop a)
|
||||
(let ((id (string->symbol (string-append "$" (number->string count)))))
|
||||
(set! count (+ count 1))
|
||||
(display id)
|
||||
(display " = ")
|
||||
(display e)
|
||||
(newline)
|
||||
(loop (acons id e a))))))))
|
||||
(lambda (key . args)
|
||||
(format (current-error-port) "exception: ~a ~a\n" key args)
|
||||
(loop a))))))))
|
||||
|
|
Loading…
Reference in a new issue