From 0923b0192c8023a1a8d2304fa318cee08500d57d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 28 Jun 2018 14:12:24 -0700 Subject: Improvements to nomsu codegen (comments are now retained) and some improvements to handling of stdin and fixes for error reporting. --- code_obj.lua | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'code_obj.lua') diff --git a/code_obj.lua b/code_obj.lua index e3f7b16..d3b9260 100644 --- a/code_obj.lua +++ b/code_obj.lua @@ -82,18 +82,29 @@ do local bits, indents = self.bits, self.indents local match = string.match for i = 1, n do - local b = select(i, ...) - assert(b) - bits[#bits + 1] = b - if type(b) == 'string' then - do - local spaces = match(b, "\n([ ]*)[^\n]*$") - if spaces then - self.current_indent = #spaces + local _continue_0 = false + repeat + local b = select(i, ...) + assert(b) + if b == '' then + _continue_0 = true + break + end + bits[#bits + 1] = b + if type(b) == 'string' then + do + local spaces = match(b, "\n([ ]*)[^\n]*$") + if spaces then + self.current_indent = #spaces + end end + elseif self.current_indent ~= 0 then + indents[#bits] = self.current_indent end - elseif self.current_indent ~= 0 then - indents[#bits] = self.current_indent + _continue_0 = true + until true + if not _continue_0 then + break end end self.__str = nil -- cgit v1.2.3