aboutsummaryrefslogtreecommitdiff
path: root/nomsu_compiler.lua
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-03-27 14:41:36 -0700
committerBruce Hill <bruce@bruce-hill.com>2019-03-27 14:42:13 -0700
commit8bf8877ff9fe4495772d9804e8c832fd0530abec (patch)
treee1ee321160bf797817b7b8069025d9c08c8a16ea /nomsu_compiler.lua
parent8719641ace1228a9b650c27b8a575cb3d3c4c761 (diff)
Added support for $($foo, baz) as equivalent to $foo.baz.
Diffstat (limited to 'nomsu_compiler.lua')
-rw-r--r--nomsu_compiler.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/nomsu_compiler.lua b/nomsu_compiler.lua
index 5495fde..4bdac9a 100644
--- a/nomsu_compiler.lua
+++ b/nomsu_compiler.lua
@@ -73,6 +73,9 @@ local math_expression = re.compile([[ (([*/^+-] / [0-9]+) " ")* [*/^+-] !. ]])
local MAX_LINE = 80
local compile
compile = function(self, tree)
+ if tree == nil then
+ error("No tree was passed in.")
+ end
if tree.version and tree.version < self.NOMSU_VERSION:up_to(#tree.version) and self._1_upgraded_from_2_to then
tree = self._1_upgraded_from_2_to(tree, tree.version, self.NOMSU_VERSION)
end
@@ -259,6 +262,11 @@ compile = function(self, tree)
elseif "Block" == _exp_0 then
local lua = LuaCode:from(tree.source)
for i, line in ipairs(tree) do
+ if line.type == "Error" then
+ return self:compile(line)
+ end
+ end
+ for i, line in ipairs(tree) do
if i > 1 then
lua:add("\n")
end
@@ -427,6 +435,9 @@ compile = function(self, tree)
local number = tostring(tree[1]):gsub("_", "")
return LuaCode:from(tree.source, number)
elseif "Var" == _exp_0 then
+ if tree[1].type == "MethodCall" then
+ return LuaCode:from(tree.source, self:compile(tree[1][1]), ".", tree[1][2]:get_stub():as_lua_id())
+ end
return LuaCode:from(tree.source, tree:as_var():as_lua_id())
elseif "FileChunks" == _exp_0 then
return error("Can't convert FileChunks to a single block of lua, since each chunk's " .. "compilation depends on the earlier chunks")