aboutsummaryrefslogtreecommitdiff
path: root/syntax_tree.lua
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.lua
parent0d88091f8d6cba8c552e2d3ffd3551819f8a4aed (diff)
Initial setup work for syntax version 5.
Diffstat (limited to 'syntax_tree.lua')
-rw-r--r--syntax_tree.lua33
1 files changed, 22 insertions, 11 deletions
diff --git a/syntax_tree.lua b/syntax_tree.lua
index ddd607c..ba74708 100644
--- a/syntax_tree.lua
+++ b/syntax_tree.lua
@@ -59,9 +59,6 @@ do
return false
end
end
- if self.target ~= other.target then
- return false
- end
return true
end,
as_lua = function(self)
@@ -146,19 +143,31 @@ do
return replacement
end,
get_args = function(self)
- assert(self.type == "Action", "Only actions have arguments")
- local args = {
- self.target
- }
- for _index_0 = 1, #self do
- local tok = self[_index_0]
- if type(tok) ~= 'string' then
- args[#args + 1] = tok
+ assert(self.type == "Action" or self.type == "MethodCall", "Only actions and method calls have arguments")
+ local args = { }
+ if self.type == "MethodCall" then
+ args[1] = self[1]
+ local _list_0 = self[2]
+ for _index_0 = 1, #_list_0 do
+ local tok = _list_0[_index_0]
+ if type(tok) ~= 'string' then
+ args[#args + 1] = tok
+ end
+ end
+ else
+ for _index_0 = 1, #self do
+ local tok = self[_index_0]
+ if type(tok) ~= 'string' then
+ args[#args + 1] = tok
+ end
end
end
return args
end,
get_stub = function(self)
+ if self.type == "MethodCall" then
+ return self[2]:get_stub()
+ end
local stub_bits = { }
local arg_i = 1
for _index_0 = 1, #self do
@@ -213,6 +222,8 @@ getmetatable(SyntaxTree).__call = function(self, t)
setmetatable(t, self.__base)
if t.type == 'Action' then
t.stub = t:get_stub()
+ elseif t.type == 'MethodCall' then
+ t.stub = t[2]:get_stub()
end
return t
end