diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-12-14 20:16:18 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-12-14 20:16:45 -0800 |
| commit | 6abec65843f0f37f7fc6032ac5db0fff3db71815 (patch) | |
| tree | 8a1525b54a6920c1a237b37b52f2b48aed7d7a76 | |
| parent | 64ba8aee074ea415b1a02715af2ec7ae99f3f37d (diff) | |
Fix for "\($x)abc" getting codegen'd to "$xabc"
| -rw-r--r-- | nomsu_decompiler.lua | 6 | ||||
| -rw-r--r-- | nomsu_decompiler.moon | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/nomsu_decompiler.lua b/nomsu_decompiler.lua index 2fe484a..1d445c9 100644 --- a/nomsu_decompiler.lua +++ b/nomsu_decompiler.lua @@ -424,7 +424,11 @@ tree_to_nomsu = function(tree) local interp_nomsu = recurse(bit) if not (interp_nomsu:is_multiline()) then if bit.type == "Var" then - if type(tree[i + 1]) == 'string' and not match(tree[i + 1], "^[ \n\t,.:;#(){}[%]]") then + local next_str = tree[i + 1] + while type(next_str) == 'table' and next_str.type == 'Text' do + next_str = next_str[1] + end + if type(next_str) == 'string' and not match(next_str, "^[ \n\t,.:;#(){}[%]]") then interp_nomsu:parenthesize() end elseif bit.type == "EscapedNomsu" or bit.type == "Block" or bit.type == "IndexChain" then diff --git a/nomsu_decompiler.moon b/nomsu_decompiler.moon index 8c559b1..9cb9ae8 100644 --- a/nomsu_decompiler.moon +++ b/nomsu_decompiler.moon @@ -333,7 +333,10 @@ tree_to_nomsu = (tree)-> interp_nomsu = recurse(bit) unless interp_nomsu\is_multiline! if bit.type == "Var" - if type(tree[i+1]) == 'string' and not match(tree[i+1], "^[ \n\t,.:;#(){}[%]]") + next_str = tree[i+1] + while type(next_str) == 'table' and next_str.type == 'Text' + next_str = next_str[1] + if type(next_str) == 'string' and not match(next_str, "^[ \n\t,.:;#(){}[%]]") interp_nomsu\parenthesize! elseif bit.type == "EscapedNomsu" or bit.type == "Block" or bit.type == "IndexChain" interp_nomsu\parenthesize! |
