1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-23 13:00:34 +02:00

tweaks to new repl

* module/system/repl/command.scm (read-command): Remove a pk.
* module/system/repl/repl.scm (run-repl): Export. Use % and abort to
  implement the prompt.
This commit is contained in:
Andy Wingo 2010-07-09 18:22:08 +02:00
parent 33df2ec719
commit 3ae78d95e6
2 changed files with 41 additions and 44 deletions

View file

@ -128,7 +128,7 @@
(define (read-command repl)
(catch #t
(lambda () (read (pk (repl-inport repl))))
(lambda () (read (repl-inport repl)))
(lambda (key . args)
(pmatch args
((,subr ,msg ,args . ,rest)

View file

@ -28,7 +28,8 @@
#:use-module (system repl error-handling)
#:use-module (system repl common)
#:use-module (system repl command)
#:export (start-repl))
#:use-module (ice-9 control)
#:export (start-repl run-repl))
@ -89,11 +90,7 @@
(run-repl (make-repl lang debug)))
(define (run-repl repl)
(let ((tag (make-prompt-tag "repl ")))
(call-with-prompt
tag
(lambda ()
(with-fluids ((*repl-stack*
(% (with-fluids ((*repl-stack*
(cons repl (or (fluid-ref *repl-stack*) '()))))
(if (null? (cdr (fluid-ref *repl-stack*)))
(repl-welcome repl))
@ -105,10 +102,10 @@
(catch 'quit
(lambda () (meta-command repl))
(lambda (k . args)
(abort-to-prompt tag args))))
(abort args))))
((eof-object? exp)
(newline)
(abort-to-prompt tag '()))
(abort '()))
(else
;; since the input port is line-buffered, consume up to the
;; newline
@ -127,11 +124,11 @@
(repl-print repl v))
l))))
(lambda (k . args)
(abort-to-prompt tag args)))))))
(abort args)))))))
(next-char #f) ;; consume trailing whitespace
(prompt-loop)))))
(prompt-loop))))
(lambda (k status)
status))))
status)))
(define (next-char wait)
(if (or wait (char-ready?))