repl.tsp (420B)
1 (define (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 library 12 (define (repl-simple) 13 (write 'stdout nil "> ") 14 (write 'stdout nil (eval (parse (read))) "\n") 15 (repl-simple))