aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nomsu_decompiler.lua10
-rw-r--r--nomsu_decompiler.moon11
2 files changed, 10 insertions, 11 deletions
diff --git a/nomsu_decompiler.lua b/nomsu_decompiler.lua
index be71c48..98e93c8 100644
--- a/nomsu_decompiler.lua
+++ b/nomsu_decompiler.lua
@@ -85,7 +85,7 @@ tree_to_inline_nomsu = function(tree)
end
end
if num_args == 1 and num_words == 0 then
- nomsu:append("()")
+ nomsu:add("()")
end
return nomsu
elseif "MethodCall" == _exp_0 then
@@ -432,9 +432,9 @@ tree_to_nomsu = function(tree)
end
if num_args == 1 and num_words == 0 then
if next_space ~= " " then
- nomsu:append(next_space)
+ nomsu:add(next_space)
end
- nomsu:append("()")
+ nomsu:add("()")
end
return nomsu
elseif "MethodCall" == _exp_0 then
@@ -469,7 +469,7 @@ tree_to_nomsu = function(tree)
if i > 1 then
nomsu:add("\n")
if tree[i - 1].type ~= "Comment" then
- needs_space[i] = ((line_nomsu:is_multiline() and prev_line:is_multiline()) or prev_line:text():match("%.%.[^\n]*$"))
+ needs_space[i] = (line_nomsu:is_multiline() and prev_line:is_multiline())
if tree[i].type == "Comment" or needs_space[i] or needs_space[i - 1] then
nomsu:add("\n")
end
@@ -590,7 +590,7 @@ tree_to_nomsu = function(tree)
if i > 1 then
sep = '\n'
end
- item_nomsu = tree_to_nomsu(item)
+ item_nomsu = item.type == "Action" and tree_to_nomsu(item) or recurse(item)
end
end
nomsu:add(sep)
diff --git a/nomsu_decompiler.moon b/nomsu_decompiler.moon
index 090e9b2..5b35b9a 100644
--- a/nomsu_decompiler.moon
+++ b/nomsu_decompiler.moon
@@ -56,7 +56,7 @@ tree_to_inline_nomsu = (tree)->
arg_nomsu\parenthesize!
nomsu\add arg_nomsu
if num_args == 1 and num_words == 0
- nomsu\append "()"
+ nomsu\add "()"
return nomsu
when "MethodCall"
@@ -321,8 +321,8 @@ tree_to_nomsu = (tree)->
if num_args == 1 and num_words == 0
if next_space != " "
- nomsu\append next_space
- nomsu\append "()"
+ nomsu\add next_space
+ nomsu\add "()"
return nomsu
when "MethodCall"
@@ -356,8 +356,7 @@ tree_to_nomsu = (tree)->
-- multi-line non-comments, or if a comment comes after a non-comment,
-- or if the last line starts with ".."
if tree[i-1].type != "Comment"
- needs_space[i] = ((line_nomsu\is_multiline! and prev_line\is_multiline!) or
- prev_line\text!\match("%.%.[^\n]*$"))
+ needs_space[i] = (line_nomsu\is_multiline! and prev_line\is_multiline!)
if tree[i].type == "Comment" or needs_space[i] or needs_space[i-1]
nomsu\add "\n"
nomsu\add line_nomsu
@@ -450,7 +449,7 @@ tree_to_nomsu = (tree)->
item_nomsu = tree_to_inline_nomsu(item)
if nomsu\trailing_line_len! + #item_nomsu\text! > MAX_LINE
sep = '\n' if i > 1
- item_nomsu = tree_to_nomsu(item)
+ item_nomsu = item.type == "Action" and tree_to_nomsu(item) or recurse(item)
nomsu\add sep
nomsu\add item_nomsu
if item_nomsu\is_multiline! or item.type == 'Comment' or item.type == "Block" or