diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-06-15 03:30:20 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-06-15 03:30:32 -0700 |
| commit | fc71b0331b6122c774585c3ab93e6e55978ecaf2 (patch) | |
| tree | 176f0f99de848eac8297dd05b58f1eb74067503f | |
| parent | 9d6932a8721322a73861a26b7316c0a920eb7084 (diff) | |
Fixed some nomsu codegen bugs
| -rw-r--r-- | nomsu.lua | 17 | ||||
| -rwxr-xr-x | nomsu.moon | 14 |
2 files changed, 26 insertions, 5 deletions
@@ -1067,12 +1067,25 @@ do if i > 1 then nomsu:append(".") end - local bit_nomsu = self:tree_to_nomsu(bit, true) + local bit_nomsu + if bit.type == "Text" and #bit == 1 and type(bit[1]) == 'string' then + if (NOMSU_DEFS.ident_char ^ 1):match(bit[1]) then + bit_nomsu = bit[1] + end + end + if not (bit_nomsu) then + bit_nomsu = self:tree_to_nomsu(bit, true) + end if not (bit_nomsu) then return nil end - if bit.type == "Action" or bit.type == "Block" then + local _exp_1 = bit.type + if "Action" == _exp_1 or "Block" == _exp_1 or "IndexChain" == _exp_1 then bit_nomsu:parenthesize() + elseif "Number" == _exp_1 then + if i < #tree then + bit_nomsu:parenthesize() + end end nomsu:append(bit_nomsu) end @@ -865,10 +865,18 @@ class NomsuCompiler for i, bit in ipairs tree if i > 1 nomsu\append "." - bit_nomsu = @tree_to_nomsu(bit, true) + local bit_nomsu + if bit.type == "Text" and #bit == 1 and type(bit[1]) == 'string' + if (NOMSU_DEFS.ident_char^1)\match(bit[1]) + bit_nomsu = bit[1] + unless bit_nomsu then bit_nomsu = @tree_to_nomsu(bit, true) return nil unless bit_nomsu - if bit.type == "Action" or bit.type == "Block" - bit_nomsu\parenthesize! + switch bit.type + when "Action", "Block", "IndexChain" + bit_nomsu\parenthesize! + when "Number" + if i < #tree + bit_nomsu\parenthesize! nomsu\append bit_nomsu return nomsu |
