aboutsummaryrefslogtreecommitdiff
path: root/syntax_tree.moon
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-11-17 14:38:05 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-11-17 14:39:08 -0800
commit7f47d4204039258cec78c767f489b7809b4257ff (patch)
treec8533068b75ab453accfe1f688705e9e94c9e279 /syntax_tree.moon
parent34a3dd22a4e132bd4e0fe3ce89831c3fe761d3d9 (diff)
In-progress (but working) overhaul of some elements including: function
calls, lib/thing.nom API, multi-assignments, varargs, etc.
Diffstat (limited to 'syntax_tree.moon')
-rw-r--r--syntax_tree.moon17
1 files changed, 11 insertions, 6 deletions
diff --git a/syntax_tree.moon b/syntax_tree.moon
index dd10d77..71b9bac 100644
--- a/syntax_tree.moon
+++ b/syntax_tree.moon
@@ -39,11 +39,13 @@ class SyntaxTree
table.insert(bits, "[ #{as_lua(k)}]=#{as_lua(v)}")
return "SyntaxTree{#{table.concat(bits, ", ")}}"
- @source_code_for_tree: setmetatable({}, {__index:(t)=>
- s = t.source
- Files = require 'files'
- f = Files.read(s.filename)
- return f
+ @source_code_for_tree: setmetatable({}, {
+ __index:(t)=>
+ s = t.source
+ Files = require 'files'
+ f = Files.read(s.filename)
+ return f
+ __mode: "k"
})
get_source_file: => @@source_code_for_tree[@]
get_source_code: => @@source_code_for_tree[@]\sub(@source.start, @source.stop)
@@ -73,7 +75,10 @@ class SyntaxTree
get_args: =>
assert(@type == "Action", "Only actions have arguments")
- return [tok for tok in *@ when type(tok) != 'string']
+ args = {@target}
+ for tok in *@
+ if type(tok) != 'string' then args[#args+1] = tok
+ return args
get_stub: =>
stub_bits = {}