aboutsummaryrefslogtreecommitdiff
path: root/nomsu_compiler.moon
diff options
context:
space:
mode:
Diffstat (limited to 'nomsu_compiler.moon')
-rw-r--r--nomsu_compiler.moon8
1 files changed, 8 insertions, 0 deletions
diff --git a/nomsu_compiler.moon b/nomsu_compiler.moon
index 4b684a4..4019632 100644
--- a/nomsu_compiler.moon
+++ b/nomsu_compiler.moon
@@ -62,6 +62,9 @@ math_expression = re.compile [[ (([*/^+-] / [0-9]+) " ")* [*/^+-] !. ]]
MAX_LINE = 80 -- For beautification purposes, try not to make lines much longer than this value
compile = (tree)=>
+ if tree == nil
+ error("No tree was passed in.")
+
-- Automatically upgrade trees from older versions:
if tree.version and tree.version < @NOMSU_VERSION\up_to(#tree.version) and @_1_upgraded_from_2_to
tree = @._1_upgraded_from_2_to(tree, tree.version, @NOMSU_VERSION)
@@ -211,6 +214,9 @@ compile = (tree)=>
when "Block"
lua = LuaCode\from(tree.source)
for i, line in ipairs tree
+ if line.type == "Error"
+ return @compile(line)
+ for i, line in ipairs tree
if i > 1 then lua\add "\n"
line_lua = @compile(line)
lua\add line_lua
@@ -345,6 +351,8 @@ compile = (tree)=>
return LuaCode\from(tree.source, number)
when "Var"
+ if tree[1].type == "MethodCall"
+ return LuaCode\from(tree.source, @compile(tree[1][1]), ".", tree[1][2]\get_stub!\as_lua_id!)
return LuaCode\from(tree.source, tree\as_var!\as_lua_id!)
when "FileChunks"