forge: improve repl: use readline, better output formatting; join input lines with newline character
This commit is contained in:
parent
3c3e9b15d7
commit
a76f59498c
3 changed files with 12 additions and 6 deletions
|
|
@ -82,13 +82,19 @@
|
|||
|
||||
;;;; code compilation and execution
|
||||
|
||||
(defun input-line (&key prompt)
|
||||
(if (null prompt)
|
||||
(setf prompt (format nil "~a> " (length (stack *forge-env*)))))
|
||||
(rl:readline :prompt prompt))
|
||||
|
||||
(defun repl ()
|
||||
(do ((input (read-line) (read-line)))
|
||||
(do ((input (input-line) (input-line)))
|
||||
((string= input "q") (stack *forge-env*))
|
||||
(handler-bind
|
||||
((end-of-file
|
||||
(lambda (c)
|
||||
(invoke-restart 'iter:try-with-more-input (read-line)))))
|
||||
(invoke-restart 'iter:try-with-more-input
|
||||
(input-line :prompt ".. ")))))
|
||||
(exec-string input))))
|
||||
|
||||
(defun exec-list (lst)
|
||||
|
|
@ -184,8 +190,8 @@
|
|||
(f:reg 'swp #'(lambda () (let ((a (f:popd)) (b (f:popd))) (f:pushd a) (f:pushd b))))
|
||||
(f:reg 'drop #'f:popd)
|
||||
|
||||
(f:reg '? #'(lambda () (format t "~a~%" (f:popd))))
|
||||
(f:reg '?? #'(lambda () (format t "~a~%" (f:stack f:*forge-env*))))
|
||||
(f:reg '? #'(lambda () (format t "~s~%" (f:popd))))
|
||||
(f:reg '?? #'(lambda () (format t "~{~s ~}~%" (f:stack f:*forge-env*))))
|
||||
|
||||
(f:reg1 'ptr #'util:ptr)
|
||||
(f:reg1 'get #'aref)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
:version "0.0.1"
|
||||
:homepage "https://www.cyberconcepts.org"
|
||||
:description "Core packages of the scopes project."
|
||||
:depends-on (:alexandria :cl-dotenv :com.inuoe.jzon
|
||||
:depends-on (:alexandria :cl-dotenv :cl-readline :com.inuoe.jzon
|
||||
:flexi-streams :ironclad :local-time :log4cl
|
||||
:lparallel :qbase64 :serapeum :str)
|
||||
:components ((:file "config" :depends-on ("util/util"))
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@
|
|||
nil)
|
||||
t))
|
||||
(try-with-more-input (more)
|
||||
(setf (data it) (str:join " " (list (data it) more)))
|
||||
(setf (data it) (str:join #\newline (list (data it) more)))
|
||||
(next it))))
|
||||
|
||||
;;;; stream iterator implementation
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue