diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-01-27 16:39:56 -0800 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-01-27 16:40:29 -0800 |
| commit | 855fe23439bbcf3b1cb8a8798d055cb30fb610c1 (patch) | |
| tree | 1e03fecf3ad173643eed36252d9b846908681b4b | |
| parent | 90c56d31352a0eeccd382ef5921baf3af4971040 (diff) | |
Tweaked code to not rely on moonscript.
| -rw-r--r-- | nomsu.lua | 12 | ||||
| -rwxr-xr-x | nomsu.moon | 5 |
2 files changed, 12 insertions, 5 deletions
@@ -1563,8 +1563,14 @@ if arg then err_hand = function(error_message) print(tostring(colored.red("ERROR:")) .. " " .. tostring(colored.bright(colored.yellow(colored.onred((error_message or "")))))) print("stack traceback:") - local to_lua - to_lua = require("moonscript.base").to_lua + local ok, to_lua = pcall(function() + return require('moonscript.base').to_lua + end) + if not ok then + to_lua = function() + return nil + end + end local nomsu_file = io.open("nomsu.moon") local nomsu_source = nomsu_file:read("*a") local _, line_table = to_lua(nomsu_source) @@ -1611,7 +1617,7 @@ if arg then if calling_fn.istailcall and not name then name = "<tail call>" end - if calling_fn.short_src == "./nomsu.moon" then + if calling_fn.short_src == "./nomsu.moon" and line_table then local char = line_table[calling_fn.currentline] local line_num = 1 for _ in nomsu_source:sub(1, char):gmatch("\n") do @@ -1006,7 +1006,8 @@ if arg -- TODO: properly print out the calling site of nomsu code, not just the *called* code - import to_lua from require "moonscript.base" + ok, to_lua = pcall -> require('moonscript.base').to_lua + if not ok then to_lua = -> nil nomsu_file = io.open("nomsu.moon") nomsu_source = nomsu_file\read("*a") _, line_table = to_lua(nomsu_source) @@ -1038,7 +1039,7 @@ if arg else if calling_fn.istailcall and not name name = "<tail call>" - if calling_fn.short_src == "./nomsu.moon" + if calling_fn.short_src == "./nomsu.moon" and line_table char = line_table[calling_fn.currentline] line_num = 1 for _ in nomsu_source\sub(1,char)\gmatch("\n") do line_num += 1 |
