diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-05-24 20:27:08 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-05-24 20:27:26 -0700 |
| commit | d9b795ee45d7a3c65bdd74da5ee042fac12cf5b8 (patch) | |
| tree | b253e502b315d6b507b8fa05379f2239378bf796 /nomsu_tree.lua | |
| parent | 446892d11ee712839084e4599a07d8decf6b3b54 (diff) | |
Adding some src map building code.
Diffstat (limited to 'nomsu_tree.lua')
| -rw-r--r-- | nomsu_tree.lua | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/nomsu_tree.lua b/nomsu_tree.lua index f4f10b2..4bacdb5 100644 --- a/nomsu_tree.lua +++ b/nomsu_tree.lua @@ -57,7 +57,7 @@ Tree = function(name, kind, methods) return _accum_0 end)(), ', ')) .. ")" end - methods.map = function(self, fn) + methods._map = function(self, fn) do local ret = fn(self) if ret then @@ -70,7 +70,7 @@ Tree = function(name, kind, methods) local _len_0 = 1 for _index_0 = 1, #self do local v = self[_index_0] - _accum_0[_len_0] = v.map and v:map(fn) or v + _accum_0[_len_0] = v._map and v:_map(fn) or v _len_0 = _len_0 + 1 end new_vals = _accum_0 @@ -82,7 +82,7 @@ Tree = function(name, kind, methods) methods.__tostring = function(self) return tostring(self.name) .. "(" .. tostring(repr(self.value)) .. ")" end - methods.map = function(self, fn) + methods._map = function(self, fn) return fn(self) or self end end @@ -96,6 +96,7 @@ Tree = function(name, kind, methods) end end Tree("Block", 'multi') +Tree("EscapedNomsu", 'multi') Tree("Text", 'multi') Tree("List", 'multi') Tree("Dict", 'multi') @@ -104,11 +105,6 @@ Tree("IndexChain", 'multi') Tree("Number", 'single') Tree("Word", 'single') Tree("Comment", 'single') -Tree("EscapedNomsu", 'single', { - map = function(self, fn) - return fn(self) or self:map(fn) - end -}) Tree("Var", 'single', { as_lua_id = function(self) return "_" .. (self.value:gsub("%W", function(c) |
