From fc71b0331b6122c774585c3ab93e6e55978ecaf2 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 15 Jun 2018 03:30:20 -0700 Subject: Fixed some nomsu codegen bugs --- nomsu.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'nomsu.lua') diff --git a/nomsu.lua b/nomsu.lua index a162b65..80f7f01 100644 --- a/nomsu.lua +++ b/nomsu.lua @@ -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 -- cgit v1.2.3