diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-06-18 18:10:59 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-06-18 18:11:09 -0700 |
| commit | f83cc3ad8afaa122867270a9b1255295e902c422 (patch) | |
| tree | 6d91f47c05f7173e3e447ae4f1412442edd6f6b2 /nomsu_tree.moon | |
| parent | a22de3fdbbebb310a07252bd99b1ca8acb685ea6 (diff) | |
More streamlining and cleanup.
Diffstat (limited to 'nomsu_tree.moon')
| -rw-r--r-- | nomsu_tree.moon | 6 |
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 *@] |
