aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-01-17 16:45:16 -0800
committerBruce Hill <bitbucket@bruce-hill.com>2018-01-17 16:45:29 -0800
commit12cc294c7ac31e3d08d6b8924dfc6cc427a1f712 (patch)
tree1f7edf01e78c6440affa1175721bd9fccd1caa48
parent8bbebb87351c2ad0684d785cd4fb02ef579707fc (diff)
Fixed some minor bugs that made generated nomsu uglier.
-rw-r--r--nomsu.lua16
-rwxr-xr-xnomsu.moon14
2 files changed, 22 insertions, 8 deletions
diff --git a/nomsu.lua b/nomsu.lua
index 76bc342..2baaf99 100644
--- a/nomsu.lua
+++ b/nomsu.lua
@@ -600,7 +600,7 @@ do
return nil
end
buff = buff .. (function()
- if nomsu.type == "Var" or nomsu.type == "List" or nomsu.type == "Dict" then
+ if bit.type == "Var" or bit.type == "List" or bit.type == "Dict" then
return "\\" .. nomsu
else
return "\\(" .. nomsu .. ")"
@@ -657,8 +657,12 @@ do
for _index_0 = 1, #_list_0 do
local bit = _list_0[_index_0]
nomsu = inline_expression(bit)
+ if line ~= "\n " and #line + #", " + #nomsu > max_line then
+ buff = buff .. line
+ line = "\n "
+ end
local sep = line == "\n " and "" or ", "
- if nomsu and #nomsu + #line < max_line then
+ if nomsu then
line = line .. (sep .. nomsu)
if #line >= max_line then
buff = buff .. line
@@ -717,7 +721,7 @@ do
return nil
end
buff = buff .. (function()
- if nomsu.type == "Var" or nomsu.type == "List" or nomsu.type == "Dict" then
+ if bit.type == "Var" or bit.type == "List" or bit.type == "Dict" then
return "\\" .. nomsu
else
return "\\(" .. nomsu .. ")"
@@ -750,7 +754,11 @@ do
local _exp_0 = tok.type
if "Block" == _exp_0 then
if #tok.value == 1 then
- nomsu = noeol_expression(tok.value[1])
+ if tok.value[1].type == "FunctionCall" then
+ nomsu = inline_expression(tok.value[1])
+ else
+ nomsu = noeol_expression(tok.value[1])
+ end
if nomsu and #(nomsu:match("[^\n]*")) < max_line then
return ": " .. nomsu
end
diff --git a/nomsu.moon b/nomsu.moon
index 3594246..960d95f 100755
--- a/nomsu.moon
+++ b/nomsu.moon
@@ -427,7 +427,7 @@ class NomsuCompiler
else
nomsu = inline_expression(bit)
return nil unless nomsu
- buff ..= if nomsu.type == "Var" or nomsu.type == "List" or nomsu.type == "Dict"
+ buff ..= if bit.type == "Var" or bit.type == "List" or bit.type == "Dict"
"\\"..nomsu
else "\\("..nomsu..")"
if #buff > max_line then return nil
@@ -461,8 +461,11 @@ class NomsuCompiler
line = "\n "
for bit in *tok.value
nomsu = inline_expression bit
+ if line != "\n " and #line + #", " + #nomsu > max_line
+ buff ..= line
+ line = "\n "
sep = line == "\n " and "" or ", "
- if nomsu and #nomsu + #line < max_line
+ if nomsu
line ..= sep..nomsu
if #line >= max_line
buff ..= line
@@ -503,7 +506,7 @@ class NomsuCompiler
else
nomsu = inline_expression(bit)
return nil unless nomsu
- buff ..= if nomsu.type == "Var" or nomsu.type == "List" or nomsu.type == "Dict"
+ buff ..= if bit.type == "Var" or bit.type == "List" or bit.type == "Dict"
"\\"..nomsu
else "\\("..nomsu..")"
return buff
@@ -525,7 +528,10 @@ class NomsuCompiler
switch tok.type
when "Block"
if #tok.value == 1
- nomsu = noeol_expression(tok.value[1])
+ nomsu = if tok.value[1].type == "FunctionCall"
+ inline_expression(tok.value[1])
+ else
+ noeol_expression(tok.value[1])
if nomsu and #(nomsu\match("[^\n]*")) < max_line
return ": "..nomsu
return noeol_expression(tok)