aboutsummaryrefslogtreecommitdiff
path: root/rewrite.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alex@cogarr.net>2020-02-02 08:11:08 -0500
committerAlexander Pickering <alex@cogarr.net>2020-02-02 08:11:08 -0500
commit57701059b1b65fc08366318e92d32d9dd7094d25 (patch)
treea569db68d27982d83fead3cc9c8192056c49509f /rewrite.lua
downloaddrydock-57701059b1b65fc08366318e92d32d9dd7094d25.tar.gz
drydock-57701059b1b65fc08366318e92d32d9dd7094d25.tar.bz2
drydock-57701059b1b65fc08366318e92d32d9dd7094d25.zip
inital commit
Diffstat (limited to 'rewrite.lua')
-rw-r--r--rewrite.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/rewrite.lua b/rewrite.lua
new file mode 100644
index 0000000..f33c12c
--- /dev/null
+++ b/rewrite.lua
@@ -0,0 +1,30 @@
+--[[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(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
+