aboutsummaryrefslogtreecommitdiff
path: root/rewrite.lua
diff options
context:
space:
mode:
authorAlexander M Pickering <alex@cogarr.net>2024-01-29 16:20:10 -0600
committerAlexander M Pickering <alex@cogarr.net>2024-01-29 16:20:10 -0600
commitc2926c5ec74d7e37da395c8c32a7ff2b4cae7d06 (patch)
treeac2bb208dab1274cdc5e9059ffe014ae19181a4c /rewrite.lua
downloadfools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.tar.gz
fools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.tar.bz2
fools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.zip
All the files
Diffstat (limited to 'rewrite.lua')
-rw-r--r--rewrite.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/rewrite.lua b/rewrite.lua
new file mode 100644
index 0000000..f132993
--- /dev/null
+++ b/rewrite.lua
@@ -0,0 +1,31 @@
+--[[Script to rewrite a stack traceback in terms of moonscript instead of lua]]
+
+for data in io.lines() do
+ local filename, linenum, rest = data:gmatch("(.*%.lua):(%d+):(.*)")()
+ if filename and linenum and rest then
+ local _,_,stripped_filename = filename:find("(%S+)")
+ local moonfilename = filename:gsub(".lua$",".moon")
+
+ --If our file is not moonscript, we won't have a debug file
+ local debugfile = io.open("debug/" .. stripped_filename.. ".X")
+ if not debugfile then
+ print("not debugfile")
+ print(data)
+ goto next
+ end
+
+ --Skip first line
+ debugfile:read("*l")
+ for line in debugfile:lines() do
+ _,_,pos,lua,moon = line:find("(%d+)%s+(%d+):%b[] >> (%d+)")
+ if tonumber(linenum) == tonumber(lua) then
+ print(string.format("\t%s:%d: %s",moonfilename,moon,rest))
+ goto next
+ end
+ end
+ else
+ print(data)
+ end
+ ::next::
+end
+