From ea310306d73e0bc6542f7133825549ae4471b06a Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 12 Sep 2018 15:31:59 -0700 Subject: Initial working version. --- syntax_tree.moon | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'syntax_tree.moon') diff --git a/syntax_tree.moon b/syntax_tree.moon index 96230a1..2f46d9e 100644 --- a/syntax_tree.moon +++ b/syntax_tree.moon @@ -10,7 +10,7 @@ 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"} + "IndexChain", "Action", "FileChunks", "Error", "Comment"} for name in *types cls = {} with cls @@ -21,6 +21,8 @@ for name in *types .is_instance = (x)=> getmetatable(x) == @ .__tostring = => "#{@type}#{repr @, ((x)-> Source\is_instance(x) and tostring(x) or nil)}" .__repr = => "#{@type}#{repr @, ((x)-> Source\is_instance(x) and tostring(x) or nil)}" + .source_code_for_tree = {} + .get_source_code = => @source_code_for_tree[@] .map = (fn)=> replacement = fn(@) if replacement == false then return nil -- cgit v1.2.3