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