aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nomsu_compiler.lua14
-rw-r--r--nomsu_compiler.moon13
2 files changed, 25 insertions, 2 deletions
diff --git a/nomsu_compiler.lua b/nomsu_compiler.lua
index a53de1a..7d02458 100644
--- a/nomsu_compiler.lua
+++ b/nomsu_compiler.lua
@@ -1059,7 +1059,19 @@ do
local pos, next_space = tree.source.start, ''
local nomsu = NomsuCode(tree.source, pop_comments(pos))
if tree.target then
- nomsu:append(self:tree_to_nomsu(tree.target), "::")
+ if tree.target.type == "Block" then
+ nomsu:append(recurse(tree.target, #nomsu:match('[^\n]*$')))
+ pos = tree.target.source.stop
+ next_space = inline and "::" or "\n..::"
+ else
+ local target_nomsu = recurse(tree.target, #nomsu:match('[^\n]*$'))
+ if tree.target.type == "Action" and not target_nomsu:is_multiline() then
+ target_nomsu:parenthesize()
+ end
+ nomsu:append(target_nomsu)
+ pos = tree.target.source.stop
+ next_space = target_nomsu:is_multiline() and "\n..::" or "::"
+ end
end
for i, bit in ipairs(tree) do
if next_space == "\n.." or (next_space == " " and nomsu:trailing_line_len() > MAX_LINE) then
diff --git a/nomsu_compiler.moon b/nomsu_compiler.moon
index ba911ce..6afc38a 100644
--- a/nomsu_compiler.moon
+++ b/nomsu_compiler.moon
@@ -675,7 +675,18 @@ with NomsuCompiler
pos, next_space = tree.source.start, ''
nomsu = NomsuCode(tree.source, pop_comments(pos))
if tree.target
- nomsu\append @tree_to_nomsu(tree.target), "::"
+ if tree.target.type == "Block"
+ nomsu\append(recurse(tree.target, #nomsu\match('[^\n]*$')))
+ pos = tree.target.source.stop
+ next_space = inline and "::" or "\n..::"
+ else
+ target_nomsu = recurse(tree.target, #nomsu\match('[^\n]*$'))
+ if tree.target.type == "Action" and not target_nomsu\is_multiline!
+ target_nomsu\parenthesize!
+ nomsu\append target_nomsu
+ pos = tree.target.source.stop
+ next_space = target_nomsu\is_multiline! and "\n..::" or "::"
+
for i,bit in ipairs tree
if next_space == "\n.." or (next_space == " " and nomsu\trailing_line_len! > MAX_LINE)
nomsu\append "\n", pop_comments(pos), '..'