blob: ba489e2e826154b7845c915d0ea31a98c8a3bcc5 (
plain) (
tree)
|
|
local chupacabra = require("chupacabra")
-- not a great, but a passable repl
local stack = {}
local function scratch(input)
local output = chupacabra.run(input, {})
table.insert(stack, {input = input, output = output})
end
local function scratch_out()
for i, entry in ipairs(stack) do
print(" input: " .. entry.input)
if type(entry.output) == "table" then
print(" output: " .. chupacabra.table_to_string(entry.output))
else
print(" output: " .. tostring(entry.output))
end
end
end
while true do
io.write("> ")
local input = io.read()
if input == "bye" then
break
end
scratch(input)
scratch_out()
stack = {}
end
|