From 82cfd3e54b5910843c091a9fb6ef3ad6b64ba757 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 14 Jun 2018 21:59:25 -0700 Subject: More streamlining and cleanup. Especially for core/metaprogramming.nom --- code_obj.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'code_obj.lua') diff --git a/code_obj.lua b/code_obj.lua index 57abef9..426a973 100644 --- a/code_obj.lua +++ b/code_obj.lua @@ -98,6 +98,29 @@ do end self.__str = nil end, + concat_append = function(self, values, joiner) + local bits, indents = self.bits, self.indents + local match = string.match + for i = 1, #values do + local b = values[i] + assert(b) + if i > 1 then + bits[#bits + 1] = joiner + 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 + end + self.__str = nil + end, prepend = function(self, ...) local n = select("#", ...) local bits, indents = self.bits, self.indents -- cgit v1.2.3