use readline in repl
This commit is contained in:
parent
029d98338d
commit
ac15ac6e2d
|
@ -2,14 +2,16 @@
|
|||
(import (scheme base)
|
||||
(scheme read)
|
||||
(scheme write)
|
||||
(scheme eval))
|
||||
(scheme eval)
|
||||
(picrin readline)
|
||||
(picrin readline history))
|
||||
|
||||
(define (repl)
|
||||
(display "> ")
|
||||
(let ((expr (read)))
|
||||
(if (eof-object? expr)
|
||||
(let ((line (readline "> ")))
|
||||
(if (eof-object? line)
|
||||
(newline) ; exit
|
||||
(begin
|
||||
(add-history line)
|
||||
(call/cc
|
||||
(lambda (exit)
|
||||
(with-exception-handler
|
||||
|
@ -18,8 +20,13 @@
|
|||
(newline)
|
||||
(exit))
|
||||
(lambda ()
|
||||
(write (eval expr '(picrin user)))
|
||||
(newline)))))
|
||||
(let ((port (open-input-string line)))
|
||||
(let loop ((expr (read port)))
|
||||
(unless (eof-object? expr)
|
||||
(write (eval expr '(picrin user)))
|
||||
(newline)
|
||||
(loop (read port))))
|
||||
(close-port port))))))
|
||||
(repl)))))
|
||||
|
||||
(export repl))
|
||||
|
|
|
@ -118,7 +118,8 @@ pic_init_core(pic_state *pic)
|
|||
pic_init_eval(pic); DONE;
|
||||
pic_init_lib(pic); DONE;
|
||||
|
||||
pic_load_piclib(pic); DONE;
|
||||
pic_init_contrib(pic); DONE;
|
||||
|
||||
pic_load_piclib(pic); DONE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue