aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-11-12 14:08:42 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-11-12 14:08:55 -0800
commit367cfa19dbab1eb436cfd92342ab5f3af4db8508 (patch)
treedf69c22ce87748363de04eaf1d2fd22db2babb8b
parenta84242b849e27147bcad8aabe04fc4bbe45d7fca (diff)
Fix for codegen of Set-style dicts.
-rw-r--r--nomsu_decompiler.lua13
-rw-r--r--nomsu_decompiler.moon12
2 files changed, 13 insertions, 12 deletions
diff --git a/nomsu_decompiler.lua b/nomsu_decompiler.lua
index 9dd2316..46316d1 100644
--- a/nomsu_decompiler.lua
+++ b/nomsu_decompiler.lua
@@ -149,9 +149,8 @@ tree_to_inline_nomsu = function(tree)
if key.type == "Action" or key.type == "Block" then
nomsu:parenthesize()
end
- assert(value.type ~= "Block", "Didn't expect to find a Block as a value in a dict")
- nomsu:append(": ")
if value then
+ nomsu:append(": ")
local value_nomsu = tree_to_inline_nomsu(value)
if value.type == "Block" then
value_nomsu:parenthesize()
@@ -442,11 +441,13 @@ tree_to_nomsu = function(tree)
if key.type == "Block" then
nomsu:parenthesize()
end
- local value_nomsu = tree_to_nomsu(value)
- if (value.type == "Block" or value.type == "EscapedNomsu") and not value_nomsu:is_multiline() then
- value_nomsu:parenthesize()
+ if value then
+ local value_nomsu = tree_to_nomsu(value)
+ if (value.type == "Block" or value.type == "EscapedNomsu") and not value_nomsu:is_multiline() then
+ value_nomsu:parenthesize()
+ end
+ nomsu:append(": ", value_nomsu)
end
- nomsu:append(": ", value_nomsu)
return nomsu
elseif "Comment" == _exp_0 then
nomsu:append("#", (tree[1]:gsub("\n", "\n ")))
diff --git a/nomsu_decompiler.moon b/nomsu_decompiler.moon
index 918779e..5b6c89e 100644
--- a/nomsu_decompiler.moon
+++ b/nomsu_decompiler.moon
@@ -107,9 +107,8 @@ tree_to_inline_nomsu = (tree)->
NomsuCode\from(key.source, key[1])
else tree_to_inline_nomsu(key)
nomsu\parenthesize! if key.type == "Action" or key.type == "Block"
- assert(value.type != "Block", "Didn't expect to find a Block as a value in a dict")
- nomsu\append ": "
if value
+ nomsu\append ": "
value_nomsu = tree_to_inline_nomsu(value)
value_nomsu\parenthesize! if value.type == "Block"
nomsu\append value_nomsu
@@ -345,10 +344,11 @@ tree_to_nomsu = (tree)->
NomsuCode\from(key.source, key[1])
else tree_to_inline_nomsu(key)
nomsu\parenthesize! if key.type == "Block"
- value_nomsu = tree_to_nomsu(value)
- if (value.type == "Block" or value.type == "EscapedNomsu") and not value_nomsu\is_multiline!
- value_nomsu\parenthesize!
- nomsu\append ": ", value_nomsu
+ if value
+ value_nomsu = tree_to_nomsu(value)
+ if (value.type == "Block" or value.type == "EscapedNomsu") and not value_nomsu\is_multiline!
+ value_nomsu\parenthesize!
+ nomsu\append ": ", value_nomsu
return nomsu
when "Comment"