mirror of
https://github.com/Reuh/candran.git
synced 2025-10-27 09:59:29 +00:00
Add static import
This commit is contained in:
parent
01e808e2e6
commit
008e7732bc
4 changed files with 334 additions and 313 deletions
|
|
@ -29,7 +29,8 @@ candran.default = {
|
|||
chunkname = "nil",
|
||||
rewriteErrors = true,
|
||||
builtInMacros = true,
|
||||
preprocessorEnv = {}
|
||||
preprocessorEnv = {},
|
||||
import = {}
|
||||
}
|
||||
|
||||
-- Autodetect version
|
||||
|
|
@ -59,6 +60,11 @@ function candran.preprocess(input, options={})
|
|||
variables = {}
|
||||
}
|
||||
|
||||
-- add auto imports
|
||||
for _, mod in ipairs(options.import) do
|
||||
input =.. "#import(%q, {loadLocal=false})\n":format(mod)
|
||||
end
|
||||
|
||||
-- generate preprocessor code
|
||||
local preprocessor = ""
|
||||
local i = 0
|
||||
|
|
@ -111,6 +117,7 @@ function candran.preprocess(input, options={})
|
|||
if not f then error("can't open the module file to import") end
|
||||
|
||||
margs = util.merge(options, { chunkname = filepath, loadLocal = true, loadPackage = true }, margs)
|
||||
margs.import = {} -- no need for recursive import
|
||||
local modcontent, modmacros = assert(candran.preprocess(f:read("*a"), margs))
|
||||
macros = util.recmerge(macros, modmacros)
|
||||
f:close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue