From 7c6047254e5aa7ce5a0667b14676b22a7447f956 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 10 Sep 2018 16:26:08 -0700 Subject: Upgraded to 3.8 (text method changes) and fixed some bugs in tree_to_nomsu. --- nomsu_compiler.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'nomsu_compiler.lua') diff --git a/nomsu_compiler.lua b/nomsu_compiler.lua index 215617f..a53de1a 100644 --- a/nomsu_compiler.lua +++ b/nomsu_compiler.lua @@ -963,8 +963,15 @@ do end local space = MAX_LINE - pos local inline + local check + check = function(prefix, nomsu, tree) + if type(tree) == 'number' then + require('ldt').breakpoint() + end + return coroutine.yield(prefix, nomsu, tree) + end for prefix, nomsu, tree in coroutine.wrap(function() - inline = self:tree_to_inline_nomsu(t, false, coroutine.yield) + inline = self:tree_to_inline_nomsu(t, false, check) end) do local len = #tostring(nomsu) if prefix + len > MAX_LINE then @@ -1083,7 +1090,11 @@ do nomsu:append(pop_comments(tree.source.stop, '\n')) return nomsu elseif "EscapedNomsu" == _exp_0 then - return NomsuCode(tree.source, "\\", recurse(tree[1], 1)) + local val_nomsu = recurse(tree[1], 1) + if tree[1].type == "Action" and not val_nomsu:is_multiline() then + val_nomsu:parenthesize() + end + return NomsuCode(tree.source, "\\", val_nomsu) elseif "Block" == _exp_0 then local nomsu = NomsuCode(tree.source, pop_comments(tree.source.start)) for i, line in ipairs(tree) do -- cgit v1.2.3