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