aboutsummaryrefslogtreecommitdiff
path: root/nomsu.lua
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-06-19 15:24:24 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-06-19 15:24:39 -0700
commitc1cec2ac8487bf7486b1ab85d24252d6658b3dfc (patch)
treee81ad65b5c6441141a430edb32935b341d838795 /nomsu.lua
parent7deed5af411689f198ebec5338476a563cb7ef28 (diff)
Tidying up error handling and REPL.
Diffstat (limited to 'nomsu.lua')
-rw-r--r--nomsu.lua13
1 files changed, 7 insertions, 6 deletions
diff --git a/nomsu.lua b/nomsu.lua
index 0b26ac0..ca0f7ac 100644
--- a/nomsu.lua
+++ b/nomsu.lua
@@ -15,7 +15,7 @@ OPTIONS
]=]
local lpeg = require('lpeg')
local re = require('re')
-local run_safely = require("error_handling")
+local Errhand = require("error_handling")
local NomsuCompiler = require("nomsu_compiler")
local NomsuCode, LuaCode, Source
do
@@ -173,16 +173,17 @@ run = function()
break
end
buff = table.concat(buff)
- FILE_CACHE["REPL#" .. repl_line] = buff
+ local pseudo_filename = "user input #" .. repl_line
+ FILE_CACHE[pseudo_filename] = buff
local err_hand
err_hand = function(error_message)
- return print_err_msg(error_message)
+ return Errhand.print_error(error_message)
end
- local ok, ret = xpcall(nomsu.run, err_hand, nomsu, buff, Source("REPL#" .. repl_line, 1, #buff))
+ local ok, ret = xpcall(nomsu.run, err_hand, nomsu, buff, Source(pseudo_filename, 1, #buff))
if ok and ret ~= nil then
print("= " .. repr(ret))
elseif not ok then
- print_err_msg(ret)
+ Errhand.print_error(ret)
end
end
end
@@ -191,5 +192,5 @@ local has_ldt, ldt = pcall(require, 'ldt')
if has_ldt then
return ldt.guard(run)
else
- return run_safely(run)
+ return Errhand.run_safely(run)
end