summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlexander M Pickering <alex@cogarr.net>2024-12-09 16:44:32 -0600
committerAlexander M Pickering <alex@cogarr.net>2024-12-09 16:44:32 -0600
commit541ef6aaee248626c1a1c6e0db05f5980d09c7a5 (patch)
tree44ff154cb2f33843bb4ded69bdaa2e6461674173 /tools
downloadggj25-541ef6aaee248626c1a1c6e0db05f5980d09c7a5.tar.gz
ggj25-541ef6aaee248626c1a1c6e0db05f5980d09c7a5.tar.bz2
ggj25-541ef6aaee248626c1a1c6e0db05f5980d09c7a5.zip
Inital commit
Diffstat (limited to 'tools')
-rw-r--r--tools/luastr.sh5
-rw-r--r--tools/rewrite.lua31
2 files changed, 36 insertions, 0 deletions
diff --git a/tools/luastr.sh b/tools/luastr.sh
new file mode 100644
index 0000000..5b50c7d
--- /dev/null
+++ b/tools/luastr.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+echo "return [=====["
+echo "$(cat $1)"
+echo "]=====]"
diff --git a/tools/rewrite.lua b/tools/rewrite.lua
new file mode 100644
index 0000000..503a0c8
--- /dev/null
+++ b/tools/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("%s+(.*%.lua):(%d+):(.*)")()
+ if filename and linenum and rest then
+ local moonfilename = filename:gsub(".lua$",".moon")
+
+ --If our file is not moonscript, we won't have a debug file
+ local debugfile, err = io.open(filename .. ".X", "r")
+ if not debugfile then
+ --print("not debugfile" .. filename .. ":" .. err)
+ 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
+ debugfile:close()
+ else
+ print(data)
+ end
+ ::next::
+end
+