aboutsummaryrefslogtreecommitdiff
path: root/nomsu_tree.moon
diff options
context:
space:
mode:
Diffstat (limited to 'nomsu_tree.moon')
-rw-r--r--nomsu_tree.moon6
1 files changed, 3 insertions, 3 deletions
diff --git a/nomsu_tree.moon b/nomsu_tree.moon
index 71bcff9..b754cd8 100644
--- a/nomsu_tree.moon
+++ b/nomsu_tree.moon
@@ -6,8 +6,8 @@
unpack or= table.unpack
AST = {}
-AST.is_syntax_tree = (n)->
- type(n) == 'table' and getmetatable(n) and AST[n.type] == getmetatable(n)
+AST.is_syntax_tree = (n, t=nil)->
+ type(n) == 'table' and getmetatable(n) and AST[n.type] == getmetatable(n) and (t == nil or n.type == t)
types = {"Number", "Var", "Block", "EscapedNomsu", "Text", "List", "Dict", "DictEntry",
"IndexChain", "Action", "FileChunks"}
@@ -19,7 +19,7 @@ for name in *types
.__name = name
.type = name
.is_instance = (x)=> getmetatable(x) == @
- .__tostring = => "#{@name}(#{concat([repr(v) for v in *@], ', ')})"
+ .__tostring = => "#{@type}(#{repr tostring(@source)}, #{concat([repr(v) for v in *@], ', ')})"
.map = (fn)=>
if replacement = fn(@) then return replacement
replacements = [AST.is_syntax_tree(v) and v\map(fn) or nil for v in *@]