aboutsummaryrefslogtreecommitdiff
path: root/syntax_tree.moon
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-12-14 17:49:36 -0800
committerBruce Hill <bruce@bruce-hill.com>2018-12-14 17:49:46 -0800
commit6ba84a0f507270fba8e7a68901dc256c2979d7f9 (patch)
tree8f342ace5a015cf14df12bb17525f02de89bf47d /syntax_tree.moon
parent0d88091f8d6cba8c552e2d3ffd3551819f8a4aed (diff)
Initial setup work for syntax version 5.
Diffstat (limited to 'syntax_tree.moon')
-rw-r--r--syntax_tree.moon18
1 files changed, 13 insertions, 5 deletions
diff --git a/syntax_tree.moon b/syntax_tree.moon
index 71b9bac..e2bbb4e 100644
--- a/syntax_tree.moon
+++ b/syntax_tree.moon
@@ -29,7 +29,6 @@ class SyntaxTree
return false if type(@) != type(other) or #@ != #other or getmetatable(@) != getmetatable(other)
for i=1,#@
return false if @[i] != other[i]
- return false if @target != other.target
return true
as_lua: =>
@@ -74,13 +73,20 @@ class SyntaxTree
return replacement
get_args: =>
- assert(@type == "Action", "Only actions have arguments")
- args = {@target}
- for tok in *@
- if type(tok) != 'string' then args[#args+1] = tok
+ assert(@type == "Action" or @type == "MethodCall", "Only actions and method calls have arguments")
+ args = {}
+ if @type == "MethodCall"
+ args[1] = @[1]
+ for tok in *@[2]
+ if type(tok) != 'string' then args[#args+1] = tok
+ else
+ for tok in *@
+ if type(tok) != 'string' then args[#args+1] = tok
return args
get_stub: =>
+ if @type == "MethodCall"
+ return @[2]\get_stub!
stub_bits = {}
arg_i = 1
for a in *@
@@ -103,6 +109,8 @@ getmetatable(SyntaxTree).__call = (t)=>
setmetatable(t, @__base)
if t.type == 'Action'
t.stub = t\get_stub!
+ elseif t.type == 'MethodCall'
+ t.stub = t[2]\get_stub!
return t
return SyntaxTree