#lang scheme/base

;; Minimalistic REPL for a string evaluator like 'forth-command.

(require
 scheme/control  ;; for 'prompt so errors don't kill the REPL
 readline/rep)   ;; readline command line editing

(provide repl)

(define (repl command)
  (printf "Press ctrl-D to quit.\n")
  (file-stream-buffer-mode (current-output-port) 'none)
  (let loop ()
    (command "OK") ;; prints OK if there's a connection
    (let ((cmd (read-line)))
      (unless (eof-object? cmd)
        (prompt (command cmd))
        (loop))))
  (printf "Dada.\n"))


