aboutsummaryrefslogtreecommitdiff
path: root/nomsu_decompiler.lua
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-01 17:15:51 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-01 17:17:23 -0800
commit3e89092833a6d407e711fe4ae5f44474ff34cf64 (patch)
tree5ffe2df86f648b604347b59999992d74f71a796c /nomsu_decompiler.lua
parente68eb04d690454428216a0f0f1b11399feeb7dc1 (diff)
Some changes to the error API, a fix for statement block parsing, and
replacing ((foo 1 baz)'s meaning) with $(foo 1 baz).
Diffstat (limited to 'nomsu_decompiler.lua')
-rw-r--r--nomsu_decompiler.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/nomsu_decompiler.lua b/nomsu_decompiler.lua
index bf04f4a..02f2426 100644
--- a/nomsu_decompiler.lua
+++ b/nomsu_decompiler.lua
@@ -506,7 +506,10 @@ tree_to_nomsu = function(tree)
else
nomsu:add("\\")
local interp_nomsu = recurse(bit)
- if not (interp_nomsu:is_multiline()) then
+ if interp_nomsu:is_multiline() then
+ local curr_indent = nomsu:text():match("\n( *)[^\n]*$") or nomsu:text():match("^( *)")
+ interp_nomsu = NomsuCode((interp_nomsu:text():gsub("\n", "\n" .. curr_indent)))
+ else
local space = max_line - nomsu:trailing_line_len()
if bit.type == "Var" then
local next_str = tree[i + 1]
@@ -524,6 +527,8 @@ tree_to_nomsu = function(tree)
interp_nomsu2 = tree_to_nomsu(bit)
end
if #interp_nomsu2:text():lines() > 3 or #interp_nomsu2:text() >= MAX_LINE * GOLDEN_RATIO then
+ local curr_indent = nomsu:text():match("\n( *)[^\n]*$") or nomsu:text():match("^( *)")
+ interp_nomsu2 = NomsuCode((interp_nomsu2:text():gsub("\n", "\n" .. curr_indent)))
interp_nomsu = interp_nomsu2
else
nomsu:add("\n..\\")