diff options
Diffstat (limited to 'repl.lua')
-rw-r--r-- | repl.lua | 42 |
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 | |||
3 | local repl = {} | ||
4 | local eval = require "eval" | ||
5 | local read = require "read" | ||
6 | local util = require "util" | ||
7 | table.unpack = table.unpack or unpack | ||
8 | |||
9 | function 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 | ||
24 | end | ||
25 | |||
26 | function 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 | ||
39 | end | ||
40 | |||
41 | --- | ||
42 | return repl | ||