about summary refs log tree commit diff stats
path: root/repl.lua
diff options
context:
space:
mode:
Diffstat (limited to 'repl.lua')
-rw-r--r--repl.lua42
1 files changed, 0 insertions, 42 deletions
diff --git a/repl.lua b/repl.lua deleted file mode 100644 index a89fd2c..0000000 --- a/repl.lua +++ /dev/null
@@ -1,42 +0,0 @@
1--- lam.repl
2
3local repl = {}
4local eval = require "eval"
5local read = require "read"
6local util = require "util"
7table.unpack = table.unpack or unpack
8
9function schemestr(x)
10 if type(x) == "table" then
11 local ts = "(" .. schemestr(util.pop(x))
12 for i,v in ipairs(x) do
13 ts = string.format("%s %s", ts, schemestr(v))
14 end
15 ts = ts .. ")"
16 return ts
17 elseif x == true then
18 return "#t"
19 elseif x == false then
20 return "#f"
21 else
22 return tostring(x)
23 end
24end
25
26function repl.repl (prompt)
27 prompt = prompt or "lam> "
28 repeat
29 io.write(prompt)
30 io.output():flush()
31 input = io.read()
32 if input == ",q" or input == ",quit" then
33 break
34 else
35 val = eval(read(input))
36 if val then print(schemestr(val)) end
37 end
38 until false
39end
40
41---
42return repl