Add history and ok/err functionality to REPL.
This commit is contained in:
parent
f3a69989fa
commit
8d22bf575c
|
@ -1,20 +1,34 @@
|
||||||
#!/usr/bin/pl
|
#!/usr/bin/pl
|
||||||
|
(def _history ())
|
||||||
|
(def __history (fn (_h) (
|
||||||
|
(prnl (at 0 _h))
|
||||||
|
(if (> (len _h) 0) (
|
||||||
|
(__history (rest _h))
|
||||||
|
) ())
|
||||||
|
)))
|
||||||
|
|
||||||
|
(def history (fn () (__history _history)))
|
||||||
|
|
||||||
(def repl (fn () (
|
(def repl (fn () (
|
||||||
(prn "pebblisp::> ")
|
(prn "pebblisp::> ")
|
||||||
|
|
||||||
(def input (inp))
|
(def input (inp))
|
||||||
|
|
||||||
(if (= input "q") () (
|
(if (= input "q") () (
|
||||||
|
(def _history (ap _history input))
|
||||||
;(switch input (
|
;(switch input (
|
||||||
; ("clear" (fn () (sys "clear")))
|
; ("clear" (sys "clear"))
|
||||||
;))
|
;))
|
||||||
|
|
||||||
(if (= input "") () (
|
(if (= input "") () (
|
||||||
(if (= input "clear") (sys "clear") (
|
(if (= input "clear") (sys "clear") (
|
||||||
(def ret (eval input))
|
(def ret (eval input))
|
||||||
(if (iserr ret) (prn "[31m[1mX => ") (prn "[1mOk =>[0m "))
|
(if (iserr ret)
|
||||||
|
(prn "[31m[1mX => ")
|
||||||
|
(prn "[1mOk =>[0m "))
|
||||||
(prnl ret)
|
(prnl ret)
|
||||||
(prn "[0m")))))
|
(prnl "[0m"))))
|
||||||
(repl)
|
)
|
||||||
))
|
(repl))))))
|
||||||
)))
|
|
||||||
|
|
||||||
(repl)
|
(repl)
|
||||||
|
|
Loading…
Reference in New Issue