aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nomsu_decompiler.lua20
-rw-r--r--nomsu_decompiler.moon11
2 files changed, 17 insertions, 14 deletions
diff --git a/nomsu_decompiler.lua b/nomsu_decompiler.lua
index b6cb659..17ac7eb 100644
--- a/nomsu_decompiler.lua
+++ b/nomsu_decompiler.lua
@@ -281,16 +281,18 @@ tree_to_nomsu = function(tree)
end
for i, bit in ipairs(tree) do
if type(bit) == "string" then
- local clump_words
- if type(tree[i - 1]) == 'string' then
- clump_words = is_operator(bit) ~= is_operator(tree[i - 1])
- else
- clump_words = bit == "'"
- end
- if i > 1 and not clump_words then
- nomsu:append(" ")
+ if next_space == " " then
+ local clump_words
+ if type(tree[i - 1]) == 'string' then
+ clump_words = is_operator(bit) ~= is_operator(tree[i - 1])
+ else
+ clump_words = bit == "'"
+ end
+ if clump_words then
+ next_space = ""
+ end
end
- nomsu:append(bit)
+ nomsu:append(next_space, bit)
next_space = nomsu:trailing_line_len() > MAX_LINE and " \\\n.." or " "
else
local bit_nomsu = recurse(bit)
diff --git a/nomsu_decompiler.moon b/nomsu_decompiler.moon
index 69d9d76..474d61f 100644
--- a/nomsu_decompiler.moon
+++ b/nomsu_decompiler.moon
@@ -209,11 +209,12 @@ tree_to_nomsu = (tree)->
for i,bit in ipairs tree
if type(bit) == "string"
- clump_words = if type(tree[i-1]) == 'string'
- is_operator(bit) != is_operator(tree[i-1])
- else bit == "'"
- nomsu\append " " if i > 1 and not clump_words
- nomsu\append bit
+ if next_space == " "
+ clump_words = if type(tree[i-1]) == 'string'
+ is_operator(bit) != is_operator(tree[i-1])
+ else bit == "'"
+ next_space = "" if clump_words
+ nomsu\append next_space, bit
next_space = nomsu\trailing_line_len! > MAX_LINE and " \\\n.." or " "
else
bit_nomsu = recurse(bit)