diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-14 15:06:03 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-07-14 15:06:17 -0700 |
| commit | 8a44869c4a548692a19afe5258e2540f7d351c8a (patch) | |
| tree | 32bb367054ea6fb665fa9ee35dceaf237a8f2055 /nomsu_compiler.lua | |
| parent | c9ff0ff04b2d1922bcfe5b1106b9979c29b167a2 (diff) | |
Aesthetic tweak to generated nomsu code with colons.
Diffstat (limited to 'nomsu_compiler.lua')
| -rw-r--r-- | nomsu_compiler.lua | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/nomsu_compiler.lua b/nomsu_compiler.lua index 788d9a0..b56fde8 100644 --- a/nomsu_compiler.lua +++ b/nomsu_compiler.lua @@ -717,6 +717,7 @@ do return error("Unknown type: " .. tostring(tree.type)) end end + local MIN_COLON_LEN = 25 NomsuCompiler.tree_to_nomsu = function(self, tree, options) options = options or { } if not (options.pop_comments) then @@ -792,7 +793,7 @@ do return nil end if bit.type == "Action" or bit.type == "Block" then - if bit.type == "Action" and i == #tree then + if bit.type == "Action" and i == #tree and #tostring(arg_nomsu) >= MIN_COLON_LEN then nomsu:append(":") else arg_nomsu:parenthesize() @@ -827,7 +828,7 @@ do end if arg_nomsu and line_len + #tostring(arg_nomsu) < MAX_LINE then if bit.type == "Action" then - if can_use_colon and i > 1 then + if can_use_colon and i > 1 and #tostring(arg_nomsu) >= MIN_COLON_LEN then nomsu:append(match(next_space, "[^ ]*"), ": ", arg_nomsu) next_space = "\n.." line_len = 2 |
