aboutsummaryrefslogtreecommitdiff
path: root/code_obj.lua
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-06-14 21:59:25 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-06-14 21:59:43 -0700
commit82cfd3e54b5910843c091a9fb6ef3ad6b64ba757 (patch)
treeaed04a3910646c82447b9b4b515169005b3010af /code_obj.lua
parent282565a309aef632502a64fef0a67b0b7efcfaaa (diff)
More streamlining and cleanup. Especially for core/metaprogramming.nom
Diffstat (limited to 'code_obj.lua')
-rw-r--r--code_obj.lua23
1 files changed, 23 insertions, 0 deletions
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