aboutsummaryrefslogtreecommitdiff
path: root/syntax_tree.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-09-12 15:31:59 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-09-12 15:32:04 -0700
commitea310306d73e0bc6542f7133825549ae4471b06a (patch)
treefcc2a5a868fe09fb599d8261f66dad96ac69bb0b /syntax_tree.moon
parent9e10c8bf006f42e90a011b8f9284e3ffa52a5859 (diff)
Initial working version.
Diffstat (limited to 'syntax_tree.moon')
-rw-r--r--syntax_tree.moon4
1 files changed, 3 insertions, 1 deletions
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