repl.tsp (410B)
1 (def (repl) 2 (print "> ") 3 (let ((expr (parse (read)))) 4 (unless (and (pair? expr) (= (car expr) 'quit)) 5 ; TODO push! ans to stack of outputs 6 (let ((ans (eval expr))) 7 (unless (void? ans) 8 (displayln ans)) 9 (repl))))) 10 11 ;; simple repl, only requires io.c tib 12 (def (repl-simple) 13 (write 'stdout Nil "> ") 14 (write 'stdout Nil (eval (parse (read))) "\n") 15 (repl-simple))