diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2017-10-19 18:16:48 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2017-10-19 18:16:48 -0700 |
| commit | 09cb00e106c809bb37eb7fd90e1a9d2dd7ec57bb (patch) | |
| tree | 92ea1feada9c7816211543d21572222ea23b6b54 | |
| parent | ca5896b7bd8579e42a7fc9601e00512518051432 (diff) | |
Recompile.
| -rw-r--r-- | nomsu.lua | 36 |
1 files changed, 22 insertions, 14 deletions
@@ -833,28 +833,36 @@ end)]]):format(concat(lua_bits, "\n")) return self:error("Invalid type for %" .. tostring(varname) .. ". Expected " .. tostring(desired_type) .. ", but got " .. tostring(x.type) .. ".") end, initialize_core = function(self) + local nomsu_string_as_lua + nomsu_string_as_lua = function(self, code) + local concat_parts = { } + local _list_0 = code.value + for _index_0 = 1, #_list_0 do + local bit = _list_0[_index_0] + if type(bit) == "string" then + insert(concat_parts, bit) + else + local expr, statement = self:tree_to_lua(bit) + if statement then + self:error("Cannot use [[" .. tostring(bit.src) .. "]] as a string interpolation value, since it's not an expression.") + end + insert(concat_parts, expr) + end + end + return concat(concat_parts) + end local lua_code lua_code = function(self, vars) - local inner_vars = setmetatable({ }, { - __index = function(_, key) - return "vars[" .. tostring(repr(key)) .. "]" - end - }) - local lua = self:tree_to_value(vars.code, inner_vars) + local lua = nomsu_string_as_lua(self, vars.code) return nil, lua end - self:defmacro("lua > %code", lua_code) + self:defmacro("lua> %code", lua_code) local lua_value lua_value = function(self, vars) - local inner_vars = setmetatable({ }, { - __index = function(_, key) - return "vars[" .. tostring(repr(key)) .. "]" - end - }) - local lua = self:tree_to_value(vars.code, inner_vars) + local lua = nomsu_string_as_lua(self, vars.code) return lua, nil end - self:defmacro("= lua %code", lua_value) + self:defmacro("=lua %code", lua_value) local run_file run_file = function(self, vars) if vars.filename:match(".*%.lua") then |
