aboutsummaryrefslogtreecommitdiff
path: root/nomsu_compiler.moon
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-12-14 19:25:59 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-12-14 19:26:05 -0800
commit2360ada21fac914a4bc5eeec752966cb3f3bba71 (patch)
tree19a122b976797f6ae3d973cfe32eb56d471e4a54 /nomsu_compiler.moon
parent83a40b7493b19e4b55167784e073e92733344b87 (diff)
Codegen tweak
Diffstat (limited to 'nomsu_compiler.moon')
-rw-r--r--nomsu_compiler.moon8
1 files changed, 5 insertions, 3 deletions
diff --git a/nomsu_compiler.moon b/nomsu_compiler.moon
index 720fe03..bffec92 100644
--- a/nomsu_compiler.moon
+++ b/nomsu_compiler.moon
@@ -174,12 +174,14 @@ compile = setmetatable({
lua = LuaCode\from(tree.source)
lua\add((stub)\as_lua_id!,"(")
- for i, arg in ipairs tree\get_args!
+ for argnum, arg in ipairs tree\get_args!
arg_lua = compile(arg)
if arg.type == "Block"
arg_lua = LuaCode\from(arg.source, "(function()\n ", arg_lua, "\nend)()")
- lua\add "," if i > 1
- lua\add(lua\trailing_line_len! + #arg_lua\text! > MAX_LINE and "\n " or " ")
+ if lua\trailing_line_len! + #arg_lua\text! > MAX_LINE
+ lua\add(argnum > 1 and ",\n " or "\n ")
+ elseif argnum > 1
+ lua\add ", "
lua\add arg_lua
lua\add ")"
return lua