diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-06-28 14:12:24 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-06-28 14:13:01 -0700 |
| commit | 0923b0192c8023a1a8d2304fa318cee08500d57d (patch) | |
| tree | 2bc60e2b119cbd4b37b12251ab9e997447bfce01 /code_obj.lua | |
| parent | 09d6bad6ac0d4509552d424471bcace649f69c8e (diff) | |
Improvements to nomsu codegen (comments are now retained) and some
improvements to handling of stdin and fixes for error reporting.
Diffstat (limited to 'code_obj.lua')
| -rw-r--r-- | code_obj.lua | 31 |
1 files changed, 21 insertions, 10 deletions
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 |
