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.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/repl.lua b/repl.lua new file mode 100644 index 0000000..34e4c94 --- /dev/null +++ b/repl.lua
@@ -0,0 +1,21 @@
1--- lam.repl
2
3local repl = {}
4local eval = require("eval").eval
5local read = require("read").read
6
7function repl.repl (prompt)
8 if not prompt then prompt = "lam> " end
9 io.input():setvbuf("line")
10 repeat
11 io.write(prompt)
12 io.output():flush()
13 local input = io.read()
14 if input == nil then break end
15 local value = eval(read(input))
16 if value then print(value) end
17 until false
18end
19
20---
21return repl