aboutsummaryrefslogtreecommitdiff
path: root/nomsu_compiler.lua
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-09-10 16:26:08 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-09-10 16:26:27 -0700
commit7c6047254e5aa7ce5a0667b14676b22a7447f956 (patch)
treef98478e6c77257610e43dc45447cd23e91bdaaae /nomsu_compiler.lua
parentc859eac2beb20889e162ca28f889cc02ac592266 (diff)
Upgraded to 3.8 (text method changes) and fixed some bugs in
tree_to_nomsu.
Diffstat (limited to 'nomsu_compiler.lua')
-rw-r--r--nomsu_compiler.lua15
1 files changed, 13 insertions, 2 deletions
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