From d2e69a13b32e8574decfe81ea275292234eba6ea Mon Sep 17 00:00:00 2001 From: Oliver Caldwell Date: Sat, 7 Jan 2023 17:07:34 +0000 Subject: [PATCH] Update Aniseed and Fennel --- lua/conjure/aniseed/deps/fennel.lua | 1292 ++++++++++++++------------- lua/conjure/aniseed/fs.lua | 8 +- 2 files changed, 661 insertions(+), 639 deletions(-) diff --git a/lua/conjure/aniseed/deps/fennel.lua b/lua/conjure/aniseed/deps/fennel.lua index 6f54283d..51428ea9 100644 --- a/lua/conjure/aniseed/deps/fennel.lua +++ b/lua/conjure/aniseed/deps/fennel.lua @@ -6,14 +6,14 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee local view = require("conjure.aniseed.fennel.view") local unpack = (table.unpack or _G.unpack) local function default_read_chunk(parser_state) - local function _616_() + local function _620_() if (0 < parser_state["stack-size"]) then return ".." else return ">> " end end - io.write(_616_()) + io.write(_620_()) io.flush() local input = io.read() return (input and (input .. "\n")) @@ -23,23 +23,23 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee return io.write("\n") end local function default_on_error(errtype, err, lua_source) - local function _618_() - local _617_ = errtype - if (_617_ == "Lua Compile") then + local function _622_() + local _621_ = errtype + if (_621_ == "Lua Compile") then return ("Bad code generated - likely a bug with the compiler:\n" .. "--- Generated Lua Start ---\n" .. lua_source .. "--- Generated Lua End ---\n") - elseif (_617_ == "Runtime") then + elseif (_621_ == "Runtime") then return (compiler.traceback(tostring(err), 4) .. "\n") elseif true then - local _ = _617_ + local _ = _621_ return ("%s error: %s\n"):format(errtype, tostring(err)) else return nil end end - return io.write(_618_()) + return io.write(_622_()) end - local save_source = table.concat({"local ___i___ = 1", "while true do", " local name, value = debug.getlocal(1, ___i___)", " if(name and name ~= \"___i___\") then", " ___replLocals___[name] = value", " ___i___ = ___i___ + 1", " else break end end"}, "\n") - local function splice_save_locals(env, lua_source) + local save_source = " ___replLocals___['%s'] = %s" + local function splice_save_locals(env, lua_source, scope) local spliced_source = {} local bind = "local %s = ___replLocals___['%s']" for line in lua_source:gmatch("([^\n]+)\n?") do @@ -49,7 +49,9 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee table.insert(spliced_source, 1, bind:format(name, name)) end if ((1 < #spliced_source) and (spliced_source[#spliced_source]):match("^ *return .*$")) then - table.insert(spliced_source, #spliced_source, save_source) + for _, name in pairs(scope.manglings) do + table.insert(spliced_source, #spliced_source, save_source:format(name, name)) + end else end return table.concat(spliced_source, "\n") @@ -64,14 +66,14 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee local scope_first_3f = ((tbl == env) or (tbl == env.___replLocals___)) local tbl_14_auto = matches local i_15_auto = #tbl_14_auto - local function _621_() + local function _625_() if scope_first_3f then return scope.manglings else return tbl end end - for k, is_mangled in utils.allpairs(_621_()) do + for k, is_mangled in utils.allpairs(_625_()) do if (max_items <= #matches) then break end local val_16_auto do @@ -142,7 +144,7 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee return input:match("^%s*,") end local function command_docs() - local _630_ + local _634_ do local tbl_14_auto = {} local i_15_auto = #tbl_14_auto @@ -154,18 +156,18 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee else end end - _630_ = tbl_14_auto + _634_ = tbl_14_auto end - return table.concat(_630_, "\n") + return table.concat(_634_, "\n") end commands.help = function(_, _0, on_values) return on_values({("Welcome to Fennel.\nThis is the REPL where you can enter code to be evaluated.\nYou can also run these repl commands:\n\n" .. command_docs() .. "\n ,exit - Leave the repl.\n\nUse ,doc something to see descriptions for individual macros and special forms.\n\nFor more information about the language, see https://fennel-lang.org/reference")}) end do end (compiler.metadata):set(commands.help, "fnl/docstring", "Show this message.") local function reload(module_name, env, on_values, on_error) - local _632_, _633_ = pcall(specials["load-code"]("return require(...)", env), module_name) - if ((_632_ == true) and (nil ~= _633_)) then - local old = _633_ + local _636_, _637_ = pcall(specials["load-code"]("return require(...)", env), module_name) + if ((_636_ == true) and (nil ~= _637_)) then + local old = _637_ local _ package.loaded[module_name] = nil _ = nil @@ -192,38 +194,38 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee else end return on_values({"ok"}) - elseif ((_632_ == false) and (nil ~= _633_)) then - local msg = _633_ + elseif ((_636_ == false) and (nil ~= _637_)) then + local msg = _637_ if (specials["macro-loaded"])[module_name] then specials["macro-loaded"][module_name] = nil return nil else - local function _638_() - local _637_ = msg:gsub("\n.*", "") - return _637_ + local function _642_() + local _641_ = msg:gsub("\n.*", "") + return _641_ end - return on_error("Runtime", _638_()) + return on_error("Runtime", _642_()) end else return nil end end local function run_command(read, on_error, f) - local _641_, _642_, _643_ = pcall(read) - if ((_641_ == true) and (_642_ == true) and (nil ~= _643_)) then - local val = _643_ + local _645_, _646_, _647_ = pcall(read) + if ((_645_ == true) and (_646_ == true) and (nil ~= _647_)) then + local val = _647_ return f(val) - elseif (_641_ == false) then + elseif (_645_ == false) then return on_error("Parse", "Couldn't parse input.") else return nil end end commands.reload = function(env, read, on_values, on_error) - local function _645_(_241) + local function _649_(_241) return reload(tostring(_241), env, on_values, on_error) end - return run_command(read, on_error, _645_) + return run_command(read, on_error, _649_) end do end (compiler.metadata):set(commands.reload, "fnl/docstring", "Reload the specified module.") commands.reset = function(env, _, on_values) @@ -232,30 +234,30 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee end do end (compiler.metadata):set(commands.reset, "fnl/docstring", "Erase all repl-local scope.") commands.complete = function(env, read, on_values, on_error, scope, chars) - local function _646_() + local function _650_() return on_values(completer(env, scope, string.char(unpack(chars)):gsub(",complete +", ""):sub(1, -2))) end - return run_command(read, on_error, _646_) + return run_command(read, on_error, _650_) end do end (compiler.metadata):set(commands.complete, "fnl/docstring", "Print all possible completions for a given input symbol.") local function apropos_2a(pattern, tbl, prefix, seen, names) for name, subtbl in pairs(tbl) do if (("string" == type(name)) and (package ~= subtbl)) then - local _647_ = type(subtbl) - if (_647_ == "function") then + local _651_ = type(subtbl) + if (_651_ == "function") then if ((prefix .. name)):match(pattern) then table.insert(names, (prefix .. name)) else end - elseif (_647_ == "table") then + elseif (_651_ == "table") then if not seen[subtbl] then - local _650_ + local _654_ do - local _649_ = seen - _649_[subtbl] = true - _650_ = _649_ + local _653_ = seen + _653_[subtbl] = true + _654_ = _653_ end - apropos_2a(pattern, subtbl, (prefix .. name:gsub("%.", "/") .. "."), _650_, names) + apropos_2a(pattern, subtbl, (prefix .. name:gsub("%.", "/") .. "."), _654_, names) else end else @@ -280,10 +282,10 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee return tbl_14_auto end commands.apropos = function(_env, read, on_values, on_error, _scope) - local function _655_(_241) + local function _659_(_241) return on_values(apropos(tostring(_241))) end - return run_command(read, on_error, _655_) + return run_command(read, on_error, _659_) end do end (compiler.metadata):set(commands.apropos, "fnl/docstring", "Print all functions matching a pattern in all loaded modules.") local function apropos_follow_path(path) @@ -304,12 +306,12 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee local tgt = package.loaded for _, path0 in ipairs(paths) do if (nil == tgt) then break end - local _658_ + local _662_ do - local _657_ = path0:gsub("%/", ".") - _658_ = _657_ + local _661_ = path0:gsub("%/", ".") + _662_ = _661_ end - tgt = tgt[_658_] + tgt = tgt[_662_] end return tgt end @@ -321,9 +323,9 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee do local tgt = apropos_follow_path(path) if ("function" == type(tgt)) then - local _659_ = (compiler.metadata):get(tgt, "fnl/docstring") - if (nil ~= _659_) then - local docstr = _659_ + local _663_ = (compiler.metadata):get(tgt, "fnl/docstring") + if (nil ~= _663_) then + local docstr = _663_ val_16_auto = (docstr:match(pattern) and path) else val_16_auto = nil @@ -341,10 +343,10 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee return tbl_14_auto end commands["apropos-doc"] = function(_env, read, on_values, on_error, _scope) - local function _663_(_241) + local function _667_(_241) return on_values(apropos_doc(tostring(_241))) end - return run_command(read, on_error, _663_) + return run_command(read, on_error, _667_) end do end (compiler.metadata):set(commands["apropos-doc"], "fnl/docstring", "Print all functions that match the pattern in their docs") local function apropos_show_docs(on_values, pattern) @@ -359,113 +361,116 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee return nil end commands["apropos-show-docs"] = function(_env, read, on_values, on_error) - local function _665_(_241) + local function _669_(_241) return apropos_show_docs(on_values, tostring(_241)) end - return run_command(read, on_error, _665_) + return run_command(read, on_error, _669_) end do end (compiler.metadata):set(commands["apropos-show-docs"], "fnl/docstring", "Print all documentations matching a pattern in function name") - local function resolve(identifier, _666_, scope) - local _arg_667_ = _666_ - local ___replLocals___ = _arg_667_["___replLocals___"] - local env = _arg_667_ + local function resolve(identifier, _670_, scope) + local _arg_671_ = _670_ + local ___replLocals___ = _arg_671_["___replLocals___"] + local env = _arg_671_ local e - local function _668_(_241, _242) + local function _672_(_241, _242) return (___replLocals___[_242] or env[_242]) end - e = setmetatable({}, {__index = _668_}) - local _669_, _670_ = pcall(compiler["compile-string"], tostring(identifier), {scope = scope}) - if ((_669_ == true) and (nil ~= _670_)) then - local code = _670_ - local _671_ = specials["load-code"](code, e)() - local function _672_() - local x = _671_ - return (type(x) == "function") - end - if ((nil ~= _671_) and _672_()) then - local x = _671_ - return x - else - return nil - end + e = setmetatable({}, {__index = _672_}) + local _673_, _674_ = pcall(compiler["compile-string"], tostring(identifier), {scope = scope}) + if ((_673_ == true) and (nil ~= _674_)) then + local code = _674_ + return specials["load-code"](code, e)() else return nil end end commands.find = function(env, read, on_values, on_error, scope) - local function _675_(_241) - local _676_ + local function _676_(_241) + local _677_ do - local _677_ = utils["sym?"](_241) - if (nil ~= _677_) then - local _678_ = resolve(_677_, env, scope) - if (nil ~= _678_) then - _676_ = debug.getinfo(_678_) + local _678_ = utils["sym?"](_241) + if (nil ~= _678_) then + local _679_ = resolve(_678_, env, scope) + if (nil ~= _679_) then + _677_ = debug.getinfo(_679_) else - _676_ = _678_ + _677_ = _679_ end else - _676_ = _677_ + _677_ = _678_ end end - if ((_G.type(_676_) == "table") and (nil ~= (_676_).short_src) and (nil ~= (_676_).source) and ((_676_).what == "Lua") and (nil ~= (_676_).linedefined)) then - local src = (_676_).short_src - local source = (_676_).source - local line = (_676_).linedefined + if ((_G.type(_677_) == "table") and ((_677_).what == "Lua") and (nil ~= (_677_).source) and (nil ~= (_677_).linedefined) and (nil ~= (_677_).short_src)) then + local source = (_677_).source + local line = (_677_).linedefined + local src = (_677_).short_src local fnlsrc do - local t_681_ = compiler.sourcemap - if (nil ~= t_681_) then - t_681_ = (t_681_)[source] + local t_682_ = compiler.sourcemap + if (nil ~= t_682_) then + t_682_ = (t_682_)[source] else end - if (nil ~= t_681_) then - t_681_ = (t_681_)[line] + if (nil ~= t_682_) then + t_682_ = (t_682_)[line] else end - if (nil ~= t_681_) then - t_681_ = (t_681_)[2] + if (nil ~= t_682_) then + t_682_ = (t_682_)[2] else end - fnlsrc = t_681_ + fnlsrc = t_682_ end return on_values({string.format("%s:%s", src, (fnlsrc or line))}) - elseif (_676_ == nil) then + elseif (_677_ == nil) then return on_error("Repl", "Unknown value") elseif true then - local _ = _676_ + local _ = _677_ return on_error("Repl", "No source info") else return nil end end - return run_command(read, on_error, _675_) + return run_command(read, on_error, _676_) end do end (compiler.metadata):set(commands.find, "fnl/docstring", "Print the filename and line number for a given function") commands.doc = function(env, read, on_values, on_error, scope) - local function _686_(_241) + local function _687_(_241) local name = tostring(_241) local path = (utils["multi-sym?"](name) or {name}) - local is_ok, target = nil, nil - local function _687_() + local ok_3f, target = nil, nil + local function _688_() return (utils["get-in"](scope.specials, path) or utils["get-in"](scope.macros, path) or resolve(name, env, scope)) end - is_ok, target = pcall(_687_) - if is_ok then + ok_3f, target = pcall(_688_) + if ok_3f then return on_values({specials.doc(target, name)}) else return on_error("Repl", "Could not resolve value for docstring lookup") end end - return run_command(read, on_error, _686_) + return run_command(read, on_error, _687_) end do end (compiler.metadata):set(commands.doc, "fnl/docstring", "Print the docstring and arglist for a function, macro, or special form.") + commands.compile = function(env, read, on_values, on_error, scope) + local function _690_(_241) + local allowedGlobals = specials["current-global-names"](env) + local ok_3f, result = pcall(compiler.compile, _241, {env = env, scope = scope, allowedGlobals = allowedGlobals}) + if ok_3f then + return on_values({result}) + else + return on_error("Repl", ("Error compiling expression: " .. result)) + end + end + return run_command(read, on_error, _690_) + end + do end (compiler.metadata):set(commands.compile, "fnl/docstring", "compiles the expression into lua and prints the result.") local function load_plugin_commands(plugins) for _, plugin in ipairs((plugins or {})) do for name, f in pairs(plugin) do - local _689_ = name:match("^repl%-command%-(.*)") - if (nil ~= _689_) then - local cmd_name = _689_ + local _692_ = name:match("^repl%-command%-(.*)") + if (nil ~= _692_) then + local cmd_name = _692_ commands[cmd_name] = (commands[cmd_name] or f) else end @@ -476,12 +481,12 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee local function run_command_loop(input, read, loop, env, on_values, on_error, scope, chars) local command_name = input:match(",([^%s/]+)") do - local _691_ = commands[command_name] - if (nil ~= _691_) then - local command = _691_ + local _694_ = commands[command_name] + if (nil ~= _694_) then + local command = _694_ command(env, read, on_values, on_error, scope, chars) elseif true then - local _ = _691_ + local _ = _694_ if ("exit" ~= command_name) then on_values({"Unknown command", command_name}) else @@ -506,10 +511,10 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee do local tbl_11_auto = {keeplines = 1000, histfile = ""} for k, v in pairs(readline.set_options({})) do - local _696_, _697_ = k, v - if ((nil ~= _696_) and (nil ~= _697_)) then - local k_12_auto = _696_ - local v_13_auto = _697_ + local _699_, _700_ = k, v + if ((nil ~= _699_) and (nil ~= _700_)) then + local k_12_auto = _699_ + local v_13_auto = _700_ tbl_11_auto[k_12_auto] = v_13_auto else end @@ -559,7 +564,7 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee local opts = ((_3foptions and utils.copy(_3foptions)) or {}) local readline = (should_use_readline_3f(opts) and try_readline_21(opts, pcall(require, "readline"))) local env = specials["wrap-env"]((opts.env or rawget(_G, "_ENV") or _G)) - local save_locals_3f = ((opts.saveLocals ~= false) and env.debug and env.debug.getlocal) + local save_locals_3f = (opts.saveLocals ~= false) local read_chunk = (opts.readChunk or default_read_chunk) local on_values = (opts.onValues or default_on_values) local on_error = (opts.onError or default_on_error) @@ -567,12 +572,12 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee local byte_stream, clear_stream = parser.granulate(read_chunk) local chars = {} local read, reset = nil, nil - local function _703_(parser_state) + local function _706_(parser_state) local c = byte_stream(parser_state) table.insert(chars, c) return c end - read, reset = parser.parser(_703_) + read, reset = parser.parser(_706_) opts.env, opts.scope = env, compiler["make-scope"]() opts.useMetadata = (opts.useMetadata ~= false) if (opts.allowedGlobals == nil) then @@ -580,15 +585,15 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee else end if opts.registerCompleter then - local function _707_() - local _705_ = env - local _706_ = opts.scope - local function _708_(...) - return completer(_705_, _706_, ...) + local function _710_() + local _708_ = env + local _709_ = opts.scope + local function _711_(...) + return completer(_708_, _709_, ...) end - return _708_ + return _711_ end - opts.registerCompleter(_707_()) + opts.registerCompleter(_710_()) else end load_plugin_commands(opts.plugins) @@ -628,43 +633,43 @@ package.preload["conjure.aniseed.fennel.repl"] = package.preload["conjure.anisee else if not_eof_3f then do - local _712_, _713_ = nil, nil - local function _715_() - local _714_ = opts - _714_["source"] = src_string - return _714_ + local _715_, _716_ = nil, nil + local function _718_() + local _717_ = opts + _717_["source"] = src_string + return _717_ end - _712_, _713_ = pcall(compiler.compile, x, _715_()) - if ((_712_ == false) and (nil ~= _713_)) then - local msg = _713_ + _715_, _716_ = pcall(compiler.compile, x, _718_()) + if ((_715_ == false) and (nil ~= _716_)) then + local msg = _716_ clear_stream() on_error("Compile", msg) - elseif ((_712_ == true) and (nil ~= _713_)) then - local src = _713_ + elseif ((_715_ == true) and (nil ~= _716_)) then + local src = _716_ local src0 if save_locals_3f then src0 = splice_save_locals(env, src, opts.scope) else src0 = src end - local _717_, _718_ = pcall(specials["load-code"], src0, env) - if ((_717_ == false) and (nil ~= _718_)) then - local msg = _718_ + local _720_, _721_ = pcall(specials["load-code"], src0, env) + if ((_720_ == false) and (nil ~= _721_)) then + local msg = _721_ clear_stream() on_error("Lua Compile", msg, src0) - elseif (true and (nil ~= _718_)) then - local _ = _717_ - local chunk = _718_ - local function _719_() + elseif (true and (nil ~= _721_)) then + local _ = _720_ + local chunk = _721_ + local function _722_() return print_values(chunk()) end - local function _720_() - local function _721_(...) + local function _723_() + local function _724_(...) return on_error("Runtime", ...) end - return _721_ + return _724_ end - xpcall(_719_, _720_()) + xpcall(_722_, _723_()) else end else @@ -694,14 +699,14 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an local unpack = (table.unpack or _G.unpack) local SPECIALS = compiler.scopes.global.specials local function wrap_env(env) - local function _411_(_, key) + local function _415_(_, key) if utils["string?"](key) then return env[compiler["global-unmangling"](key)] else return env[key] end end - local function _413_(_, key, value) + local function _417_(_, key, value) if utils["string?"](key) then env[compiler["global-unmangling"](key)] = value return nil @@ -710,38 +715,38 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an return nil end end - local function _415_() + local function _419_() local function putenv(k, v) - local _416_ + local _420_ if utils["string?"](k) then - _416_ = compiler["global-unmangling"](k) + _420_ = compiler["global-unmangling"](k) else - _416_ = k + _420_ = k end - return _416_, v + return _420_, v end return next, utils.kvmap(env, putenv), nil end - return setmetatable({}, {__index = _411_, __newindex = _413_, __pairs = _415_}) + return setmetatable({}, {__index = _415_, __newindex = _417_, __pairs = _419_}) end local function current_global_names(_3fenv) local mt do - local _418_ = getmetatable(_3fenv) - if ((_G.type(_418_) == "table") and (nil ~= (_418_).__pairs)) then - local mtpairs = (_418_).__pairs + local _422_ = getmetatable(_3fenv) + if ((_G.type(_422_) == "table") and (nil ~= (_422_).__pairs)) then + local mtpairs = (_422_).__pairs local tbl_11_auto = {} for k, v in mtpairs(_3fenv) do - local _419_, _420_ = k, v - if ((nil ~= _419_) and (nil ~= _420_)) then - local k_12_auto = _419_ - local v_13_auto = _420_ + local _423_, _424_ = k, v + if ((nil ~= _423_) and (nil ~= _424_)) then + local k_12_auto = _423_ + local v_13_auto = _424_ tbl_11_auto[k_12_auto] = v_13_auto else end end mt = tbl_11_auto - elseif (_418_ == nil) then + elseif (_422_ == nil) then mt = (_3fenv or _G) else mt = nil @@ -751,16 +756,16 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an end local function load_code(code, _3fenv, _3ffilename) local env = (_3fenv or rawget(_G, "_ENV") or _G) - local _423_, _424_ = rawget(_G, "setfenv"), rawget(_G, "loadstring") - if ((nil ~= _423_) and (nil ~= _424_)) then - local setfenv = _423_ - local loadstring = _424_ + local _427_, _428_ = rawget(_G, "setfenv"), rawget(_G, "loadstring") + if ((nil ~= _427_) and (nil ~= _428_)) then + local setfenv = _427_ + local loadstring = _428_ local f = assert(loadstring(code, _3ffilename)) - local _425_ = f - setfenv(_425_, env) - return _425_ + local _429_ = f + setfenv(_429_, env) + return _429_ elseif true then - local _ = _423_ + local _ = _427_ return assert(load(code, _3ffilename, "t", env)) else return nil @@ -774,13 +779,13 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an local mt = getmetatable(tgt) if ((type(tgt) == "function") or ((type(mt) == "table") and (type(mt.__call) == "function"))) then local arglist = table.concat(((compiler.metadata):get(tgt, "fnl/arglist") or {"#"}), " ") - local _427_ + local _431_ if (0 < #arglist) then - _427_ = " " + _431_ = " " else - _427_ = "" + _431_ = "" end - return string.format("(%s%s%s)\n %s", name, _427_, arglist, docstring) + return string.format("(%s%s%s)\n %s", name, _431_, arglist, docstring) else return string.format("%s\n %s", name, docstring) end @@ -869,7 +874,7 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an doc_special("values", {"..."}, "Return multiple values from a function. Must be in tail position.") local function deep_tostring(x, key_3f) if utils["list?"](x) then - local _436_ + local _440_ do local tbl_14_auto = {} local i_15_auto = #tbl_14_auto @@ -881,11 +886,11 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an else end end - _436_ = tbl_14_auto + _440_ = tbl_14_auto end - return ("(" .. table.concat(_436_, " ") .. ")") + return ("(" .. table.concat(_440_, " ") .. ")") elseif utils["sequence?"](x) then - local _438_ + local _442_ do local tbl_14_auto = {} local i_15_auto = #tbl_14_auto @@ -897,15 +902,15 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an else end end - _438_ = tbl_14_auto + _442_ = tbl_14_auto end - return ("[" .. table.concat(_438_, " ") .. "]") + return ("[" .. table.concat(_442_, " ") .. "]") elseif utils["table?"](x) then - local _440_ + local _444_ do local tbl_14_auto = {} local i_15_auto = #tbl_14_auto - for k, v in pairs(x) do + for k, v in utils.stablepairs(x) do local val_16_auto = (deep_tostring(k, true) .. " " .. deep_tostring(v)) if (nil ~= val_16_auto) then i_15_auto = (i_15_auto + 1) @@ -913,9 +918,9 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an else end end - _440_ = tbl_14_auto + _444_ = tbl_14_auto end - return ("{" .. table.concat(_440_, " ") .. "}") + return ("{" .. table.concat(_444_, " ") .. "}") elseif (key_3f and utils["string?"](x) and x:find("^[-%w?\\^_!$%&*+./@:|<=>]+$")) then return (":" .. x) elseif utils["string?"](x) then @@ -927,10 +932,10 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an local function set_fn_metadata(arg_list, docstring, parent, fn_name) if utils.root.options.useMetadata then local args - local function _443_(_241) + local function _447_(_241) return ("\"%s\""):format(deep_tostring(_241)) end - args = utils.map(arg_list, _443_) + args = utils.map(arg_list, _447_) local meta_fields = {"\"fnl/arglist\"", ("{" .. table.concat(args, ", ") .. "}")} if docstring then table.insert(meta_fields, "\"fnl/docstring\"") @@ -945,13 +950,13 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an end local function get_fn_name(ast, scope, fn_name, multi) if (fn_name and (fn_name[1] ~= "nil")) then - local _446_ + local _450_ if not multi then - _446_ = compiler["declare-local"](fn_name, {}, scope, ast) + _450_ = compiler["declare-local"](fn_name, {}, scope, ast) else - _446_ = (compiler["symbol-to-expression"](fn_name, scope))[1] + _450_ = (compiler["symbol-to-expression"](fn_name, scope))[1] end - return _446_, not multi, 3 + return _450_, not multi, 3 else return nil, true, 2 end @@ -960,13 +965,13 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an for i = (index + 1), #ast do compiler.compile1(ast[i], f_scope, f_chunk, {nval = (((i ~= #ast) and 0) or nil), tail = (i == #ast)}) end - local _449_ + local _453_ if local_3f then - _449_ = "local function %s(%s)" + _453_ = "local function %s(%s)" else - _449_ = "%s = function(%s)" + _453_ = "%s = function(%s)" end - compiler.emit(parent, string.format(_449_, fn_name, table.concat(arg_name_list, ", ")), ast) + compiler.emit(parent, string.format(_453_, fn_name, table.concat(arg_name_list, ", ")), ast) compiler.emit(parent, f_chunk, ast) compiler.emit(parent, "end", ast) set_fn_metadata(f_metadata["fnl/arglist"], f_metadata["fnl/docstring"], parent, fn_name) @@ -982,29 +987,29 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an local index_2a = (index + 1) local expr = ast[index_2a] if (utils["string?"](expr) and (index_2a < #ast)) then - local _452_ + local _456_ do - local _451_ = f_metadata - _451_["fnl/docstring"] = expr - _452_ = _451_ + local _455_ = f_metadata + _455_["fnl/docstring"] = expr + _456_ = _455_ end - return _452_, index_2a + return _456_, index_2a elseif (utils["table?"](expr) and (index_2a < #ast)) then - local _453_ + local _457_ do local tbl_11_auto = f_metadata for k, v in pairs(expr) do - local _454_, _455_ = k, v - if ((nil ~= _454_) and (nil ~= _455_)) then - local k_12_auto = _454_ - local v_13_auto = _455_ + local _458_, _459_ = k, v + if ((nil ~= _458_) and (nil ~= _459_)) then + local k_12_auto = _458_ + local v_13_auto = _459_ tbl_11_auto[k_12_auto] = v_13_auto else end end - _453_ = tbl_11_auto + _457_ = tbl_11_auto end - return _453_, index_2a + return _457_, index_2a else return f_metadata, index end @@ -1012,9 +1017,9 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an SPECIALS.fn = function(ast, scope, parent) local f_scope do - local _458_ = compiler["make-scope"](scope) - do end (_458_)["vararg"] = false - f_scope = _458_ + local _462_ = compiler["make-scope"](scope) + do end (_462_)["vararg"] = false + f_scope = _462_ end local f_chunk = {} local fn_sym = utils["sym?"](ast[2]) @@ -1049,29 +1054,29 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an doc_special("fn", {"name?", "args", "docstring?", "..."}, "Function syntax. May optionally include a name and docstring or a metadata table.\nIf a name is provided, the function will be bound in the current scope.\nWhen called with the wrong number of args, excess args will be discarded\nand lacking args will be nil, use lambda for arity-checked functions.", true) SPECIALS.lua = function(ast, _, parent) compiler.assert(((#ast == 2) or (#ast == 3)), "expected 1 or 2 arguments", ast) - local _462_ + local _466_ do - local _461_ = utils["sym?"](ast[2]) - if (nil ~= _461_) then - _462_ = tostring(_461_) + local _465_ = utils["sym?"](ast[2]) + if (nil ~= _465_) then + _466_ = tostring(_465_) else - _462_ = _461_ + _466_ = _465_ end end - if ("nil" ~= _462_) then + if ("nil" ~= _466_) then table.insert(parent, {ast = ast, leaf = tostring(ast[2])}) else end - local _466_ + local _470_ do - local _465_ = utils["sym?"](ast[3]) - if (nil ~= _465_) then - _466_ = tostring(_465_) + local _469_ = utils["sym?"](ast[3]) + if (nil ~= _469_) then + _470_ = tostring(_469_) else - _466_ = _465_ + _470_ = _469_ end end - if ("nil" ~= _466_) then + if ("nil" ~= _470_) then return tostring(ast[3]) else return nil @@ -1080,8 +1085,8 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an local function dot(ast, scope, parent) compiler.assert((1 < #ast), "expected table argument", ast) local len = #ast - local _let_469_ = compiler.compile1(ast[2], scope, parent, {nval = 1}) - local lhs = _let_469_[1] + local _let_473_ = compiler.compile1(ast[2], scope, parent, {nval = 1}) + local lhs = _let_473_[1] if (len == 2) then return tostring(lhs) else @@ -1091,8 +1096,8 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an if (utils["string?"](index) and utils["valid-lua-identifier?"](index)) then table.insert(indices, ("." .. index)) else - local _let_470_ = compiler.compile1(index, scope, parent, {nval = 1}) - local index0 = _let_470_[1] + local _let_474_ = compiler.compile1(index, scope, parent, {nval = 1}) + local index0 = _let_474_[1] table.insert(indices, ("[" .. tostring(index0) .. "]")) end end @@ -1137,7 +1142,7 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an end doc_special("var", {"name", "val"}, "Introduce new mutable local.") local function kv_3f(t) - local _474_ + local _478_ do local tbl_14_auto = {} local i_15_auto = #tbl_14_auto @@ -1154,9 +1159,9 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an else end end - _474_ = tbl_14_auto + _478_ = tbl_14_auto end - return (_474_)[1] + return (_478_)[1] end SPECIALS.let = function(ast, scope, parent, opts) local bindings = ast[2] @@ -1183,24 +1188,24 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an end end local function disambiguate_3f(rootstr, parent) - local function _479_() - local _478_ = get_prev_line(parent) - if (nil ~= _478_) then - local prev_line = _478_ + local function _483_() + local _482_ = get_prev_line(parent) + if (nil ~= _482_) then + local prev_line = _482_ return prev_line:match("%)$") else return nil end end - return (rootstr:match("^{") or _479_()) + return (rootstr:match("^{") or _483_()) end SPECIALS.tset = function(ast, scope, parent) compiler.assert((3 < #ast), "expected table, key, and value arguments", ast) local root = (compiler.compile1(ast[2], scope, parent, {nval = 1}))[1] local keys = {} for i = 3, (#ast - 1) do - local _let_481_ = compiler.compile1(ast[i], scope, parent, {nval = 1}) - local key = _let_481_[1] + local _let_485_ = compiler.compile1(ast[i], scope, parent, {nval = 1}) + local key = _let_485_[1] table.insert(keys, tostring(key)) end local value = (compiler.compile1(ast[#ast], scope, parent, {nval = 1}))[1] @@ -1324,8 +1329,8 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an end local function compile_until(condition, scope, chunk) if condition then - local _let_490_ = compiler.compile1(condition, scope, chunk, {nval = 1}) - local condition_lua = _let_490_[1] + local _let_494_ = compiler.compile1(condition, scope, chunk, {nval = 1}) + local condition_lua = _let_494_[1] return compiler.emit(chunk, ("if %s then break end"):format(tostring(condition_lua)), utils.expr(condition, "expression")) else return nil @@ -1408,10 +1413,10 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an SPECIALS["for"] = for_2a doc_special("for", {"[index start stop step?]", "..."}, "Numeric loop construct.\nEvaluates body once for each value between start and stop (inclusive).", true) local function native_method_call(ast, _scope, _parent, target, args) - local _let_494_ = ast - local _ = _let_494_[1] - local _0 = _let_494_[2] - local method_string = _let_494_[3] + local _let_498_ = ast + local _ = _let_498_[1] + local _0 = _let_498_[2] + local method_string = _let_498_[3] local call_string if ((target.type == "literal") or (target.type == "varg") or (target.type == "expression")) then call_string = "(%s):%s(%s)" @@ -1433,18 +1438,18 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an end local function method_call(ast, scope, parent) compiler.assert((2 < #ast), "expected at least 2 arguments", ast) - local _let_496_ = compiler.compile1(ast[2], scope, parent, {nval = 1}) - local target = _let_496_[1] + local _let_500_ = compiler.compile1(ast[2], scope, parent, {nval = 1}) + local target = _let_500_[1] local args = {} for i = 4, #ast do local subexprs - local _497_ + local _501_ if (i ~= #ast) then - _497_ = 1 + _501_ = 1 else - _497_ = nil + _501_ = nil end - subexprs = compiler.compile1(ast[i], scope, parent, {nval = _497_}) + subexprs = compiler.compile1(ast[i], scope, parent, {nval = _501_}) utils.map(subexprs, tostring, args) end if (utils["string?"](ast[3]) and utils["valid-lua-identifier?"](ast[3])) then @@ -1482,10 +1487,10 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an compiler.assert((#ast == 2), "expected one argument", ast) local f_scope do - local _502_ = compiler["make-scope"](scope) - do end (_502_)["vararg"] = false - _502_["hashfn"] = true - f_scope = _502_ + local _506_ = compiler["make-scope"](scope) + do end (_506_)["vararg"] = false + _506_["hashfn"] = true + f_scope = _506_ end local f_chunk = {} local name = compiler.gensym(scope) @@ -1523,9 +1528,9 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an return utils.expr(name, "sym") end doc_special("hashfn", {"..."}, "Function literal shorthand; args are either $... OR $1, $2, etc.") - local function maybe_short_circuit_protect(ast, i, name, _506_) - local _arg_507_ = _506_ - local mac = _arg_507_["macros"] + local function maybe_short_circuit_protect(ast, i, name, _510_) + local _arg_511_ = _510_ + local mac = _arg_511_["macros"] local call = (utils["list?"](ast) and tostring(ast[1])) if ((("or" == name) or ("and" == name)) and (1 < i) and (mac[call] or ("set" == call) or ("tset" == call) or ("global" == call))) then return utils.list(utils.sym("do"), ast) @@ -1546,40 +1551,40 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an table.insert(operands, tostring(subexprs[1])) end end - local _510_ = #operands - if (_510_ == 0) then - local _512_ + local _514_ = #operands + if (_514_ == 0) then + local _516_ do - local _511_ = zero_arity - compiler.assert(_511_, "Expected more than 0 arguments", ast) - _512_ = _511_ + local _515_ = zero_arity + compiler.assert(_515_, "Expected more than 0 arguments", ast) + _516_ = _515_ end - return utils.expr(_512_, "literal") - elseif (_510_ == 1) then + return utils.expr(_516_, "literal") + elseif (_514_ == 1) then if unary_prefix then return ("(" .. unary_prefix .. padded_op .. operands[1] .. ")") else return operands[1] end elseif true then - local _ = _510_ + local _ = _514_ return ("(" .. table.concat(operands, padded_op) .. ")") else return nil end end local function define_arithmetic_special(name, zero_arity, unary_prefix, _3flua_name) - local _518_ + local _522_ do - local _515_ = (_3flua_name or name) - local _516_ = zero_arity - local _517_ = unary_prefix - local function _519_(...) - return arithmetic_special(_515_, _516_, _517_, ...) + local _519_ = (_3flua_name or name) + local _520_ = zero_arity + local _521_ = unary_prefix + local function _523_(...) + return arithmetic_special(_519_, _520_, _521_, ...) end - _518_ = _519_ + _522_ = _523_ end - SPECIALS[name] = _518_ + SPECIALS[name] = _522_ return doc_special(name, {"a", "b", "..."}, "Arithmetic operator; works the same as Lua but accepts more arguments.") end define_arithmetic_special("+", "0") @@ -1608,13 +1613,13 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an local prefixed_lib_name = ("bit." .. lib_name) for i = 2, len do local subexprs - local _520_ + local _524_ if (i ~= len) then - _520_ = 1 + _524_ = 1 else - _520_ = nil + _524_ = nil end - subexprs = compiler.compile1(ast[i], scope, parent, {nval = _520_}) + subexprs = compiler.compile1(ast[i], scope, parent, {nval = _524_}) utils.map(subexprs, tostring, operands) end if (#operands == 1) then @@ -1633,18 +1638,18 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an end end local function define_bitop_special(name, zero_arity, unary_prefix, native) - local _530_ + local _534_ do - local _526_ = native - local _527_ = name - local _528_ = zero_arity - local _529_ = unary_prefix - local function _531_(...) - return bitop_special(_526_, _527_, _528_, _529_, ...) + local _530_ = native + local _531_ = name + local _532_ = zero_arity + local _533_ = unary_prefix + local function _535_(...) + return bitop_special(_530_, _531_, _532_, _533_, ...) end - _530_ = _531_ + _534_ = _535_ end - SPECIALS[name] = _530_ + SPECIALS[name] = _534_ return nil end define_bitop_special("lshift", nil, "1", "<<") @@ -1658,15 +1663,15 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an doc_special("bor", {"x1", "x2", "..."}, "Bitwise OR of any number of arguments.\nOnly works in Lua 5.3+ or LuaJIT with the --use-bit-lib flag.") doc_special("bxor", {"x1", "x2", "..."}, "Bitwise XOR of any number of arguments.\nOnly works in Lua 5.3+ or LuaJIT with the --use-bit-lib flag.") doc_special("..", {"a", "b", "..."}, "String concatenation operator; works the same as Lua but accepts more arguments.") - local function native_comparator(op, _532_, scope, parent) - local _arg_533_ = _532_ - local _ = _arg_533_[1] - local lhs_ast = _arg_533_[2] - local rhs_ast = _arg_533_[3] - local _let_534_ = compiler.compile1(lhs_ast, scope, parent, {nval = 1}) - local lhs = _let_534_[1] - local _let_535_ = compiler.compile1(rhs_ast, scope, parent, {nval = 1}) - local rhs = _let_535_[1] + local function native_comparator(op, _536_, scope, parent) + local _arg_537_ = _536_ + local _ = _arg_537_[1] + local lhs_ast = _arg_537_[2] + local rhs_ast = _arg_537_[3] + local _let_538_ = compiler.compile1(lhs_ast, scope, parent, {nval = 1}) + local lhs = _let_538_[1] + local _let_539_ = compiler.compile1(rhs_ast, scope, parent, {nval = 1}) + local rhs = _let_539_[1] return string.format("(%s %s %s)", tostring(lhs), op, tostring(rhs)) end local function double_eval_protected_comparator(op, chain_op, ast, scope, parent) @@ -1742,21 +1747,21 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an end local safe_require = nil local function safe_compiler_env() - local _539_ + local _543_ do - local _538_ = rawget(_G, "utf8") - if (nil ~= _538_) then - _539_ = utils.copy(_538_) + local _542_ = rawget(_G, "utf8") + if (nil ~= _542_) then + _543_ = utils.copy(_542_) else - _539_ = _538_ + _543_ = _542_ end end - return {table = utils.copy(table), math = utils.copy(math), string = utils.copy(string), pairs = pairs, ipairs = ipairs, select = select, tostring = tostring, tonumber = tonumber, bit = rawget(_G, "bit"), pcall = pcall, xpcall = xpcall, next = next, print = print, type = type, assert = assert, error = error, setmetatable = setmetatable, getmetatable = safe_getmetatable, require = safe_require, rawlen = rawget(_G, "rawlen"), rawget = rawget, rawset = rawset, rawequal = rawequal, _VERSION = _VERSION, utf8 = _539_} + return {table = utils.copy(table), math = utils.copy(math), string = utils.copy(string), pairs = utils.stablepairs, ipairs = ipairs, select = select, tostring = tostring, tonumber = tonumber, bit = rawget(_G, "bit"), pcall = pcall, xpcall = xpcall, next = next, print = print, type = type, assert = assert, error = error, setmetatable = setmetatable, getmetatable = safe_getmetatable, require = safe_require, rawlen = rawget(_G, "rawlen"), rawget = rawget, rawset = rawset, rawequal = rawequal, _VERSION = _VERSION, utf8 = _543_} end local function combined_mt_pairs(env) local combined = {} - local _let_541_ = getmetatable(env) - local __index = _let_541_["__index"] + local _let_545_ = getmetatable(env) + local __index = _let_545_["__index"] if ("table" == type(__index)) then for k, v in pairs(__index) do combined[k] = v @@ -1771,42 +1776,42 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an local function make_compiler_env(ast, scope, parent, _3fopts) local provided do - local _543_ = (_3fopts or utils.root.options) - if ((_G.type(_543_) == "table") and ((_543_)["compiler-env"] == "strict")) then + local _547_ = (_3fopts or utils.root.options) + if ((_G.type(_547_) == "table") and ((_547_)["compiler-env"] == "strict")) then provided = safe_compiler_env() - elseif ((_G.type(_543_) == "table") and (nil ~= (_543_).compilerEnv)) then - local compilerEnv = (_543_).compilerEnv + elseif ((_G.type(_547_) == "table") and (nil ~= (_547_).compilerEnv)) then + local compilerEnv = (_547_).compilerEnv provided = compilerEnv - elseif ((_G.type(_543_) == "table") and (nil ~= (_543_)["compiler-env"])) then - local compiler_env = (_543_)["compiler-env"] + elseif ((_G.type(_547_) == "table") and (nil ~= (_547_)["compiler-env"])) then + local compiler_env = (_547_)["compiler-env"] provided = compiler_env elseif true then - local _ = _543_ + local _ = _547_ provided = safe_compiler_env(false) else provided = nil end end local env - local function _545_(base) + local function _549_(base) return utils.sym(compiler.gensym((compiler.scopes.macro or scope), base)) end - local function _546_() + local function _550_() return compiler.scopes.macro end - local function _547_(symbol) + local function _551_(symbol) compiler.assert(compiler.scopes.macro, "must call from macro", ast) return compiler.scopes.macro.manglings[tostring(symbol)] end - local function _548_(form) + local function _552_(form) compiler.assert(compiler.scopes.macro, "must call from macro", ast) return compiler.macroexpand(form, compiler.scopes.macro) end - env = {_AST = ast, _CHUNK = parent, _IS_COMPILER = true, _SCOPE = scope, _SPECIALS = compiler.scopes.global.specials, _VARARG = utils.varg(), ["macro-loaded"] = macro_loaded, unpack = unpack, ["assert-compile"] = compiler.assert, view = view, version = utils.version, metadata = compiler.metadata, ["ast-source"] = utils["ast-source"], list = utils.list, ["list?"] = utils["list?"], ["table?"] = utils["table?"], sequence = utils.sequence, ["sequence?"] = utils["sequence?"], sym = utils.sym, ["sym?"] = utils["sym?"], ["multi-sym?"] = utils["multi-sym?"], comment = utils.comment, ["comment?"] = utils["comment?"], ["varg?"] = utils["varg?"], gensym = _545_, ["get-scope"] = _546_, ["in-scope?"] = _547_, macroexpand = _548_} + env = {_AST = ast, _CHUNK = parent, _IS_COMPILER = true, _SCOPE = scope, _SPECIALS = compiler.scopes.global.specials, _VARARG = utils.varg(), ["macro-loaded"] = macro_loaded, unpack = unpack, ["assert-compile"] = compiler.assert, view = view, version = utils.version, metadata = compiler.metadata, ["ast-source"] = utils["ast-source"], list = utils.list, ["list?"] = utils["list?"], ["table?"] = utils["table?"], sequence = utils.sequence, ["sequence?"] = utils["sequence?"], sym = utils.sym, ["sym?"] = utils["sym?"], ["multi-sym?"] = utils["multi-sym?"], comment = utils.comment, ["comment?"] = utils["comment?"], ["varg?"] = utils["varg?"], gensym = _549_, ["get-scope"] = _550_, ["in-scope?"] = _551_, macroexpand = _552_} env._G = env return setmetatable(env, {__index = provided, __newindex = provided, __pairs = combined_mt_pairs}) end - local function _550_(...) + local function _554_(...) local tbl_14_auto = {} local i_15_auto = #tbl_14_auto for c in string.gmatch((package.config or ""), "([^\n]+)") do @@ -1819,10 +1824,10 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an end return tbl_14_auto end - local _local_549_ = _550_(...) - local dirsep = _local_549_[1] - local pathsep = _local_549_[2] - local pathmark = _local_549_[3] + local _local_553_ = _554_(...) + local dirsep = _local_553_[1] + local pathsep = _local_553_[2] + local pathmark = _local_553_[3] local pkg_config = {dirsep = (dirsep or "/"), pathmark = (pathmark or ";"), pathsep = (pathsep or "?")} local function escapepat(str) return string.gsub(str, "[^%w]", "%%%1") @@ -1835,40 +1840,40 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an local function try_path(path) local filename = path:gsub(escapepat(pkg_config.pathmark), no_dot_module) local filename2 = path:gsub(escapepat(pkg_config.pathmark), modulename) - local _552_ = (io.open(filename) or io.open(filename2)) - if (nil ~= _552_) then - local file = _552_ + local _556_ = (io.open(filename) or io.open(filename2)) + if (nil ~= _556_) then + local file = _556_ file:close() return filename elseif true then - local _ = _552_ + local _ = _556_ return nil, ("no file '" .. filename .. "'") else return nil end end local function find_in_path(start, _3ftried_paths) - local _554_ = fullpath:match(pattern, start) - if (nil ~= _554_) then - local path = _554_ - local _555_, _556_ = try_path(path) - if (nil ~= _555_) then - local filename = _555_ + local _558_ = fullpath:match(pattern, start) + if (nil ~= _558_) then + local path = _558_ + local _559_, _560_ = try_path(path) + if (nil ~= _559_) then + local filename = _559_ return filename - elseif ((_555_ == nil) and (nil ~= _556_)) then - local error = _556_ - local function _558_() - local _557_ = (_3ftried_paths or {}) - table.insert(_557_, error) - return _557_ + elseif ((_559_ == nil) and (nil ~= _560_)) then + local error = _560_ + local function _562_() + local _561_ = (_3ftried_paths or {}) + table.insert(_561_, error) + return _561_ end - return find_in_path((start + #path + 1), _558_()) + return find_in_path((start + #path + 1), _562_()) else return nil end elseif true then - local _ = _554_ - local function _560_() + local _ = _558_ + local function _564_() local tried_paths = table.concat((_3ftried_paths or {}), "\n\9") if (_VERSION < "Lua 5.4") then return ("\n\9" .. tried_paths) @@ -1876,7 +1881,7 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an return tried_paths end end - return nil, _560_() + return nil, _564_() else return nil end @@ -1884,33 +1889,33 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an return find_in_path(1) end local function make_searcher(_3foptions) - local function _563_(module_name) + local function _567_(module_name) local opts = utils.copy(utils.root.options) for k, v in pairs((_3foptions or {})) do opts[k] = v end opts["module-name"] = module_name - local _564_, _565_ = search_module(module_name) - if (nil ~= _564_) then - local filename = _564_ - local _568_ + local _568_, _569_ = search_module(module_name) + if (nil ~= _568_) then + local filename = _568_ + local _572_ do - local _566_ = filename - local _567_ = opts - local function _569_(...) - return utils["fennel-module"].dofile(_566_, _567_, ...) + local _570_ = filename + local _571_ = opts + local function _573_(...) + return utils["fennel-module"].dofile(_570_, _571_, ...) end - _568_ = _569_ + _572_ = _573_ end - return _568_, filename - elseif ((_564_ == nil) and (nil ~= _565_)) then - local error = _565_ + return _572_, filename + elseif ((_568_ == nil) and (nil ~= _569_)) then + local error = _569_ return error else return nil end end - return _563_ + return _567_ end local function dofile_with_searcher(fennel_macro_searcher, filename, opts, ...) local searchers = (package.loaders or package.searchers or {}) @@ -1922,42 +1927,42 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an local function fennel_macro_searcher(module_name) local opts do - local _571_ = utils.copy(utils.root.options) - do end (_571_)["module-name"] = module_name - _571_["env"] = "_COMPILER" - _571_["requireAsInclude"] = false - _571_["allowedGlobals"] = nil - opts = _571_ - end - local _572_ = search_module(module_name, utils["fennel-module"]["macro-path"]) - if (nil ~= _572_) then - local filename = _572_ - local _573_ + local _575_ = utils.copy(utils.root.options) + do end (_575_)["module-name"] = module_name + _575_["env"] = "_COMPILER" + _575_["requireAsInclude"] = false + _575_["allowedGlobals"] = nil + opts = _575_ + end + local _576_ = search_module(module_name, utils["fennel-module"]["macro-path"]) + if (nil ~= _576_) then + local filename = _576_ + local _577_ if (opts["compiler-env"] == _G) then - local _574_ = fennel_macro_searcher - local _575_ = filename - local _576_ = opts - local function _578_(...) - return dofile_with_searcher(_574_, _575_, _576_, ...) - end - _573_ = _578_ - else + local _578_ = fennel_macro_searcher local _579_ = filename local _580_ = opts local function _582_(...) - return utils["fennel-module"].dofile(_579_, _580_, ...) + return dofile_with_searcher(_578_, _579_, _580_, ...) + end + _577_ = _582_ + else + local _583_ = filename + local _584_ = opts + local function _586_(...) + return utils["fennel-module"].dofile(_583_, _584_, ...) end - _573_ = _582_ + _577_ = _586_ end - return _573_, filename + return _577_, filename else return nil end end local function lua_macro_searcher(module_name) - local _585_ = search_module(module_name, package.path) - if (nil ~= _585_) then - local filename = _585_ + local _589_ = search_module(module_name, package.path) + if (nil ~= _589_) then + local filename = _589_ local code do local f = io.open(filename) @@ -1969,10 +1974,10 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an return error(..., 0) end end - local function _587_() + local function _591_() return assert(f:read("*a")) end - code = close_handlers_8_auto(_G.xpcall(_587_, (package.loaded.fennel or debug).traceback)) + code = close_handlers_8_auto(_G.xpcall(_591_, (package.loaded.fennel or debug).traceback)) end local chunk = load_code(code, make_compiler_env(), filename) return chunk, filename @@ -1982,16 +1987,16 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an end local macro_searchers = {fennel_macro_searcher, lua_macro_searcher} local function search_macro_module(modname, n) - local _589_ = macro_searchers[n] - if (nil ~= _589_) then - local f = _589_ - local _590_, _591_ = f(modname) - if ((nil ~= _590_) and true) then - local loader = _590_ - local _3ffilename = _591_ + local _593_ = macro_searchers[n] + if (nil ~= _593_) then + local f = _593_ + local _594_, _595_ = f(modname) + if ((nil ~= _594_) and true) then + local loader = _594_ + local _3ffilename = _595_ return loader, _3ffilename elseif true then - local _ = _590_ + local _ = _594_ return search_macro_module(modname, (n + 1)) else return nil @@ -2007,29 +2012,29 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an return nil end end - local function _595_(modname) - local function _596_() + local function _599_(modname) + local function _600_() local loader, filename = search_macro_module(modname, 1) compiler.assert(loader, (modname .. " module not found.")) do end (macro_loaded)[modname] = loader(modname, filename) return macro_loaded[modname] end - return (macro_loaded[modname] or sandbox_fennel_module(modname) or _596_()) + return (macro_loaded[modname] or sandbox_fennel_module(modname) or _600_()) end - safe_require = _595_ + safe_require = _599_ local function add_macros(macros_2a, ast, scope) compiler.assert(utils["table?"](macros_2a), "expected macros to be table", ast) for k, v in pairs(macros_2a) do compiler.assert((type(v) == "function"), "expected each macro to be function", ast) - compiler["check-binding-valid"](utils.sym(k), scope, ast) + compiler["check-binding-valid"](utils.sym(k), scope, ast, {["macro?"] = true}) do end (scope.macros)[k] = v end return nil end - local function resolve_module_name(_597_, _scope, _parent, opts) - local _arg_598_ = _597_ - local filename = _arg_598_["filename"] - local second = _arg_598_[2] + local function resolve_module_name(_601_, _scope, _parent, opts) + local _arg_602_ = _601_ + local filename = _arg_602_["filename"] + local second = _arg_602_[2] local filename0 = (filename or (utils["table?"](second) and second.filename)) local module_name = utils.root.options["module-name"] local modexpr = compiler.compile(second, opts) @@ -2088,10 +2093,10 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an return error(..., 0) end end - local function _604_() + local function _608_() return assert(f:read("*all")):gsub("[\13\n]*$", "") end - src = close_handlers_8_auto(_G.xpcall(_604_, (package.loaded.fennel or debug).traceback)) + src = close_handlers_8_auto(_G.xpcall(_608_, (package.loaded.fennel or debug).traceback)) end local ret = utils.expr(("require(\"" .. mod .. "\")"), "statement") local target = ("package.preload[%q]"):format(mod) @@ -2123,12 +2128,12 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an compiler.assert((#ast == 2), "expected one argument", ast) local modexpr do - local _607_, _608_ = pcall(resolve_module_name, ast, scope, parent, opts) - if ((_607_ == true) and (nil ~= _608_)) then - local modname = _608_ + local _611_, _612_ = pcall(resolve_module_name, ast, scope, parent, opts) + if ((_611_ == true) and (nil ~= _612_)) then + local modname = _612_ modexpr = utils.expr(string.format("%q", modname), "literal") elseif true then - local _ = _607_ + local _ = _611_ modexpr = (compiler.compile1(ast[2], scope, parent, {nval = 1}))[1] else modexpr = nil @@ -2147,13 +2152,13 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an utils.root.options["module-name"] = mod _ = nil local res - local function _612_() - local _611_ = search_module(mod) - if (nil ~= _611_) then - local fennel_path = _611_ + local function _616_() + local _615_ = search_module(mod) + if (nil ~= _615_) then + local fennel_path = _615_ return include_path(ast, opts, fennel_path, mod, true) elseif true then - local _0 = _611_ + local _0 = _615_ local lua_path = search_module(mod, package.path) if lua_path then return include_path(ast, opts, lua_path, mod, false) @@ -2166,7 +2171,7 @@ package.preload["conjure.aniseed.fennel.specials"] = package.preload["conjure.an return nil end end - res = ((utils["member?"](mod, (utils.root.options.skipInclude or {})) and opts.fallback(modexpr, true)) or include_circular_fallback(mod, modexpr, opts.fallback, ast) or utils.root.scope.includes[mod] or _612_()) + res = ((utils["member?"](mod, (utils.root.options.skipInclude or {})) and opts.fallback(modexpr, true)) or include_circular_fallback(mod, modexpr, opts.fallback, ast) or utils.root.scope.includes[mod] or _616_()) utils.root.options["module-name"] = oldmod return res end @@ -2202,13 +2207,13 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an local scopes = {} local function make_scope(_3fparent) local parent = (_3fparent or scopes.global) - local _254_ + local _257_ if parent then - _254_ = ((parent.depth or 0) + 1) + _257_ = ((parent.depth or 0) + 1) else - _254_ = 0 + _257_ = 0 end - return {includes = setmetatable({}, {__index = (parent and parent.includes)}), macros = setmetatable({}, {__index = (parent and parent.macros)}), manglings = setmetatable({}, {__index = (parent and parent.manglings)}), specials = setmetatable({}, {__index = (parent and parent.specials)}), symmeta = setmetatable({}, {__index = (parent and parent.symmeta)}), unmanglings = setmetatable({}, {__index = (parent and parent.unmanglings)}), gensyms = setmetatable({}, {__index = (parent and parent.gensyms)}), autogensyms = setmetatable({}, {__index = (parent and parent.autogensyms)}), vararg = (parent and parent.vararg), depth = _254_, hashfn = (parent and parent.hashfn), refedglobals = {}, parent = parent} + return {includes = setmetatable({}, {__index = (parent and parent.includes)}), macros = setmetatable({}, {__index = (parent and parent.macros)}), manglings = setmetatable({}, {__index = (parent and parent.manglings)}), specials = setmetatable({}, {__index = (parent and parent.specials)}), symmeta = setmetatable({}, {__index = (parent and parent.symmeta)}), unmanglings = setmetatable({}, {__index = (parent and parent.unmanglings)}), gensyms = setmetatable({}, {__index = (parent and parent.gensyms)}), autogensyms = setmetatable({}, {__index = (parent and parent.autogensyms)}), vararg = (parent and parent.vararg), depth = _257_, hashfn = (parent and parent.hashfn), refedglobals = {}, parent = parent} end local function assert_msg(ast, msg) local ast_tbl @@ -2226,9 +2231,9 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an end local function assert_compile(condition, msg, ast) if not condition then - local _let_257_ = (utils.root.options or {}) - local source = _let_257_["source"] - local unfriendly = _let_257_["unfriendly"] + local _let_260_ = (utils.root.options or {}) + local source = _let_260_["source"] + local unfriendly = _let_260_["unfriendly"] if (nil == utils.hook("assert-compile", condition, msg, ast, utils.root.reset)) then utils.root.reset() if (unfriendly or not friend or not _G.io or not _G.io.read) then @@ -2248,33 +2253,33 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an scopes.macro = scopes.global local serialize_subst = {["\7"] = "\\a", ["\8"] = "\\b", ["\9"] = "\\t", ["\n"] = "n", ["\11"] = "\\v", ["\12"] = "\\f"} local function serialize_string(str) - local function _261_(_241) + local function _264_(_241) return ("\\" .. _241:byte()) end - return string.gsub(string.gsub(string.format("%q", str), ".", serialize_subst), "[\128-\255]", _261_) + return string.gsub(string.gsub(string.format("%q", str), ".", serialize_subst), "[\128-\255]", _264_) end local function global_mangling(str) if utils["valid-lua-identifier?"](str) then return str else - local function _262_(_241) + local function _265_(_241) return string.format("_%02x", _241:byte()) end - return ("__fnl_global__" .. str:gsub("[^%w]", _262_)) + return ("__fnl_global__" .. str:gsub("[^%w]", _265_)) end end local function global_unmangling(identifier) - local _264_ = string.match(identifier, "^__fnl_global__(.*)$") - if (nil ~= _264_) then - local rest = _264_ - local _265_ - local function _266_(_241) + local _267_ = string.match(identifier, "^__fnl_global__(.*)$") + if (nil ~= _267_) then + local rest = _267_ + local _268_ + local function _269_(_241) return string.char(tonumber(_241:sub(2), 16)) end - _265_ = string.gsub(rest, "_[%da-f][%da-f]", _266_) - return _265_ + _268_ = string.gsub(rest, "_[%da-f][%da-f]", _269_) + return _268_ elseif true then - local _ = _264_ + local _ = _267_ return identifier else return nil @@ -2300,10 +2305,10 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an raw = str end local mangling - local function _270_(_241) + local function _273_(_241) return string.format("_%02x", _241:byte()) end - mangling = string.gsub(string.gsub(raw, "-", "_"), "[^%w_]", _270_) + mangling = string.gsub(string.gsub(raw, "-", "_"), "[^%w_]", _273_) local unique = unique_mangling(mangling, mangling, scope, 0) do end (scope.unmanglings)[unique] = str do @@ -2356,27 +2361,36 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an return table.concat(parts, ".") end local function autogensym(base, scope) - local _273_ = utils["multi-sym?"](base) - if (nil ~= _273_) then - local parts = _273_ + local _276_ = utils["multi-sym?"](base) + if (nil ~= _276_) then + local parts = _276_ return combine_auto_gensym(parts, autogensym(parts[1], scope)) elseif true then - local _ = _273_ - local function _274_() + local _ = _276_ + local function _277_() local mangling = gensym(scope, base:sub(1, ( - 2)), "auto") do end (scope.autogensyms)[base] = mangling return mangling end - return (scope.autogensyms[base] or _274_()) + return (scope.autogensyms[base] or _277_()) else return nil end end - local function check_binding_valid(symbol, scope, ast) + local function check_binding_valid(symbol, scope, ast, _3fopts) local name = tostring(symbol) + local macro_3f + do + local t_279_ = _3fopts + if (nil ~= t_279_) then + t_279_ = (t_279_)["macro?"] + else + end + macro_3f = t_279_ + end assert_compile(not name:find("&"), "invalid character: &") assert_compile(not name:find("^%."), "invalid character: .") - assert_compile(not (scope.specials[name] or scope.macros[name]), ("local %s was overshadowed by a special form or macro"):format(name), ast) + assert_compile(not (scope.specials[name] or (not macro_3f and scope.macros[name])), ("local %s was overshadowed by a special form or macro"):format(name), ast) return assert_compile(not utils["quoted?"](symbol), string.format("macro tried to bind %s without gensym", name), symbol) end local function declare_local(symbol, meta, scope, ast, _3ftemp_manglings) @@ -2476,26 +2490,24 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an end return table.concat(out, "\n") end - local function flatten_chunk(sm, chunk, tab, depth) + local function flatten_chunk(file_sourcemap, chunk, tab, depth) if chunk.leaf then - local code = chunk.leaf - local info = chunk.ast - if sm then - table.insert(sm, {(info and info.filename), (info and info.line)}) - else - end - return code + local _let_291_ = utils["ast-source"](chunk.ast) + local filename = _let_291_["filename"] + local line = _let_291_["line"] + table.insert(file_sourcemap, {filename, line}) + return chunk.leaf else local tab0 do - local _287_ = tab - if (_287_ == true) then + local _292_ = tab + if (_292_ == true) then tab0 = " " - elseif (_287_ == false) then + elseif (_292_ == false) then tab0 = "" - elseif (_287_ == tab) then + elseif (_292_ == tab) then tab0 = tab - elseif (_287_ == nil) then + elseif (_292_ == nil) then tab0 = "" else tab0 = nil @@ -2503,7 +2515,7 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an end local function parter(c) if (c.leaf or (0 < #c)) then - local sub = flatten_chunk(sm, c, tab0, (depth + 1)) + local sub = flatten_chunk(file_sourcemap, c, tab0, (depth + 1)) if (0 < depth) then return (tab0 .. sub:gsub("\n", ("\n" .. tab0))) else @@ -2530,35 +2542,32 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an if options.correlate then return flatten_chunk_correlated(chunk0, options), {} else - local sm = {} - local ret = flatten_chunk(sm, chunk0, options.indent, 0) - if sm then - sm.short_src = (options.filename or make_short_src((options.source or ret))) - if options.filename then - sm.key = ("@" .. options.filename) - else - sm.key = ret - end - sourcemap[sm.key] = sm + local file_sourcemap = {} + local src = flatten_chunk(file_sourcemap, chunk0, options.indent, 0) + file_sourcemap.short_src = (options.filename or make_short_src((options.source or src))) + if options.filename then + file_sourcemap.key = ("@" .. options.filename) else + file_sourcemap.key = src end - return ret, sm + sourcemap[file_sourcemap.key] = file_sourcemap + return src, file_sourcemap end end local function make_metadata() - local function _296_(self, tgt, key) + local function _300_(self, tgt, key) if self[tgt] then return self[tgt][key] else return nil end end - local function _298_(self, tgt, key, value) + local function _302_(self, tgt, key, value) self[tgt] = (self[tgt] or {}) do end (self[tgt])[key] = value return tgt end - local function _299_(self, tgt, ...) + local function _303_(self, tgt, ...) local kv_len = select("#", ...) local kvs = {...} if ((kv_len % 2) ~= 0) then @@ -2571,7 +2580,7 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an end return tgt end - return setmetatable({}, {__index = {get = _296_, set = _298_, setall = _299_}, __mode = "k"}) + return setmetatable({}, {__index = {get = _300_, set = _302_, setall = _303_}, __mode = "k"}) end local function exprs1(exprs) return table.concat(utils.map(exprs, tostring), ", ") @@ -2621,37 +2630,37 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an end if opts.target then local result = exprs1(exprs) - local function _307_() + local function _311_() if (result == "") then return "nil" else return result end end - emit(parent, string.format("%s = %s", opts.target, _307_()), ast) + emit(parent, string.format("%s = %s", opts.target, _311_()), ast) else end if (opts.tail or opts.target) then return {returned = true} else - local _309_ = exprs - _309_["returned"] = true - return _309_ + local _313_ = exprs + _313_["returned"] = true + return _313_ end end local function find_macro(ast, scope) local macro_2a do - local _311_ = utils["sym?"](ast[1]) - if (_311_ ~= nil) then - local _312_ = tostring(_311_) - if (_312_ ~= nil) then - macro_2a = scope.macros[_312_] + local _315_ = utils["sym?"](ast[1]) + if (_315_ ~= nil) then + local _316_ = tostring(_315_) + if (_316_ ~= nil) then + macro_2a = scope.macros[_316_] else - macro_2a = _312_ + macro_2a = _316_ end else - macro_2a = _311_ + macro_2a = _315_ end end local multi_sym_parts = utils["multi-sym?"](ast[1]) @@ -2663,12 +2672,12 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an return macro_2a end end - local function propagate_trace_info(_316_, _index, node) - local _arg_317_ = _316_ - local filename = _arg_317_["filename"] - local line = _arg_317_["line"] - local bytestart = _arg_317_["bytestart"] - local byteend = _arg_317_["byteend"] + local function propagate_trace_info(_320_, _index, node) + local _arg_321_ = _320_ + local filename = _arg_321_["filename"] + local line = _arg_321_["line"] + local bytestart = _arg_321_["bytestart"] + local byteend = _arg_321_["byteend"] do local src = utils["ast-source"](node) if (("table" == type(node)) and (filename ~= src.filename)) then @@ -2692,8 +2701,8 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an local function quote_literal_nils(index, node, parent) if (parent and utils["list?"](parent)) then for i = 1, max_n(parent) do - local _320_ = parent[i] - if (_320_ == nil) then + local _324_ = parent[i] + if (_324_ == nil) then parent[i] = utils.sym("nil") else end @@ -2703,10 +2712,10 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an return index, node, parent end local function comp(f, g) - local function _323_(...) + local function _327_(...) return f(g(...)) end - return _323_ + return _327_ end local function built_in_3f(m) local found_3f = false @@ -2717,41 +2726,41 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an return found_3f end local function macroexpand_2a(ast, scope, _3fonce) - local _324_ + local _328_ if utils["list?"](ast) then - _324_ = find_macro(ast, scope) + _328_ = find_macro(ast, scope) else - _324_ = nil + _328_ = nil end - if (_324_ == false) then + if (_328_ == false) then return ast - elseif (nil ~= _324_) then - local macro_2a = _324_ + elseif (nil ~= _328_) then + local macro_2a = _328_ local old_scope = scopes.macro local _ scopes.macro = scope _ = nil local ok, transformed = nil, nil - local function _326_() + local function _330_() return macro_2a(unpack(ast, 2)) end - local function _327_() + local function _331_() if built_in_3f(macro_2a) then return tostring else return debug.traceback end end - ok, transformed = xpcall(_326_, _327_()) - local _329_ + ok, transformed = xpcall(_330_, _331_()) + local _333_ do - local _328_ = ast - local function _330_(...) - return propagate_trace_info(_328_, ...) + local _332_ = ast + local function _334_(...) + return propagate_trace_info(_332_, ...) end - _329_ = _330_ + _333_ = _334_ end - utils["walk-tree"](transformed, comp(_329_, quote_literal_nils)) + utils["walk-tree"](transformed, comp(_333_, quote_literal_nils)) scopes.macro = old_scope assert_compile(ok, transformed, ast) if (_3fonce or not transformed) then @@ -2760,7 +2769,7 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an return macroexpand_2a(transformed, scope) end elseif true then - local _ = _324_ + local _ = _328_ return ast else return nil @@ -2794,14 +2803,14 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an assert_compile((utils["sym?"](ast[1]) or utils["list?"](ast[1]) or ("string" == type(ast[1]))), ("cannot call literal value " .. tostring(ast[1])), ast) for i = 2, len do local subexprs - local _336_ + local _340_ if (i ~= len) then - _336_ = 1 + _340_ = 1 else - _336_ = nil + _340_ = nil end - subexprs = compile1(ast[i], scope, parent, {nval = _336_}) - table.insert(fargs, (subexprs[1] or utils.expr("nil", "literal"))) + subexprs = compile1(ast[i], scope, parent, {nval = _340_}) + table.insert(fargs, subexprs[1]) if (i == len) then for j = 2, #subexprs do table.insert(fargs, subexprs[j]) @@ -2838,13 +2847,13 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an end end local function compile_varg(ast, scope, parent, opts) - local _341_ + local _345_ if scope.hashfn then - _341_ = "use $... in hashfn" + _345_ = "use $... in hashfn" else - _341_ = "unexpected vararg" + _345_ = "unexpected vararg" end - assert_compile(scope.vararg, _341_, ast) + assert_compile(scope.vararg, _345_, ast) return handle_compile_opts({utils.expr("...", "varg")}, parent, opts, ast) end local function compile_sym(ast, scope, parent, opts) @@ -2859,20 +2868,20 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an return handle_compile_opts({e}, parent, opts, ast) end local function serialize_number(n) - local _344_ = string.gsub(tostring(n), ",", ".") - return _344_ + local _348_ = string.gsub(tostring(n), ",", ".") + return _348_ end local function compile_scalar(ast, _scope, parent, opts) local serialize do - local _345_ = type(ast) - if (_345_ == "nil") then + local _349_ = type(ast) + if (_349_ == "nil") then serialize = tostring - elseif (_345_ == "boolean") then + elseif (_349_ == "boolean") then serialize = tostring - elseif (_345_ == "string") then + elseif (_349_ == "string") then serialize = serialize_string - elseif (_345_ == "number") then + elseif (_349_ == "number") then serialize = serialize_number else serialize = nil @@ -2887,8 +2896,8 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an if ((type(k) == "string") and utils["valid-lua-identifier?"](k)) then return {k, k} else - local _let_347_ = compile1(k, scope, parent, {nval = 1}) - local compiled = _let_347_[1] + local _let_351_ = compile1(k, scope, parent, {nval = 1}) + local compiled = _let_351_[1] local kstr = ("[" .. tostring(compiled) .. "]") return {kstr, k} end @@ -2911,15 +2920,15 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an end keys = tbl_14_auto end - local function _353_(_351_) - local _arg_352_ = _351_ - local k1 = _arg_352_[1] - local k2 = _arg_352_[2] - local _let_354_ = compile1(ast[k2], scope, parent, {nval = 1}) - local v = _let_354_[1] + local function _357_(_355_) + local _arg_356_ = _355_ + local k1 = _arg_356_[1] + local k2 = _arg_356_[2] + local _let_358_ = compile1(ast[k2], scope, parent, {nval = 1}) + local v = _let_358_[1] return string.format("%s = %s", k1, tostring(v)) end - utils.map(keys, _353_, buffer) + utils.map(keys, _357_, buffer) end for i = 1, #ast do local nval = ((i ~= #ast) and 1) @@ -2946,12 +2955,12 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an end local function destructure(to, from, ast, scope, parent, opts) local opts0 = (opts or {}) - local _let_356_ = opts0 - local isvar = _let_356_["isvar"] - local declaration = _let_356_["declaration"] - local forceglobal = _let_356_["forceglobal"] - local forceset = _let_356_["forceset"] - local symtype = _let_356_["symtype"] + local _let_360_ = opts0 + local isvar = _let_360_["isvar"] + local declaration = _let_360_["declaration"] + local forceglobal = _let_360_["forceglobal"] + local forceset = _let_360_["forceset"] + local symtype = _let_360_["symtype"] local symtype0 = ("_" .. (symtype or "dst")) local setter if declaration then @@ -2990,14 +2999,14 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an end local function compile_top_target(lvalues) local inits - local function _362_(_241) + local function _366_(_241) if scope.manglings[_241] then return _241 else return "nil" end end - inits = utils.map(lvalues, _362_) + inits = utils.map(lvalues, _366_) local init = table.concat(inits, ", ") local lvalue = table.concat(lvalues, ", ") local plast = parent[#parent] @@ -3039,7 +3048,7 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an local unpack_fn = "function (t, k, e)\n local mt = getmetatable(t)\n if 'table' == type(mt) and mt.__fennelrest then\n return mt.__fennelrest(t, k)\n elseif e then\n local rest = {}\n for k, v in pairs(t) do\n if not e[k] then rest[k] = v end\n end\n return rest\n else\n return {(table.unpack or unpack)(t, k)}\n end\n end" local function destructure_kv_rest(s, v, left, excluded_keys, destructure1) local exclude_str - local _369_ + local _373_ do local tbl_14_auto = {} local i_15_auto = #tbl_14_auto @@ -3051,9 +3060,9 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an else end end - _369_ = tbl_14_auto + _373_ = tbl_14_auto end - exclude_str = table.concat(_369_, ", ") + exclude_str = table.concat(_373_, ", ") local subexpr = utils.expr(string.format(string.gsub(("(" .. unpack_fn .. ")(%s, %s, {%s})"), "\n%s*", " "), s, tostring(v), exclude_str), "expression") return destructure1(v, {subexpr}, left) end @@ -3068,16 +3077,16 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an local s = gensym(scope, symtype0) local right do - local _371_ + local _375_ if top_3f then - _371_ = exprs1(compile1(from, scope, parent)) + _375_ = exprs1(compile1(from, scope, parent)) else - _371_ = exprs1(rightexprs) + _375_ = exprs1(rightexprs) end - if (_371_ == "") then + if (_375_ == "") then right = "nil" - elseif (nil ~= _371_) then - local right0 = _371_ + elseif (nil ~= _375_) then + local right0 = _375_ right = right0 else right = nil @@ -3250,14 +3259,14 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an else end if (info.what == "Lua") then - local function _391_() + local function _395_() if info.name then return ("'" .. info.name .. "'") else return "?" end end - return string.format(" %s:%d: in function %s", info.short_src, info.currentline, _391_()) + return string.format(" %s:%d: in function %s", info.short_src, info.currentline, _395_()) elseif (info.short_src == "(tail call)") then return " (tail call)" else @@ -3281,11 +3290,11 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an local done_3f, level = false, (_3fstart or 2) while not done_3f do do - local _395_ = debug.getinfo(level, "Sln") - if (_395_ == nil) then + local _399_ = debug.getinfo(level, "Sln") + if (_399_ == nil) then done_3f = true - elseif (nil ~= _395_) then - local info = _395_ + elseif (nil ~= _399_) then + local info = _399_ table.insert(lines, traceback_frame(info)) else end @@ -3296,14 +3305,14 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an end end local function entry_transform(fk, fv) - local function _398_(k, v) + local function _402_(k, v) if (type(k) == "number") then return k, fv(v) else return fk(k), fv(v) end end - return _398_ + return _402_ end local function mixed_concat(t, joiner) local seen = {} @@ -3349,10 +3358,10 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an return res[1] elseif utils["list?"](form) then local mapped - local function _403_() + local function _407_() return nil end - mapped = utils.kvmap(form, entry_transform(_403_, q)) + mapped = utils.kvmap(form, entry_transform(_407_, q)) local filename if form.filename then filename = string.format("%q", form.filename) @@ -3370,13 +3379,13 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an else filename = "nil" end - local _406_ + local _410_ if source then - _406_ = source.line + _410_ = source.line else - _406_ = "nil" + _410_ = "nil" end - return string.format("setmetatable({%s}, {filename=%s, line=%s, sequence=%s})", mixed_concat(mapped, ", "), filename, _406_, "(getmetatable(sequence()))['sequence']") + return string.format("setmetatable({%s}, {filename=%s, line=%s, sequence=%s})", mixed_concat(mapped, ", "), filename, _410_, "(getmetatable(sequence()))['sequence']") elseif (type(form) == "table") then local mapped = utils.kvmap(form, entry_transform(q, q)) local source = getmetatable(form) @@ -3386,14 +3395,14 @@ package.preload["conjure.aniseed.fennel.compiler"] = package.preload["conjure.an else filename = "nil" end - local function _409_() + local function _413_() if source then return source.line else return "nil" end end - return string.format("setmetatable({%s}, {filename=%s, line=%s})", mixed_concat(mapped, ", "), filename, _409_()) + return string.format("setmetatable({%s}, {filename=%s, line=%s})", mixed_concat(mapped, ", "), filename, _413_()) elseif (type(form) == "string") then return serialize_string(form) else @@ -3560,9 +3569,6 @@ package.preload["conjure.aniseed.fennel.parser"] = package.preload["conjure.anis return _195_ end local delims = {[40] = 41, [41] = true, [91] = 93, [93] = true, [123] = 125, [125] = true} - local function whitespace_3f(b) - return ((b == 32) or (function(_196_,_197_,_198_) return (_196_ <= _197_) and (_197_ <= _198_) end)(9,b,13)) - end local function sym_char_3f(b) local b0 if ("number" == type(b)) then @@ -3574,14 +3580,14 @@ package.preload["conjure.aniseed.fennel.parser"] = package.preload["conjure.anis end local prefixes = {[35] = "hashfn", [39] = "quote", [44] = "unquote", [96] = "quote"} local function char_starter_3f(b) - return ((function(_200_,_201_,_202_) return (_200_ < _201_) and (_201_ < _202_) end)(1,b,127) or (function(_203_,_204_,_205_) return (_203_ < _204_) and (_204_ < _205_) end)(192,b,247)) - end - local function parser_fn(getbyte, filename, _206_) - local _arg_207_ = _206_ - local source = _arg_207_["source"] - local unfriendly = _arg_207_["unfriendly"] - local comments = _arg_207_["comments"] - local options = _arg_207_ + return ((function(_197_,_198_,_199_) return (_197_ < _198_) and (_198_ < _199_) end)(1,b,127) or (function(_200_,_201_,_202_) return (_200_ < _201_) and (_201_ < _202_) end)(192,b,247)) + end + local function parser_fn(getbyte, filename, _203_) + local _arg_204_ = _203_ + local source = _arg_204_["source"] + local unfriendly = _arg_204_["unfriendly"] + local comments = _arg_204_["comments"] + local options = _arg_204_ local stack = {} local line, byteindex, col, prev_col, lastb = 1, 0, 0, 0, nil local function ungetb(ub) @@ -3615,6 +3621,17 @@ package.preload["conjure.aniseed.fennel.parser"] = package.preload["conjure.anis end return r end + local function whitespace_3f(b) + local function _214_() + local t_213_ = options.whitespace + if (nil ~= t_213_) then + t_213_ = (t_213_)[b] + else + end + return t_213_ + end + return ((b == 32) or (function(_210_,_211_,_212_) return (_210_ <= _211_) and (_211_ <= _212_) end)(9,b,13) or _214_()) + end local function parse_error(msg, _3fcol_adjust) local col0 = (col + (_3fcol_adjust or -1)) if (nil == utils["hook-opts"]("parse-error", options, msg, filename, (line or "?"), col0, source, utils.root.reset)) then @@ -3635,25 +3652,25 @@ package.preload["conjure.aniseed.fennel.parser"] = package.preload["conjure.anis return nil end local function dispatch(v) - local _215_ = stack[#stack] - if (_215_ == nil) then + local _218_ = stack[#stack] + if (_218_ == nil) then retval, done_3f, whitespace_since_dispatch = v, true, false return nil - elseif ((_G.type(_215_) == "table") and (nil ~= (_215_).prefix)) then - local prefix = (_215_).prefix + elseif ((_G.type(_218_) == "table") and (nil ~= (_218_).prefix)) then + local prefix = (_218_).prefix local source0 do - local _216_ = table.remove(stack) - set_source_fields(_216_) - source0 = _216_ + local _219_ = table.remove(stack) + set_source_fields(_219_) + source0 = _219_ end local list = utils.list(utils.sym(prefix, source0), v) for k, v0 in pairs(source0) do list[k] = v0 end return dispatch(list) - elseif (nil ~= _215_) then - local top = _215_ + elseif (nil ~= _218_) then + local top = _218_ whitespace_since_dispatch = false return table.insert(top, v) else @@ -3662,13 +3679,13 @@ package.preload["conjure.aniseed.fennel.parser"] = package.preload["conjure.anis end local function badend() local accum = utils.map(stack, "closer") - local _218_ + local _221_ if (#stack == 1) then - _218_ = "" + _221_ = "" else - _218_ = "s" + _221_ = "s" end - return parse_error(string.format("expected closing delimiter%s %s", _218_, string.char(unpack(accum)))) + return parse_error(string.format("expected closing delimiter%s %s", _221_, string.char(unpack(accum)))) end local function skip_whitespace(b) if (b and whitespace_3f(b)) then @@ -3682,16 +3699,17 @@ package.preload["conjure.aniseed.fennel.parser"] = package.preload["conjure.anis end local function parse_comment(b, contents) if (b and (10 ~= b)) then - local function _222_() - local _221_ = contents - table.insert(_221_, string.char(b)) - return _221_ + local function _225_() + local _224_ = contents + table.insert(_224_, string.char(b)) + return _224_ end - return parse_comment(getb(), _222_()) + return parse_comment(getb(), _225_()) elseif comments then + ungetb(10) return dispatch(utils.comment(table.concat(contents), {line = (line - 1), filename = filename})) else - return b + return nil end end local function open_table(b) @@ -3712,12 +3730,12 @@ package.preload["conjure.aniseed.fennel.parser"] = package.preload["conjure.anis return dispatch(val) end local function add_comment_at(comments0, index, node) - local _225_ = (comments0)[index] - if (nil ~= _225_) then - local existing = _225_ + local _228_ = (comments0)[index] + if (nil ~= _228_) then + local existing = _228_ return table.insert(existing, node) elseif true then - local _ = _225_ + local _ = _228_ comments0[index] = {node} return nil else @@ -3799,16 +3817,16 @@ package.preload["conjure.aniseed.fennel.parser"] = package.preload["conjure.anis table.insert(chars, b) local state0 do - local _235_ = {state, b} - if ((_G.type(_235_) == "table") and ((_235_)[1] == "base") and ((_235_)[2] == 92)) then + local _238_ = {state, b} + if ((_G.type(_238_) == "table") and ((_238_)[1] == "base") and ((_238_)[2] == 92)) then state0 = "backslash" - elseif ((_G.type(_235_) == "table") and ((_235_)[1] == "base") and ((_235_)[2] == 34)) then + elseif ((_G.type(_238_) == "table") and ((_238_)[1] == "base") and ((_238_)[2] == 34)) then state0 = "done" - elseif ((_G.type(_235_) == "table") and ((_235_)[1] == "backslash") and ((_235_)[2] == 10)) then + elseif ((_G.type(_238_) == "table") and ((_238_)[1] == "backslash") and ((_238_)[2] == 10)) then table.remove(chars, (#chars - 1)) state0 = "base" elseif true then - local _ = _235_ + local _ = _238_ state0 = "base" else state0 = nil @@ -3833,11 +3851,11 @@ package.preload["conjure.aniseed.fennel.parser"] = package.preload["conjure.anis table.remove(stack) local raw = string.char(unpack(chars)) local formatted = raw:gsub("[\7-\13]", escape_char) - local _239_ = (rawget(_G, "loadstring") or load)(("return " .. formatted)) - if (nil ~= _239_) then - local load_fn = _239_ + local _242_ = (rawget(_G, "loadstring") or load)(("return " .. formatted)) + if (nil ~= _242_) then + local load_fn = _242_ return dispatch(load_fn()) - elseif (_239_ == nil) then + elseif (_242_ == nil) then return parse_error(("Invalid string: " .. raw)) else return nil @@ -3875,13 +3893,13 @@ package.preload["conjure.aniseed.fennel.parser"] = package.preload["conjure.anis dispatch((tonumber(number_with_stripped_underscores) or parse_error(("could not read number \"" .. rawstr .. "\"")))) return true else - local _245_ = tonumber(number_with_stripped_underscores) - if (nil ~= _245_) then - local x = _245_ + local _248_ = tonumber(number_with_stripped_underscores) + if (nil ~= _248_) then + local x = _248_ dispatch(x) return true elseif true then - local _ = _245_ + local _ = _248_ return false else return nil @@ -3952,11 +3970,11 @@ package.preload["conjure.aniseed.fennel.parser"] = package.preload["conjure.anis end return parse_loop(skip_whitespace(getb())) end - local function _252_() + local function _255_() stack, line, byteindex, col, lastb = {}, 1, 0, 0, nil return nil end - return parse_stream, _252_ + return parse_stream, _255_ end local function parser(stream_or_string, _3ffilename, _3foptions) local filename = (_3ffilename or "unknown") @@ -4230,7 +4248,7 @@ package.preload["conjure.aniseed.fennel.view"] = package.preload["conjure.anisee do local tbl_14_auto = {} local i_15_auto = #tbl_14_auto - for _, _40_ in pairs(kv) do + for _, _40_ in ipairs(kv) do local _each_41_ = _40_ local k = _each_41_[1] local v = _each_41_[2] @@ -4274,7 +4292,7 @@ package.preload["conjure.aniseed.fennel.view"] = package.preload["conjure.anisee do local tbl_14_auto = {} local i_15_auto = #tbl_14_auto - for _, _45_ in pairs(kv) do + for _, _45_ in ipairs(kv) do local _each_46_ = _45_ local _0 = _each_46_[1] local v = _each_46_[2] @@ -4545,7 +4563,7 @@ package.preload["conjure.aniseed.fennel.view"] = package.preload["conjure.anisee end package.preload["conjure.aniseed.fennel.utils"] = package.preload["conjure.aniseed.fennel.utils"] or function(...) local view = require("conjure.aniseed.fennel.view") - local version = "1.2.0" + local version = "1.2.1" local function luajit_vm_3f() return ((nil ~= _G.jit) and (type(_G.jit) == "table") and (nil ~= _G.jit.on) and (nil ~= _G.jit.off) and (type(_G.jit.version_num) == "number")) end @@ -5104,14 +5122,14 @@ local function eval(str, options, ...) local env = eval_env(opts.env, opts) local lua_source = compiler["compile-string"](str, opts) local loader - local function _732_(...) + local function _735_(...) if opts.filename then return ("@" .. opts.filename) else return str end end - loader = specials["load-code"](lua_source, env, _732_(...)) + loader = specials["load-code"](lua_source, env, _735_(...)) opts.filename = nil return loader(...) end @@ -5136,10 +5154,10 @@ local function syntax() out[k] = {["macro?"] = true, ["body-form?"] = utils["member?"](k, body_3f), ["binding-form?"] = utils["member?"](k, binding_3f), ["define?"] = utils["member?"](k, define_3f)} end for k, v in pairs(_G) do - local _733_ = type(v) - if (_733_ == "function") then + local _736_ = type(v) + if (_736_ == "function") then out[k] = {["global?"] = true, ["function?"] = true} - elseif (_733_ == "table") then + elseif (_736_ == "table") then for k2, v2 in pairs(v) do if (("function" == type(v2)) and (k ~= "_G")) then out[(k .. "." .. k2)] = {["function?"] = true, ["global?"] = true} @@ -5152,7 +5170,11 @@ local function syntax() end return out end -local mod = {list = utils.list, ["list?"] = utils["list?"], sym = utils.sym, ["sym?"] = utils["sym?"], ["multi-sym?"] = utils["multi-sym?"], sequence = utils.sequence, ["sequence?"] = utils["sequence?"], comment = utils.comment, ["comment?"] = utils["comment?"], varg = utils.varg, ["varg?"] = utils["varg?"], ["sym-char?"] = parser["sym-char?"], parser = parser.parser, compile = compiler.compile, ["compile-string"] = compiler["compile-string"], ["compile-stream"] = compiler["compile-stream"], eval = eval, repl = repl, view = view, dofile = dofile_2a, ["load-code"] = specials["load-code"], doc = specials.doc, metadata = compiler.metadata, traceback = compiler.traceback, version = utils.version, ["runtime-version"] = utils["runtime-version"], ["ast-source"] = utils["ast-source"], path = utils.path, ["macro-path"] = utils["macro-path"], ["macro-loaded"] = specials["macro-loaded"], ["macro-searchers"] = specials["macro-searchers"], ["search-module"] = specials["search-module"], ["make-searcher"] = specials["make-searcher"], searcher = specials["make-searcher"](), syntax = syntax, gensym = compiler.gensym, scope = compiler["make-scope"], mangle = compiler["global-mangling"], unmangle = compiler["global-unmangling"], compile1 = compiler.compile1, ["string-stream"] = parser["string-stream"], granulate = parser.granulate, loadCode = specials["load-code"], make_searcher = specials["make-searcher"], makeSearcher = specials["make-searcher"], searchModule = specials["search-module"], macroPath = utils["macro-path"], macroSearchers = specials["macro-searchers"], macroLoaded = specials["macro-loaded"], compileStream = compiler["compile-stream"], compileString = compiler["compile-string"], stringStream = parser["string-stream"], runtimeVersion = utils["runtime-version"]} +local mod = {list = utils.list, ["list?"] = utils["list?"], sym = utils.sym, ["sym?"] = utils["sym?"], ["multi-sym?"] = utils["multi-sym?"], sequence = utils.sequence, ["sequence?"] = utils["sequence?"], ["table?"] = utils["table?"], comment = utils.comment, ["comment?"] = utils["comment?"], varg = utils.varg, ["varg?"] = utils["varg?"], ["sym-char?"] = parser["sym-char?"], parser = parser.parser, compile = compiler.compile, ["compile-string"] = compiler["compile-string"], ["compile-stream"] = compiler["compile-stream"], eval = eval, repl = repl, view = view, dofile = dofile_2a, ["load-code"] = specials["load-code"], doc = specials.doc, metadata = compiler.metadata, traceback = compiler.traceback, version = utils.version, ["runtime-version"] = utils["runtime-version"], ["ast-source"] = utils["ast-source"], path = utils.path, ["macro-path"] = utils["macro-path"], ["macro-loaded"] = specials["macro-loaded"], ["macro-searchers"] = specials["macro-searchers"], ["search-module"] = specials["search-module"], ["make-searcher"] = specials["make-searcher"], searcher = specials["make-searcher"](), syntax = syntax, gensym = compiler.gensym, scope = compiler["make-scope"], mangle = compiler["global-mangling"], unmangle = compiler["global-unmangling"], compile1 = compiler.compile1, ["string-stream"] = parser["string-stream"], granulate = parser.granulate, loadCode = specials["load-code"], make_searcher = specials["make-searcher"], makeSearcher = specials["make-searcher"], searchModule = specials["search-module"], macroPath = utils["macro-path"], macroSearchers = specials["macro-searchers"], macroLoaded = specials["macro-loaded"], compileStream = compiler["compile-stream"], compileString = compiler["compile-string"], stringStream = parser["string-stream"], runtimeVersion = utils["runtime-version"]} +mod.install = function(_3fopts) + table.insert((package.searchers or package.loaders), specials["make-searcher"](_3fopts)) + return mod +end utils["fennel-module"] = mod do local builtin_macros = [===[;; These macros are awkward because their definition cannot rely on the any @@ -5169,7 +5191,7 @@ do The value of the second form is spliced into the first arg of the third, etc." (var x val) (each [_ e (ipairs [...])] - (let [elt (copy (if (list? e) e (list e)))] + (let [elt (if (list? e) (copy e) (list e))] (table.insert elt 2 x) (set x elt))) x) @@ -5180,7 +5202,7 @@ do rather than the first." (var x val) (each [_ e (ipairs [...])] - (let [elt (copy (if (list? e) e (list e)))] + (let [elt (if (list? e) (copy e) (list e))] (table.insert elt x) (set x elt))) x) @@ -5190,8 +5212,7 @@ do Same as -> except will short-circuit with nil when it encounters a nil value." (if (= nil ?e) val - (let [e (copy ?e) - el (if (list? e) e (list e)) + (let [el (if (list? ?e) (copy ?e) (list ?e)) tmp (gensym)] (table.insert el 2 tmp) `(let [,tmp ,val] @@ -5204,8 +5225,7 @@ do Same as ->> except will short-circuit with nil when it encounters a nil value." (if (= nil ?e) val - (let [e (copy ?e) - el (if (list? e) e (list e)) + (let [el (if (list? ?e) (copy ?e) (list ?e)) tmp (gensym)] (table.insert el tmp) `(let [,tmp ,val] @@ -5231,10 +5251,12 @@ do (fn doto* [val ...] "Evaluate val and splice it into the first argument of subsequent forms." (assert (not= val nil) "missing subject") - (let [name (gensym) - form `(let [,name ,val])] + (let [rebind? (or (not (sym? val)) + (multi-sym? val)) + name (if rebind? (gensym) val) + form (if rebind? `(let [,name ,val]) `(do))] (each [_ elt (ipairs [...])] - (let [elt (copy (if (list? elt) elt (list elt)))] + (let [elt (if (list? elt) (copy elt) (list elt))] (table.insert elt 2 name) (table.insert form elt))) (table.insert form name) @@ -5787,17 +5809,17 @@ do ]===] local module_name = "conjure.aniseed.fennel.macros" local _ - local function _736_() + local function _739_() return mod end - package.preload[module_name] = _736_ + package.preload[module_name] = _739_ _ = nil local env do - local _737_ = specials["make-compiler-env"](nil, compiler.scopes.compiler, {}) - do end (_737_)["utils"] = utils - _737_["fennel"] = mod - env = _737_ + local _740_ = specials["make-compiler-env"](nil, compiler.scopes.compiler, {}) + do end (_740_)["utils"] = utils + _740_["fennel"] = mod + env = _740_ end local built_ins = eval(builtin_macros, {env = env, scope = compiler.scopes.compiler, allowedGlobals = false, useMetadata = true, filename = "src/fennel/macros.fnl", moduleName = module_name}) for k, v in pairs(built_ins) do diff --git a/lua/conjure/aniseed/fs.lua b/lua/conjure/aniseed/fs.lua index 50fb6b2c..9e27c4a2 100644 --- a/lua/conjure/aniseed/fs.lua +++ b/lua/conjure/aniseed/fs.lua @@ -41,10 +41,6 @@ local function glob_dir_newer_3f(a_dir, b_dir, expr, b_dir_path_fn) return newer_3f end _2amodule_2a["glob-dir-newer?"] = glob_dir_newer_3f -local function macro_file_path_3f(path) - return a["string?"](string.match(path, "macros?.fnl$")) -end -_2amodule_2a["macro-file-path?"] = macro_file_path_3f local path_sep do local os = string.lower(jit.os) @@ -55,4 +51,8 @@ do end end _2amodule_2a["path-sep"] = path_sep +local function macro_file_path_3f(path) + return (a["string?"](string.match(path, "macros?.fnl$")) or a["string?"](string.match(path, (path_sep .. "macros?" .. path_sep)))) +end +_2amodule_2a["macro-file-path?"] = macro_file_path_3f return _2amodule_2a