aboutsummaryrefslogtreecommitdiff
path: root/nomsu_compiler.lua
diff options
context:
space:
mode:
Diffstat (limited to 'nomsu_compiler.lua')
-rw-r--r--nomsu_compiler.lua22
1 files changed, 10 insertions, 12 deletions
diff --git a/nomsu_compiler.lua b/nomsu_compiler.lua
index dff7eb7..8c2d90b 100644
--- a/nomsu_compiler.lua
+++ b/nomsu_compiler.lua
@@ -157,7 +157,7 @@ do
return false
end
NomsuCompiler.environment = {
- NOMSU_COMPILER_VERSION = 9,
+ NOMSU_COMPILER_VERSION = 10,
NOMSU_SYNTAX_VERSION = max_parser_version,
next = next,
unpack = unpack,
@@ -459,19 +459,10 @@ do
return add_lua_bits(self, "value", code)
end,
["use 1"] = function(self, tree, path)
- local lua = LuaCode(tree.source)
if path.type == 'Text' and #path == 1 and type(path[1]) == 'string' then
- for _, f in Files.walk(path[1]) do
- if match(f, "%.lua$") or match(f, "%.nom$") or match(f, "^/dev/fd/[012]$") then
- self:import(self:run_file(f))
- if #lua.bits > 0 then
- lua:append("\n")
- end
- lua:append("nomsu:import(nomsu:run_file(" .. tostring(f:as_lua()) .. "))")
- end
- end
+ self:import_file(path[1])
end
- return lua
+ return LuaCode(tree.source, "nomsu:import_file(" .. tostring(self:compile(path)) .. ")")
end,
["tests"] = function(self, tree)
return LuaCode.Value(tree.source, "TESTS")
@@ -533,6 +524,13 @@ do
end
end
end
+ NomsuCompiler.import_file = function(self, path)
+ for _, f in Files.walk(path) do
+ if match(f, "%.lua$") or match(f, "%.nom$") or match(f, "^/dev/fd/[012]$") then
+ self:import(self:run_file(f))
+ end
+ end
+ end
NomsuCompiler.run = function(self, to_run, compile_actions)
local source = to_run.source or Source(to_run, 1, #to_run)
if type(source) == 'string' then