From f83cc3ad8afaa122867270a9b1255295e902c422 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Mon, 18 Jun 2018 18:10:59 -0700 Subject: More streamlining and cleanup. --- nomsu_tree.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'nomsu_tree.lua') diff --git a/nomsu_tree.lua b/nomsu_tree.lua index 05fb22c..227a674 100644 --- a/nomsu_tree.lua +++ b/nomsu_tree.lua @@ -9,8 +9,11 @@ local Source Source = require("code_obj").Source local unpack = unpack or table.unpack local AST = { } -AST.is_syntax_tree = function(n) - return type(n) == 'table' and getmetatable(n) and AST[n.type] == getmetatable(n) +AST.is_syntax_tree = function(n, t) + if t == nil then + t = nil + end + return type(n) == 'table' and getmetatable(n) and AST[n.type] == getmetatable(n) and (t == nil or n.type == t) end local types = { "Number", @@ -37,7 +40,7 @@ for _index_0 = 1, #types do return getmetatable(x) == self end cls.__tostring = function(self) - return tostring(self.name) .. "(" .. tostring(concat((function() + return tostring(self.type) .. "(" .. tostring(repr(tostring(self.source))) .. ", " .. tostring(concat((function() local _accum_0 = { } local _len_0 = 1 for _index_1 = 1, #self do -- cgit v1.2.3