diff options
-rw-r--r-- | repl.lua | 17 |
1 files 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 = {} | |||
4 | local eval = require("eval").eval | 4 | local eval = require("eval").eval |
5 | local read = require("read").read | 5 | local read = require("read").read |
6 | 6 | ||
7 | local function schemeprint (x) | ||
8 | if x == true then | ||
9 | print("#t") | ||
10 | elseif x == false then | ||
11 | print("#f") | ||
12 | else | ||
13 | print(x) | ||
14 | end | ||
15 | end | ||
16 | |||
7 | function repl.repl (prompt) | 17 | function repl.repl (prompt) |
8 | if not prompt then prompt = "lam> " end | 18 | if not prompt then prompt = "lam> " end |
9 | io.input():setvbuf("line") | 19 | io.input():setvbuf("line") |
@@ -11,9 +21,10 @@ function repl.repl (prompt) | |||
11 | io.write(prompt) | 21 | io.write(prompt) |
12 | io.output():flush() | 22 | io.output():flush() |
13 | local input = io.read() | 23 | local input = io.read() |
14 | if input == nil then break end | 24 | if input ~= "" then |
15 | local value = eval(read(input)) | 25 | local value = eval(read(input)) |
16 | if value then print(value) end | 26 | if value ~= nil then schemeprint(value) end |
27 | end | ||
17 | until false | 28 | until false |
18 | end | 29 | end |
19 | 30 | ||