blob: abd555d39aa80e4eb0179b959aa2059e5d7ea5ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/usr/bin/env lua
local readline = require('readline')
local utils = require('utils')
local reader = require('reader')
local printer = require('printer')
-- read
function READ(str)
return reader.read_str(str)
end
-- eval
function EVAL(ast, env)
return ast
end
-- print
function PRINT(exp)
return printer._pr_str(exp, true)
end
-- repl
function rep(str)
return PRINT(EVAL(READ(str),""))
end
while true do
line = readline.readline("user> ")
if not line then break end
xpcall(function()
print(rep(line))
end, function(exc)
if exc then
if types._malexception_Q(exc) then
exc = printer._pr_str(exc.val, true)
end
print("Error: " .. exc)
print(debug.traceback())
end
end)
end
|