From 7f5993dc2c4d074fb273673a7ad5fe6151dc7acb Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sat, 23 Mar 2024 15:51:44 -0500 Subject: Improve repl --- repl.lua | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/repl.lua b/repl.lua index 34e4c94..b198880 100644 --- a/repl.lua +++ b/repl.lua @@ -4,6 +4,16 @@ local repl = {} local eval = require("eval").eval local read = require("read").read +local function schemeprint (x) + if x == true then + print("#t") + elseif x == false then + print("#f") + else + print(x) + end +end + function repl.repl (prompt) if not prompt then prompt = "lam> " end io.input():setvbuf("line") @@ -11,9 +21,10 @@ function repl.repl (prompt) io.write(prompt) io.output():flush() local input = io.read() - if input == nil then break end - local value = eval(read(input)) - if value then print(value) end + if input ~= "" then + local value = eval(read(input)) + if value ~= nil then schemeprint(value) end + end until false end -- cgit 1.4.1-21-gabe81