aboutsummaryrefslogtreecommitdiff
path: root/nomsu_compiler.lua
diff options
context:
space:
mode:
Diffstat (limited to 'nomsu_compiler.lua')
-rw-r--r--nomsu_compiler.lua28
1 files changed, 8 insertions, 20 deletions
diff --git a/nomsu_compiler.lua b/nomsu_compiler.lua
index 02460b3..215617f 100644
--- a/nomsu_compiler.lua
+++ b/nomsu_compiler.lua
@@ -4,10 +4,10 @@ local utils = require('utils')
local Files = require('files')
local repr, stringify, equivalent
repr, stringify, equivalent = utils.repr, utils.stringify, utils.equivalent
-local List, Dict
+local List, Dict, Text
do
local _obj_0 = require('containers')
- List, Dict = _obj_0.List, _obj_0.Dict
+ List, Dict, Text = _obj_0.List, _obj_0.Dict, _obj_0.Text
end
colors = require('consolecolors')
colored = setmetatable({ }, {
@@ -74,23 +74,6 @@ table.copy = function(t)
return _tbl_0
end)(), getmetatable(t))
end
-do
- local STRING_METATABLE = getmetatable("")
- STRING_METATABLE.__add = function(self, other)
- return self .. stringify(other)
- end
- STRING_METATABLE.__index = function(self, i)
- local ret = string[i]
- if ret ~= nil then
- return ret
- end
- if type(i) == 'number' then
- return sub(self, i, i)
- elseif type(i) == 'table' then
- return sub(self, i[1], i[2])
- end
- end
-end
local MAX_LINE = 80
local NomsuCompiler = setmetatable({
name = "Nomsu"
@@ -531,7 +514,12 @@ do
end
local lua = LuaCode.Value(tree.source)
if tree.target then
- lua:append(self:compile(tree.target), ":")
+ local target_lua = self:compile(tree.target)
+ if tostring(target_lua):match("^%(.*%)$") or tostring(target_lua):match("^[_a-zA-Z][_a-zA-Z0-9]*$") then
+ lua:append(target_lua, ":")
+ else
+ lua:append("(", target_lua, "):")
+ end
end
lua:append(string.as_lua_id(stub), "(")
local args = { }