diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-01-18 14:22:17 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-01-18 14:22:48 -0800 |
| commit | 10bd72e858a8ffaacafa296dbbc429dc73b0111c (patch) | |
| tree | 3dec18257ac6d1affe78aa33a9b389a25eda1256 /bootstrap.lua | |
| parent | 520acd39795766354fc44c6e15f5f33f255ca33a (diff) | |
Added `tree` back as a parameter to compile actions, which helps with
better error reporting, e.g. for (fail) (no arguments). Overall better
error reporting now. Also added shorthand ("Action" tree with ...) for
(SyntaxTree {.type = "Action", .1 = ...}).
Diffstat (limited to 'bootstrap.lua')
| -rw-r--r-- | bootstrap.lua | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/bootstrap.lua b/bootstrap.lua index 27a1953..97a565d 100644 --- a/bootstrap.lua +++ b/bootstrap.lua @@ -14,7 +14,7 @@ local fail_at fail_at = require('nomsu_compiler').fail_at local MAX_LINE = 80 local compile_actions = { - [""] = function(self, fn, ...) + [""] = function(self, _t, fn, ...) local lua = LuaCode() local fn_lua = self:compile(fn) lua:add(fn_lua) @@ -31,7 +31,7 @@ local compile_actions = { lua:add(")") return lua end, - ["Lua"] = function(self, code) + ["Lua"] = function(self, _t, code) if not code then return LuaCode("LuaCode()") end @@ -62,7 +62,7 @@ local compile_actions = { end return operate_on_text(code) end, - ["lua >"] = function(self, code) + ["lua >"] = function(self, _t, code) if code.type ~= "Text" then return code end @@ -83,7 +83,7 @@ local compile_actions = { end return operate_on_text(code) end, - ["= lua"] = function(self, code) + ["= lua"] = function(self, _t, code) return self:compile(SyntaxTree({ type = "Action", "lua", @@ -91,19 +91,19 @@ local compile_actions = { code })) end, - ["1 as lua"] = function(self, code) + ["1 as lua"] = function(self, _t, code) return LuaCode("_ENV:compile(", self:compile(code), ")") end, - ["use"] = function(self, path) + ["use"] = function(self, _t, path) return LuaCode("_ENV:use(" .. tostring(self:compile(path)) .. ")") end, - ["export"] = function(self, path) + ["export"] = function(self, _t, path) return LuaCode("_ENV:export(" .. tostring(self:compile(path)) .. ")") end, - ["run"] = function(self, path) + ["run"] = function(self, _t, path) return LuaCode("_ENV:run(" .. tostring(self:compile(path)) .. ")") end, - ["test"] = function(self, body) + ["test"] = function(self, _t, body) if not (body.type == 'Block') then fail_at(body, "Compile error: This should be a Block") end @@ -121,22 +121,22 @@ local compile_actions = { })) return LuaCode("TESTS[" .. tostring(tostring(body.source):as_lua()) .. "] = ", test_text) end, - ["is jit"] = function(self, code) + ["is jit"] = function(self, _t, code) return LuaCode("jit") end, - ["Lua version"] = function(self, code) + ["Lua version"] = function(self, _t, code) return LuaCode("_VERSION") end, - ["nomsu environment"] = function(self) + ["nomsu environment"] = function(self, _t) return LuaCode("_ENV") end, - ["nomsu environment name"] = function(self) + ["nomsu environment name"] = function(self, _t) return LuaCode('"_ENV"') end, - ["this file was run directly"] = function(self) + ["this file was run directly"] = function(self, _t) return LuaCode('WAS_RUN_DIRECTLY') end, - ["the command line arguments"] = function(self) + ["the command line arguments"] = function(self, _t) return LuaCode('COMMAND_LINE_ARGS') end } |
