aboutsummaryrefslogtreecommitdiff
path: root/nomsu_decompiler.moon
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-14 16:29:38 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-14 16:30:12 -0800
commit5eb1b276adef1ec0755f170380f5b67bb465cee2 (patch)
tree09f043f01345e07daef73c98806424f89acbe306 /nomsu_decompiler.moon
parentc1c32688a4afc43f6addb99b8b5fa878944a70e3 (diff)
Fixed some bugs with append/add discrepancy, misguided ".." matching for
needs_space, and list items getting falsely forced into indented form.
Diffstat (limited to 'nomsu_decompiler.moon')
-rw-r--r--nomsu_decompiler.moon11
1 files changed, 5 insertions, 6 deletions
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