; repl.neb ; by mryouse ; ; a REPL for neb, written in neb (def _history_ (list)) (func history () _history_) (func !! () (def cmd (first (list-reverse (history)))) (print (->string cmd)) (eval (parse-neb cmd))) (func save-repl (filename :string) (def fil (open-write filename)) (write (concat (join (history) "\n") "\n") fil) (close fil)) (func prompt (nxt) (concat "#" (->string nxt) "> ")) (func repl () (print "### neb :)(: IN NEB!") (print "version: < 0") (def next-cmd-num 1) (func evaluate-cmd (cmd) (def evaluated (parse-neb cmd)) (print (concat "=> " (->string evaluated))) (redef next-cmd-num (+ 1 next-cmd-num)) (redef _history_ (append _history_ cmd))) ; this is the actual loop part (while #true (def this-cmd (strip (read-line (prompt next-cmd-num)))) (if (not (eq? "" this-cmd)) (try (evaluate-cmd this-cmd) (print (concat "panic! " _panic_)))))) (repl)