Skip to content

Commit

Permalink
Aniseed/Fennel updates!
Browse files Browse the repository at this point in the history
  • Loading branch information
Olical committed Nov 14, 2021
1 parent 3cf4b30 commit 63c4a77
Show file tree
Hide file tree
Showing 5 changed files with 654 additions and 568 deletions.
27 changes: 14 additions & 13 deletions lua/nvim-local-fennel/aniseed/compile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ local function macros_prefix(code, opts)
filename = _1_
end
end
local _3_
if filename then
_3_ = ("\"" .. string.gsub(filename, "\\", "\\\\") .. "\"")
else
_3_ = "nil"
local function _3_()
if filename then
return ("\"" .. string.gsub(filename, "\\", "\\\\") .. "\"")
else
return "nil"
end
end
return ("(local *file* " .. _3_ .. ")" .. "(require-macros \"" .. macros_module .. "\")\n" .. (code or ""))
return ("(local *file* " .. _3_() .. ")" .. "(require-macros \"" .. macros_module .. "\")\n" .. (code or ""))
end
_2amodule_2a["macros-prefix"] = macros_prefix
local marker_prefix = "ANISEED_"
Expand All @@ -45,20 +46,20 @@ do end (_2amodule_locals_2a)["delete-marker-pat"] = delete_marker_pat
local function str(code, opts)
ANISEED_STATIC_MODULES = (true == a.get(opts, "static?"))
local fnl = fennel.impl()
local function _5_()
local function _4_()
return string.gsub(string.gsub(fnl.compileString(macros_prefix(code, opts), a["merge!"]({allowedGlobals = false, compilerEnv = _G}, opts)), (delete_marker_pat .. "\n"), "\n"), (delete_marker_pat .. "$"), "")
end
return xpcall(_5_, fnl.traceback)
return xpcall(_4_, fnl.traceback)
end
_2amodule_2a["str"] = str
local function file(src, dest, opts)
local code = a.slurp(src)
local _6_, _7_ = str(code, a["merge!"]({filename = src, ["static?"] = true}, opts))
if ((_6_ == false) and (nil ~= _7_)) then
local err = _7_
local _5_, _6_ = str(code, a["merge!"]({filename = src, ["static?"] = true}, opts))
if ((_5_ == false) and (nil ~= _6_)) then
local err = _6_
return nvim.err_writeln(err)
elseif ((_6_ == true) and (nil ~= _7_)) then
local result = _7_
elseif ((_5_ == true) and (nil ~= _6_)) then
local result = _6_
fs.mkdirp(fs.basename(dest))
return a.spit(dest, result)
else
Expand Down
20 changes: 16 additions & 4 deletions lua/nvim-local-fennel/aniseed/core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,30 @@ local function rand(n)
return (math.random() * (n or 1))
end
_2amodule_2a["rand"] = rand
local function string_3f(x)
return ("string" == type(x))
end
_2amodule_2a["string?"] = string_3f
local function nil_3f(x)
return (nil == x)
end
_2amodule_2a["nil?"] = nil_3f
local function number_3f(x)
return ("number" == type(x))
end
_2amodule_2a["number?"] = number_3f
local function boolean_3f(x)
return ("boolean" == type(x))
end
_2amodule_2a["boolean?"] = boolean_3f
local function string_3f(x)
return ("string" == type(x))
end
_2amodule_2a["string?"] = string_3f
local function table_3f(x)
return ("table" == type(x))
end
_2amodule_2a["table?"] = table_3f
local function function_3f(value)
return ("function" == type(value))
end
_2amodule_2a["function?"] = function_3f
local function count(xs)
if table_3f(xs) then
return table.maxn(xs)
Expand Down
Loading

0 comments on commit 63c4a77

Please sign in to comment.