From 14094762ab3d023500e04b2d1268698a22c521ea Mon Sep 17 00:00:00 2001 From: XeroOl Date: Sun, 9 Jun 2024 16:05:34 -0500 Subject: [PATCH] Switch from rxi/json to dkjson, switch folder structure --- Makefile | 6 +- deps/dkjson.lua | 749 ++++++++++ {test/faith => deps}/faith.fnl | 0 {src => deps}/fennel.lua | 1518 ++++++++++----------- {test => deps}/pl/LICENSE.md | 0 {test => deps}/pl/stringio.lua | 0 fennel | 1744 ++++++++++++------------ src/fennel-ls/json-rpc.fnl | 8 +- src/fennel-ls/json/.github/FUNDING.yml | 1 - src/fennel-ls/json/LICENSE | 20 - src/fennel-ls/json/json.lua | 404 ------ src/fennel-ls/lint.fnl | 31 +- src/fennel-ls/message.fnl | 2 +- test/goto-definition.fnl | 2 +- test/hover.fnl | 2 +- test/json-rpc.fnl | 2 +- test/references.fnl | 2 +- test/rename.fnl | 2 +- tools/unvendor.fnl | 18 +- tools/vendor.fnl | 28 +- 20 files changed, 2430 insertions(+), 2109 deletions(-) create mode 100644 deps/dkjson.lua rename {test/faith => deps}/faith.fnl (100%) rename {src => deps}/fennel.lua (88%) rename {test => deps}/pl/LICENSE.md (100%) rename {test => deps}/pl/stringio.lua (100%) delete mode 100644 src/fennel-ls/json/.github/FUNDING.yml delete mode 100644 src/fennel-ls/json/LICENSE delete mode 100644 src/fennel-ls/json/json.lua diff --git a/Makefile b/Makefile index b283c2b..049d1e4 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ DESTDIR ?= PREFIX ?= /usr/local BINDIR ?= $(PREFIX)/bin -FENNELFLAGS=--add-package-path "src/?.lua" --add-fennel-path "src/?.fnl" +FENNELFLAGS=--add-package-path "src/?.lua;deps/?.lua" --add-fennel-path "src/?.fnl;deps/?.fnl" FENNELFLAGS+=--skip-include fennel.compiler EXTRA_FENNELFLAGS ?= FENNELFLAGS+= $(EXTRA_FENNELFLAGS) @@ -30,10 +30,10 @@ clean: rm -f $(EXE) test: - TESTING=1 $(FENNEL) $(FENNELFLAGS) --add-fennel-path "test/faith/?.fnl" test/init.fnl + TESTING=1 $(FENNEL) $(FENNELFLAGS) test/init.fnl repl: - $(FENNEL) $(FENNELFLAGS) --add-fennel-path "test/faith/?.fnl" + $(FENNEL) $(FENNELFLAGS) testall: $(MAKE) test LUA=lua5.1 diff --git a/deps/dkjson.lua b/deps/dkjson.lua new file mode 100644 index 0000000..7a86724 --- /dev/null +++ b/deps/dkjson.lua @@ -0,0 +1,749 @@ +-- Module options: +local always_use_lpeg = false +local register_global_module_table = false +local global_module_name = 'json' + +--[==[ + +David Kolf's JSON module for Lua 5.1 - 5.4 + +Version 2.7 + + +For the documentation see the corresponding readme.txt or visit +. + +You can contact the author by sending an e-mail to 'david' at the +domain 'dkolf.de'. + + +Copyright (C) 2010-2024 David Heiko Kolf + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +--]==] + +-- global dependencies: +local pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset = + pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset +local error, require, pcall, select = error, require, pcall, select +local floor, huge = math.floor, math.huge +local strrep, gsub, strsub, strbyte, strchar, strfind, strlen, strformat = + string.rep, string.gsub, string.sub, string.byte, string.char, + string.find, string.len, string.format +local strmatch = string.match +local concat = table.concat + +local json = { version = "dkjson 2.7" } + +local jsonlpeg = {} + +if register_global_module_table then + if always_use_lpeg then + _G[global_module_name] = jsonlpeg + else + _G[global_module_name] = json + end +end + +local _ENV = nil -- blocking globals in Lua 5.2 and later + +pcall (function() + -- Enable access to blocked metatables. + -- Don't worry, this module doesn't change anything in them. + local debmeta = require "debug".getmetatable + if debmeta then getmetatable = debmeta end +end) + +json.null = setmetatable ({}, { + __tojson = function () return "null" end +}) + +local function isarray (tbl) + local max, n, arraylen = 0, 0, 0 + for k,v in pairs (tbl) do + if k == 'n' and type(v) == 'number' then + arraylen = v + if v > max then + max = v + end + else + if type(k) ~= 'number' or k < 1 or floor(k) ~= k then + return false + end + if k > max then + max = k + end + n = n + 1 + end + end + if max > 10 and max > arraylen and max > n * 2 then + return false -- don't create an array with too many holes + end + return true, max +end + +local escapecodes = { + ["\""] = "\\\"", ["\\"] = "\\\\", ["\b"] = "\\b", ["\f"] = "\\f", + ["\n"] = "\\n", ["\r"] = "\\r", ["\t"] = "\\t" +} + +local function escapeutf8 (uchar) + local value = escapecodes[uchar] + if value then + return value + end + local a, b, c, d = strbyte (uchar, 1, 4) + a, b, c, d = a or 0, b or 0, c or 0, d or 0 + if a <= 0x7f then + value = a + elseif 0xc0 <= a and a <= 0xdf and b >= 0x80 then + value = (a - 0xc0) * 0x40 + b - 0x80 + elseif 0xe0 <= a and a <= 0xef and b >= 0x80 and c >= 0x80 then + value = ((a - 0xe0) * 0x40 + b - 0x80) * 0x40 + c - 0x80 + elseif 0xf0 <= a and a <= 0xf7 and b >= 0x80 and c >= 0x80 and d >= 0x80 then + value = (((a - 0xf0) * 0x40 + b - 0x80) * 0x40 + c - 0x80) * 0x40 + d - 0x80 + else + return "" + end + if value <= 0xffff then + return strformat ("\\u%.4x", value) + elseif value <= 0x10ffff then + -- encode as UTF-16 surrogate pair + value = value - 0x10000 + local highsur, lowsur = 0xD800 + floor (value/0x400), 0xDC00 + (value % 0x400) + return strformat ("\\u%.4x\\u%.4x", highsur, lowsur) + else + return "" + end +end + +local function fsub (str, pattern, repl) + -- gsub always builds a new string in a buffer, even when no match + -- exists. First using find should be more efficient when most strings + -- don't contain the pattern. + if strfind (str, pattern) then + return gsub (str, pattern, repl) + else + return str + end +end + +local function quotestring (value) + -- based on the regexp "escapable" in https://github.com/douglascrockford/JSON-js + value = fsub (value, "[%z\1-\31\"\\\127]", escapeutf8) + if strfind (value, "[\194\216\220\225\226\239]") then + value = fsub (value, "\194[\128-\159\173]", escapeutf8) + value = fsub (value, "\216[\128-\132]", escapeutf8) + value = fsub (value, "\220\143", escapeutf8) + value = fsub (value, "\225\158[\180\181]", escapeutf8) + value = fsub (value, "\226\128[\140-\143\168-\175]", escapeutf8) + value = fsub (value, "\226\129[\160-\175]", escapeutf8) + value = fsub (value, "\239\187\191", escapeutf8) + value = fsub (value, "\239\191[\176-\191]", escapeutf8) + end + return "\"" .. value .. "\"" +end +json.quotestring = quotestring + +local function replace(str, o, n) + local i, j = strfind (str, o, 1, true) + if i then + return strsub(str, 1, i-1) .. n .. strsub(str, j+1, -1) + else + return str + end +end + +-- locale independent num2str and str2num functions +local decpoint, numfilter + +local function updatedecpoint () + decpoint = strmatch(tostring(0.5), "([^05+])") + -- build a filter that can be used to remove group separators + numfilter = "[^0-9%-%+eE" .. gsub(decpoint, "[%^%$%(%)%%%.%[%]%*%+%-%?]", "%%%0") .. "]+" +end + +updatedecpoint() + +local function num2str (num) + return replace(fsub(tostring(num), numfilter, ""), decpoint, ".") +end + +local function str2num (str) + local num = tonumber(replace(str, ".", decpoint)) + if not num then + updatedecpoint() + num = tonumber(replace(str, ".", decpoint)) + end + return num +end + +local function addnewline2 (level, buffer, buflen) + buffer[buflen+1] = "\n" + buffer[buflen+2] = strrep (" ", level) + buflen = buflen + 2 + return buflen +end + +function json.addnewline (state) + if state.indent then + state.bufferlen = addnewline2 (state.level or 0, + state.buffer, state.bufferlen or #(state.buffer)) + end +end + +local encode2 -- forward declaration + +local function addpair (key, value, prev, indent, level, buffer, buflen, tables, globalorder, state) + local kt = type (key) + if kt ~= 'string' and kt ~= 'number' then + return nil, "type '" .. kt .. "' is not supported as a key by JSON." + end + if prev then + buflen = buflen + 1 + buffer[buflen] = "," + end + if indent then + buflen = addnewline2 (level, buffer, buflen) + end + buffer[buflen+1] = quotestring (key) + buffer[buflen+2] = ":" + return encode2 (value, indent, level, buffer, buflen + 2, tables, globalorder, state) +end + +local function appendcustom(res, buffer, state) + local buflen = state.bufferlen + if type (res) == 'string' then + buflen = buflen + 1 + buffer[buflen] = res + end + return buflen +end + +local function exception(reason, value, state, buffer, buflen, defaultmessage) + defaultmessage = defaultmessage or reason + local handler = state.exception + if not handler then + return nil, defaultmessage + else + state.bufferlen = buflen + local ret, msg = handler (reason, value, state, defaultmessage) + if not ret then return nil, msg or defaultmessage end + return appendcustom(ret, buffer, state) + end +end + +function json.encodeexception(reason, value, state, defaultmessage) + return quotestring("<" .. defaultmessage .. ">") +end + +encode2 = function (value, indent, level, buffer, buflen, tables, globalorder, state) + local valtype = type (value) + local valmeta = getmetatable (value) + valmeta = type (valmeta) == 'table' and valmeta -- only tables + local valtojson = valmeta and valmeta.__tojson + if valtojson then + if tables[value] then + return exception('reference cycle', value, state, buffer, buflen) + end + tables[value] = true + state.bufferlen = buflen + local ret, msg = valtojson (value, state) + if not ret then return exception('custom encoder failed', value, state, buffer, buflen, msg) end + tables[value] = nil + buflen = appendcustom(ret, buffer, state) + elseif value == nil then + buflen = buflen + 1 + buffer[buflen] = "null" + elseif valtype == 'number' then + local s + if value ~= value or value >= huge or -value >= huge then + -- This is the behaviour of the original JSON implementation. + s = "null" + else + s = num2str (value) + end + buflen = buflen + 1 + buffer[buflen] = s + elseif valtype == 'boolean' then + buflen = buflen + 1 + buffer[buflen] = value and "true" or "false" + elseif valtype == 'string' then + buflen = buflen + 1 + buffer[buflen] = quotestring (value) + elseif valtype == 'table' then + if tables[value] then + return exception('reference cycle', value, state, buffer, buflen) + end + tables[value] = true + level = level + 1 + local isa, n = isarray (value) + if n == 0 and valmeta and valmeta.__jsontype == 'object' then + isa = false + end + local msg + if isa then -- JSON array + buflen = buflen + 1 + buffer[buflen] = "[" + for i = 1, n do + buflen, msg = encode2 (value[i], indent, level, buffer, buflen, tables, globalorder, state) + if not buflen then return nil, msg end + if i < n then + buflen = buflen + 1 + buffer[buflen] = "," + end + end + buflen = buflen + 1 + buffer[buflen] = "]" + else -- JSON object + local prev = false + buflen = buflen + 1 + buffer[buflen] = "{" + local order = valmeta and valmeta.__jsonorder or globalorder + if order then + local used = {} + n = #order + for i = 1, n do + local k = order[i] + local v = value[k] + if v ~= nil then + used[k] = true + buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state) + if not buflen then return nil, msg end + prev = true -- add a seperator before the next element + end + end + for k,v in pairs (value) do + if not used[k] then + buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state) + if not buflen then return nil, msg end + prev = true -- add a seperator before the next element + end + end + else -- unordered + for k,v in pairs (value) do + buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state) + if not buflen then return nil, msg end + prev = true -- add a seperator before the next element + end + end + if indent then + buflen = addnewline2 (level - 1, buffer, buflen) + end + buflen = buflen + 1 + buffer[buflen] = "}" + end + tables[value] = nil + else + return exception ('unsupported type', value, state, buffer, buflen, + "type '" .. valtype .. "' is not supported by JSON.") + end + return buflen +end + +function json.encode (value, state) + state = state or {} + local oldbuffer = state.buffer + local buffer = oldbuffer or {} + state.buffer = buffer + updatedecpoint() + local ret, msg = encode2 (value, state.indent, state.level or 0, + buffer, state.bufferlen or 0, state.tables or {}, state.keyorder, state) + if not ret then + error (msg, 2) + elseif oldbuffer == buffer then + state.bufferlen = ret + return true + else + state.bufferlen = nil + state.buffer = nil + return concat (buffer) + end +end + +local function loc (str, where) + local line, pos, linepos = 1, 1, 0 + while true do + pos = strfind (str, "\n", pos, true) + if pos and pos < where then + line = line + 1 + linepos = pos + pos = pos + 1 + else + break + end + end + return "line " .. line .. ", column " .. (where - linepos) +end + +local function unterminated (str, what, where) + return nil, strlen (str) + 1, "unterminated " .. what .. " at " .. loc (str, where) +end + +local function scanwhite (str, pos) + while true do + pos = strfind (str, "%S", pos) + if not pos then return nil end + local sub2 = strsub (str, pos, pos + 1) + if sub2 == "\239\187" and strsub (str, pos + 2, pos + 2) == "\191" then + -- UTF-8 Byte Order Mark + pos = pos + 3 + elseif sub2 == "//" then + pos = strfind (str, "[\n\r]", pos + 2) + if not pos then return nil end + elseif sub2 == "/*" then + pos = strfind (str, "*/", pos + 2) + if not pos then return nil end + pos = pos + 2 + else + return pos + end + end +end + +local escapechars = { + ["\""] = "\"", ["\\"] = "\\", ["/"] = "/", ["b"] = "\b", ["f"] = "\f", + ["n"] = "\n", ["r"] = "\r", ["t"] = "\t" +} + +local function unichar (value) + if value < 0 then + return nil + elseif value <= 0x007f then + return strchar (value) + elseif value <= 0x07ff then + return strchar (0xc0 + floor(value/0x40), + 0x80 + (floor(value) % 0x40)) + elseif value <= 0xffff then + return strchar (0xe0 + floor(value/0x1000), + 0x80 + (floor(value/0x40) % 0x40), + 0x80 + (floor(value) % 0x40)) + elseif value <= 0x10ffff then + return strchar (0xf0 + floor(value/0x40000), + 0x80 + (floor(value/0x1000) % 0x40), + 0x80 + (floor(value/0x40) % 0x40), + 0x80 + (floor(value) % 0x40)) + else + return nil + end +end + +local function scanstring (str, pos) + local lastpos = pos + 1 + local buffer, n = {}, 0 + while true do + local nextpos = strfind (str, "[\"\\]", lastpos) + if not nextpos then + return unterminated (str, "string", pos) + end + if nextpos > lastpos then + n = n + 1 + buffer[n] = strsub (str, lastpos, nextpos - 1) + end + if strsub (str, nextpos, nextpos) == "\"" then + lastpos = nextpos + 1 + break + else + local escchar = strsub (str, nextpos + 1, nextpos + 1) + local value + if escchar == "u" then + value = tonumber (strsub (str, nextpos + 2, nextpos + 5), 16) + if value then + local value2 + if 0xD800 <= value and value <= 0xDBff then + -- we have the high surrogate of UTF-16. Check if there is a + -- low surrogate escaped nearby to combine them. + if strsub (str, nextpos + 6, nextpos + 7) == "\\u" then + value2 = tonumber (strsub (str, nextpos + 8, nextpos + 11), 16) + if value2 and 0xDC00 <= value2 and value2 <= 0xDFFF then + value = (value - 0xD800) * 0x400 + (value2 - 0xDC00) + 0x10000 + else + value2 = nil -- in case it was out of range for a low surrogate + end + end + end + value = value and unichar (value) + if value then + if value2 then + lastpos = nextpos + 12 + else + lastpos = nextpos + 6 + end + end + end + end + if not value then + value = escapechars[escchar] or escchar + lastpos = nextpos + 2 + end + n = n + 1 + buffer[n] = value + end + end + if n == 1 then + return buffer[1], lastpos + elseif n > 1 then + return concat (buffer), lastpos + else + return "", lastpos + end +end + +local scanvalue -- forward declaration + +local function scantable (what, closechar, str, startpos, nullval, objectmeta, arraymeta) + local len = strlen (str) + local tbl, n = {}, 0 + local pos = startpos + 1 + if what == 'object' then + setmetatable (tbl, objectmeta) + else + setmetatable (tbl, arraymeta) + end + while true do + pos = scanwhite (str, pos) + if not pos then return unterminated (str, what, startpos) end + local char = strsub (str, pos, pos) + if char == closechar then + return tbl, pos + 1 + end + local val1, err + val1, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta) + if err then return nil, pos, err end + pos = scanwhite (str, pos) + if not pos then return unterminated (str, what, startpos) end + char = strsub (str, pos, pos) + if char == ":" then + if val1 == nil then + return nil, pos, "cannot use nil as table index (at " .. loc (str, pos) .. ")" + end + pos = scanwhite (str, pos + 1) + if not pos then return unterminated (str, what, startpos) end + local val2 + val2, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta) + if err then return nil, pos, err end + tbl[val1] = val2 + pos = scanwhite (str, pos) + if not pos then return unterminated (str, what, startpos) end + char = strsub (str, pos, pos) + else + n = n + 1 + tbl[n] = val1 + end + if char == "," then + pos = pos + 1 + end + end +end + +scanvalue = function (str, pos, nullval, objectmeta, arraymeta) + pos = pos or 1 + pos = scanwhite (str, pos) + if not pos then + return nil, strlen (str) + 1, "no valid JSON value (reached the end)" + end + local char = strsub (str, pos, pos) + if char == "{" then + return scantable ('object', "}", str, pos, nullval, objectmeta, arraymeta) + elseif char == "[" then + return scantable ('array', "]", str, pos, nullval, objectmeta, arraymeta) + elseif char == "\"" then + return scanstring (str, pos) + else + local pstart, pend = strfind (str, "^%-?[%d%.]+[eE]?[%+%-]?%d*", pos) + if pstart then + local number = str2num (strsub (str, pstart, pend)) + if number then + return number, pend + 1 + end + end + pstart, pend = strfind (str, "^%a%w*", pos) + if pstart then + local name = strsub (str, pstart, pend) + if name == "true" then + return true, pend + 1 + elseif name == "false" then + return false, pend + 1 + elseif name == "null" then + return nullval, pend + 1 + end + end + return nil, pos, "no valid JSON value at " .. loc (str, pos) + end +end + +local function optionalmetatables(...) + if select("#", ...) > 0 then + return ... + else + return {__jsontype = 'object'}, {__jsontype = 'array'} + end +end + +function json.decode (str, pos, nullval, ...) + local objectmeta, arraymeta = optionalmetatables(...) + return scanvalue (str, pos, nullval, objectmeta, arraymeta) +end + +function json.use_lpeg () + local g = require ("lpeg") + + if type(g.version) == 'function' and g.version() == "0.11" then + error "due to a bug in LPeg 0.11, it cannot be used for JSON matching" + end + + local pegmatch = g.match + local P, S, R = g.P, g.S, g.R + + local function ErrorCall (str, pos, msg, state) + if not state.msg then + state.msg = msg .. " at " .. loc (str, pos) + state.pos = pos + end + return false + end + + local function Err (msg) + return g.Cmt (g.Cc (msg) * g.Carg (2), ErrorCall) + end + + local function ErrorUnterminatedCall (str, pos, what, state) + return ErrorCall (str, pos - 1, "unterminated " .. what, state) + end + + local SingleLineComment = P"//" * (1 - S"\n\r")^0 + local MultiLineComment = P"/*" * (1 - P"*/")^0 * P"*/" + local Space = (S" \n\r\t" + P"\239\187\191" + SingleLineComment + MultiLineComment)^0 + + local function ErrUnterminated (what) + return g.Cmt (g.Cc (what) * g.Carg (2), ErrorUnterminatedCall) + end + + local PlainChar = 1 - S"\"\\\n\r" + local EscapeSequence = (P"\\" * g.C (S"\"\\/bfnrt" + Err "unsupported escape sequence")) / escapechars + local HexDigit = R("09", "af", "AF") + local function UTF16Surrogate (match, pos, high, low) + high, low = tonumber (high, 16), tonumber (low, 16) + if 0xD800 <= high and high <= 0xDBff and 0xDC00 <= low and low <= 0xDFFF then + return true, unichar ((high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000) + else + return false + end + end + local function UTF16BMP (hex) + return unichar (tonumber (hex, 16)) + end + local U16Sequence = (P"\\u" * g.C (HexDigit * HexDigit * HexDigit * HexDigit)) + local UnicodeEscape = g.Cmt (U16Sequence * U16Sequence, UTF16Surrogate) + U16Sequence/UTF16BMP + local Char = UnicodeEscape + EscapeSequence + PlainChar + local String = P"\"" * (g.Cs (Char ^ 0) * P"\"" + ErrUnterminated "string") + local Integer = P"-"^(-1) * (P"0" + (R"19" * R"09"^0)) + local Fractal = P"." * R"09"^0 + local Exponent = (S"eE") * (S"+-")^(-1) * R"09"^1 + local Number = (Integer * Fractal^(-1) * Exponent^(-1))/str2num + local Constant = P"true" * g.Cc (true) + P"false" * g.Cc (false) + P"null" * g.Carg (1) + local SimpleValue = Number + String + Constant + local ArrayContent, ObjectContent + + -- The functions parsearray and parseobject parse only a single value/pair + -- at a time and store them directly to avoid hitting the LPeg limits. + local function parsearray (str, pos, nullval, state) + local obj, cont + local start = pos + local npos + local t, nt = {}, 0 + repeat + obj, cont, npos = pegmatch (ArrayContent, str, pos, nullval, state) + if cont == 'end' then + return ErrorUnterminatedCall (str, start, "array", state) + end + pos = npos + if cont == 'cont' or cont == 'last' then + nt = nt + 1 + t[nt] = obj + end + until cont ~= 'cont' + return pos, setmetatable (t, state.arraymeta) + end + + local function parseobject (str, pos, nullval, state) + local obj, key, cont + local start = pos + local npos + local t = {} + repeat + key, obj, cont, npos = pegmatch (ObjectContent, str, pos, nullval, state) + if cont == 'end' then + return ErrorUnterminatedCall (str, start, "object", state) + end + pos = npos + if cont == 'cont' or cont == 'last' then + t[key] = obj + end + until cont ~= 'cont' + return pos, setmetatable (t, state.objectmeta) + end + + local Array = P"[" * g.Cmt (g.Carg(1) * g.Carg(2), parsearray) + local Object = P"{" * g.Cmt (g.Carg(1) * g.Carg(2), parseobject) + local Value = Space * (Array + Object + SimpleValue) + local ExpectedValue = Value + Space * Err "value expected" + local ExpectedKey = String + Err "key expected" + local End = P(-1) * g.Cc'end' + local ErrInvalid = Err "invalid JSON" + ArrayContent = (Value * Space * (P"," * g.Cc'cont' + P"]" * g.Cc'last'+ End + ErrInvalid) + g.Cc(nil) * (P"]" * g.Cc'empty' + End + ErrInvalid)) * g.Cp() + local Pair = g.Cg (Space * ExpectedKey * Space * (P":" + Err "colon expected") * ExpectedValue) + ObjectContent = (g.Cc(nil) * g.Cc(nil) * P"}" * g.Cc'empty' + End + (Pair * Space * (P"," * g.Cc'cont' + P"}" * g.Cc'last' + End + ErrInvalid) + ErrInvalid)) * g.Cp() + local DecodeValue = ExpectedValue * g.Cp () + + jsonlpeg.version = json.version + jsonlpeg.encode = json.encode + jsonlpeg.null = json.null + jsonlpeg.quotestring = json.quotestring + jsonlpeg.addnewline = json.addnewline + jsonlpeg.encodeexception = json.encodeexception + jsonlpeg.using_lpeg = true + + function jsonlpeg.decode (str, pos, nullval, ...) + local state = {} + state.objectmeta, state.arraymeta = optionalmetatables(...) + local obj, retpos = pegmatch (DecodeValue, str, pos, nullval, state) + if state.msg then + return nil, state.pos, state.msg + else + return obj, retpos + end + end + + -- cache result of this function: + json.use_lpeg = function () return jsonlpeg end + jsonlpeg.use_lpeg = json.use_lpeg + + return jsonlpeg +end + +if always_use_lpeg then + return json.use_lpeg() +end + +return json + diff --git a/test/faith/faith.fnl b/deps/faith.fnl similarity index 100% rename from test/faith/faith.fnl rename to deps/faith.fnl diff --git a/src/fennel.lua b/deps/fennel.lua similarity index 88% rename from src/fennel.lua rename to deps/fennel.lua index a13ca11..6b3f8fa 100644 --- a/src/fennel.lua +++ b/deps/fennel.lua @@ -25,18 +25,18 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) return io.write("\n") end local function default_on_error(errtype, err, lua_source) - local function _617_() - local _616_0 = errtype - if (_616_0 == "Lua Compile") then + local function _616_() + local _615_0 = errtype + if (_615_0 == "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 (_616_0 == "Runtime") then + elseif (_615_0 == "Runtime") then return (compiler.traceback(tostring(err), 4) .. "\n") else - local _ = _616_0 + local _ = _615_0 return ("%s error: %s\n"):format(errtype, tostring(err)) end end - return io.write(_617_()) + return io.write(_616_()) end local function splice_save_locals(env, lua_source, scope) local saves = nil @@ -76,25 +76,25 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) else gap = " " end - local function _623_() + local function _622_() if next(saves) then return (table.concat(saves, " ") .. gap) else return "" end end - local function _626_() - local _624_0, _625_0 = lua_source:match("^(.*)[\n ](return .*)$") - if ((nil ~= _624_0) and (nil ~= _625_0)) then - local body = _624_0 - local _return = _625_0 + local function _625_() + local _623_0, _624_0 = lua_source:match("^(.*)[\n ](return .*)$") + if ((nil ~= _623_0) and (nil ~= _624_0)) then + local body = _623_0 + local _return = _624_0 return (body .. gap .. table.concat(binds, " ") .. gap .. _return) else - local _ = _624_0 + local _ = _623_0 return lua_source end end - return (_623_() .. _626_()) + return (_622_() .. _625_()) end local function completer(env, scope, text) local max_items = 2000 @@ -106,14 +106,14 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) local scope_first_3f = ((tbl == env) or (tbl == env.___replLocals___)) local tbl_17_ = matches local i_18_ = #tbl_17_ - local function _628_() + local function _627_() if scope_first_3f then return scope.manglings else return tbl end end - for k, is_mangled in utils.allpairs(_628_()) do + for k, is_mangled in utils.allpairs(_627_()) do if (max_items <= #matches) then break end local val_19_ = nil do @@ -181,7 +181,7 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) return input:match("^%s*,") end local function command_docs() - local _637_ + local _636_ do local tbl_17_ = {} local i_18_ = #tbl_17_ @@ -192,18 +192,18 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) tbl_17_[i_18_] = val_19_ end end - _637_ = tbl_17_ + _636_ = tbl_17_ end - return table.concat(_637_, "\n") + return table.concat(_636_, "\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 ,return FORM - Evaluate FORM and return its value to the REPL's caller.\n ,exit - Leave the repl.\n\nUse ,doc something to see descriptions for individual macros and special forms.\nValues from previous inputs are kept in *1, *2, and *3.\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 _639_0, _640_0 = pcall(specials["load-code"]("return require(...)", env), module_name) - if ((_639_0 == true) and (nil ~= _640_0)) then - local old = _640_0 + local _638_0, _639_0 = pcall(specials["load-code"]("return require(...)", env), module_name) + if ((_638_0 == true) and (nil ~= _639_0)) then + local old = _639_0 local _ = nil package.loaded[module_name] = nil _ = nil @@ -228,8 +228,8 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) package.loaded[module_name] = old end return on_values({"ok"}) - elseif ((_639_0 == false) and (nil ~= _640_0)) then - local msg = _640_0 + elseif ((_638_0 == false) and (nil ~= _639_0)) then + local msg = _639_0 if msg:match("loop or previous error loading module") then package.loaded[module_name] = nil return reload(module_name, env, on_values, on_error) @@ -237,32 +237,32 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) specials["macro-loaded"][module_name] = nil return nil else - local function _645_() - local _644_0 = msg:gsub("\n.*", "") - return _644_0 + local function _644_() + local _643_0 = msg:gsub("\n.*", "") + return _643_0 end - return on_error("Runtime", _645_()) + return on_error("Runtime", _644_()) end end end local function run_command(read, on_error, f) - local _648_0, _649_0, _650_0 = pcall(read) - if ((_648_0 == true) and (_649_0 == true) and (nil ~= _650_0)) then - local val = _650_0 - local _651_0, _652_0 = pcall(f, val) - if ((_651_0 == false) and (nil ~= _652_0)) then - local msg = _652_0 + local _647_0, _648_0, _649_0 = pcall(read) + if ((_647_0 == true) and (_648_0 == true) and (nil ~= _649_0)) then + local val = _649_0 + local _650_0, _651_0 = pcall(f, val) + if ((_650_0 == false) and (nil ~= _651_0)) then + local msg = _651_0 return on_error("Runtime", msg) end - elseif (_648_0 == false) then + elseif (_647_0 == false) then return on_error("Parse", "Couldn't parse input.") end end commands.reload = function(env, read, on_values, on_error) - local function _655_(_241) + local function _654_(_241) return reload(tostring(_241), env, on_values, on_error) end - return run_command(read, on_error, _655_) + return run_command(read, on_error, _654_) end do end (compiler.metadata):set(commands.reload, "fnl/docstring", "Reload the specified module.") commands.reset = function(env, _, on_values) @@ -271,28 +271,28 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) 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 _656_() + local function _655_() return on_values(completer(env, scope, table.concat(chars):gsub(",complete +", ""):sub(1, -2))) end - return run_command(read, on_error, _656_) + return run_command(read, on_error, _655_) 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 _657_0 = type(subtbl) - if (_657_0 == "function") then + local _656_0 = type(subtbl) + if (_656_0 == "function") then if ((prefix .. name)):match(pattern) then table.insert(names, (prefix .. name)) end - elseif (_657_0 == "table") then + elseif (_656_0 == "table") then if not seen[subtbl] then - local _659_ + local _658_ do seen[subtbl] = true - _659_ = seen + _658_ = seen end - apropos_2a(pattern, subtbl, (prefix .. name:gsub("%.", "/") .. "."), _659_, names) + apropos_2a(pattern, subtbl, (prefix .. name:gsub("%.", "/") .. "."), _658_, names) end end end @@ -313,10 +313,10 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) return tbl_17_ end commands.apropos = function(_env, read, on_values, on_error, _scope) - local function _664_(_241) + local function _663_(_241) return on_values(apropos(tostring(_241))) end - return run_command(read, on_error, _664_) + return run_command(read, on_error, _663_) 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) @@ -336,12 +336,12 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) local tgt = package.loaded for _, path0 in ipairs(paths) do if (nil == tgt) then break end - local _667_ + local _666_ do - local _666_0 = path0:gsub("%/", ".") - _667_ = _666_0 + local _665_0 = path0:gsub("%/", ".") + _666_ = _665_0 end - tgt = tgt[_667_] + tgt = tgt[_666_] end return tgt end @@ -353,9 +353,9 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) do local tgt = apropos_follow_path(path) if ("function" == type(tgt)) then - local _668_0 = (compiler.metadata):get(tgt, "fnl/docstring") - if (nil ~= _668_0) then - local docstr = _668_0 + local _667_0 = (compiler.metadata):get(tgt, "fnl/docstring") + if (nil ~= _667_0) then + local docstr = _667_0 val_19_ = (docstr:match(pattern) and path) else val_19_ = nil @@ -372,10 +372,10 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) return tbl_17_ end commands["apropos-doc"] = function(_env, read, on_values, on_error, _scope) - local function _672_(_241) + local function _671_(_241) return on_values(apropos_doc(tostring(_241))) end - return run_command(read, on_error, _672_) + return run_command(read, on_error, _671_) 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) @@ -389,108 +389,108 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) return nil end commands["apropos-show-docs"] = function(_env, read, on_values, on_error) - local function _674_(_241) + local function _673_(_241) return apropos_show_docs(on_values, tostring(_241)) end - return run_command(read, on_error, _674_) + return run_command(read, on_error, _673_) 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, _675_0, scope) - local _676_ = _675_0 - local env = _676_ - local ___replLocals___ = _676_["___replLocals___"] + local function resolve(identifier, _674_0, scope) + local _675_ = _674_0 + local env = _675_ + local ___replLocals___ = _675_["___replLocals___"] local e = nil - local function _677_(_241, _242) + local function _676_(_241, _242) return (___replLocals___[scope.unmanglings[_242]] or env[_242]) end - e = setmetatable({}, {__index = _677_}) - local function _678_(...) - local _679_0, _680_0 = ... - if ((_679_0 == true) and (nil ~= _680_0)) then - local code = _680_0 - local function _681_(...) - local _682_0, _683_0 = ... - if ((_682_0 == true) and (nil ~= _683_0)) then - local val = _683_0 + e = setmetatable({}, {__index = _676_}) + local function _677_(...) + local _678_0, _679_0 = ... + if ((_678_0 == true) and (nil ~= _679_0)) then + local code = _679_0 + local function _680_(...) + local _681_0, _682_0 = ... + if ((_681_0 == true) and (nil ~= _682_0)) then + local val = _682_0 return val else - local _ = _682_0 + local _ = _681_0 return nil end end - return _681_(pcall(specials["load-code"](code, e))) + return _680_(pcall(specials["load-code"](code, e))) else - local _ = _679_0 + local _ = _678_0 return nil end end - return _678_(pcall(compiler["compile-string"], tostring(identifier), {scope = scope})) + return _677_(pcall(compiler["compile-string"], tostring(identifier), {scope = scope})) end commands.find = function(env, read, on_values, on_error, scope) - local function _686_(_241) - local _687_0 = nil + local function _685_(_241) + local _686_0 = nil do - local _688_0 = utils["sym?"](_241) - if (nil ~= _688_0) then - local _689_0 = resolve(_688_0, env, scope) - if (nil ~= _689_0) then - _687_0 = debug.getinfo(_689_0) + local _687_0 = utils["sym?"](_241) + if (nil ~= _687_0) then + local _688_0 = resolve(_687_0, env, scope) + if (nil ~= _688_0) then + _686_0 = debug.getinfo(_688_0) else - _687_0 = _689_0 + _686_0 = _688_0 end else - _687_0 = _688_0 + _686_0 = _687_0 end end - if ((_G.type(_687_0) == "table") and (nil ~= _687_0.linedefined) and (nil ~= _687_0.short_src) and (nil ~= _687_0.source) and (_687_0.what == "Lua")) then - local line = _687_0.linedefined - local src = _687_0.short_src - local source = _687_0.source + if ((_G.type(_686_0) == "table") and (nil ~= _686_0.linedefined) and (nil ~= _686_0.short_src) and (nil ~= _686_0.source) and (_686_0.what == "Lua")) then + local line = _686_0.linedefined + local src = _686_0.short_src + local source = _686_0.source local fnlsrc = nil do - local _692_0 = compiler.sourcemap - if (nil ~= _692_0) then - _692_0 = _692_0[source] + local _691_0 = compiler.sourcemap + if (nil ~= _691_0) then + _691_0 = _691_0[source] end - if (nil ~= _692_0) then - _692_0 = _692_0[line] + if (nil ~= _691_0) then + _691_0 = _691_0[line] end - if (nil ~= _692_0) then - _692_0 = _692_0[2] + if (nil ~= _691_0) then + _691_0 = _691_0[2] end - fnlsrc = _692_0 + fnlsrc = _691_0 end return on_values({string.format("%s:%s", src, (fnlsrc or line))}) - elseif (_687_0 == nil) then + elseif (_686_0 == nil) then return on_error("Repl", "Unknown value") else - local _ = _687_0 + local _ = _686_0 return on_error("Repl", "No source info") end end - return run_command(read, on_error, _686_) + return run_command(read, on_error, _685_) 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 _697_(_241) + local function _696_(_241) local name = tostring(_241) local path = (utils["multi-sym?"](name) or {name}) local ok_3f, target = nil, nil - local function _698_() + local function _697_() return (utils["get-in"](scope.specials, path) or utils["get-in"](scope.macros, path) or resolve(name, env, scope)) end - ok_3f, target = pcall(_698_) + ok_3f, target = pcall(_697_) if ok_3f then return on_values({specials.doc(target, name)}) else return on_error("Repl", ("Could not find " .. name .. " for docs.")) end end - return run_command(read, on_error, _697_) + return run_command(read, on_error, _696_) 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 _700_(_241) + local function _699_(_241) local allowedGlobals = specials["current-global-names"](env) local ok_3f, result = pcall(compiler.compile, _241, {allowedGlobals = allowedGlobals, env = env, scope = scope}) if ok_3f then @@ -499,15 +499,15 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) return on_error("Repl", ("Error compiling expression: " .. result)) end end - return run_command(read, on_error, _700_) + return run_command(read, on_error, _699_) 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 i = #(plugins or {}), 1, -1 do for name, f in pairs(plugins[i]) do - local _702_0 = name:match("^repl%-command%-(.*)") - if (nil ~= _702_0) then - local cmd_name = _702_0 + local _701_0 = name:match("^repl%-command%-(.*)") + if (nil ~= _701_0) then + local cmd_name = _701_0 commands[cmd_name] = f end end @@ -517,12 +517,12 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) local function run_command_loop(input, read, loop, env, on_values, on_error, scope, chars) local command_name = input:match(",([^%s/]+)") do - local _704_0 = commands[command_name] - if (nil ~= _704_0) then - local command = _704_0 + local _703_0 = commands[command_name] + if (nil ~= _703_0) then + local command = _703_0 command(env, read, on_values, on_error, scope, chars) else - local _ = _704_0 + local _ = _703_0 if ((command_name ~= "exit") and (command_name ~= "return")) then on_values({"Unknown command", command_name}) end @@ -572,9 +572,9 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) end local function repl(_3foptions) local old_root_options = utils.root.options - local _713_ = utils.copy(_3foptions) - local opts = _713_ - local _3ffennelrc = _713_["fennelrc"] + local _712_ = utils.copy(_3foptions) + local opts = _712_ + local _3ffennelrc = _712_["fennelrc"] local _ = nil opts.fennelrc = nil _ = nil @@ -589,20 +589,20 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) local callbacks = {env = env, onError = (opts.onError or default_on_error), onValues = (opts.onValues or default_on_values), pp = (opts.pp or view), readChunk = (opts.readChunk or default_read_chunk)} local save_locals_3f = (opts.saveLocals ~= false) local byte_stream, clear_stream = nil, nil - local function _715_(_241) + local function _714_(_241) return callbacks.readChunk(_241) end - byte_stream, clear_stream = parser.granulate(_715_) + byte_stream, clear_stream = parser.granulate(_714_) local chars = {} local read, reset = nil, nil - local function _716_(parser_state) + local function _715_(parser_state) local b = byte_stream(parser_state) if b then table.insert(chars, string.char(b)) end return b end - read, reset = parser.parser(_716_) + read, reset = parser.parser(_715_) depth = (depth + 1) if opts.message then callbacks.onValues({opts.message}) @@ -617,14 +617,14 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) opts.init(opts, depth) end if opts.registerCompleter then - local function _722_() - local _721_0 = opts.scope - local function _723_(...) - return completer(env, _721_0, ...) + local function _721_() + local _720_0 = opts.scope + local function _722_(...) + return completer(env, _720_0, ...) end - return _723_ + return _722_ end - opts.registerCompleter(_722_()) + opts.registerCompleter(_721_()) end load_plugin_commands(opts.plugins) if save_locals_3f then @@ -671,28 +671,28 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) return run_command_loop(src_string, read, loop, env, callbacks.onValues, callbacks.onError, opts.scope, chars) else if not_eof_3f then - local function _727_(...) - local _728_0, _729_0 = ... - if ((_728_0 == true) and (nil ~= _729_0)) then - local src = _729_0 - local function _730_(...) - local _731_0, _732_0 = ... - if ((_731_0 == true) and (nil ~= _732_0)) then - local chunk = _732_0 - local function _733_() + local function _726_(...) + local _727_0, _728_0 = ... + if ((_727_0 == true) and (nil ~= _728_0)) then + local src = _728_0 + local function _729_(...) + local _730_0, _731_0 = ... + if ((_730_0 == true) and (nil ~= _731_0)) then + local chunk = _731_0 + local function _732_() return print_values(save_value(chunk())) end - local function _734_(...) + local function _733_(...) return callbacks.onError("Runtime", ...) end - return xpcall(_733_, _734_) - elseif ((_731_0 == false) and (nil ~= _732_0)) then - local msg = _732_0 + return xpcall(_732_, _733_) + elseif ((_730_0 == false) and (nil ~= _731_0)) then + local msg = _731_0 clear_stream() return callbacks.onError("Compile", msg) end end - local function _737_(...) + local function _736_(...) local src0 = nil if save_locals_3f then src0 = splice_save_locals(env, src, opts.scope) @@ -701,18 +701,18 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) end return pcall(specials["load-code"], src0, env) end - return _730_(_737_(...)) - elseif ((_728_0 == false) and (nil ~= _729_0)) then - local msg = _729_0 + return _729_(_736_(...)) + elseif ((_727_0 == false) and (nil ~= _728_0)) then + local msg = _728_0 clear_stream() return callbacks.onError("Compile", msg) end end - local function _739_() + local function _738_() opts["source"] = src_string return opts end - _727_(pcall(compiler.compile, form, _739_())) + _726_(pcall(compiler.compile, form, _738_())) utils.root.options = old_root_options if exit_next_3f then return env.___replLocals___["*1"] @@ -732,10 +732,10 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) end return value end - local function _745_(overrides, _3fopts) + local function _744_(overrides, _3fopts) return repl(utils.copy(_3fopts, utils.copy(overrides))) end - return setmetatable({}, {__call = _745_, __index = {repl = repl}}) + return setmetatable({}, {__call = _744_, __index = {repl = repl}}) end package.preload["fennel.specials"] = package.preload["fennel.specials"] or function(...) local utils = require("fennel.utils") @@ -745,14 +745,14 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct local unpack = (table.unpack or _G.unpack) local SPECIALS = compiler.scopes.global.specials local function wrap_env(env) - local function _421_(_, key) + local function _420_(_, key) if utils["string?"](key) then return env[compiler["global-unmangling"](key)] else return env[key] end end - local function _423_(_, key, value) + local function _422_(_, key, value) if utils["string?"](key) then env[compiler["global-unmangling"](key)] = value return nil @@ -761,19 +761,19 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct return nil end end - local function _425_() + local function _424_() local function putenv(k, v) - local _426_ + local _425_ if utils["string?"](k) then - _426_ = compiler["global-unmangling"](k) + _425_ = compiler["global-unmangling"](k) else - _426_ = k + _425_ = k end - return _426_, v + return _425_, v end return next, utils.kvmap(env, putenv), nil end - return setmetatable({}, {__index = _421_, __newindex = _423_, __pairs = _425_}) + return setmetatable({}, {__index = _420_, __newindex = _422_, __pairs = _424_}) end local function fennel_module_name() return (utils.root.options.moduleName or "fennel") @@ -781,9 +781,9 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct local function current_global_names(_3fenv) local mt = nil do - local _428_0 = getmetatable(_3fenv) - if ((_G.type(_428_0) == "table") and (nil ~= _428_0.__pairs)) then - local mtpairs = _428_0.__pairs + local _427_0 = getmetatable(_3fenv) + if ((_G.type(_427_0) == "table") and (nil ~= _427_0.__pairs)) then + local mtpairs = _427_0.__pairs local tbl_14_ = {} for k, v in mtpairs(_3fenv) do local k_15_, v_16_ = k, v @@ -792,7 +792,7 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end end mt = tbl_14_ - elseif (_428_0 == nil) then + elseif (_427_0 == nil) then mt = (_3fenv or _G) else mt = nil @@ -802,15 +802,15 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end local function load_code(code, _3fenv, _3ffilename) local env = (_3fenv or rawget(_G, "_ENV") or _G) - local _431_0, _432_0 = rawget(_G, "setfenv"), rawget(_G, "loadstring") - if ((nil ~= _431_0) and (nil ~= _432_0)) then - local setfenv = _431_0 - local loadstring = _432_0 + local _430_0, _431_0 = rawget(_G, "setfenv"), rawget(_G, "loadstring") + if ((nil ~= _430_0) and (nil ~= _431_0)) then + local setfenv = _430_0 + local loadstring = _431_0 local f = assert(loadstring(code, _3ffilename)) setfenv(f, env) return f else - local _ = _431_0 + local _ = _430_0 return assert(load(code, _3ffilename, "t", env)) end end @@ -822,13 +822,13 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct 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 _434_ + local _433_ if (0 < #arglist) then - _434_ = " " + _433_ = " " else - _434_ = "" + _433_ = "" end - return string.format("(%s%s%s)\n %s", name, _434_, arglist, docstring) + return string.format("(%s%s%s)\n %s", name, _433_, arglist, docstring) else return string.format("%s\n %s", name, docstring) end @@ -938,9 +938,9 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct local opts = {nval = 1, tail = false} local scope = compiler["make-scope"]() local chunk = {} - local _444_ = compiler.compile1(v, scope, chunk, opts) - local _445_ = _444_[1] - local v0 = _445_[1] + local _443_ = compiler.compile1(v, scope, chunk, opts) + local _444_ = _443_[1] + local v0 = _444_[1] return v0 end local function insert_meta(meta, k, v) @@ -948,23 +948,23 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct compiler.assert((type(k) == "string"), ("expected string keys in metadata table, got: %s"):format(view(k, view_opts))) compiler.assert(literal_3f(v), ("expected literal value in metadata table, got: %s %s"):format(view(k, view_opts), view(v, view_opts))) table.insert(meta, view(k)) - local function _446_() + local function _445_() if ("string" == type(v)) then return view(v, view_opts) else return compile_value(v) end end - table.insert(meta, _446_()) + table.insert(meta, _445_()) return meta end local function insert_arglist(meta, arg_list) local view_opts = {["escape-newlines?"] = true, ["line-length"] = math.huge, ["one-line?"] = true} table.insert(meta, "\"fnl/arglist\"") - local function _447_(_241) + local function _446_(_241) return view(view(_241, view_opts)) end - table.insert(meta, ("{" .. table.concat(utils.map(arg_list, _447_), ", ") .. "}")) + table.insert(meta, ("{" .. table.concat(utils.map(arg_list, _446_), ", ") .. "}")) return meta end local function set_fn_metadata(f_metadata, parent, fn_name) @@ -983,13 +983,13 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end local function get_fn_name(ast, scope, fn_name, multi) if (fn_name and (fn_name[1] ~= "nil")) then - local _450_ + local _449_ if not multi then - _450_ = compiler["declare-local"](fn_name, {}, scope, ast) + _449_ = compiler["declare-local"](fn_name, {}, scope, ast) else - _450_ = compiler["symbol-to-expression"](fn_name, scope)[1] + _449_ = compiler["symbol-to-expression"](fn_name, scope)[1] end - return _450_, not multi, 3 + return _449_, not multi, 3 else return nil, true, 2 end @@ -999,13 +999,13 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct 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 _453_ + local _452_ if local_3f then - _453_ = "local function %s(%s)" + _452_ = "local function %s(%s)" else - _453_ = "%s = function(%s)" + _452_ = "%s = function(%s)" end - compiler.emit(parent, string.format(_453_, fn_name, table.concat(arg_name_list, ", ")), ast) + compiler.emit(parent, string.format(_452_, fn_name, table.concat(arg_name_list, ", ")), ast) compiler.emit(parent, f_chunk, ast) compiler.emit(parent, "end", ast) set_fn_metadata(f_metadata, parent, fn_name) @@ -1027,7 +1027,7 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end end local function get_function_metadata(ast, arg_list, index) - local function _456_(_241, _242) + local function _455_(_241, _242) local tbl_14_ = _241 for k, v in pairs(_242) do local k_15_, v_16_ = k, v @@ -1037,18 +1037,18 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end return tbl_14_ end - local function _458_(_241, _242) + local function _457_(_241, _242) _241["fnl/docstring"] = _242 return _241 end - return maybe_metadata(ast, utils["kv-table?"], _456_, maybe_metadata(ast, utils["string?"], _458_, {["fnl/arglist"] = arg_list}, index)) + return maybe_metadata(ast, utils["kv-table?"], _455_, maybe_metadata(ast, utils["string?"], _457_, {["fnl/arglist"] = arg_list}, index)) end SPECIALS.fn = function(ast, scope, parent) local f_scope = nil do - local _459_0 = compiler["make-scope"](scope) - _459_0["vararg"] = false - f_scope = _459_0 + local _458_0 = compiler["make-scope"](scope) + _458_0["vararg"] = false + f_scope = _458_0 end local f_chunk = {} local fn_sym = utils["sym?"](ast[2]) @@ -1108,28 +1108,28 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct 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 _464_ + local _463_ do - local _463_0 = utils["sym?"](ast[2]) - if (nil ~= _463_0) then - _464_ = tostring(_463_0) + local _462_0 = utils["sym?"](ast[2]) + if (nil ~= _462_0) then + _463_ = tostring(_462_0) else - _464_ = _463_0 + _463_ = _462_0 end end - if ("nil" ~= _464_) then + if ("nil" ~= _463_) then table.insert(parent, {ast = ast, leaf = tostring(ast[2])}) end - local _468_ + local _467_ do - local _467_0 = utils["sym?"](ast[3]) - if (nil ~= _467_0) then - _468_ = tostring(_467_0) + local _466_0 = utils["sym?"](ast[3]) + if (nil ~= _466_0) then + _467_ = tostring(_466_0) else - _468_ = _467_0 + _467_ = _466_0 end end - if ("nil" ~= _468_) then + if ("nil" ~= _467_) then return tostring(ast[3]) end end @@ -1137,8 +1137,8 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct compiler.assert((1 < #ast), "expected table argument", ast) local len = #ast local lhs_node = compiler.macroexpand(ast[2], scope) - local _471_ = compiler.compile1(lhs_node, scope, parent, {nval = 1}) - local lhs = _471_[1] + local _470_ = compiler.compile1(lhs_node, scope, parent, {nval = 1}) + local lhs = _470_[1] if (len == 2) then return tostring(lhs) else @@ -1148,8 +1148,8 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct if (utils["string?"](index) and utils["valid-lua-identifier?"](index)) then table.insert(indices, ("." .. index)) else - local _472_ = compiler.compile1(index, scope, parent, {nval = 1}) - local index0 = _472_[1] + local _471_ = compiler.compile1(index, scope, parent, {nval = 1}) + local index0 = _471_[1] table.insert(indices, ("[" .. tostring(index0) .. "]")) end end @@ -1194,7 +1194,7 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end doc_special("var", {"name", "val"}, "Introduce new mutable local.") local function kv_3f(t) - local _476_ + local _475_ do local tbl_17_ = {} local i_18_ = #tbl_17_ @@ -1210,9 +1210,9 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct tbl_17_[i_18_] = val_19_ end end - _476_ = tbl_17_ + _475_ = tbl_17_ end - return _476_[1] + return _475_[1] end SPECIALS.let = function(ast, scope, parent, opts) local bindings = ast[2] @@ -1239,22 +1239,22 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end end local function disambiguate_3f(rootstr, parent) - local function _481_() - local _480_0 = get_prev_line(parent) - if (nil ~= _480_0) then - local prev_line = _480_0 + local function _480_() + local _479_0 = get_prev_line(parent) + if (nil ~= _479_0) then + local prev_line = _479_0 return prev_line:match("%)$") end end - return (rootstr:match("^{") or rootstr:match("^%(") or _481_()) + return (rootstr:match("^{") or rootstr:match("^%(") or _480_()) 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 _483_ = compiler.compile1(ast[i], scope, parent, {nval = 1}) - local key = _483_[1] + local _482_ = compiler.compile1(ast[i], scope, parent, {nval = 1}) + local key = _482_[1] table.insert(keys, tostring(key)) end local value = compiler.compile1(ast[#ast], scope, parent, {nval = 1})[1] @@ -1378,10 +1378,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct local function remove_until_condition(bindings, ast) local _until = nil for i = (#bindings - 1), 3, -1 do - local _493_0 = clause_3f(bindings[i]) - if ((_493_0 == false) or (_493_0 == nil)) then - elseif (nil ~= _493_0) then - local clause = _493_0 + local _492_0 = clause_3f(bindings[i]) + if ((_492_0 == false) or (_492_0 == nil)) then + elseif (nil ~= _492_0) then + local clause = _492_0 compiler.assert(((clause == "until") and not _until), ("unexpected iterator clause: " .. clause), ast) table.remove(bindings, i) _until = table.remove(bindings, i) @@ -1391,8 +1391,8 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end local function compile_until(_3fcondition, scope, chunk) if _3fcondition then - local _495_ = compiler.compile1(_3fcondition, scope, chunk, {nval = 1}) - local condition_lua = _495_[1] + local _494_ = compiler.compile1(_3fcondition, scope, chunk, {nval = 1}) + local condition_lua = _494_[1] return compiler.emit(chunk, ("if %s then break end"):format(tostring(condition_lua)), utils.expr(_3fcondition, "expression")) end end @@ -1492,10 +1492,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct 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 _501_ = ast - local _ = _501_[1] - local _0 = _501_[2] - local method_string = _501_[3] + local _500_ = ast + local _ = _500_[1] + local _0 = _500_[2] + local method_string = _500_[3] local call_string = nil if ((target.type == "literal") or (target.type == "varg") or (target.type == "expression")) then call_string = "(%s):%s(%s)" @@ -1517,18 +1517,18 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end local function method_call(ast, scope, parent) compiler.assert((2 < #ast), "expected at least 2 arguments", ast) - local _503_ = compiler.compile1(ast[2], scope, parent, {nval = 1}) - local target = _503_[1] + local _502_ = compiler.compile1(ast[2], scope, parent, {nval = 1}) + local target = _502_[1] local args = {} for i = 4, #ast do local subexprs = nil - local _504_ + local _503_ if (i ~= #ast) then - _504_ = 1 + _503_ = 1 else - _504_ = nil + _503_ = nil end - subexprs = compiler.compile1(ast[i], scope, parent, {nval = _504_}) + subexprs = compiler.compile1(ast[i], scope, parent, {nval = _503_}) utils.map(subexprs, tostring, args) end if (utils["string?"](ast[3]) and utils["valid-lua-identifier?"](ast[3])) then @@ -1543,7 +1543,7 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct doc_special(":", {"tbl", "method-name", "..."}, "Call the named method on tbl with the provided args.\nMethod name doesn't have to be known at compile-time; if it is, use\n(tbl:method-name ...) instead.") SPECIALS.comment = function(ast, _, parent) local c = nil - local _507_ + local _506_ do local tbl_17_ = {} local i_18_ = #tbl_17_ @@ -1559,9 +1559,9 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct tbl_17_[i_18_] = val_19_ end end - _507_ = tbl_17_ + _506_ = tbl_17_ end - c = table.concat(_507_, " "):gsub("%]%]", "]\\]") + c = table.concat(_506_, " "):gsub("%]%]", "]\\]") return compiler.emit(parent, ("--[[ " .. c .. " ]]"), ast) end doc_special("comment", {"..."}, "Comment which will be emitted in Lua output.", true) @@ -1582,10 +1582,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct compiler.assert((#ast == 2), "expected one argument", ast) local f_scope = nil do - local _512_0 = compiler["make-scope"](scope) - _512_0["vararg"] = false - _512_0["hashfn"] = true - f_scope = _512_0 + local _511_0 = compiler["make-scope"](scope) + _511_0["vararg"] = false + _511_0["hashfn"] = true + f_scope = _511_0 end local f_chunk = {} local name = compiler.gensym(scope) @@ -1626,9 +1626,9 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct 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, _517_0) - local _518_ = _517_0 - local mac = _518_["macros"] + local function maybe_short_circuit_protect(ast, i, name, _516_0) + local _517_ = _516_0 + local mac = _517_["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.list(utils.sym("fn"), utils.sequence(utils.varg()), ast)) @@ -1649,15 +1649,15 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct table.insert(operands, tostring(subexprs[1])) end end - local _521_0 = #operands - if (_521_0 == 0) then - local _522_ + local _520_0 = #operands + if (_520_0 == 0) then + local _521_ do compiler.assert(zero_arity, "Expected more than 0 arguments", ast) - _522_ = zero_arity + _521_ = zero_arity end - return utils.expr(_522_, "literal") - elseif (_521_0 == 1) then + return utils.expr(_521_, "literal") + elseif (_520_0 == 1) then if utils["varg?"](ast[2]) then return compiler.assert(false, "tried to use vararg with operator", ast) elseif unary_prefix then @@ -1666,20 +1666,20 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct return operands[1] end else - local _ = _521_0 + local _ = _520_0 return ("(" .. table.concat(operands, padded_op) .. ")") end end local function define_arithmetic_special(name, zero_arity, unary_prefix, _3flua_name) - local _526_ + local _525_ do - local _525_0 = (_3flua_name or name) - local function _527_(...) - return operator_special(_525_0, zero_arity, unary_prefix, ...) + local _524_0 = (_3flua_name or name) + local function _526_(...) + return operator_special(_524_0, zero_arity, unary_prefix, ...) end - _526_ = _527_ + _525_ = _526_ end - SPECIALS[name] = _526_ + SPECIALS[name] = _525_ return doc_special(name, {"a", "b", "..."}, "Arithmetic operator; works the same as Lua but accepts more arguments.") end define_arithmetic_special("+", "0") @@ -1708,13 +1708,13 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct local prefixed_lib_name = ("bit." .. lib_name) for i = 2, len do local subexprs = nil - local _528_ + local _527_ if (i ~= len) then - _528_ = 1 + _527_ = 1 else - _528_ = nil + _527_ = nil end - subexprs = compiler.compile1(ast[i], scope, parent, {nval = _528_}) + subexprs = compiler.compile1(ast[i], scope, parent, {nval = _527_}) utils.map(subexprs, tostring, operands) end if (#operands == 1) then @@ -1733,10 +1733,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end end local function define_bitop_special(name, zero_arity, unary_prefix, native) - local function _534_(...) + local function _533_(...) return bitop_special(native, name, zero_arity, unary_prefix, ...) end - SPECIALS[name] = _534_ + SPECIALS[name] = _533_ return nil end define_bitop_special("lshift", nil, "1", "<<") @@ -1751,8 +1751,8 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct 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.") SPECIALS.bnot = function(ast, scope, parent) compiler.assert((#ast == 2), "expected one argument", ast) - local _535_ = compiler.compile1(ast[2], scope, parent, {nval = 1}) - local value = _535_[1] + local _534_ = compiler.compile1(ast[2], scope, parent, {nval = 1}) + local value = _534_[1] if utils.root.options.useBitLib then return ("bit.bnot(" .. tostring(value) .. ")") else @@ -1761,15 +1761,15 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end doc_special("bnot", {"x"}, "Bitwise negation; only 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, _537_0, scope, parent) - local _538_ = _537_0 - local _ = _538_[1] - local lhs_ast = _538_[2] - local rhs_ast = _538_[3] - local _539_ = compiler.compile1(lhs_ast, scope, parent, {nval = 1}) - local lhs = _539_[1] - local _540_ = compiler.compile1(rhs_ast, scope, parent, {nval = 1}) - local rhs = _540_[1] + local function native_comparator(op, _536_0, scope, parent) + local _537_ = _536_0 + local _ = _537_[1] + local lhs_ast = _537_[2] + local rhs_ast = _537_[3] + local _538_ = compiler.compile1(lhs_ast, scope, parent, {nval = 1}) + local lhs = _538_[1] + local _539_ = compiler.compile1(rhs_ast, scope, parent, {nval = 1}) + local rhs = _539_[1] return string.format("(%s %s %s)", tostring(lhs), op, tostring(rhs)) end local function idempotent_comparator(op, chain_op, ast, scope, parent) @@ -1882,21 +1882,21 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end local safe_require = nil local function safe_compiler_env() - local _547_ + local _546_ do - local _546_0 = rawget(_G, "utf8") - if (nil ~= _546_0) then - _547_ = utils.copy(_546_0) + local _545_0 = rawget(_G, "utf8") + if (nil ~= _545_0) then + _546_ = utils.copy(_545_0) else - _547_ = _546_0 + _546_ = _545_0 end end - return {_VERSION = _VERSION, assert = assert, bit = rawget(_G, "bit"), error = error, getmetatable = safe_getmetatable, ipairs = ipairs, math = utils.copy(math), next = next, pairs = utils.stablepairs, pcall = pcall, print = print, rawequal = rawequal, rawget = rawget, rawlen = rawget(_G, "rawlen"), rawset = rawset, require = safe_require, select = select, setmetatable = setmetatable, string = utils.copy(string), table = utils.copy(table), tonumber = tonumber, tostring = tostring, type = type, utf8 = _547_, xpcall = xpcall} + return {_VERSION = _VERSION, assert = assert, bit = rawget(_G, "bit"), error = error, getmetatable = safe_getmetatable, ipairs = ipairs, math = utils.copy(math), next = next, pairs = utils.stablepairs, pcall = pcall, print = print, rawequal = rawequal, rawget = rawget, rawlen = rawget(_G, "rawlen"), rawset = rawset, require = safe_require, select = select, setmetatable = setmetatable, string = utils.copy(string), table = utils.copy(table), tonumber = tonumber, tostring = tostring, type = type, utf8 = _546_, xpcall = xpcall} end local function combined_mt_pairs(env) local combined = {} - local _549_ = getmetatable(env) - local __index = _549_["__index"] + local _548_ = getmetatable(env) + local __index = _548_["__index"] if ("table" == type(__index)) then for k, v in pairs(__index) do combined[k] = v @@ -1910,40 +1910,40 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct local function make_compiler_env(ast, scope, parent, _3fopts) local provided = nil do - local _551_0 = (_3fopts or utils.root.options) - if ((_G.type(_551_0) == "table") and (_551_0["compiler-env"] == "strict")) then + local _550_0 = (_3fopts or utils.root.options) + if ((_G.type(_550_0) == "table") and (_550_0["compiler-env"] == "strict")) then provided = safe_compiler_env() - elseif ((_G.type(_551_0) == "table") and (nil ~= _551_0.compilerEnv)) then - local compilerEnv = _551_0.compilerEnv + elseif ((_G.type(_550_0) == "table") and (nil ~= _550_0.compilerEnv)) then + local compilerEnv = _550_0.compilerEnv provided = compilerEnv - elseif ((_G.type(_551_0) == "table") and (nil ~= _551_0["compiler-env"])) then - local compiler_env = _551_0["compiler-env"] + elseif ((_G.type(_550_0) == "table") and (nil ~= _550_0["compiler-env"])) then + local compiler_env = _550_0["compiler-env"] provided = compiler_env else - local _ = _551_0 + local _ = _550_0 provided = safe_compiler_env() end end local env = nil - local function _553_() + local function _552_() return compiler.scopes.macro end - local function _554_(symbol) + local function _553_(symbol) compiler.assert(compiler.scopes.macro, "must call from macro", ast) return compiler.scopes.macro.manglings[tostring(symbol)] end - local function _555_(base) + local function _554_(base) return utils.sym(compiler.gensym((compiler.scopes.macro or scope), base)) end - local function _556_(form) + local function _555_(form) compiler.assert(compiler.scopes.macro, "must call from macro", ast) return compiler.macroexpand(form, compiler.scopes.macro) end - env = {["assert-compile"] = compiler.assert, ["ast-source"] = utils["ast-source"], ["comment?"] = utils["comment?"], ["fennel-module-name"] = fennel_module_name, ["get-scope"] = _553_, ["in-scope?"] = _554_, ["list?"] = utils["list?"], ["macro-loaded"] = macro_loaded, ["multi-sym?"] = utils["multi-sym?"], ["sequence?"] = utils["sequence?"], ["sym?"] = utils["sym?"], ["table?"] = utils["table?"], ["varg?"] = utils["varg?"], _AST = ast, _CHUNK = parent, _IS_COMPILER = true, _SCOPE = scope, _SPECIALS = compiler.scopes.global.specials, _VARARG = utils.varg(), comment = utils.comment, gensym = _555_, list = utils.list, macroexpand = _556_, sequence = utils.sequence, sym = utils.sym, unpack = unpack, version = utils.version, view = view} + env = {["assert-compile"] = compiler.assert, ["ast-source"] = utils["ast-source"], ["comment?"] = utils["comment?"], ["fennel-module-name"] = fennel_module_name, ["get-scope"] = _552_, ["in-scope?"] = _553_, ["list?"] = utils["list?"], ["macro-loaded"] = macro_loaded, ["multi-sym?"] = utils["multi-sym?"], ["sequence?"] = utils["sequence?"], ["sym?"] = utils["sym?"], ["table?"] = utils["table?"], ["varg?"] = utils["varg?"], _AST = ast, _CHUNK = parent, _IS_COMPILER = true, _SCOPE = scope, _SPECIALS = compiler.scopes.global.specials, _VARARG = utils.varg(), comment = utils.comment, gensym = _554_, list = utils.list, macroexpand = _555_, sequence = utils.sequence, sym = utils.sym, unpack = unpack, version = utils.version, view = view} env._G = env return setmetatable(env, {__index = provided, __newindex = provided, __pairs = combined_mt_pairs}) end - local function _557_(...) + local function _556_(...) local tbl_17_ = {} local i_18_ = #tbl_17_ for c in string.gmatch((package.config or ""), "([^\n]+)") do @@ -1955,10 +1955,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end return tbl_17_ end - local _559_ = _557_(...) - local dirsep = _559_[1] - local pathsep = _559_[2] - local pathmark = _559_[3] + local _558_ = _556_(...) + local dirsep = _558_[1] + local pathsep = _558_[2] + local pathmark = _558_[3] local pkg_config = {dirsep = (dirsep or "/"), pathmark = (pathmark or "?"), pathsep = (pathsep or ";")} local function escapepat(str) return string.gsub(str, "[^%w]", "%%%1") @@ -1971,36 +1971,36 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct 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 _560_0 = (io.open(filename) or io.open(filename2)) - if (nil ~= _560_0) then - local file = _560_0 + local _559_0 = (io.open(filename) or io.open(filename2)) + if (nil ~= _559_0) then + local file = _559_0 file:close() return filename else - local _ = _560_0 + local _ = _559_0 return nil, ("no file '" .. filename .. "'") end end local function find_in_path(start, _3ftried_paths) - local _562_0 = fullpath:match(pattern, start) - if (nil ~= _562_0) then - local path = _562_0 - local _563_0, _564_0 = try_path(path) - if (nil ~= _563_0) then - local filename = _563_0 + local _561_0 = fullpath:match(pattern, start) + if (nil ~= _561_0) then + local path = _561_0 + local _562_0, _563_0 = try_path(path) + if (nil ~= _562_0) then + local filename = _562_0 return filename - elseif ((_563_0 == nil) and (nil ~= _564_0)) then - local error = _564_0 - local function _566_() - local _565_0 = (_3ftried_paths or {}) - table.insert(_565_0, error) - return _565_0 + elseif ((_562_0 == nil) and (nil ~= _563_0)) then + local error = _563_0 + local function _565_() + local _564_0 = (_3ftried_paths or {}) + table.insert(_564_0, error) + return _564_0 end - return find_in_path((start + #path + 1), _566_()) + return find_in_path((start + #path + 1), _565_()) end else - local _ = _562_0 - local function _568_() + local _ = _561_0 + local function _567_() local tried_paths = table.concat((_3ftried_paths or {}), "\n\9") if (_VERSION < "Lua 5.4") then return ("\n\9" .. tried_paths) @@ -2008,31 +2008,31 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct return tried_paths end end - return nil, _568_() + return nil, _567_() end end return find_in_path(1) end local function make_searcher(_3foptions) - local function _571_(module_name) + local function _570_(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 _572_0, _573_0 = search_module(module_name) - if (nil ~= _572_0) then - local filename = _572_0 - local function _574_(...) + local _571_0, _572_0 = search_module(module_name) + if (nil ~= _571_0) then + local filename = _571_0 + local function _573_(...) return utils["fennel-module"].dofile(filename, opts, ...) end - return _574_, filename - elseif ((_572_0 == nil) and (nil ~= _573_0)) then - local error = _573_0 + return _573_, filename + elseif ((_571_0 == nil) and (nil ~= _572_0)) then + local error = _572_0 return error end end - return _571_ + return _570_ end local function dofile_with_searcher(fennel_macro_searcher, filename, opts, ...) local searchers = (package.loaders or package.searchers or {}) @@ -2044,35 +2044,35 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct local function fennel_macro_searcher(module_name) local opts = nil do - local _576_0 = utils.copy(utils.root.options) - _576_0["module-name"] = module_name - _576_0["env"] = "_COMPILER" - _576_0["requireAsInclude"] = false - _576_0["allowedGlobals"] = nil - opts = _576_0 + local _575_0 = utils.copy(utils.root.options) + _575_0["module-name"] = module_name + _575_0["env"] = "_COMPILER" + _575_0["requireAsInclude"] = false + _575_0["allowedGlobals"] = nil + opts = _575_0 end - local _577_0 = search_module(module_name, utils["fennel-module"]["macro-path"]) - if (nil ~= _577_0) then - local filename = _577_0 - local _578_ + local _576_0 = search_module(module_name, utils["fennel-module"]["macro-path"]) + if (nil ~= _576_0) then + local filename = _576_0 + local _577_ if (opts["compiler-env"] == _G) then - local function _579_(...) + local function _578_(...) return dofile_with_searcher(fennel_macro_searcher, filename, opts, ...) end - _578_ = _579_ + _577_ = _578_ else - local function _580_(...) + local function _579_(...) return utils["fennel-module"].dofile(filename, opts, ...) end - _578_ = _580_ + _577_ = _579_ end - return _578_, filename + return _577_, filename end end local function lua_macro_searcher(module_name) - local _583_0 = search_module(module_name, package.path) - if (nil ~= _583_0) then - local filename = _583_0 + local _582_0 = search_module(module_name, package.path) + if (nil ~= _582_0) then + local filename = _582_0 local code = nil do local f = io.open(filename) @@ -2084,10 +2084,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct return error(..., 0) end end - local function _585_() + local function _584_() return assert(f:read("*a")) end - code = close_handlers_10_(_G.xpcall(_585_, (package.loaded.fennel or debug).traceback)) + code = close_handlers_10_(_G.xpcall(_584_, (package.loaded.fennel or debug).traceback)) end local chunk = load_code(code, make_compiler_env(), filename) return chunk, filename @@ -2095,38 +2095,38 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end local macro_searchers = {fennel_macro_searcher, lua_macro_searcher} local function search_macro_module(modname, n) - local _587_0 = macro_searchers[n] - if (nil ~= _587_0) then - local f = _587_0 - local _588_0, _589_0 = f(modname) - if ((nil ~= _588_0) and true) then - local loader = _588_0 - local _3ffilename = _589_0 + local _586_0 = macro_searchers[n] + if (nil ~= _586_0) then + local f = _586_0 + local _587_0, _588_0 = f(modname) + if ((nil ~= _587_0) and true) then + local loader = _587_0 + local _3ffilename = _588_0 return loader, _3ffilename else - local _ = _588_0 + local _ = _587_0 return search_macro_module(modname, (n + 1)) end end end local function sandbox_fennel_module(modname) if ((modname == "fennel.macros") or (package and package.loaded and ("table" == type(package.loaded[modname])) and (package.loaded[modname].metadata == compiler.metadata))) then - local function _592_(_, ...) + local function _591_(_, ...) return (compiler.metadata):setall(...) end - return {metadata = {setall = _592_}, view = view} + return {metadata = {setall = _591_}, view = view} end end - local function _594_(modname) - local function _595_() + local function _593_(modname) + local function _594_() local loader, filename = search_macro_module(modname, 1) compiler.assert(loader, (modname .. " module not found.")) macro_loaded[modname] = loader(modname, filename) return macro_loaded[modname] end - return (macro_loaded[modname] or sandbox_fennel_module(modname) or _595_()) + return (macro_loaded[modname] or sandbox_fennel_module(modname) or _594_()) end - safe_require = _594_ + safe_require = _593_ 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 @@ -2136,10 +2136,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end return nil end - local function resolve_module_name(_596_0, _scope, _parent, opts) - local _597_ = _596_0 - local second = _597_[2] - local filename = _597_["filename"] + local function resolve_module_name(_595_0, _scope, _parent, opts) + local _596_ = _595_0 + local second = _596_[2] + local filename = _596_["filename"] local filename0 = (filename or (utils["table?"](second) and second.filename)) local module_name = utils.root.options["module-name"] local modexpr = compiler.compile(second, opts) @@ -2196,10 +2196,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct return error(..., 0) end end - local function _603_() + local function _602_() return assert(f:read("*all")):gsub("[\13\n]*$", "") end - src = close_handlers_10_(_G.xpcall(_603_, (package.loaded.fennel or debug).traceback)) + src = close_handlers_10_(_G.xpcall(_602_, (package.loaded.fennel or debug).traceback)) end local ret = utils.expr(("require(\"" .. mod .. "\")"), "statement") local target = ("package.preload[%q]"):format(mod) @@ -2229,12 +2229,12 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct compiler.assert((#ast == 2), "expected one argument", ast) local modexpr = nil do - local _606_0, _607_0 = pcall(resolve_module_name, ast, scope, parent, opts) - if ((_606_0 == true) and (nil ~= _607_0)) then - local modname = _607_0 + local _605_0, _606_0 = pcall(resolve_module_name, ast, scope, parent, opts) + if ((_605_0 == true) and (nil ~= _606_0)) then + local modname = _606_0 modexpr = utils.expr(string.format("%q", modname), "literal") else - local _ = _606_0 + local _ = _605_0 modexpr = compiler.compile1(ast[2], scope, parent, {nval = 1})[1] end end @@ -2251,13 +2251,13 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct utils.root.options["module-name"] = mod _ = nil local res = nil - local function _611_() - local _610_0 = search_module(mod) - if (nil ~= _610_0) then - local fennel_path = _610_0 + local function _610_() + local _609_0 = search_module(mod) + if (nil ~= _609_0) then + local fennel_path = _609_0 return include_path(ast, opts, fennel_path, mod, true) else - local _0 = _610_0 + local _0 = _609_0 local lua_path = search_module(mod, package.path) if lua_path then return include_path(ast, opts, lua_path, mod, false) @@ -2268,7 +2268,7 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end 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 _611_()) + 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 _610_()) utils.root.options["module-name"] = oldmod return res end @@ -2319,13 +2319,13 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct local scopes = {compiler = nil, global = nil, macro = nil} local function make_scope(_3fparent) local parent = (_3fparent or scopes.global) - local _265_ + local _264_ if parent then - _265_ = ((parent.depth or 0) + 1) + _264_ = ((parent.depth or 0) + 1) else - _265_ = 0 + _264_ = 0 end - return {["gensym-base"] = setmetatable({}, {__index = (parent and parent["gensym-base"])}), autogensyms = setmetatable({}, {__index = (parent and parent.autogensyms)}), depth = _265_, gensyms = setmetatable({}, {__index = (parent and parent.gensyms)}), hashfn = (parent and parent.hashfn), includes = setmetatable({}, {__index = (parent and parent.includes)}), macros = setmetatable({}, {__index = (parent and parent.macros)}), manglings = setmetatable({}, {__index = (parent and parent.manglings)}), parent = parent, refedglobals = {}, specials = setmetatable({}, {__index = (parent and parent.specials)}), symmeta = setmetatable({}, {__index = (parent and parent.symmeta)}), unmanglings = setmetatable({}, {__index = (parent and parent.unmanglings)}), vararg = (parent and parent.vararg)} + return {["gensym-base"] = setmetatable({}, {__index = (parent and parent["gensym-base"])}), autogensyms = setmetatable({}, {__index = (parent and parent.autogensyms)}), depth = _264_, gensyms = setmetatable({}, {__index = (parent and parent.gensyms)}), hashfn = (parent and parent.hashfn), includes = setmetatable({}, {__index = (parent and parent.includes)}), macros = setmetatable({}, {__index = (parent and parent.macros)}), manglings = setmetatable({}, {__index = (parent and parent.manglings)}), parent = parent, refedglobals = {}, specials = setmetatable({}, {__index = (parent and parent.specials)}), symmeta = setmetatable({}, {__index = (parent and parent.symmeta)}), unmanglings = setmetatable({}, {__index = (parent and parent.unmanglings)}), vararg = (parent and parent.vararg)} end local function assert_msg(ast, msg) local ast_tbl = nil @@ -2343,10 +2343,10 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end local function assert_compile(condition, msg, ast, _3ffallback_ast) if not condition then - local _268_ = (utils.root.options or {}) - local error_pinpoint = _268_["error-pinpoint"] - local source = _268_["source"] - local unfriendly = _268_["unfriendly"] + local _267_ = (utils.root.options or {}) + local error_pinpoint = _267_["error-pinpoint"] + local source = _267_["source"] + local unfriendly = _267_["unfriendly"] local ast0 = nil if next(utils["ast-source"](ast)) then ast0 = ast @@ -2370,33 +2370,33 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct scopes.macro = scopes.global local serialize_subst = {["\11"] = "\\v", ["\12"] = "\\f", ["\7"] = "\\a", ["\8"] = "\\b", ["\9"] = "\\t", ["\n"] = "n"} local function serialize_string(str) - local function _273_(_241) + local function _272_(_241) return ("\\" .. _241:byte()) end - return string.gsub(string.gsub(string.format("%q", str), ".", serialize_subst), "[\128-\255]", _273_) + return string.gsub(string.gsub(string.format("%q", str), ".", serialize_subst), "[\128-\255]", _272_) end local function global_mangling(str) if utils["valid-lua-identifier?"](str) then return str else - local function _274_(_241) + local function _273_(_241) return string.format("_%02x", _241:byte()) end - return ("__fnl_global__" .. str:gsub("[^%w]", _274_)) + return ("__fnl_global__" .. str:gsub("[^%w]", _273_)) end end local function global_unmangling(identifier) - local _276_0 = string.match(identifier, "^__fnl_global__(.*)$") - if (nil ~= _276_0) then - local rest = _276_0 - local _277_0 = nil - local function _278_(_241) + local _275_0 = string.match(identifier, "^__fnl_global__(.*)$") + if (nil ~= _275_0) then + local rest = _275_0 + local _276_0 = nil + local function _277_(_241) return string.char(tonumber(_241:sub(2), 16)) end - _277_0 = string.gsub(rest, "_[%da-f][%da-f]", _278_) - return _277_0 + _276_0 = string.gsub(rest, "_[%da-f][%da-f]", _277_) + return _276_0 else - local _ = _276_0 + local _ = _275_0 return identifier end end @@ -2420,10 +2420,10 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct raw = str end local mangling = nil - local function _282_(_241) + local function _281_(_241) return string.format("_%02x", _241:byte()) end - mangling = string.gsub(string.gsub(raw, "-", "_"), "[^%w_]", _282_) + mangling = string.gsub(string.gsub(raw, "-", "_"), "[^%w_]", _281_) local unique = unique_mangling(mangling, mangling, scope, 0) scope.unmanglings[unique] = (scope["gensym-base"][str] or str) do @@ -2478,29 +2478,29 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return table.concat(parts, ".") end local function autogensym(base, scope) - local _286_0 = utils["multi-sym?"](base) - if (nil ~= _286_0) then - local parts = _286_0 + local _285_0 = utils["multi-sym?"](base) + if (nil ~= _285_0) then + local parts = _285_0 return combine_auto_gensym(parts, autogensym(parts[1], scope)) else - local _ = _286_0 - local function _287_() + local _ = _285_0 + local function _286_() local mangling = gensym(scope, base:sub(1, -2), "auto") scope.autogensyms[base] = mangling return mangling end - return (scope.autogensyms[base] or _287_()) + return (scope.autogensyms[base] or _286_()) end end local function check_binding_valid(symbol, scope, ast, _3fopts) local name = tostring(symbol) local macro_3f = nil do - local _289_0 = _3fopts - if (nil ~= _289_0) then - _289_0 = _289_0["macro?"] + local _288_0 = _3fopts + if (nil ~= _288_0) then + _288_0 = _288_0["macro?"] end - macro_3f = _289_0 + macro_3f = _288_0 end assert_compile(("&" ~= name:match("[&.:]")), "invalid character: &", symbol) assert_compile(not name:find("^%."), "invalid character: .", symbol) @@ -2598,22 +2598,22 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end local function flatten_chunk(file_sourcemap, chunk, tab, depth) if chunk.leaf then - local _301_ = utils["ast-source"](chunk.ast) - local filename = _301_["filename"] - local line = _301_["line"] + local _300_ = utils["ast-source"](chunk.ast) + local filename = _300_["filename"] + local line = _300_["line"] table.insert(file_sourcemap, {filename, line}) return chunk.leaf else local tab0 = nil do - local _302_0 = tab - if (_302_0 == true) then + local _301_0 = tab + if (_301_0 == true) then tab0 = " " - elseif (_302_0 == false) then + elseif (_301_0 == false) then tab0 = "" - elseif (_302_0 == tab) then + elseif (_301_0 == tab) then tab0 = tab - elseif (_302_0 == nil) then + elseif (_301_0 == nil) then tab0 = "" else tab0 = nil @@ -2659,7 +2659,7 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end end local function make_metadata() - local function _310_(self, tgt, _3fkey) + local function _309_(self, tgt, _3fkey) if self[tgt] then if (nil ~= _3fkey) then return self[tgt][_3fkey] @@ -2668,12 +2668,12 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end end end - local function _313_(self, tgt, key, value) + local function _312_(self, tgt, key, value) self[tgt] = (self[tgt] or {}) self[tgt][key] = value return tgt end - local function _314_(self, tgt, ...) + local function _313_(self, tgt, ...) local kv_len = select("#", ...) local kvs = {...} if ((kv_len % 2) ~= 0) then @@ -2685,7 +2685,7 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end return tgt end - return setmetatable({}, {__index = {get = _310_, set = _313_, setall = _314_}, __mode = "k"}) + return setmetatable({}, {__index = {get = _309_, set = _312_, setall = _313_}, __mode = "k"}) end local function exprs1(exprs) return table.concat(utils.map(exprs, tostring), ", ") @@ -2731,14 +2731,14 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end if opts.target then local result = exprs1(exprs) - local function _322_() + local function _321_() if (result == "") then return "nil" else return result end end - emit(parent, string.format("%s = %s", opts.target, _322_()), ast) + emit(parent, string.format("%s = %s", opts.target, _321_()), ast) end if (opts.tail or opts.target) then return {returned = true} @@ -2750,16 +2750,16 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct local function find_macro(ast, scope) local macro_2a = nil do - local _325_0 = utils["sym?"](ast[1]) - if (_325_0 ~= nil) then - local _326_0 = tostring(_325_0) - if (_326_0 ~= nil) then - macro_2a = scope.macros[_326_0] + local _324_0 = utils["sym?"](ast[1]) + if (_324_0 ~= nil) then + local _325_0 = tostring(_324_0) + if (_325_0 ~= nil) then + macro_2a = scope.macros[_325_0] else - macro_2a = _326_0 + macro_2a = _325_0 end else - macro_2a = _325_0 + macro_2a = _324_0 end end local multi_sym_parts = utils["multi-sym?"](ast[1]) @@ -2771,12 +2771,12 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return macro_2a end end - local function propagate_trace_info(_330_0, _index, node) - local _331_ = _330_0 - local byteend = _331_["byteend"] - local bytestart = _331_["bytestart"] - local filename = _331_["filename"] - local line = _331_["line"] + local function propagate_trace_info(_329_0, _index, node) + local _330_ = _329_0 + local byteend = _330_["byteend"] + local bytestart = _330_["bytestart"] + local filename = _330_["filename"] + local line = _330_["line"] do local src = utils["ast-source"](node) if (("table" == type(node)) and (filename ~= src.filename)) then @@ -2789,8 +2789,8 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct local function quote_literal_nils(index, node, parent) if (parent and utils["list?"](parent)) then for i = 1, utils.maxn(parent) do - local _333_0 = parent[i] - if (_333_0 == nil) then + local _332_0 = parent[i] + if (_332_0 == nil) then parent[i] = utils.sym("nil") end end @@ -2798,10 +2798,10 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return index, node, parent end local function comp(f, g) - local function _336_(...) + local function _335_(...) return f(g(...)) end - return _336_ + return _335_ end local function built_in_3f(m) local found_3f = false @@ -2812,36 +2812,36 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return found_3f end local function macroexpand_2a(ast, scope, _3fonce) - local _337_0 = nil + local _336_0 = nil if utils["list?"](ast) then - _337_0 = find_macro(ast, scope) + _336_0 = find_macro(ast, scope) else - _337_0 = nil + _336_0 = nil end - if (_337_0 == false) then + if (_336_0 == false) then return ast - elseif (nil ~= _337_0) then - local macro_2a = _337_0 + elseif (nil ~= _336_0) then + local macro_2a = _336_0 local old_scope = scopes.macro local _ = nil scopes.macro = scope _ = nil local ok, transformed = nil, nil - local function _339_() + local function _338_() return macro_2a(unpack(ast, 2)) end - local function _340_() + local function _339_() if built_in_3f(macro_2a) then return tostring else return debug.traceback end end - ok, transformed = xpcall(_339_, _340_()) - local function _341_(...) + ok, transformed = xpcall(_338_, _339_()) + local function _340_(...) return propagate_trace_info(ast, ...) end - utils["walk-tree"](transformed, comp(_341_, quote_literal_nils)) + utils["walk-tree"](transformed, comp(_340_, quote_literal_nils)) scopes.macro = old_scope assert_compile(ok, transformed, ast) utils.hook("macroexpand", ast, transformed, scope) @@ -2851,7 +2851,7 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return macroexpand_2a(transformed, scope) end else - local _ = _337_0 + local _ = _336_0 return ast end end @@ -2883,13 +2883,13 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct 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 = nil - local _347_ + local _346_ if (i ~= len) then - _347_ = 1 + _346_ = 1 else - _347_ = nil + _346_ = nil end - subexprs = compile1(ast[i], scope, parent, {nval = _347_}) + subexprs = compile1(ast[i], scope, parent, {nval = _346_}) table.insert(fargs, subexprs[1]) if (i == len) then for j = 2, #subexprs do @@ -2927,13 +2927,13 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end end local function compile_varg(ast, scope, parent, opts) - local _352_ + local _351_ if scope.hashfn then - _352_ = "use $... in hashfn" + _351_ = "use $... in hashfn" else - _352_ = "unexpected vararg" + _351_ = "unexpected vararg" end - assert_compile(scope.vararg, _352_, ast) + assert_compile(scope.vararg, _351_, ast) return handle_compile_opts({utils.expr("...", "varg")}, parent, opts, ast) end local function compile_sym(ast, scope, parent, opts) @@ -2948,20 +2948,20 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return handle_compile_opts({e}, parent, opts, ast) end local function serialize_number(n) - local _355_0 = string.gsub(tostring(n), ",", ".") - return _355_0 + local _354_0 = string.gsub(tostring(n), ",", ".") + return _354_0 end local function compile_scalar(ast, _scope, parent, opts) local serialize = nil do - local _356_0 = type(ast) - if (_356_0 == "nil") then + local _355_0 = type(ast) + if (_355_0 == "nil") then serialize = tostring - elseif (_356_0 == "boolean") then + elseif (_355_0 == "boolean") then serialize = tostring - elseif (_356_0 == "string") then + elseif (_355_0 == "string") then serialize = serialize_string - elseif (_356_0 == "number") then + elseif (_355_0 == "number") then serialize = serialize_number else serialize = nil @@ -2974,8 +2974,8 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct if ((type(k) == "string") and utils["valid-lua-identifier?"](k)) then return k else - local _358_ = compile1(k, scope, parent, {nval = 1}) - local compiled = _358_[1] + local _357_ = compile1(k, scope, parent, {nval = 1}) + local compiled = _357_[1] return ("[" .. tostring(compiled) .. "]") end end @@ -3004,8 +3004,8 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct for k in utils.stablepairs(ast) do local val_19_ = nil if not keys[k] then - local _361_ = compile1(ast[k], scope, parent, {nval = 1}) - local v = _361_[1] + local _360_ = compile1(ast[k], scope, parent, {nval = 1}) + local v = _360_[1] val_19_ = string.format("%s = %s", escape_key(k), tostring(v)) else val_19_ = nil @@ -3037,12 +3037,12 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end local function destructure(to, from, ast, scope, parent, opts) local opts0 = (opts or {}) - local _365_ = opts0 - local declaration = _365_["declaration"] - local forceglobal = _365_["forceglobal"] - local forceset = _365_["forceset"] - local isvar = _365_["isvar"] - local symtype = _365_["symtype"] + local _364_ = opts0 + local declaration = _364_["declaration"] + local forceglobal = _364_["forceglobal"] + local forceset = _364_["forceset"] + local isvar = _364_["isvar"] + local symtype = _364_["symtype"] local symtype0 = ("_" .. (symtype or "dst")) local setter = nil if declaration then @@ -3058,8 +3058,8 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return declare_local(symbol, nil, scope, symbol, new_manglings) else local parts = (utils["multi-sym?"](raw) or {raw}) - local _367_ = parts - local first = _367_[1] + local _366_ = parts + local first = _366_[1] local meta = scope.symmeta[first] assert_compile(not raw:find(":"), "cannot set method sym", symbol) if ((#parts == 1) and not forceset) then @@ -3080,14 +3080,14 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end local function compile_top_target(lvalues) local inits = nil - local function _372_(_241) + local function _371_(_241) if scope.manglings[_241] then return _241 else return "nil" end end - inits = utils.map(lvalues, _372_) + inits = utils.map(lvalues, _371_) local init = table.concat(inits, ", ") local lvalue = table.concat(lvalues, ", ") local plast = parent[#parent] @@ -3125,7 +3125,7 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct 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 = nil - local _379_ + local _378_ do local tbl_17_ = {} local i_18_ = #tbl_17_ @@ -3136,9 +3136,9 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct tbl_17_[i_18_] = val_19_ end end - _379_ = tbl_17_ + _378_ = tbl_17_ end - exclude_str = table.concat(_379_, ", ") + exclude_str = table.concat(_378_, ", ") 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 @@ -3153,16 +3153,16 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct local s = gensym(scope, symtype0) local right = nil do - local _381_0 = nil + local _380_0 = nil if top_3f then - _381_0 = exprs1(compile1(from, scope, parent)) + _380_0 = exprs1(compile1(from, scope, parent)) else - _381_0 = exprs1(rightexprs) + _380_0 = exprs1(rightexprs) end - if (_381_0 == "") then + if (_380_0 == "") then right = "nil" - elseif (nil ~= _381_0) then - local right0 = _381_0 + elseif (nil ~= _380_0) then + local right0 = _380_0 right = right0 else right = nil @@ -3270,8 +3270,8 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct if opts.assertAsRepl then scope.macros.assert = scope.macros["assert-repl"] end - local _396_ = utils.root - _396_["set-reset"](_396_) + local _395_ = utils.root + _395_["set-reset"](_395_) utils.root.chunk, utils.root.scope, utils.root.options = chunk, scope, opts for i = 1, #asts do local exprs = compile1(asts[i], scope, chunk, {nval = (((i < #asts) and 0) or nil), tail = (i == #asts)}) @@ -3323,14 +3323,14 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct info.currentline = (remap[info.currentline][2] or -1) end if (info.what == "Lua") then - local function _401_() + local function _400_() if info.name then return ("'" .. info.name .. "'") else return "?" end end - return string.format("\9%s:%d: in function %s", info.short_src, info.currentline, _401_()) + return string.format("\9%s:%d: in function %s", info.short_src, info.currentline, _400_()) elseif (info.short_src == "(tail call)") then return " (tail call)" else @@ -3354,11 +3354,11 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct local done_3f, level = false, (_3fstart or 2) while not done_3f do do - local _405_0 = debug.getinfo(level, "Sln") - if (_405_0 == nil) then + local _404_0 = debug.getinfo(level, "Sln") + if (_404_0 == nil) then done_3f = true - elseif (nil ~= _405_0) then - local info = _405_0 + elseif (nil ~= _404_0) then + local info = _404_0 table.insert(lines, traceback_frame(info)) end end @@ -3368,14 +3368,14 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end end local function entry_transform(fk, fv) - local function _408_(k, v) + local function _407_(k, v) if (type(k) == "number") then return k, fv(v) else return fk(k), fv(v) end end - return _408_ + return _407_ end local function mixed_concat(t, joiner) local seen = {} @@ -3420,10 +3420,10 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return res[1] elseif utils["list?"](form) then local mapped = nil - local function _413_() + local function _412_() return nil end - mapped = utils.kvmap(form, entry_transform(_413_, q)) + mapped = utils.kvmap(form, entry_transform(_412_, q)) local filename = nil if form.filename then filename = string.format("%q", form.filename) @@ -3441,13 +3441,13 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct else filename = "nil" end - local _416_ + local _415_ if source then - _416_ = source.line + _415_ = source.line else - _416_ = "nil" + _415_ = "nil" end - return string.format("setmetatable({%s}, {filename=%s, line=%s, sequence=%s})", mixed_concat(mapped, ", "), filename, _416_, "(getmetatable(sequence()))['sequence']") + return string.format("setmetatable({%s}, {filename=%s, line=%s, sequence=%s})", mixed_concat(mapped, ", "), filename, _415_, "(getmetatable(sequence()))['sequence']") elseif (type(form) == "table") then local mapped = utils.kvmap(form, entry_transform(q, q)) local source = getmetatable(form) @@ -3457,14 +3457,14 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct else filename = "nil" end - local function _419_() + local function _418_() if source then return source.line else return "nil" end end - return string.format("setmetatable({%s}, {filename=%s, line=%s})", mixed_concat(mapped, ", "), filename, _419_()) + return string.format("setmetatable({%s}, {filename=%s, line=%s})", mixed_concat(mapped, ", "), filename, _418_()) elseif (type(form) == "string") then return serialize_string(form) else @@ -3517,13 +3517,13 @@ package.preload["fennel.friend"] = package.preload["fennel.friend"] or function( return error(..., 0) end end - local function _188_() + local function _187_() for _ = 2, line do f:read() end return f:read() end - return close_handlers_10_(_G.xpcall(_188_, (package.loaded.fennel or debug).traceback)) + return close_handlers_10_(_G.xpcall(_187_, (package.loaded.fennel or debug).traceback)) end end local function sub(str, start, _end) @@ -3539,8 +3539,8 @@ package.preload["fennel.friend"] = package.preload["fennel.friend"] or function( if ((opts and (false == opts["error-pinpoint"])) or (os and os.getenv and os.getenv("NO_COLOR"))) then return codeline else - local _191_ = (opts or {}) - local error_pinpoint = _191_["error-pinpoint"] + local _190_ = (opts or {}) + local error_pinpoint = _190_["error-pinpoint"] local endcol = (_3fendcol or col) local eol = nil if utf8_ok_3f then @@ -3548,19 +3548,19 @@ package.preload["fennel.friend"] = package.preload["fennel.friend"] or function( else eol = string.len(codeline) end - local _193_ = (error_pinpoint or {"\27[7m", "\27[0m"}) - local open = _193_[1] - local close = _193_[2] + local _192_ = (error_pinpoint or {"\27[7m", "\27[0m"}) + local open = _192_[1] + local close = _192_[2] return (sub(codeline, 1, col) .. open .. sub(codeline, (col + 1), (endcol + 1)) .. close .. sub(codeline, (endcol + 2), eol)) end end - local function friendly_msg(msg, _195_0, source, opts) - local _196_ = _195_0 - local col = _196_["col"] - local endcol = _196_["endcol"] - local endline = _196_["endline"] - local filename = _196_["filename"] - local line = _196_["line"] + local function friendly_msg(msg, _194_0, source, opts) + local _195_ = _194_0 + local col = _195_["col"] + local endcol = _195_["endcol"] + local endline = _195_["endline"] + local filename = _195_["filename"] + local line = _195_["line"] local ok, codeline = pcall(read_line, filename, line, source) local endcol0 = nil if (ok and codeline and (line ~= endline)) then @@ -3583,10 +3583,10 @@ package.preload["fennel.friend"] = package.preload["fennel.friend"] or function( end local function assert_compile(condition, msg, ast, source, opts) if not condition then - local _200_ = utils["ast-source"](ast) - local col = _200_["col"] - local filename = _200_["filename"] - local line = _200_["line"] + local _199_ = utils["ast-source"](ast) + local col = _199_["col"] + local filename = _199_["filename"] + local line = _199_["line"] error(friendly_msg(("%s:%s:%s: Compile error: %s"):format((filename or "unknown"), (line or "?"), (col or "?"), msg), utils["ast-source"](ast), source, opts), 0) end return condition @@ -3602,36 +3602,36 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( local unpack = (table.unpack or _G.unpack) local function granulate(getchunk) local c, index, done_3f = "", 1, false - local function _202_(parser_state) + local function _201_(parser_state) if not done_3f then if (index <= #c) then local b = c:byte(index) index = (index + 1) return b else - local _203_0 = getchunk(parser_state) - local function _204_() - local char = _203_0 + local _202_0 = getchunk(parser_state) + local function _203_() + local char = _202_0 return (char ~= "") end - if ((nil ~= _203_0) and _204_()) then - local char = _203_0 + if ((nil ~= _202_0) and _203_()) then + local char = _202_0 c = char index = 2 return c:byte() else - local _ = _203_0 + local _ = _202_0 done_3f = true return nil end end end end - local function _208_() + local function _207_() c = "" return nil end - return _202_, _208_ + return _201_, _207_ end local function string_stream(str, _3foptions) local str0 = str:gsub("^#!", ";;") @@ -3639,12 +3639,12 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( _3foptions.source = str0 end local index = 1 - local function _210_() + local function _209_() local r = str0:byte(index) index = (index + 1) return r end - return _210_ + return _209_ end local delims = {[123] = 125, [125] = true, [40] = 41, [41] = true, [91] = 93, [93] = true} local function sym_char_3f(b) @@ -3660,12 +3660,12 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( local function char_starter_3f(b) return (((1 < b) and (b < 127)) or ((192 < b) and (b < 247))) end - local function parser_fn(getbyte, filename, _212_0) - local _213_ = _212_0 - local options = _213_ - local comments = _213_["comments"] - local source = _213_["source"] - local unfriendly = _213_["unfriendly"] + local function parser_fn(getbyte, filename, _211_0) + local _212_ = _211_0 + local options = _212_ + local comments = _212_["comments"] + local source = _212_["source"] + local unfriendly = _212_["unfriendly"] local stack = {} local line, byteindex, col, prev_col, lastb = 1, 0, 0, 0, nil local function ungetb(ub) @@ -3698,14 +3698,14 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( return r end local function whitespace_3f(b) - local function _221_() - local _220_0 = options.whitespace - if (nil ~= _220_0) then - _220_0 = _220_0[b] + local function _220_() + local _219_0 = options.whitespace + if (nil ~= _219_0) then + _219_0 = _219_0[b] end - return _220_0 + return _219_0 end - return ((b == 32) or ((9 <= b) and (b <= 13)) or _221_()) + return ((b == 32) or ((9 <= b) and (b <= 13)) or _220_()) end local function parse_error(msg, _3fcol_adjust) local col0 = (col + (_3fcol_adjust or -1)) @@ -3725,38 +3725,38 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( return nil end local function dispatch(v) - local _225_0 = stack[#stack] - if (_225_0 == nil) then + local _224_0 = stack[#stack] + if (_224_0 == nil) then retval, done_3f, whitespace_since_dispatch = v, true, false return nil - elseif ((_G.type(_225_0) == "table") and (nil ~= _225_0.prefix)) then - local prefix = _225_0.prefix + elseif ((_G.type(_224_0) == "table") and (nil ~= _224_0.prefix)) then + local prefix = _224_0.prefix local source0 = nil do - local _226_0 = table.remove(stack) - set_source_fields(_226_0) - source0 = _226_0 + local _225_0 = table.remove(stack) + set_source_fields(_225_0) + source0 = _225_0 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 ~= _225_0) then - local top = _225_0 + elseif (nil ~= _224_0) then + local top = _224_0 whitespace_since_dispatch = false return table.insert(top, v) end end local function badend() local accum = utils.map(stack, "closer") - local _228_ + local _227_ if (#stack == 1) then - _228_ = "" + _227_ = "" else - _228_ = "s" + _227_ = "s" end - return parse_error(string.format("expected closing delimiter%s %s", _228_, string.char(unpack(accum)))) + return parse_error(string.format("expected closing delimiter%s %s", _227_, string.char(unpack(accum)))) end local function skip_whitespace(b, close_table) if (b and whitespace_3f(b)) then @@ -3774,11 +3774,11 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( end local function parse_comment(b, contents) if (b and (10 ~= b)) then - local function _231_() + local function _230_() table.insert(contents, string.char(b)) return contents end - return parse_comment(getb(), _231_()) + return parse_comment(getb(), _230_()) elseif comments then ungetb(10) return dispatch(utils.comment(table.concat(contents), {filename = filename, line = line})) @@ -3804,12 +3804,12 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( return dispatch(setmetatable(tbl, mt)) end local function add_comment_at(comments0, index, node) - local _235_0 = comments0[index] - if (nil ~= _235_0) then - local existing = _235_0 + local _234_0 = comments0[index] + if (nil ~= _234_0) then + local existing = _234_0 return table.insert(existing, node) else - local _ = _235_0 + local _ = _234_0 comments0[index] = {node} return nil end @@ -3888,16 +3888,16 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( end local state0 = nil do - local _246_0 = {state, b} - if ((_G.type(_246_0) == "table") and (_246_0[1] == "base") and (_246_0[2] == 92)) then + local _245_0 = {state, b} + if ((_G.type(_245_0) == "table") and (_245_0[1] == "base") and (_245_0[2] == 92)) then state0 = "backslash" - elseif ((_G.type(_246_0) == "table") and (_246_0[1] == "base") and (_246_0[2] == 34)) then + elseif ((_G.type(_245_0) == "table") and (_245_0[1] == "base") and (_245_0[2] == 34)) then state0 = "done" - elseif ((_G.type(_246_0) == "table") and (_246_0[1] == "backslash") and (_246_0[2] == 10)) then + elseif ((_G.type(_245_0) == "table") and (_245_0[1] == "backslash") and (_245_0[2] == 10)) then table.remove(chars, (#chars - 1)) state0 = "base" else - local _ = _246_0 + local _ = _245_0 state0 = "base" end end @@ -3919,11 +3919,11 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( table.remove(stack) local raw = table.concat(chars) local formatted = raw:gsub("[\7-\13]", escape_char) - local _250_0 = (rawget(_G, "loadstring") or load)(("return " .. formatted)) - if (nil ~= _250_0) then - local load_fn = _250_0 + local _249_0 = (rawget(_G, "loadstring") or load)(("return " .. formatted)) + if (nil ~= _249_0) then + local load_fn = _249_0 return dispatch(load_fn()) - elseif (_250_0 == nil) then + elseif (_249_0 == nil) then return parse_error(("Invalid string: " .. raw)) end end @@ -3956,13 +3956,13 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( dispatch((tonumber(number_with_stripped_underscores) or parse_error(("could not read number \"" .. rawstr .. "\"")))) return true else - local _256_0 = tonumber(number_with_stripped_underscores) - if (nil ~= _256_0) then - local x = _256_0 + local _255_0 = tonumber(number_with_stripped_underscores) + if (nil ~= _255_0) then + local x = _255_0 dispatch(x) return true else - local _ = _256_0 + local _ = _255_0 return false end end @@ -4025,11 +4025,11 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( end return parse_loop(skip_whitespace(getb(), close_table)) end - local function _263_() + local function _262_() stack, line, byteindex, col, lastb = {}, 1, 0, 0, ((lastb ~= 10) and lastb) return nil end - return parse_stream, _263_ + return parse_stream, _262_ end local function parser(stream_or_string, _3ffilename, _3foptions) local filename = (_3ffilename or "unknown") @@ -4046,7 +4046,7 @@ end local utils = nil package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) local type_order = {["function"] = 5, boolean = 2, number = 1, string = 3, table = 4, thread = 7, userdata = 6} - local default_opts = {["detect-cycles?"] = true, ["elide-syms?"] = false, ["empty-as-sequence?"] = false, ["escape-newlines?"] = false, ["line-length"] = 80, ["max-sparse-gap"] = 10, ["metamethod?"] = true, ["one-line?"] = false, ["prefer-colon?"] = false, ["utf8?"] = true, depth = 128} + local default_opts = {["detect-cycles?"] = true, ["empty-as-sequence?"] = false, ["escape-newlines?"] = false, ["line-length"] = 80, ["max-sparse-gap"] = 10, ["metamethod?"] = true, ["one-line?"] = false, ["prefer-colon?"] = false, ["utf8?"] = true, depth = 128} local lua_pairs = pairs local lua_ipairs = ipairs local function pairs(t) @@ -4345,11 +4345,7 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) local k0 = pp(k, options0, (indent0 + 1), true) local v0 = pp(v, options0, (indent0 + slength(k0) + 1)) multiline_3f = (multiline_3f or k0:find("\n") or v0:find("\n")) - if ((k0:sub(1, 1) == ":") and (k0:sub(2) == v0)) then - val_19_ = (": " .. v0) - else - val_19_ = (k0 .. " " .. v0) - end + val_19_ = (k0 .. " " .. v0) end if (nil ~= val_19_) then i_18_ = (i_18_ + 1) @@ -4384,10 +4380,10 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) local options0 = normalize_opts(options) local tbl_17_ = {} local i_18_ = #tbl_17_ - for _, _52_0 in ipairs(kv) do - local _53_ = _52_0 - local _0 = _53_[1] - local v = _53_[2] + for _, _51_0 in ipairs(kv) do + local _52_ = _51_0 + local _0 = _52_[1] + local v = _52_[2] local val_19_ = nil do local v0 = pp(v, options0, indent0) @@ -4413,7 +4409,7 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) end else local oneline = nil - local _57_ + local _56_ do local tbl_17_ = {} local i_18_ = #tbl_17_ @@ -4424,9 +4420,9 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) tbl_17_[i_18_] = val_19_ end end - _57_ = tbl_17_ + _56_ = tbl_17_ end - oneline = table.concat(_57_, " ") + oneline = table.concat(_56_, " ") if (not getopt(options, "one-line?") and (force_multi_line_3f or oneline:find("\n") or (options["line-length"] < (indent + length_2a(oneline))))) then return table.concat(lines, ("\n" .. string.rep(" ", indent))) else @@ -4443,10 +4439,10 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) end else local _ = nil - local function _62_(_241) + local function _61_(_241) return visible_cycle_3f(_241, options) end - options["visible-cycle?"] = _62_ + options["visible-cycle?"] = _61_ _ = nil local lines, force_multi_line_3f = nil, nil do @@ -4454,13 +4450,13 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) lines, force_multi_line_3f = metamethod(t, pp, options0, indent) end options["visible-cycle?"] = nil - local _63_0 = type(lines) - if (_63_0 == "string") then + local _62_0 = type(lines) + if (_62_0 == "string") then return lines - elseif (_63_0 == "table") then + elseif (_62_0 == "table") then return concat_lines(lines, options, indent, force_multi_line_3f) else - local _0 = _63_0 + local _0 = _62_0 return error("__fennelview metamethod must return a table of lines") end end @@ -4469,40 +4465,40 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) options.level = (options.level + 1) local x0 = nil do - local _66_0 = nil + local _65_0 = nil if getopt(options, "metamethod?") then - local _67_0 = x - if (nil ~= _67_0) then - local _68_0 = getmetatable(_67_0) - if (nil ~= _68_0) then - _66_0 = _68_0.__fennelview + local _66_0 = x + if (nil ~= _66_0) then + local _67_0 = getmetatable(_66_0) + if (nil ~= _67_0) then + _65_0 = _67_0.__fennelview else - _66_0 = _68_0 + _65_0 = _67_0 end else - _66_0 = _67_0 + _65_0 = _66_0 end else - _66_0 = nil + _65_0 = nil end - if (nil ~= _66_0) then - local metamethod = _66_0 + if (nil ~= _65_0) then + local metamethod = _65_0 x0 = pp_metamethod(x, metamethod, options, indent) else - local _ = _66_0 - local _72_0, _73_0 = table_kv_pairs(x, options) - if (true and (_73_0 == "empty")) then - local _0 = _72_0 + local _ = _65_0 + local _71_0, _72_0 = table_kv_pairs(x, options) + if (true and (_72_0 == "empty")) then + local _0 = _71_0 if getopt(options, "empty-as-sequence?") then x0 = "[]" else x0 = "{}" end - elseif ((nil ~= _72_0) and (_73_0 == "table")) then - local kv = _72_0 + elseif ((nil ~= _71_0) and (_72_0 == "table")) then + local kv = _71_0 x0 = pp_associative(x, kv, options, indent) - elseif ((nil ~= _72_0) and (_73_0 == "seq")) then - local kv = _72_0 + elseif ((nil ~= _71_0) and (_72_0 == "seq")) then + local kv = _71_0 x0 = pp_sequence(x, kv, options, indent) else x0 = nil @@ -4513,8 +4509,8 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) return x0 end local function number__3estring(n) - local _77_0 = string.gsub(tostring(n), ",", ".") - return _77_0 + local _76_0 = string.gsub(tostring(n), ",", ".") + return _76_0 end local function colon_string_3f(s) return s:find("^[-%w?^_!$%&*+./|<=>]+$") @@ -4532,12 +4528,12 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) local ret = nil for _, init0 in ipairs(inits) do if ret then break end - ret = (byte and (function(_78_,_79_,_80_) return (_78_ <= _79_) and (_79_ <= _80_) end)(init0["min-byte"],byte,init0["max-byte"]) and init0) + ret = (byte and (function(_77_,_78_,_79_) return (_77_ <= _78_) and (_78_ <= _79_) end)(init0["min-byte"],byte,init0["max-byte"]) and init0) end init = ret end local code = nil - local function _81_() + local function _80_() local code0 = nil if init then code0 = (byte - init["min-byte"]) @@ -4550,8 +4546,8 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) end return code0 end - code = (init and _81_()) - if (code and (function(_83_,_84_,_85_) return (_83_ <= _84_) and (_84_ <= _85_) end)(init["min-code"],code,init["max-code"]) and not ((55296 <= code) and (code <= 57343))) then + code = (init and _80_()) + if (code and (function(_82_,_83_,_84_) return (_82_ <= _83_) and (_83_ <= _84_) end)(init["min-code"],code,init["max-code"]) and not ((55296 <= code) and (code <= 57343))) then return init.len end end @@ -4578,16 +4574,16 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) local esc_newline_3f = ((len < 2) or (getopt(options, "escape-newlines?") and (len < (options["line-length"] - indent)))) local byte_escape = (getopt(options, "byte-escape") or default_byte_escape) local escs = nil - local _89_ + local _88_ if esc_newline_3f then - _89_ = "\\n" + _88_ = "\\n" else - _89_ = "\n" + _88_ = "\n" end - local function _91_(_241, _242) + local function _90_(_241, _242) return byte_escape(_242:byte(), options) end - escs = setmetatable({["\""] = "\\\"", ["\11"] = "\\v", ["\12"] = "\\f", ["\13"] = "\\r", ["\7"] = "\\a", ["\8"] = "\\b", ["\9"] = "\\t", ["\\"] = "\\\\", ["\n"] = _89_}, {__index = _91_}) + escs = setmetatable({["\""] = "\\\"", ["\11"] = "\\v", ["\12"] = "\\f", ["\13"] = "\\r", ["\7"] = "\\a", ["\8"] = "\\b", ["\9"] = "\\t", ["\\"] = "\\\\", ["\n"] = _88_}, {__index = _90_}) local str0 = ("\"" .. str:gsub("[%c\\\"]", escs) .. "\"") if getopt(options, "utf8?") then return utf8_escape(str0, options) @@ -4616,7 +4612,7 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) end return defaults end - local function _94_(x, options, indent, colon_3f) + local function _93_(x, options, indent, colon_3f) local indent0 = (indent or 0) local options0 = (options or make_options(x)) local x0 = nil @@ -4626,19 +4622,19 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) x0 = x end local tv = type(x0) - local function _97_() - local _96_0 = getmetatable(x0) - if ((_G.type(_96_0) == "table") and true) then - local __fennelview = _96_0.__fennelview + local function _96_() + local _95_0 = getmetatable(x0) + if ((_G.type(_95_0) == "table") and true) then + local __fennelview = _95_0.__fennelview return __fennelview end end - if ((tv == "table") or ((tv == "userdata") and _97_())) then + if ((tv == "table") or ((tv == "userdata") and _96_())) then return pp_table(x0, options0, indent0) elseif (tv == "number") then return number__3estring(x0) else - local function _99_() + local function _98_() if (colon_3f ~= nil) then return colon_3f elseif ("function" == type(options0["prefer-colon?"])) then @@ -4647,7 +4643,7 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) return getopt(options0, "prefer-colon?") end end - if ((tv == "string") and colon_string_3f(x0) and _99_()) then + if ((tv == "string") and colon_string_3f(x0) and _98_()) then return (":" .. x0) elseif (tv == "string") then return pp_string(x0, options0, indent0) @@ -4658,7 +4654,7 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) end end end - pp = _94_ + pp = _93_ local function _view(x, _3foptions) return pp(x, make_options(x, _3foptions), 0) end @@ -4703,32 +4699,32 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. end local len = nil do - local _104_0, _105_0 = pcall(require, "utf8") - if ((_104_0 == true) and (nil ~= _105_0)) then - local utf8 = _105_0 + local _103_0, _104_0 = pcall(require, "utf8") + if ((_103_0 == true) and (nil ~= _104_0)) then + local utf8 = _104_0 len = utf8.len else - local _ = _104_0 + local _ = _103_0 len = string.len end end local kv_order = {boolean = 2, number = 1, string = 3, table = 4} local function kv_compare(a, b) - local _107_0, _108_0 = type(a), type(b) - if (((_107_0 == "number") and (_108_0 == "number")) or ((_107_0 == "string") and (_108_0 == "string"))) then + local _106_0, _107_0 = type(a), type(b) + if (((_106_0 == "number") and (_107_0 == "number")) or ((_106_0 == "string") and (_107_0 == "string"))) then return (a < b) else - local function _109_() - local a_t = _107_0 - local b_t = _108_0 + local function _108_() + local a_t = _106_0 + local b_t = _107_0 return (a_t ~= b_t) end - if (((nil ~= _107_0) and (nil ~= _108_0)) and _109_()) then - local a_t = _107_0 - local b_t = _108_0 + if (((nil ~= _106_0) and (nil ~= _107_0)) and _108_()) then + local a_t = _106_0 + local b_t = _107_0 return ((kv_order[a_t] or 5) < (kv_order[b_t] or 5)) else - local _ = _107_0 + local _ = _106_0 return (tostring(a) < tostring(b)) end end @@ -4760,20 +4756,20 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. local function stablepairs(t) local mt_keys = nil do - local _113_0 = getmetatable(t) - if (nil ~= _113_0) then - _113_0 = _113_0.keys + local _112_0 = getmetatable(t) + if (nil ~= _112_0) then + _112_0 = _112_0.keys end - mt_keys = _113_0 + mt_keys = _112_0 end local succ, prev, first_mt = nil, nil, nil - local function _115_(_241) + local function _114_(_241) return t[_241] end - succ, prev, first_mt = add_stable_keys({}, nil, (mt_keys or {}), _115_) + succ, prev, first_mt = add_stable_keys({}, nil, (mt_keys or {}), _114_) local pairs_keys = nil do - local _116_0 = nil + local _115_0 = nil do local tbl_17_ = {} local i_18_ = #tbl_17_ @@ -4784,10 +4780,10 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. tbl_17_[i_18_] = val_19_ end end - _116_0 = tbl_17_ + _115_0 = tbl_17_ end - table.sort(_116_0, kv_compare) - pairs_keys = _116_0 + table.sort(_115_0, kv_compare) + pairs_keys = _115_0 end local succ0, _, first_after_mt = add_stable_keys(succ, prev, pairs_keys) local first = nil @@ -4797,19 +4793,19 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. first = first_mt end local function stablenext(tbl, key) - local _119_0 = nil + local _118_0 = nil if (key == nil) then - _119_0 = first + _118_0 = first else - _119_0 = succ0[key] + _118_0 = succ0[key] end - if (nil ~= _119_0) then - local next_key = _119_0 - local _121_0 = tbl[next_key] - if (_121_0 ~= nil) then - return next_key, _121_0 + if (nil ~= _118_0) then + local next_key = _118_0 + local _120_0 = tbl[next_key] + if (_120_0 ~= nil) then + return next_key, _120_0 else - return _121_0 + return _120_0 end end end @@ -4820,25 +4816,25 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. if (0 == #path) then return _3ffallback else - local _124_0 = nil + local _123_0 = nil do local t = tbl for _, k in ipairs(path) do if (nil == t) then break end - local _125_0 = type(t) - if (_125_0 == "table") then + local _124_0 = type(t) + if (_124_0 == "table") then t = t[k] else t = nil end end - _124_0 = t + _123_0 = t end - if (nil ~= _124_0) then - local res = _124_0 + if (nil ~= _123_0) then + local res = _123_0 return res else - local _ = _124_0 + local _ = _123_0 return _3ffallback end end @@ -4849,15 +4845,15 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. if (type(f) == "function") then f0 = f else - local function _129_(_241) + local function _128_(_241) return _241[f] end - f0 = _129_ + f0 = _128_ end for _, x in ipairs(t) do - local _131_0 = f0(x) - if (nil ~= _131_0) then - local v = _131_0 + local _130_0 = f0(x) + if (nil ~= _130_0) then + local v = _130_0 table.insert(out, v) end end @@ -4869,19 +4865,19 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. if (type(f) == "function") then f0 = f else - local function _133_(_241) + local function _132_(_241) return _241[f] end - f0 = _133_ + f0 = _132_ end for k, x in stablepairs(t) do - local _135_0, _136_0 = f0(k, x) - if ((nil ~= _135_0) and (nil ~= _136_0)) then - local key = _135_0 - local value = _136_0 - out[key] = value - elseif (nil ~= _135_0) then + local _134_0, _135_0 = f0(k, x) + if ((nil ~= _134_0) and (nil ~= _135_0)) then + local key = _134_0 local value = _135_0 + out[key] = value + elseif (nil ~= _134_0) then + local value = _134_0 table.insert(out, value) end end @@ -4898,13 +4894,13 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. return tbl_14_ end local function member_3f(x, tbl, _3fn) - local _139_0 = tbl[(_3fn or 1)] - if (_139_0 == x) then + local _138_0 = tbl[(_3fn or 1)] + if (_138_0 == x) then return true - elseif (_139_0 == nil) then + elseif (_138_0 == nil) then return nil else - local _ = _139_0 + local _ = _138_0 return member_3f(x, tbl, ((_3fn or 1) + 1)) end end @@ -4939,9 +4935,9 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. seen[next_state] = true return next_state, value else - local _142_0 = getmetatable(t) - if ((_G.type(_142_0) == "table") and true) then - local __index = _142_0.__index + local _141_0 = getmetatable(t) + if ((_G.type(_141_0) == "table") and true) then + local __index = _141_0.__index if ("table" == type(__index)) then t = __index return allpairs_next(t) @@ -4959,10 +4955,10 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. local safe = {} local view0 = nil if _3fview then - local function _146_(_241) + local function _145_(_241) return _3fview(_241, _3foptions, _3findent) end - view0 = _146_ + view0 = _145_ else view0 = view end @@ -4983,19 +4979,19 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. end local symbol_mt = {"SYMBOL", __eq = sym_3d, __fennelview = deref, __lt = sym_3c, __tostring = deref} local expr_mt = nil - local function _148_(x) + local function _147_(x) return tostring(deref(x)) end - expr_mt = {"EXPR", __tostring = _148_} + expr_mt = {"EXPR", __tostring = _147_} local list_mt = {"LIST", __fennelview = list__3estring, __tostring = list__3estring} local comment_mt = {"COMMENT", __eq = sym_3d, __fennelview = comment_view, __lt = sym_3c, __tostring = deref} local sequence_marker = {"SEQUENCE"} local varg_mt = {"VARARG", __fennelview = deref, __tostring = deref} local getenv = nil - local function _149_() + local function _148_() return nil end - getenv = ((os and os.getenv) or _149_) + getenv = ((os and os.getenv) or _148_) local function debug_on_3f(flag) local level = (getenv("FENNEL_DEBUG") or "") return ((level == "all") or level:find(flag)) @@ -5004,7 +5000,7 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. return setmetatable({...}, list_mt) end local function sym(str, _3fsource) - local _150_ + local _149_ do local tbl_14_ = {str} for k, v in pairs((_3fsource or {})) do @@ -5018,13 +5014,13 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. tbl_14_[k_15_] = v_16_ end end - _150_ = tbl_14_ + _149_ = tbl_14_ end - return setmetatable(_150_, symbol_mt) + return setmetatable(_149_, symbol_mt) end nil_sym = sym("nil") local function sequence(...) - local function _153_(seq, view0, inspector, indent) + local function _152_(seq, view0, inspector, indent) local opts = nil do inspector["empty-as-sequence?"] = {after = inspector["empty-as-sequence?"], once = true} @@ -5033,19 +5029,19 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. end return view0(seq, opts, indent) end - return setmetatable({...}, {__fennelview = _153_, sequence = sequence_marker}) + return setmetatable({...}, {__fennelview = _152_, sequence = sequence_marker}) end local function expr(strcode, etype) return setmetatable({strcode, type = etype}, expr_mt) end local function comment_2a(contents, _3fsource) - local _154_ = (_3fsource or {}) - local filename = _154_["filename"] - local line = _154_["line"] + local _153_ = (_3fsource or {}) + local filename = _153_["filename"] + local line = _153_["line"] return setmetatable({contents, filename = filename, line = line}, comment_mt) end local function varg(_3fsource) - local _155_ + local _154_ do local tbl_14_ = {"..."} for k, v in pairs((_3fsource or {})) do @@ -5059,9 +5055,9 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. tbl_14_[k_15_] = v_16_ end end - _155_ = tbl_14_ + _154_ = tbl_14_ end - return setmetatable(_155_, varg_mt) + return setmetatable(_154_, varg_mt) end local function expr_3f(x) return ((type(x) == "table") and (getmetatable(x) == expr_mt) and x) @@ -5111,7 +5107,7 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. elseif (type(str) ~= "string") then return false else - local function _161_() + local function _160_() local parts = {} for part in str:gmatch("[^%.%:]+[%.%:]?") do local last_char = part:sub(-1) @@ -5126,7 +5122,7 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. end return (next(parts) and parts) end - return ((str:match("%.") or str:match(":")) and not str:match("%.%.") and (str:byte() ~= string.byte(".")) and (str:byte() ~= string.byte(":")) and (str:byte(-1) ~= string.byte(".")) and (str:byte(-1) ~= string.byte(":")) and _161_()) + return ((str:match("%.") or str:match(":")) and not str:match("%.%.") and (str:byte() ~= string.byte(".")) and (str:byte() ~= string.byte(":")) and (str:byte(-1) ~= string.byte(".")) and (str:byte(-1) ~= string.byte(":")) and _160_()) end end local function quoted_3f(symbol) @@ -5160,15 +5156,15 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. return subopts end local root = nil - local function _166_() + local function _165_() end - root = {chunk = nil, options = nil, reset = _166_, scope = nil} - root["set-reset"] = function(_167_0) - local _168_ = _167_0 - local chunk = _168_["chunk"] - local options = _168_["options"] - local reset = _168_["reset"] - local scope = _168_["scope"] + root = {chunk = nil, options = nil, reset = _165_, scope = nil} + root["set-reset"] = function(_166_0) + local _167_ = _166_0 + local chunk = _167_["chunk"] + local options = _167_["options"] + local reset = _167_["reset"] + local scope = _167_["scope"] root.reset = function() root.chunk, root.scope, root.options, root.reset = chunk, scope, options, reset return nil @@ -5188,13 +5184,13 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. if (_G.io and _G.io.stderr) then local loc = nil do - local _170_0 = ast_source(_3fast) - if ((_G.type(_170_0) == "table") and (nil ~= _170_0.filename) and (nil ~= _170_0.line)) then - local filename = _170_0.filename - local line = _170_0.line + local _169_0 = ast_source(_3fast) + if ((_G.type(_169_0) == "table") and (nil ~= _169_0.filename) and (nil ~= _169_0.line)) then + local filename = _169_0.filename + local line = _169_0.line loc = (filename .. ":" .. line .. ": ") else - local _ = _170_0 + local _ = _169_0 loc = "" end end @@ -5202,11 +5198,11 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. end end local warned = {} - local function check_plugin_version(_173_0) - local _174_ = _173_0 - local plugin = _174_ - local name = _174_["name"] - local versions = _174_["versions"] + local function check_plugin_version(_172_0) + local _173_ = _172_0 + local plugin = _173_ + local name = _173_["name"] + local versions = _173_["versions"] if (not member_3f(version:gsub("-dev", ""), (versions or {})) and not warned[plugin]) then warned[plugin] = true return warn(string.format("plugin %s does not support Fennel version %s", (name or "unknown"), version)) @@ -5214,29 +5210,29 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. end local function hook_opts(event, _3foptions, ...) local plugins = nil - local function _177_(...) - local _176_0 = _3foptions - if (nil ~= _176_0) then - _176_0 = _176_0.plugins + local function _176_(...) + local _175_0 = _3foptions + if (nil ~= _175_0) then + _175_0 = _175_0.plugins end - return _176_0 + return _175_0 end - local function _180_(...) - local _179_0 = root.options - if (nil ~= _179_0) then - _179_0 = _179_0.plugins + local function _179_(...) + local _178_0 = root.options + if (nil ~= _178_0) then + _178_0 = _178_0.plugins end - return _179_0 + return _178_0 end - plugins = (_177_(...) or _180_(...)) + plugins = (_176_(...) or _179_(...)) if plugins then local result = nil for _, plugin in ipairs(plugins) do if result then break end check_plugin_version(plugin) - local _182_0 = plugin[event] - if (nil ~= _182_0) then - local f = _182_0 + local _181_0 = plugin[event] + if (nil ~= _181_0) then + local f = _181_0 result = f(...) else result = nil @@ -5285,14 +5281,14 @@ local function eval(str, _3foptions, ...) local env = eval_env(opts.env, opts) local lua_source = compiler["compile-string"](str, opts) local loader = nil - local function _751_(...) + local function _750_(...) if opts.filename then return ("@" .. opts.filename) else return str end end - loader = specials["load-code"](lua_source, env, _751_(...)) + loader = specials["load-code"](lua_source, env, _750_(...)) opts.filename = nil return loader(...) end @@ -5318,10 +5314,10 @@ local function syntax() out[k] = {["binding-form?"] = utils["member?"](k, binding_3f), ["body-form?"] = utils["member?"](k, body_3f), ["define?"] = utils["member?"](k, define_3f), ["macro?"] = true} end for k, v in pairs(_G) do - local _752_0 = type(v) - if (_752_0 == "function") then + local _751_0 = type(v) + if (_751_0 == "function") then out[k] = {["function?"] = true, ["global?"] = true} - elseif (_752_0 == "table") then + elseif (_751_0 == "table") then if not k:find("^_") then for k2, v2 in pairs(v) do if ("function" == type(v2)) then @@ -5343,18 +5339,18 @@ utils["fennel-module"] = mod do local module_name = "fennel.macros" local _ = nil - local function _756_() + local function _755_() return mod end - package.preload[module_name] = _756_ + package.preload[module_name] = _755_ _ = nil local env = nil do - local _757_0 = specials["make-compiler-env"](nil, compiler.scopes.compiler, {}) - _757_0["utils"] = utils - _757_0["fennel"] = mod - _757_0["get-function-metadata"] = specials["get-function-metadata"] - env = _757_0 + local _756_0 = specials["make-compiler-env"](nil, compiler.scopes.compiler, {}) + _756_0["utils"] = utils + _756_0["fennel"] = mod + _756_0["get-function-metadata"] = specials["get-function-metadata"] + env = _756_0 end local built_ins = eval([===[;; fennel-ls: macro-file diff --git a/test/pl/LICENSE.md b/deps/pl/LICENSE.md similarity index 100% rename from test/pl/LICENSE.md rename to deps/pl/LICENSE.md diff --git a/test/pl/stringio.lua b/deps/pl/stringio.lua similarity index 100% rename from test/pl/stringio.lua rename to deps/pl/stringio.lua diff --git a/fennel b/fennel index 001eb66..8a91eaf 100755 --- a/fennel +++ b/fennel @@ -3,24 +3,24 @@ -- SPDX-FileCopyrightText: Calvin Rose and contributors package.preload["fennel.binary"] = package.preload["fennel.binary"] or function(...) local fennel = require("fennel") - local _788_ = require("fennel.utils") - local copy = _788_["copy"] - local warn = _788_["warn"] + local _787_ = require("fennel.utils") + local copy = _787_["copy"] + local warn = _787_["warn"] local function shellout(command) local f = io.popen(command) local stdout = f:read("*all") return (f:close() and stdout) end local function execute(cmd) - local _789_0 = os.execute(cmd) - if (_789_0 == 0) then + local _788_0 = os.execute(cmd) + if (_788_0 == 0) then return true - elseif (_789_0 == true) then + elseif (_788_0 == true) then return true end end local function string__3ec_hex_literal(characters) - local _791_ + local _790_ do local tbl_17_ = {} local i_18_ = #tbl_17_ @@ -31,9 +31,9 @@ package.preload["fennel.binary"] = package.preload["fennel.binary"] or function( tbl_17_[i_18_] = val_19_ end end - _791_ = tbl_17_ + _790_ = tbl_17_ end - return table.concat(_791_, ", ") + return table.concat(_790_, ", ") end local c_shim = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n#include \n#include \n#include \n#ifdef __cplusplus\n}\n#endif\n#include \n#include \n#include \n#include \n\n#if LUA_VERSION_NUM == 501\n #define LUA_OK 0\n#endif\n\n/* Copied from lua.c */\n\nstatic lua_State *globalL = NULL;\n\nstatic void lstop (lua_State *L, lua_Debug *ar) {\n (void)ar; /* unused arg. */\n lua_sethook(L, NULL, 0, 0); /* reset hook */\n luaL_error(L, \"interrupted!\");\n}\n\nstatic void laction (int i) {\n signal(i, SIG_DFL); /* if another SIGINT happens, terminate process */\n lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);\n}\n\nstatic void createargtable (lua_State *L, char **argv, int argc, int script) {\n int i, narg;\n if (script == argc) script = 0; /* no script name? */\n narg = argc - (script + 1); /* number of positive indices */\n lua_createtable(L, narg, script + 1);\n for (i = 0; i < argc; i++) {\n lua_pushstring(L, argv[i]);\n lua_rawseti(L, -2, i - script);\n }\n lua_setglobal(L, \"arg\");\n}\n\nstatic int msghandler (lua_State *L) {\n const char *msg = lua_tostring(L, 1);\n if (msg == NULL) { /* is error object not a string? */\n if (luaL_callmeta(L, 1, \"__tostring\") && /* does it have a metamethod */\n lua_type(L, -1) == LUA_TSTRING) /* that produces a string? */\n return 1; /* that is the message */\n else\n msg = lua_pushfstring(L, \"(error object is a %%s value)\",\n luaL_typename(L, 1));\n }\n /* Call debug.traceback() instead of luaL_traceback() for Lua 5.1 compat. */\n lua_getglobal(L, \"debug\");\n lua_getfield(L, -1, \"traceback\");\n /* debug */\n lua_remove(L, -2);\n lua_pushstring(L, msg);\n /* original msg */\n lua_remove(L, -3);\n lua_pushinteger(L, 2); /* skip this function and traceback */\n lua_call(L, 2, 1); /* call debug.traceback */\n return 1; /* return the traceback */\n}\n\nstatic int docall (lua_State *L, int narg, int nres) {\n int status;\n int base = lua_gettop(L) - narg; /* function index */\n lua_pushcfunction(L, msghandler); /* push message handler */\n lua_insert(L, base); /* put it under function and args */\n globalL = L; /* to be available to 'laction' */\n signal(SIGINT, laction); /* set C-signal handler */\n status = lua_pcall(L, narg, nres, base);\n signal(SIGINT, SIG_DFL); /* reset C-signal handler */\n lua_remove(L, base); /* remove message handler from the stack */\n return status;\n}\n\nint main(int argc, char *argv[]) {\n lua_State *L = luaL_newstate();\n luaL_openlibs(L);\n createargtable(L, argv, argc, 0);\n\n static const unsigned char lua_loader_program[] = {\n%s\n};\n if(luaL_loadbuffer(L, (const char*)lua_loader_program,\n sizeof(lua_loader_program), \"%s\") != LUA_OK) {\n fprintf(stderr, \"luaL_loadbuffer: %%s\\n\", lua_tostring(L, -1));\n lua_close(L);\n return 1;\n }\n\n /* lua_bundle */\n lua_newtable(L);\n static const unsigned char lua_require_1[] = {\n %s\n };\n lua_pushlstring(L, (const char*)lua_require_1, sizeof(lua_require_1));\n lua_setfield(L, -2, \"%s\");\n\n%s\n\n if (docall(L, 1, LUA_MULTRET)) {\n const char *errmsg = lua_tostring(L, 1);\n if (errmsg) {\n fprintf(stderr, \"%%s\\n\", errmsg);\n }\n lua_close(L);\n return 1;\n }\n lua_close(L);\n return 0;\n}" local function compile_fennel(filename, options) @@ -50,13 +50,13 @@ package.preload["fennel.binary"] = package.preload["fennel.binary"] or function( local function module_name(open, rename, used_renames) local require_name = nil do - local _794_0 = rename[open] - if (nil ~= _794_0) then - local renamed = _794_0 + local _793_0 = rename[open] + if (nil ~= _793_0) then + local renamed = _793_0 used_renames[open] = true require_name = renamed else - local _ = _794_0 + local _ = _793_0 require_name = open end end @@ -95,14 +95,14 @@ package.preload["fennel.binary"] = package.preload["fennel.binary"] or function( local dotpath = filename:gsub("^%.%/", ""):gsub("[\\/]", ".") local dotpath_noextension = (dotpath:match("(.+)%.") or dotpath) local fennel_loader = nil - local _798_ + local _797_ do - _798_ = "(do (local bundle_2_ ...) (fn loader_3_ [name_4_] (match (or (. bundle_2_ name_4_) (. bundle_2_ (.. name_4_ \".init\"))) (mod_5_ ? (= \"function\" (type mod_5_))) mod_5_ (mod_5_ ? (= \"string\" (type mod_5_))) (assert (if (= _VERSION \"Lua 5.1\") (loadstring mod_5_ name_4_) (load mod_5_ name_4_))) nil (values nil (: \"\n\\tmodule '%%s' not found in fennel bundle\" \"format\" name_4_)))) (table.insert (or package.loaders package.searchers) 2 loader_3_) ((assert (loader_3_ \"%s\")) ((or unpack table.unpack) arg)))" + _797_ = "(do (local bundle_2_ ...) (fn loader_3_ [name_4_] (match (or (. bundle_2_ name_4_) (. bundle_2_ (.. name_4_ \".init\"))) (mod_5_ ? (= \"function\" (type mod_5_))) mod_5_ (mod_5_ ? (= \"string\" (type mod_5_))) (assert (if (= _VERSION \"Lua 5.1\") (loadstring mod_5_ name_4_) (load mod_5_ name_4_))) nil (values nil (: \"\n\\tmodule '%%s' not found in fennel bundle\" \"format\" name_4_)))) (table.insert (or package.loaders package.searchers) 2 loader_3_) ((assert (loader_3_ \"%s\")) ((or unpack table.unpack) arg)))" end - fennel_loader = _798_:format(dotpath_noextension) + fennel_loader = _797_:format(dotpath_noextension) local lua_loader = fennel["compile-string"](fennel_loader) - local _799_ = options - local rename_modules = _799_["rename-modules"] + local _798_ = options + local rename_modules = _798_["rename-modules"] return c_shim:format(string__3ec_hex_literal(lua_loader), basename_noextension, string__3ec_hex_literal(compile_fennel(filename, options)), dotpath_noextension, native_loader(native, {["rename-modules"] = rename_modules})) end local function write_c(filename, native, options) @@ -115,28 +115,28 @@ package.preload["fennel.binary"] = package.preload["fennel.binary"] or function( local function compile_binary(lua_c_path, executable_name, static_lua, lua_include_dir, native) local cc = (os.getenv("CC") or "cc") local rdynamic, bin_extension, ldl_3f = nil, nil, nil - local _801_ + local _800_ do - local _800_0 = shellout((cc .. " -dumpmachine")) - if (nil ~= _800_0) then - _801_ = _800_0:match("mingw") + local _799_0 = shellout((cc .. " -dumpmachine")) + if (nil ~= _799_0) then + _800_ = _799_0:match("mingw") else - _801_ = _800_0 + _800_ = _799_0 end end - if _801_ then + if _800_ then rdynamic, bin_extension, ldl_3f = "", ".exe", false else rdynamic, bin_extension, ldl_3f = "-rdynamic", "", true end local compile_command = nil - local _804_ + local _803_ if ldl_3f then - _804_ = "-ldl" + _803_ = "-ldl" else - _804_ = "" + _803_ = "" end - compile_command = {cc, "-Os", lua_c_path, table.concat(native, " "), static_lua, rdynamic, "-lm", _804_, "-o", (executable_name .. bin_extension), "-I", lua_include_dir, os.getenv("CC_OPTS")} + compile_command = {cc, "-Os", lua_c_path, table.concat(native, " "), static_lua, rdynamic, "-lm", _803_, "-o", (executable_name .. bin_extension), "-I", lua_include_dir, os.getenv("CC_OPTS")} if os.getenv("FENNEL_DEBUG") then print("Compiling with", table.concat(compile_command, " ")) end @@ -154,17 +154,17 @@ package.preload["fennel.binary"] = package.preload["fennel.binary"] or function( if (version_extension and (version_extension ~= "") and not version_extension:match("%.%d+")) then return false else - local _809_0 = extension - if (_809_0 == "a") then + local _808_0 = extension + if (_808_0 == "a") then return path - elseif (_809_0 == "o") then + elseif (_808_0 == "o") then return path - elseif (_809_0 == "so") then + elseif (_808_0 == "so") then return path - elseif (_809_0 == "dylib") then + elseif (_808_0 == "dylib") then return path else - local _ = _809_0 + local _ = _808_0 return false end end @@ -196,10 +196,10 @@ package.preload["fennel.binary"] = package.preload["fennel.binary"] or function( return native end local function compile(filename, executable_name, static_lua, lua_include_dir, options, args) - local _816_ = extract_native_args(args) - local libraries = _816_["libraries"] - local modules = _816_["modules"] - local rename_modules = _816_["rename-modules"] + local _815_ = extract_native_args(args) + local libraries = _815_["libraries"] + local modules = _815_["modules"] + local rename_modules = _815_["rename-modules"] local opts = {["rename-modules"] = rename_modules} copy(options, opts) return compile_binary(write_c(filename, modules, opts), executable_name, static_lua, lua_include_dir, libraries) @@ -233,18 +233,18 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) return io.write("\n") end local function default_on_error(errtype, err, lua_source) - local function _617_() - local _616_0 = errtype - if (_616_0 == "Lua Compile") then + local function _616_() + local _615_0 = errtype + if (_615_0 == "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 (_616_0 == "Runtime") then + elseif (_615_0 == "Runtime") then return (compiler.traceback(tostring(err), 4) .. "\n") else - local _ = _616_0 + local _ = _615_0 return ("%s error: %s\n"):format(errtype, tostring(err)) end end - return io.write(_617_()) + return io.write(_616_()) end local function splice_save_locals(env, lua_source, scope) local saves = nil @@ -284,25 +284,25 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) else gap = " " end - local function _623_() + local function _622_() if next(saves) then return (table.concat(saves, " ") .. gap) else return "" end end - local function _626_() - local _624_0, _625_0 = lua_source:match("^(.*)[\n ](return .*)$") - if ((nil ~= _624_0) and (nil ~= _625_0)) then - local body = _624_0 - local _return = _625_0 + local function _625_() + local _623_0, _624_0 = lua_source:match("^(.*)[\n ](return .*)$") + if ((nil ~= _623_0) and (nil ~= _624_0)) then + local body = _623_0 + local _return = _624_0 return (body .. gap .. table.concat(binds, " ") .. gap .. _return) else - local _ = _624_0 + local _ = _623_0 return lua_source end end - return (_623_() .. _626_()) + return (_622_() .. _625_()) end local function completer(env, scope, text) local max_items = 2000 @@ -314,14 +314,14 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) local scope_first_3f = ((tbl == env) or (tbl == env.___replLocals___)) local tbl_17_ = matches local i_18_ = #tbl_17_ - local function _628_() + local function _627_() if scope_first_3f then return scope.manglings else return tbl end end - for k, is_mangled in utils.allpairs(_628_()) do + for k, is_mangled in utils.allpairs(_627_()) do if (max_items <= #matches) then break end local val_19_ = nil do @@ -389,7 +389,7 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) return input:match("^%s*,") end local function command_docs() - local _637_ + local _636_ do local tbl_17_ = {} local i_18_ = #tbl_17_ @@ -400,18 +400,18 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) tbl_17_[i_18_] = val_19_ end end - _637_ = tbl_17_ + _636_ = tbl_17_ end - return table.concat(_637_, "\n") + return table.concat(_636_, "\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 ,return FORM - Evaluate FORM and return its value to the REPL's caller.\n ,exit - Leave the repl.\n\nUse ,doc something to see descriptions for individual macros and special forms.\nValues from previous inputs are kept in *1, *2, and *3.\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 _639_0, _640_0 = pcall(specials["load-code"]("return require(...)", env), module_name) - if ((_639_0 == true) and (nil ~= _640_0)) then - local old = _640_0 + local _638_0, _639_0 = pcall(specials["load-code"]("return require(...)", env), module_name) + if ((_638_0 == true) and (nil ~= _639_0)) then + local old = _639_0 local _ = nil package.loaded[module_name] = nil _ = nil @@ -436,8 +436,8 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) package.loaded[module_name] = old end return on_values({"ok"}) - elseif ((_639_0 == false) and (nil ~= _640_0)) then - local msg = _640_0 + elseif ((_638_0 == false) and (nil ~= _639_0)) then + local msg = _639_0 if msg:match("loop or previous error loading module") then package.loaded[module_name] = nil return reload(module_name, env, on_values, on_error) @@ -445,32 +445,32 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) specials["macro-loaded"][module_name] = nil return nil else - local function _645_() - local _644_0 = msg:gsub("\n.*", "") - return _644_0 + local function _644_() + local _643_0 = msg:gsub("\n.*", "") + return _643_0 end - return on_error("Runtime", _645_()) + return on_error("Runtime", _644_()) end end end local function run_command(read, on_error, f) - local _648_0, _649_0, _650_0 = pcall(read) - if ((_648_0 == true) and (_649_0 == true) and (nil ~= _650_0)) then - local val = _650_0 - local _651_0, _652_0 = pcall(f, val) - if ((_651_0 == false) and (nil ~= _652_0)) then - local msg = _652_0 + local _647_0, _648_0, _649_0 = pcall(read) + if ((_647_0 == true) and (_648_0 == true) and (nil ~= _649_0)) then + local val = _649_0 + local _650_0, _651_0 = pcall(f, val) + if ((_650_0 == false) and (nil ~= _651_0)) then + local msg = _651_0 return on_error("Runtime", msg) end - elseif (_648_0 == false) then + elseif (_647_0 == false) then return on_error("Parse", "Couldn't parse input.") end end commands.reload = function(env, read, on_values, on_error) - local function _655_(_241) + local function _654_(_241) return reload(tostring(_241), env, on_values, on_error) end - return run_command(read, on_error, _655_) + return run_command(read, on_error, _654_) end do end (compiler.metadata):set(commands.reload, "fnl/docstring", "Reload the specified module.") commands.reset = function(env, _, on_values) @@ -479,28 +479,28 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) 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 _656_() + local function _655_() return on_values(completer(env, scope, table.concat(chars):gsub(",complete +", ""):sub(1, -2))) end - return run_command(read, on_error, _656_) + return run_command(read, on_error, _655_) 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 _657_0 = type(subtbl) - if (_657_0 == "function") then + local _656_0 = type(subtbl) + if (_656_0 == "function") then if ((prefix .. name)):match(pattern) then table.insert(names, (prefix .. name)) end - elseif (_657_0 == "table") then + elseif (_656_0 == "table") then if not seen[subtbl] then - local _659_ + local _658_ do seen[subtbl] = true - _659_ = seen + _658_ = seen end - apropos_2a(pattern, subtbl, (prefix .. name:gsub("%.", "/") .. "."), _659_, names) + apropos_2a(pattern, subtbl, (prefix .. name:gsub("%.", "/") .. "."), _658_, names) end end end @@ -521,10 +521,10 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) return tbl_17_ end commands.apropos = function(_env, read, on_values, on_error, _scope) - local function _664_(_241) + local function _663_(_241) return on_values(apropos(tostring(_241))) end - return run_command(read, on_error, _664_) + return run_command(read, on_error, _663_) 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) @@ -544,12 +544,12 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) local tgt = package.loaded for _, path0 in ipairs(paths) do if (nil == tgt) then break end - local _667_ + local _666_ do - local _666_0 = path0:gsub("%/", ".") - _667_ = _666_0 + local _665_0 = path0:gsub("%/", ".") + _666_ = _665_0 end - tgt = tgt[_667_] + tgt = tgt[_666_] end return tgt end @@ -561,9 +561,9 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) do local tgt = apropos_follow_path(path) if ("function" == type(tgt)) then - local _668_0 = (compiler.metadata):get(tgt, "fnl/docstring") - if (nil ~= _668_0) then - local docstr = _668_0 + local _667_0 = (compiler.metadata):get(tgt, "fnl/docstring") + if (nil ~= _667_0) then + local docstr = _667_0 val_19_ = (docstr:match(pattern) and path) else val_19_ = nil @@ -580,10 +580,10 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) return tbl_17_ end commands["apropos-doc"] = function(_env, read, on_values, on_error, _scope) - local function _672_(_241) + local function _671_(_241) return on_values(apropos_doc(tostring(_241))) end - return run_command(read, on_error, _672_) + return run_command(read, on_error, _671_) 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) @@ -597,108 +597,108 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) return nil end commands["apropos-show-docs"] = function(_env, read, on_values, on_error) - local function _674_(_241) + local function _673_(_241) return apropos_show_docs(on_values, tostring(_241)) end - return run_command(read, on_error, _674_) + return run_command(read, on_error, _673_) 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, _675_0, scope) - local _676_ = _675_0 - local env = _676_ - local ___replLocals___ = _676_["___replLocals___"] + local function resolve(identifier, _674_0, scope) + local _675_ = _674_0 + local env = _675_ + local ___replLocals___ = _675_["___replLocals___"] local e = nil - local function _677_(_241, _242) + local function _676_(_241, _242) return (___replLocals___[scope.unmanglings[_242]] or env[_242]) end - e = setmetatable({}, {__index = _677_}) - local function _678_(...) - local _679_0, _680_0 = ... - if ((_679_0 == true) and (nil ~= _680_0)) then - local code = _680_0 - local function _681_(...) - local _682_0, _683_0 = ... - if ((_682_0 == true) and (nil ~= _683_0)) then - local val = _683_0 + e = setmetatable({}, {__index = _676_}) + local function _677_(...) + local _678_0, _679_0 = ... + if ((_678_0 == true) and (nil ~= _679_0)) then + local code = _679_0 + local function _680_(...) + local _681_0, _682_0 = ... + if ((_681_0 == true) and (nil ~= _682_0)) then + local val = _682_0 return val else - local _ = _682_0 + local _ = _681_0 return nil end end - return _681_(pcall(specials["load-code"](code, e))) + return _680_(pcall(specials["load-code"](code, e))) else - local _ = _679_0 + local _ = _678_0 return nil end end - return _678_(pcall(compiler["compile-string"], tostring(identifier), {scope = scope})) + return _677_(pcall(compiler["compile-string"], tostring(identifier), {scope = scope})) end commands.find = function(env, read, on_values, on_error, scope) - local function _686_(_241) - local _687_0 = nil + local function _685_(_241) + local _686_0 = nil do - local _688_0 = utils["sym?"](_241) - if (nil ~= _688_0) then - local _689_0 = resolve(_688_0, env, scope) - if (nil ~= _689_0) then - _687_0 = debug.getinfo(_689_0) + local _687_0 = utils["sym?"](_241) + if (nil ~= _687_0) then + local _688_0 = resolve(_687_0, env, scope) + if (nil ~= _688_0) then + _686_0 = debug.getinfo(_688_0) else - _687_0 = _689_0 + _686_0 = _688_0 end else - _687_0 = _688_0 + _686_0 = _687_0 end end - if ((_G.type(_687_0) == "table") and (nil ~= _687_0.linedefined) and (nil ~= _687_0.short_src) and (nil ~= _687_0.source) and (_687_0.what == "Lua")) then - local line = _687_0.linedefined - local src = _687_0.short_src - local source = _687_0.source + if ((_G.type(_686_0) == "table") and (nil ~= _686_0.linedefined) and (nil ~= _686_0.short_src) and (nil ~= _686_0.source) and (_686_0.what == "Lua")) then + local line = _686_0.linedefined + local src = _686_0.short_src + local source = _686_0.source local fnlsrc = nil do - local _692_0 = compiler.sourcemap - if (nil ~= _692_0) then - _692_0 = _692_0[source] + local _691_0 = compiler.sourcemap + if (nil ~= _691_0) then + _691_0 = _691_0[source] end - if (nil ~= _692_0) then - _692_0 = _692_0[line] + if (nil ~= _691_0) then + _691_0 = _691_0[line] end - if (nil ~= _692_0) then - _692_0 = _692_0[2] + if (nil ~= _691_0) then + _691_0 = _691_0[2] end - fnlsrc = _692_0 + fnlsrc = _691_0 end return on_values({string.format("%s:%s", src, (fnlsrc or line))}) - elseif (_687_0 == nil) then + elseif (_686_0 == nil) then return on_error("Repl", "Unknown value") else - local _ = _687_0 + local _ = _686_0 return on_error("Repl", "No source info") end end - return run_command(read, on_error, _686_) + return run_command(read, on_error, _685_) 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 _697_(_241) + local function _696_(_241) local name = tostring(_241) local path = (utils["multi-sym?"](name) or {name}) local ok_3f, target = nil, nil - local function _698_() + local function _697_() return (utils["get-in"](scope.specials, path) or utils["get-in"](scope.macros, path) or resolve(name, env, scope)) end - ok_3f, target = pcall(_698_) + ok_3f, target = pcall(_697_) if ok_3f then return on_values({specials.doc(target, name)}) else return on_error("Repl", ("Could not find " .. name .. " for docs.")) end end - return run_command(read, on_error, _697_) + return run_command(read, on_error, _696_) 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 _700_(_241) + local function _699_(_241) local allowedGlobals = specials["current-global-names"](env) local ok_3f, result = pcall(compiler.compile, _241, {allowedGlobals = allowedGlobals, env = env, scope = scope}) if ok_3f then @@ -707,15 +707,15 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) return on_error("Repl", ("Error compiling expression: " .. result)) end end - return run_command(read, on_error, _700_) + return run_command(read, on_error, _699_) 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 i = #(plugins or {}), 1, -1 do for name, f in pairs(plugins[i]) do - local _702_0 = name:match("^repl%-command%-(.*)") - if (nil ~= _702_0) then - local cmd_name = _702_0 + local _701_0 = name:match("^repl%-command%-(.*)") + if (nil ~= _701_0) then + local cmd_name = _701_0 commands[cmd_name] = f end end @@ -725,12 +725,12 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) local function run_command_loop(input, read, loop, env, on_values, on_error, scope, chars) local command_name = input:match(",([^%s/]+)") do - local _704_0 = commands[command_name] - if (nil ~= _704_0) then - local command = _704_0 + local _703_0 = commands[command_name] + if (nil ~= _703_0) then + local command = _703_0 command(env, read, on_values, on_error, scope, chars) else - local _ = _704_0 + local _ = _703_0 if ((command_name ~= "exit") and (command_name ~= "return")) then on_values({"Unknown command", command_name}) end @@ -780,9 +780,9 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) end local function repl(_3foptions) local old_root_options = utils.root.options - local _713_ = utils.copy(_3foptions) - local opts = _713_ - local _3ffennelrc = _713_["fennelrc"] + local _712_ = utils.copy(_3foptions) + local opts = _712_ + local _3ffennelrc = _712_["fennelrc"] local _ = nil opts.fennelrc = nil _ = nil @@ -797,20 +797,20 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) local callbacks = {env = env, onError = (opts.onError or default_on_error), onValues = (opts.onValues or default_on_values), pp = (opts.pp or view), readChunk = (opts.readChunk or default_read_chunk)} local save_locals_3f = (opts.saveLocals ~= false) local byte_stream, clear_stream = nil, nil - local function _715_(_241) + local function _714_(_241) return callbacks.readChunk(_241) end - byte_stream, clear_stream = parser.granulate(_715_) + byte_stream, clear_stream = parser.granulate(_714_) local chars = {} local read, reset = nil, nil - local function _716_(parser_state) + local function _715_(parser_state) local b = byte_stream(parser_state) if b then table.insert(chars, string.char(b)) end return b end - read, reset = parser.parser(_716_) + read, reset = parser.parser(_715_) depth = (depth + 1) if opts.message then callbacks.onValues({opts.message}) @@ -825,14 +825,14 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) opts.init(opts, depth) end if opts.registerCompleter then - local function _722_() - local _721_0 = opts.scope - local function _723_(...) - return completer(env, _721_0, ...) + local function _721_() + local _720_0 = opts.scope + local function _722_(...) + return completer(env, _720_0, ...) end - return _723_ + return _722_ end - opts.registerCompleter(_722_()) + opts.registerCompleter(_721_()) end load_plugin_commands(opts.plugins) if save_locals_3f then @@ -879,28 +879,28 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) return run_command_loop(src_string, read, loop, env, callbacks.onValues, callbacks.onError, opts.scope, chars) else if not_eof_3f then - local function _727_(...) - local _728_0, _729_0 = ... - if ((_728_0 == true) and (nil ~= _729_0)) then - local src = _729_0 - local function _730_(...) - local _731_0, _732_0 = ... - if ((_731_0 == true) and (nil ~= _732_0)) then - local chunk = _732_0 - local function _733_() + local function _726_(...) + local _727_0, _728_0 = ... + if ((_727_0 == true) and (nil ~= _728_0)) then + local src = _728_0 + local function _729_(...) + local _730_0, _731_0 = ... + if ((_730_0 == true) and (nil ~= _731_0)) then + local chunk = _731_0 + local function _732_() return print_values(save_value(chunk())) end - local function _734_(...) + local function _733_(...) return callbacks.onError("Runtime", ...) end - return xpcall(_733_, _734_) - elseif ((_731_0 == false) and (nil ~= _732_0)) then - local msg = _732_0 + return xpcall(_732_, _733_) + elseif ((_730_0 == false) and (nil ~= _731_0)) then + local msg = _731_0 clear_stream() return callbacks.onError("Compile", msg) end end - local function _737_(...) + local function _736_(...) local src0 = nil if save_locals_3f then src0 = splice_save_locals(env, src, opts.scope) @@ -909,18 +909,18 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) end return pcall(specials["load-code"], src0, env) end - return _730_(_737_(...)) - elseif ((_728_0 == false) and (nil ~= _729_0)) then - local msg = _729_0 + return _729_(_736_(...)) + elseif ((_727_0 == false) and (nil ~= _728_0)) then + local msg = _728_0 clear_stream() return callbacks.onError("Compile", msg) end end - local function _739_() + local function _738_() opts["source"] = src_string return opts end - _727_(pcall(compiler.compile, form, _739_())) + _726_(pcall(compiler.compile, form, _738_())) utils.root.options = old_root_options if exit_next_3f then return env.___replLocals___["*1"] @@ -940,10 +940,10 @@ package.preload["fennel.repl"] = package.preload["fennel.repl"] or function(...) end return value end - local function _745_(overrides, _3fopts) + local function _744_(overrides, _3fopts) return repl(utils.copy(_3fopts, utils.copy(overrides))) end - return setmetatable({}, {__call = _745_, __index = {repl = repl}}) + return setmetatable({}, {__call = _744_, __index = {repl = repl}}) end package.preload["fennel.specials"] = package.preload["fennel.specials"] or function(...) local utils = require("fennel.utils") @@ -953,14 +953,14 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct local unpack = (table.unpack or _G.unpack) local SPECIALS = compiler.scopes.global.specials local function wrap_env(env) - local function _421_(_, key) + local function _420_(_, key) if utils["string?"](key) then return env[compiler["global-unmangling"](key)] else return env[key] end end - local function _423_(_, key, value) + local function _422_(_, key, value) if utils["string?"](key) then env[compiler["global-unmangling"](key)] = value return nil @@ -969,19 +969,19 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct return nil end end - local function _425_() + local function _424_() local function putenv(k, v) - local _426_ + local _425_ if utils["string?"](k) then - _426_ = compiler["global-unmangling"](k) + _425_ = compiler["global-unmangling"](k) else - _426_ = k + _425_ = k end - return _426_, v + return _425_, v end return next, utils.kvmap(env, putenv), nil end - return setmetatable({}, {__index = _421_, __newindex = _423_, __pairs = _425_}) + return setmetatable({}, {__index = _420_, __newindex = _422_, __pairs = _424_}) end local function fennel_module_name() return (utils.root.options.moduleName or "fennel") @@ -989,9 +989,9 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct local function current_global_names(_3fenv) local mt = nil do - local _428_0 = getmetatable(_3fenv) - if ((_G.type(_428_0) == "table") and (nil ~= _428_0.__pairs)) then - local mtpairs = _428_0.__pairs + local _427_0 = getmetatable(_3fenv) + if ((_G.type(_427_0) == "table") and (nil ~= _427_0.__pairs)) then + local mtpairs = _427_0.__pairs local tbl_14_ = {} for k, v in mtpairs(_3fenv) do local k_15_, v_16_ = k, v @@ -1000,7 +1000,7 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end end mt = tbl_14_ - elseif (_428_0 == nil) then + elseif (_427_0 == nil) then mt = (_3fenv or _G) else mt = nil @@ -1010,15 +1010,15 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end local function load_code(code, _3fenv, _3ffilename) local env = (_3fenv or rawget(_G, "_ENV") or _G) - local _431_0, _432_0 = rawget(_G, "setfenv"), rawget(_G, "loadstring") - if ((nil ~= _431_0) and (nil ~= _432_0)) then - local setfenv = _431_0 - local loadstring = _432_0 + local _430_0, _431_0 = rawget(_G, "setfenv"), rawget(_G, "loadstring") + if ((nil ~= _430_0) and (nil ~= _431_0)) then + local setfenv = _430_0 + local loadstring = _431_0 local f = assert(loadstring(code, _3ffilename)) setfenv(f, env) return f else - local _ = _431_0 + local _ = _430_0 return assert(load(code, _3ffilename, "t", env)) end end @@ -1030,13 +1030,13 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct 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 _434_ + local _433_ if (0 < #arglist) then - _434_ = " " + _433_ = " " else - _434_ = "" + _433_ = "" end - return string.format("(%s%s%s)\n %s", name, _434_, arglist, docstring) + return string.format("(%s%s%s)\n %s", name, _433_, arglist, docstring) else return string.format("%s\n %s", name, docstring) end @@ -1146,9 +1146,9 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct local opts = {nval = 1, tail = false} local scope = compiler["make-scope"]() local chunk = {} - local _444_ = compiler.compile1(v, scope, chunk, opts) - local _445_ = _444_[1] - local v0 = _445_[1] + local _443_ = compiler.compile1(v, scope, chunk, opts) + local _444_ = _443_[1] + local v0 = _444_[1] return v0 end local function insert_meta(meta, k, v) @@ -1156,23 +1156,23 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct compiler.assert((type(k) == "string"), ("expected string keys in metadata table, got: %s"):format(view(k, view_opts))) compiler.assert(literal_3f(v), ("expected literal value in metadata table, got: %s %s"):format(view(k, view_opts), view(v, view_opts))) table.insert(meta, view(k)) - local function _446_() + local function _445_() if ("string" == type(v)) then return view(v, view_opts) else return compile_value(v) end end - table.insert(meta, _446_()) + table.insert(meta, _445_()) return meta end local function insert_arglist(meta, arg_list) local view_opts = {["escape-newlines?"] = true, ["line-length"] = math.huge, ["one-line?"] = true} table.insert(meta, "\"fnl/arglist\"") - local function _447_(_241) + local function _446_(_241) return view(view(_241, view_opts)) end - table.insert(meta, ("{" .. table.concat(utils.map(arg_list, _447_), ", ") .. "}")) + table.insert(meta, ("{" .. table.concat(utils.map(arg_list, _446_), ", ") .. "}")) return meta end local function set_fn_metadata(f_metadata, parent, fn_name) @@ -1191,13 +1191,13 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end local function get_fn_name(ast, scope, fn_name, multi) if (fn_name and (fn_name[1] ~= "nil")) then - local _450_ + local _449_ if not multi then - _450_ = compiler["declare-local"](fn_name, {}, scope, ast) + _449_ = compiler["declare-local"](fn_name, {}, scope, ast) else - _450_ = compiler["symbol-to-expression"](fn_name, scope)[1] + _449_ = compiler["symbol-to-expression"](fn_name, scope)[1] end - return _450_, not multi, 3 + return _449_, not multi, 3 else return nil, true, 2 end @@ -1207,13 +1207,13 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct 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 _453_ + local _452_ if local_3f then - _453_ = "local function %s(%s)" + _452_ = "local function %s(%s)" else - _453_ = "%s = function(%s)" + _452_ = "%s = function(%s)" end - compiler.emit(parent, string.format(_453_, fn_name, table.concat(arg_name_list, ", ")), ast) + compiler.emit(parent, string.format(_452_, fn_name, table.concat(arg_name_list, ", ")), ast) compiler.emit(parent, f_chunk, ast) compiler.emit(parent, "end", ast) set_fn_metadata(f_metadata, parent, fn_name) @@ -1235,7 +1235,7 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end end local function get_function_metadata(ast, arg_list, index) - local function _456_(_241, _242) + local function _455_(_241, _242) local tbl_14_ = _241 for k, v in pairs(_242) do local k_15_, v_16_ = k, v @@ -1245,18 +1245,18 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end return tbl_14_ end - local function _458_(_241, _242) + local function _457_(_241, _242) _241["fnl/docstring"] = _242 return _241 end - return maybe_metadata(ast, utils["kv-table?"], _456_, maybe_metadata(ast, utils["string?"], _458_, {["fnl/arglist"] = arg_list}, index)) + return maybe_metadata(ast, utils["kv-table?"], _455_, maybe_metadata(ast, utils["string?"], _457_, {["fnl/arglist"] = arg_list}, index)) end SPECIALS.fn = function(ast, scope, parent) local f_scope = nil do - local _459_0 = compiler["make-scope"](scope) - _459_0["vararg"] = false - f_scope = _459_0 + local _458_0 = compiler["make-scope"](scope) + _458_0["vararg"] = false + f_scope = _458_0 end local f_chunk = {} local fn_sym = utils["sym?"](ast[2]) @@ -1316,28 +1316,28 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct 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 _464_ + local _463_ do - local _463_0 = utils["sym?"](ast[2]) - if (nil ~= _463_0) then - _464_ = tostring(_463_0) + local _462_0 = utils["sym?"](ast[2]) + if (nil ~= _462_0) then + _463_ = tostring(_462_0) else - _464_ = _463_0 + _463_ = _462_0 end end - if ("nil" ~= _464_) then + if ("nil" ~= _463_) then table.insert(parent, {ast = ast, leaf = tostring(ast[2])}) end - local _468_ + local _467_ do - local _467_0 = utils["sym?"](ast[3]) - if (nil ~= _467_0) then - _468_ = tostring(_467_0) + local _466_0 = utils["sym?"](ast[3]) + if (nil ~= _466_0) then + _467_ = tostring(_466_0) else - _468_ = _467_0 + _467_ = _466_0 end end - if ("nil" ~= _468_) then + if ("nil" ~= _467_) then return tostring(ast[3]) end end @@ -1345,8 +1345,8 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct compiler.assert((1 < #ast), "expected table argument", ast) local len = #ast local lhs_node = compiler.macroexpand(ast[2], scope) - local _471_ = compiler.compile1(lhs_node, scope, parent, {nval = 1}) - local lhs = _471_[1] + local _470_ = compiler.compile1(lhs_node, scope, parent, {nval = 1}) + local lhs = _470_[1] if (len == 2) then return tostring(lhs) else @@ -1356,8 +1356,8 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct if (utils["string?"](index) and utils["valid-lua-identifier?"](index)) then table.insert(indices, ("." .. index)) else - local _472_ = compiler.compile1(index, scope, parent, {nval = 1}) - local index0 = _472_[1] + local _471_ = compiler.compile1(index, scope, parent, {nval = 1}) + local index0 = _471_[1] table.insert(indices, ("[" .. tostring(index0) .. "]")) end end @@ -1402,7 +1402,7 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end doc_special("var", {"name", "val"}, "Introduce new mutable local.") local function kv_3f(t) - local _476_ + local _475_ do local tbl_17_ = {} local i_18_ = #tbl_17_ @@ -1418,9 +1418,9 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct tbl_17_[i_18_] = val_19_ end end - _476_ = tbl_17_ + _475_ = tbl_17_ end - return _476_[1] + return _475_[1] end SPECIALS.let = function(ast, scope, parent, opts) local bindings = ast[2] @@ -1447,22 +1447,22 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end end local function disambiguate_3f(rootstr, parent) - local function _481_() - local _480_0 = get_prev_line(parent) - if (nil ~= _480_0) then - local prev_line = _480_0 + local function _480_() + local _479_0 = get_prev_line(parent) + if (nil ~= _479_0) then + local prev_line = _479_0 return prev_line:match("%)$") end end - return (rootstr:match("^{") or rootstr:match("^%(") or _481_()) + return (rootstr:match("^{") or rootstr:match("^%(") or _480_()) 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 _483_ = compiler.compile1(ast[i], scope, parent, {nval = 1}) - local key = _483_[1] + local _482_ = compiler.compile1(ast[i], scope, parent, {nval = 1}) + local key = _482_[1] table.insert(keys, tostring(key)) end local value = compiler.compile1(ast[#ast], scope, parent, {nval = 1})[1] @@ -1586,10 +1586,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct local function remove_until_condition(bindings, ast) local _until = nil for i = (#bindings - 1), 3, -1 do - local _493_0 = clause_3f(bindings[i]) - if ((_493_0 == false) or (_493_0 == nil)) then - elseif (nil ~= _493_0) then - local clause = _493_0 + local _492_0 = clause_3f(bindings[i]) + if ((_492_0 == false) or (_492_0 == nil)) then + elseif (nil ~= _492_0) then + local clause = _492_0 compiler.assert(((clause == "until") and not _until), ("unexpected iterator clause: " .. clause), ast) table.remove(bindings, i) _until = table.remove(bindings, i) @@ -1599,8 +1599,8 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end local function compile_until(_3fcondition, scope, chunk) if _3fcondition then - local _495_ = compiler.compile1(_3fcondition, scope, chunk, {nval = 1}) - local condition_lua = _495_[1] + local _494_ = compiler.compile1(_3fcondition, scope, chunk, {nval = 1}) + local condition_lua = _494_[1] return compiler.emit(chunk, ("if %s then break end"):format(tostring(condition_lua)), utils.expr(_3fcondition, "expression")) end end @@ -1700,10 +1700,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct 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 _501_ = ast - local _ = _501_[1] - local _0 = _501_[2] - local method_string = _501_[3] + local _500_ = ast + local _ = _500_[1] + local _0 = _500_[2] + local method_string = _500_[3] local call_string = nil if ((target.type == "literal") or (target.type == "varg") or (target.type == "expression")) then call_string = "(%s):%s(%s)" @@ -1725,18 +1725,18 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end local function method_call(ast, scope, parent) compiler.assert((2 < #ast), "expected at least 2 arguments", ast) - local _503_ = compiler.compile1(ast[2], scope, parent, {nval = 1}) - local target = _503_[1] + local _502_ = compiler.compile1(ast[2], scope, parent, {nval = 1}) + local target = _502_[1] local args = {} for i = 4, #ast do local subexprs = nil - local _504_ + local _503_ if (i ~= #ast) then - _504_ = 1 + _503_ = 1 else - _504_ = nil + _503_ = nil end - subexprs = compiler.compile1(ast[i], scope, parent, {nval = _504_}) + subexprs = compiler.compile1(ast[i], scope, parent, {nval = _503_}) utils.map(subexprs, tostring, args) end if (utils["string?"](ast[3]) and utils["valid-lua-identifier?"](ast[3])) then @@ -1751,7 +1751,7 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct doc_special(":", {"tbl", "method-name", "..."}, "Call the named method on tbl with the provided args.\nMethod name doesn't have to be known at compile-time; if it is, use\n(tbl:method-name ...) instead.") SPECIALS.comment = function(ast, _, parent) local c = nil - local _507_ + local _506_ do local tbl_17_ = {} local i_18_ = #tbl_17_ @@ -1767,9 +1767,9 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct tbl_17_[i_18_] = val_19_ end end - _507_ = tbl_17_ + _506_ = tbl_17_ end - c = table.concat(_507_, " "):gsub("%]%]", "]\\]") + c = table.concat(_506_, " "):gsub("%]%]", "]\\]") return compiler.emit(parent, ("--[[ " .. c .. " ]]"), ast) end doc_special("comment", {"..."}, "Comment which will be emitted in Lua output.", true) @@ -1790,10 +1790,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct compiler.assert((#ast == 2), "expected one argument", ast) local f_scope = nil do - local _512_0 = compiler["make-scope"](scope) - _512_0["vararg"] = false - _512_0["hashfn"] = true - f_scope = _512_0 + local _511_0 = compiler["make-scope"](scope) + _511_0["vararg"] = false + _511_0["hashfn"] = true + f_scope = _511_0 end local f_chunk = {} local name = compiler.gensym(scope) @@ -1834,9 +1834,9 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct 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, _517_0) - local _518_ = _517_0 - local mac = _518_["macros"] + local function maybe_short_circuit_protect(ast, i, name, _516_0) + local _517_ = _516_0 + local mac = _517_["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.list(utils.sym("fn"), utils.sequence(utils.varg()), ast)) @@ -1857,15 +1857,15 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct table.insert(operands, tostring(subexprs[1])) end end - local _521_0 = #operands - if (_521_0 == 0) then - local _522_ + local _520_0 = #operands + if (_520_0 == 0) then + local _521_ do compiler.assert(zero_arity, "Expected more than 0 arguments", ast) - _522_ = zero_arity + _521_ = zero_arity end - return utils.expr(_522_, "literal") - elseif (_521_0 == 1) then + return utils.expr(_521_, "literal") + elseif (_520_0 == 1) then if utils["varg?"](ast[2]) then return compiler.assert(false, "tried to use vararg with operator", ast) elseif unary_prefix then @@ -1874,20 +1874,20 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct return operands[1] end else - local _ = _521_0 + local _ = _520_0 return ("(" .. table.concat(operands, padded_op) .. ")") end end local function define_arithmetic_special(name, zero_arity, unary_prefix, _3flua_name) - local _526_ + local _525_ do - local _525_0 = (_3flua_name or name) - local function _527_(...) - return operator_special(_525_0, zero_arity, unary_prefix, ...) + local _524_0 = (_3flua_name or name) + local function _526_(...) + return operator_special(_524_0, zero_arity, unary_prefix, ...) end - _526_ = _527_ + _525_ = _526_ end - SPECIALS[name] = _526_ + SPECIALS[name] = _525_ return doc_special(name, {"a", "b", "..."}, "Arithmetic operator; works the same as Lua but accepts more arguments.") end define_arithmetic_special("+", "0") @@ -1916,13 +1916,13 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct local prefixed_lib_name = ("bit." .. lib_name) for i = 2, len do local subexprs = nil - local _528_ + local _527_ if (i ~= len) then - _528_ = 1 + _527_ = 1 else - _528_ = nil + _527_ = nil end - subexprs = compiler.compile1(ast[i], scope, parent, {nval = _528_}) + subexprs = compiler.compile1(ast[i], scope, parent, {nval = _527_}) utils.map(subexprs, tostring, operands) end if (#operands == 1) then @@ -1941,10 +1941,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end end local function define_bitop_special(name, zero_arity, unary_prefix, native) - local function _534_(...) + local function _533_(...) return bitop_special(native, name, zero_arity, unary_prefix, ...) end - SPECIALS[name] = _534_ + SPECIALS[name] = _533_ return nil end define_bitop_special("lshift", nil, "1", "<<") @@ -1959,8 +1959,8 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct 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.") SPECIALS.bnot = function(ast, scope, parent) compiler.assert((#ast == 2), "expected one argument", ast) - local _535_ = compiler.compile1(ast[2], scope, parent, {nval = 1}) - local value = _535_[1] + local _534_ = compiler.compile1(ast[2], scope, parent, {nval = 1}) + local value = _534_[1] if utils.root.options.useBitLib then return ("bit.bnot(" .. tostring(value) .. ")") else @@ -1969,15 +1969,15 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end doc_special("bnot", {"x"}, "Bitwise negation; only 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, _537_0, scope, parent) - local _538_ = _537_0 - local _ = _538_[1] - local lhs_ast = _538_[2] - local rhs_ast = _538_[3] - local _539_ = compiler.compile1(lhs_ast, scope, parent, {nval = 1}) - local lhs = _539_[1] - local _540_ = compiler.compile1(rhs_ast, scope, parent, {nval = 1}) - local rhs = _540_[1] + local function native_comparator(op, _536_0, scope, parent) + local _537_ = _536_0 + local _ = _537_[1] + local lhs_ast = _537_[2] + local rhs_ast = _537_[3] + local _538_ = compiler.compile1(lhs_ast, scope, parent, {nval = 1}) + local lhs = _538_[1] + local _539_ = compiler.compile1(rhs_ast, scope, parent, {nval = 1}) + local rhs = _539_[1] return string.format("(%s %s %s)", tostring(lhs), op, tostring(rhs)) end local function idempotent_comparator(op, chain_op, ast, scope, parent) @@ -2090,21 +2090,21 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end local safe_require = nil local function safe_compiler_env() - local _547_ + local _546_ do - local _546_0 = rawget(_G, "utf8") - if (nil ~= _546_0) then - _547_ = utils.copy(_546_0) + local _545_0 = rawget(_G, "utf8") + if (nil ~= _545_0) then + _546_ = utils.copy(_545_0) else - _547_ = _546_0 + _546_ = _545_0 end end - return {_VERSION = _VERSION, assert = assert, bit = rawget(_G, "bit"), error = error, getmetatable = safe_getmetatable, ipairs = ipairs, math = utils.copy(math), next = next, pairs = utils.stablepairs, pcall = pcall, print = print, rawequal = rawequal, rawget = rawget, rawlen = rawget(_G, "rawlen"), rawset = rawset, require = safe_require, select = select, setmetatable = setmetatable, string = utils.copy(string), table = utils.copy(table), tonumber = tonumber, tostring = tostring, type = type, utf8 = _547_, xpcall = xpcall} + return {_VERSION = _VERSION, assert = assert, bit = rawget(_G, "bit"), error = error, getmetatable = safe_getmetatable, ipairs = ipairs, math = utils.copy(math), next = next, pairs = utils.stablepairs, pcall = pcall, print = print, rawequal = rawequal, rawget = rawget, rawlen = rawget(_G, "rawlen"), rawset = rawset, require = safe_require, select = select, setmetatable = setmetatable, string = utils.copy(string), table = utils.copy(table), tonumber = tonumber, tostring = tostring, type = type, utf8 = _546_, xpcall = xpcall} end local function combined_mt_pairs(env) local combined = {} - local _549_ = getmetatable(env) - local __index = _549_["__index"] + local _548_ = getmetatable(env) + local __index = _548_["__index"] if ("table" == type(__index)) then for k, v in pairs(__index) do combined[k] = v @@ -2118,40 +2118,40 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct local function make_compiler_env(ast, scope, parent, _3fopts) local provided = nil do - local _551_0 = (_3fopts or utils.root.options) - if ((_G.type(_551_0) == "table") and (_551_0["compiler-env"] == "strict")) then + local _550_0 = (_3fopts or utils.root.options) + if ((_G.type(_550_0) == "table") and (_550_0["compiler-env"] == "strict")) then provided = safe_compiler_env() - elseif ((_G.type(_551_0) == "table") and (nil ~= _551_0.compilerEnv)) then - local compilerEnv = _551_0.compilerEnv + elseif ((_G.type(_550_0) == "table") and (nil ~= _550_0.compilerEnv)) then + local compilerEnv = _550_0.compilerEnv provided = compilerEnv - elseif ((_G.type(_551_0) == "table") and (nil ~= _551_0["compiler-env"])) then - local compiler_env = _551_0["compiler-env"] + elseif ((_G.type(_550_0) == "table") and (nil ~= _550_0["compiler-env"])) then + local compiler_env = _550_0["compiler-env"] provided = compiler_env else - local _ = _551_0 + local _ = _550_0 provided = safe_compiler_env() end end local env = nil - local function _553_() + local function _552_() return compiler.scopes.macro end - local function _554_(symbol) + local function _553_(symbol) compiler.assert(compiler.scopes.macro, "must call from macro", ast) return compiler.scopes.macro.manglings[tostring(symbol)] end - local function _555_(base) + local function _554_(base) return utils.sym(compiler.gensym((compiler.scopes.macro or scope), base)) end - local function _556_(form) + local function _555_(form) compiler.assert(compiler.scopes.macro, "must call from macro", ast) return compiler.macroexpand(form, compiler.scopes.macro) end - env = {["assert-compile"] = compiler.assert, ["ast-source"] = utils["ast-source"], ["comment?"] = utils["comment?"], ["fennel-module-name"] = fennel_module_name, ["get-scope"] = _553_, ["in-scope?"] = _554_, ["list?"] = utils["list?"], ["macro-loaded"] = macro_loaded, ["multi-sym?"] = utils["multi-sym?"], ["sequence?"] = utils["sequence?"], ["sym?"] = utils["sym?"], ["table?"] = utils["table?"], ["varg?"] = utils["varg?"], _AST = ast, _CHUNK = parent, _IS_COMPILER = true, _SCOPE = scope, _SPECIALS = compiler.scopes.global.specials, _VARARG = utils.varg(), comment = utils.comment, gensym = _555_, list = utils.list, macroexpand = _556_, sequence = utils.sequence, sym = utils.sym, unpack = unpack, version = utils.version, view = view} + env = {["assert-compile"] = compiler.assert, ["ast-source"] = utils["ast-source"], ["comment?"] = utils["comment?"], ["fennel-module-name"] = fennel_module_name, ["get-scope"] = _552_, ["in-scope?"] = _553_, ["list?"] = utils["list?"], ["macro-loaded"] = macro_loaded, ["multi-sym?"] = utils["multi-sym?"], ["sequence?"] = utils["sequence?"], ["sym?"] = utils["sym?"], ["table?"] = utils["table?"], ["varg?"] = utils["varg?"], _AST = ast, _CHUNK = parent, _IS_COMPILER = true, _SCOPE = scope, _SPECIALS = compiler.scopes.global.specials, _VARARG = utils.varg(), comment = utils.comment, gensym = _554_, list = utils.list, macroexpand = _555_, sequence = utils.sequence, sym = utils.sym, unpack = unpack, version = utils.version, view = view} env._G = env return setmetatable(env, {__index = provided, __newindex = provided, __pairs = combined_mt_pairs}) end - local function _557_(...) + local function _556_(...) local tbl_17_ = {} local i_18_ = #tbl_17_ for c in string.gmatch((package.config or ""), "([^\n]+)") do @@ -2163,10 +2163,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end return tbl_17_ end - local _559_ = _557_(...) - local dirsep = _559_[1] - local pathsep = _559_[2] - local pathmark = _559_[3] + local _558_ = _556_(...) + local dirsep = _558_[1] + local pathsep = _558_[2] + local pathmark = _558_[3] local pkg_config = {dirsep = (dirsep or "/"), pathmark = (pathmark or "?"), pathsep = (pathsep or ";")} local function escapepat(str) return string.gsub(str, "[^%w]", "%%%1") @@ -2179,36 +2179,36 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct 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 _560_0 = (io.open(filename) or io.open(filename2)) - if (nil ~= _560_0) then - local file = _560_0 + local _559_0 = (io.open(filename) or io.open(filename2)) + if (nil ~= _559_0) then + local file = _559_0 file:close() return filename else - local _ = _560_0 + local _ = _559_0 return nil, ("no file '" .. filename .. "'") end end local function find_in_path(start, _3ftried_paths) - local _562_0 = fullpath:match(pattern, start) - if (nil ~= _562_0) then - local path = _562_0 - local _563_0, _564_0 = try_path(path) - if (nil ~= _563_0) then - local filename = _563_0 + local _561_0 = fullpath:match(pattern, start) + if (nil ~= _561_0) then + local path = _561_0 + local _562_0, _563_0 = try_path(path) + if (nil ~= _562_0) then + local filename = _562_0 return filename - elseif ((_563_0 == nil) and (nil ~= _564_0)) then - local error = _564_0 - local function _566_() - local _565_0 = (_3ftried_paths or {}) - table.insert(_565_0, error) - return _565_0 + elseif ((_562_0 == nil) and (nil ~= _563_0)) then + local error = _563_0 + local function _565_() + local _564_0 = (_3ftried_paths or {}) + table.insert(_564_0, error) + return _564_0 end - return find_in_path((start + #path + 1), _566_()) + return find_in_path((start + #path + 1), _565_()) end else - local _ = _562_0 - local function _568_() + local _ = _561_0 + local function _567_() local tried_paths = table.concat((_3ftried_paths or {}), "\n\9") if (_VERSION < "Lua 5.4") then return ("\n\9" .. tried_paths) @@ -2216,31 +2216,31 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct return tried_paths end end - return nil, _568_() + return nil, _567_() end end return find_in_path(1) end local function make_searcher(_3foptions) - local function _571_(module_name) + local function _570_(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 _572_0, _573_0 = search_module(module_name) - if (nil ~= _572_0) then - local filename = _572_0 - local function _574_(...) + local _571_0, _572_0 = search_module(module_name) + if (nil ~= _571_0) then + local filename = _571_0 + local function _573_(...) return utils["fennel-module"].dofile(filename, opts, ...) end - return _574_, filename - elseif ((_572_0 == nil) and (nil ~= _573_0)) then - local error = _573_0 + return _573_, filename + elseif ((_571_0 == nil) and (nil ~= _572_0)) then + local error = _572_0 return error end end - return _571_ + return _570_ end local function dofile_with_searcher(fennel_macro_searcher, filename, opts, ...) local searchers = (package.loaders or package.searchers or {}) @@ -2252,35 +2252,35 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct local function fennel_macro_searcher(module_name) local opts = nil do - local _576_0 = utils.copy(utils.root.options) - _576_0["module-name"] = module_name - _576_0["env"] = "_COMPILER" - _576_0["requireAsInclude"] = false - _576_0["allowedGlobals"] = nil - opts = _576_0 + local _575_0 = utils.copy(utils.root.options) + _575_0["module-name"] = module_name + _575_0["env"] = "_COMPILER" + _575_0["requireAsInclude"] = false + _575_0["allowedGlobals"] = nil + opts = _575_0 end - local _577_0 = search_module(module_name, utils["fennel-module"]["macro-path"]) - if (nil ~= _577_0) then - local filename = _577_0 - local _578_ + local _576_0 = search_module(module_name, utils["fennel-module"]["macro-path"]) + if (nil ~= _576_0) then + local filename = _576_0 + local _577_ if (opts["compiler-env"] == _G) then - local function _579_(...) + local function _578_(...) return dofile_with_searcher(fennel_macro_searcher, filename, opts, ...) end - _578_ = _579_ + _577_ = _578_ else - local function _580_(...) + local function _579_(...) return utils["fennel-module"].dofile(filename, opts, ...) end - _578_ = _580_ + _577_ = _579_ end - return _578_, filename + return _577_, filename end end local function lua_macro_searcher(module_name) - local _583_0 = search_module(module_name, package.path) - if (nil ~= _583_0) then - local filename = _583_0 + local _582_0 = search_module(module_name, package.path) + if (nil ~= _582_0) then + local filename = _582_0 local code = nil do local f = io.open(filename) @@ -2292,10 +2292,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct return error(..., 0) end end - local function _585_() + local function _584_() return assert(f:read("*a")) end - code = close_handlers_10_(_G.xpcall(_585_, (package.loaded.fennel or debug).traceback)) + code = close_handlers_10_(_G.xpcall(_584_, (package.loaded.fennel or debug).traceback)) end local chunk = load_code(code, make_compiler_env(), filename) return chunk, filename @@ -2303,38 +2303,38 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end local macro_searchers = {fennel_macro_searcher, lua_macro_searcher} local function search_macro_module(modname, n) - local _587_0 = macro_searchers[n] - if (nil ~= _587_0) then - local f = _587_0 - local _588_0, _589_0 = f(modname) - if ((nil ~= _588_0) and true) then - local loader = _588_0 - local _3ffilename = _589_0 + local _586_0 = macro_searchers[n] + if (nil ~= _586_0) then + local f = _586_0 + local _587_0, _588_0 = f(modname) + if ((nil ~= _587_0) and true) then + local loader = _587_0 + local _3ffilename = _588_0 return loader, _3ffilename else - local _ = _588_0 + local _ = _587_0 return search_macro_module(modname, (n + 1)) end end end local function sandbox_fennel_module(modname) if ((modname == "fennel.macros") or (package and package.loaded and ("table" == type(package.loaded[modname])) and (package.loaded[modname].metadata == compiler.metadata))) then - local function _592_(_, ...) + local function _591_(_, ...) return (compiler.metadata):setall(...) end - return {metadata = {setall = _592_}, view = view} + return {metadata = {setall = _591_}, view = view} end end - local function _594_(modname) - local function _595_() + local function _593_(modname) + local function _594_() local loader, filename = search_macro_module(modname, 1) compiler.assert(loader, (modname .. " module not found.")) macro_loaded[modname] = loader(modname, filename) return macro_loaded[modname] end - return (macro_loaded[modname] or sandbox_fennel_module(modname) or _595_()) + return (macro_loaded[modname] or sandbox_fennel_module(modname) or _594_()) end - safe_require = _594_ + safe_require = _593_ 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 @@ -2344,10 +2344,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end return nil end - local function resolve_module_name(_596_0, _scope, _parent, opts) - local _597_ = _596_0 - local second = _597_[2] - local filename = _597_["filename"] + local function resolve_module_name(_595_0, _scope, _parent, opts) + local _596_ = _595_0 + local second = _596_[2] + local filename = _596_["filename"] local filename0 = (filename or (utils["table?"](second) and second.filename)) local module_name = utils.root.options["module-name"] local modexpr = compiler.compile(second, opts) @@ -2404,10 +2404,10 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct return error(..., 0) end end - local function _603_() + local function _602_() return assert(f:read("*all")):gsub("[\13\n]*$", "") end - src = close_handlers_10_(_G.xpcall(_603_, (package.loaded.fennel or debug).traceback)) + src = close_handlers_10_(_G.xpcall(_602_, (package.loaded.fennel or debug).traceback)) end local ret = utils.expr(("require(\"" .. mod .. "\")"), "statement") local target = ("package.preload[%q]"):format(mod) @@ -2437,12 +2437,12 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct compiler.assert((#ast == 2), "expected one argument", ast) local modexpr = nil do - local _606_0, _607_0 = pcall(resolve_module_name, ast, scope, parent, opts) - if ((_606_0 == true) and (nil ~= _607_0)) then - local modname = _607_0 + local _605_0, _606_0 = pcall(resolve_module_name, ast, scope, parent, opts) + if ((_605_0 == true) and (nil ~= _606_0)) then + local modname = _606_0 modexpr = utils.expr(string.format("%q", modname), "literal") else - local _ = _606_0 + local _ = _605_0 modexpr = compiler.compile1(ast[2], scope, parent, {nval = 1})[1] end end @@ -2459,13 +2459,13 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct utils.root.options["module-name"] = mod _ = nil local res = nil - local function _611_() - local _610_0 = search_module(mod) - if (nil ~= _610_0) then - local fennel_path = _610_0 + local function _610_() + local _609_0 = search_module(mod) + if (nil ~= _609_0) then + local fennel_path = _609_0 return include_path(ast, opts, fennel_path, mod, true) else - local _0 = _610_0 + local _0 = _609_0 local lua_path = search_module(mod, package.path) if lua_path then return include_path(ast, opts, lua_path, mod, false) @@ -2476,7 +2476,7 @@ package.preload["fennel.specials"] = package.preload["fennel.specials"] or funct end 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 _611_()) + 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 _610_()) utils.root.options["module-name"] = oldmod return res end @@ -2527,13 +2527,13 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct local scopes = {compiler = nil, global = nil, macro = nil} local function make_scope(_3fparent) local parent = (_3fparent or scopes.global) - local _265_ + local _264_ if parent then - _265_ = ((parent.depth or 0) + 1) + _264_ = ((parent.depth or 0) + 1) else - _265_ = 0 + _264_ = 0 end - return {["gensym-base"] = setmetatable({}, {__index = (parent and parent["gensym-base"])}), autogensyms = setmetatable({}, {__index = (parent and parent.autogensyms)}), depth = _265_, gensyms = setmetatable({}, {__index = (parent and parent.gensyms)}), hashfn = (parent and parent.hashfn), includes = setmetatable({}, {__index = (parent and parent.includes)}), macros = setmetatable({}, {__index = (parent and parent.macros)}), manglings = setmetatable({}, {__index = (parent and parent.manglings)}), parent = parent, refedglobals = {}, specials = setmetatable({}, {__index = (parent and parent.specials)}), symmeta = setmetatable({}, {__index = (parent and parent.symmeta)}), unmanglings = setmetatable({}, {__index = (parent and parent.unmanglings)}), vararg = (parent and parent.vararg)} + return {["gensym-base"] = setmetatable({}, {__index = (parent and parent["gensym-base"])}), autogensyms = setmetatable({}, {__index = (parent and parent.autogensyms)}), depth = _264_, gensyms = setmetatable({}, {__index = (parent and parent.gensyms)}), hashfn = (parent and parent.hashfn), includes = setmetatable({}, {__index = (parent and parent.includes)}), macros = setmetatable({}, {__index = (parent and parent.macros)}), manglings = setmetatable({}, {__index = (parent and parent.manglings)}), parent = parent, refedglobals = {}, specials = setmetatable({}, {__index = (parent and parent.specials)}), symmeta = setmetatable({}, {__index = (parent and parent.symmeta)}), unmanglings = setmetatable({}, {__index = (parent and parent.unmanglings)}), vararg = (parent and parent.vararg)} end local function assert_msg(ast, msg) local ast_tbl = nil @@ -2551,10 +2551,10 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end local function assert_compile(condition, msg, ast, _3ffallback_ast) if not condition then - local _268_ = (utils.root.options or {}) - local error_pinpoint = _268_["error-pinpoint"] - local source = _268_["source"] - local unfriendly = _268_["unfriendly"] + local _267_ = (utils.root.options or {}) + local error_pinpoint = _267_["error-pinpoint"] + local source = _267_["source"] + local unfriendly = _267_["unfriendly"] local ast0 = nil if next(utils["ast-source"](ast)) then ast0 = ast @@ -2578,33 +2578,33 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct scopes.macro = scopes.global local serialize_subst = {["\11"] = "\\v", ["\12"] = "\\f", ["\7"] = "\\a", ["\8"] = "\\b", ["\9"] = "\\t", ["\n"] = "n"} local function serialize_string(str) - local function _273_(_241) + local function _272_(_241) return ("\\" .. _241:byte()) end - return string.gsub(string.gsub(string.format("%q", str), ".", serialize_subst), "[\128-\255]", _273_) + return string.gsub(string.gsub(string.format("%q", str), ".", serialize_subst), "[\128-\255]", _272_) end local function global_mangling(str) if utils["valid-lua-identifier?"](str) then return str else - local function _274_(_241) + local function _273_(_241) return string.format("_%02x", _241:byte()) end - return ("__fnl_global__" .. str:gsub("[^%w]", _274_)) + return ("__fnl_global__" .. str:gsub("[^%w]", _273_)) end end local function global_unmangling(identifier) - local _276_0 = string.match(identifier, "^__fnl_global__(.*)$") - if (nil ~= _276_0) then - local rest = _276_0 - local _277_0 = nil - local function _278_(_241) + local _275_0 = string.match(identifier, "^__fnl_global__(.*)$") + if (nil ~= _275_0) then + local rest = _275_0 + local _276_0 = nil + local function _277_(_241) return string.char(tonumber(_241:sub(2), 16)) end - _277_0 = string.gsub(rest, "_[%da-f][%da-f]", _278_) - return _277_0 + _276_0 = string.gsub(rest, "_[%da-f][%da-f]", _277_) + return _276_0 else - local _ = _276_0 + local _ = _275_0 return identifier end end @@ -2628,10 +2628,10 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct raw = str end local mangling = nil - local function _282_(_241) + local function _281_(_241) return string.format("_%02x", _241:byte()) end - mangling = string.gsub(string.gsub(raw, "-", "_"), "[^%w_]", _282_) + mangling = string.gsub(string.gsub(raw, "-", "_"), "[^%w_]", _281_) local unique = unique_mangling(mangling, mangling, scope, 0) scope.unmanglings[unique] = (scope["gensym-base"][str] or str) do @@ -2686,29 +2686,29 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return table.concat(parts, ".") end local function autogensym(base, scope) - local _286_0 = utils["multi-sym?"](base) - if (nil ~= _286_0) then - local parts = _286_0 + local _285_0 = utils["multi-sym?"](base) + if (nil ~= _285_0) then + local parts = _285_0 return combine_auto_gensym(parts, autogensym(parts[1], scope)) else - local _ = _286_0 - local function _287_() + local _ = _285_0 + local function _286_() local mangling = gensym(scope, base:sub(1, -2), "auto") scope.autogensyms[base] = mangling return mangling end - return (scope.autogensyms[base] or _287_()) + return (scope.autogensyms[base] or _286_()) end end local function check_binding_valid(symbol, scope, ast, _3fopts) local name = tostring(symbol) local macro_3f = nil do - local _289_0 = _3fopts - if (nil ~= _289_0) then - _289_0 = _289_0["macro?"] + local _288_0 = _3fopts + if (nil ~= _288_0) then + _288_0 = _288_0["macro?"] end - macro_3f = _289_0 + macro_3f = _288_0 end assert_compile(("&" ~= name:match("[&.:]")), "invalid character: &", symbol) assert_compile(not name:find("^%."), "invalid character: .", symbol) @@ -2806,22 +2806,22 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end local function flatten_chunk(file_sourcemap, chunk, tab, depth) if chunk.leaf then - local _301_ = utils["ast-source"](chunk.ast) - local filename = _301_["filename"] - local line = _301_["line"] + local _300_ = utils["ast-source"](chunk.ast) + local filename = _300_["filename"] + local line = _300_["line"] table.insert(file_sourcemap, {filename, line}) return chunk.leaf else local tab0 = nil do - local _302_0 = tab - if (_302_0 == true) then + local _301_0 = tab + if (_301_0 == true) then tab0 = " " - elseif (_302_0 == false) then + elseif (_301_0 == false) then tab0 = "" - elseif (_302_0 == tab) then + elseif (_301_0 == tab) then tab0 = tab - elseif (_302_0 == nil) then + elseif (_301_0 == nil) then tab0 = "" else tab0 = nil @@ -2867,7 +2867,7 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end end local function make_metadata() - local function _310_(self, tgt, _3fkey) + local function _309_(self, tgt, _3fkey) if self[tgt] then if (nil ~= _3fkey) then return self[tgt][_3fkey] @@ -2876,12 +2876,12 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end end end - local function _313_(self, tgt, key, value) + local function _312_(self, tgt, key, value) self[tgt] = (self[tgt] or {}) self[tgt][key] = value return tgt end - local function _314_(self, tgt, ...) + local function _313_(self, tgt, ...) local kv_len = select("#", ...) local kvs = {...} if ((kv_len % 2) ~= 0) then @@ -2893,7 +2893,7 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end return tgt end - return setmetatable({}, {__index = {get = _310_, set = _313_, setall = _314_}, __mode = "k"}) + return setmetatable({}, {__index = {get = _309_, set = _312_, setall = _313_}, __mode = "k"}) end local function exprs1(exprs) return table.concat(utils.map(exprs, tostring), ", ") @@ -2939,14 +2939,14 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end if opts.target then local result = exprs1(exprs) - local function _322_() + local function _321_() if (result == "") then return "nil" else return result end end - emit(parent, string.format("%s = %s", opts.target, _322_()), ast) + emit(parent, string.format("%s = %s", opts.target, _321_()), ast) end if (opts.tail or opts.target) then return {returned = true} @@ -2958,16 +2958,16 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct local function find_macro(ast, scope) local macro_2a = nil do - local _325_0 = utils["sym?"](ast[1]) - if (_325_0 ~= nil) then - local _326_0 = tostring(_325_0) - if (_326_0 ~= nil) then - macro_2a = scope.macros[_326_0] + local _324_0 = utils["sym?"](ast[1]) + if (_324_0 ~= nil) then + local _325_0 = tostring(_324_0) + if (_325_0 ~= nil) then + macro_2a = scope.macros[_325_0] else - macro_2a = _326_0 + macro_2a = _325_0 end else - macro_2a = _325_0 + macro_2a = _324_0 end end local multi_sym_parts = utils["multi-sym?"](ast[1]) @@ -2979,12 +2979,12 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return macro_2a end end - local function propagate_trace_info(_330_0, _index, node) - local _331_ = _330_0 - local byteend = _331_["byteend"] - local bytestart = _331_["bytestart"] - local filename = _331_["filename"] - local line = _331_["line"] + local function propagate_trace_info(_329_0, _index, node) + local _330_ = _329_0 + local byteend = _330_["byteend"] + local bytestart = _330_["bytestart"] + local filename = _330_["filename"] + local line = _330_["line"] do local src = utils["ast-source"](node) if (("table" == type(node)) and (filename ~= src.filename)) then @@ -2997,8 +2997,8 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct local function quote_literal_nils(index, node, parent) if (parent and utils["list?"](parent)) then for i = 1, utils.maxn(parent) do - local _333_0 = parent[i] - if (_333_0 == nil) then + local _332_0 = parent[i] + if (_332_0 == nil) then parent[i] = utils.sym("nil") end end @@ -3006,10 +3006,10 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return index, node, parent end local function comp(f, g) - local function _336_(...) + local function _335_(...) return f(g(...)) end - return _336_ + return _335_ end local function built_in_3f(m) local found_3f = false @@ -3020,36 +3020,36 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return found_3f end local function macroexpand_2a(ast, scope, _3fonce) - local _337_0 = nil + local _336_0 = nil if utils["list?"](ast) then - _337_0 = find_macro(ast, scope) + _336_0 = find_macro(ast, scope) else - _337_0 = nil + _336_0 = nil end - if (_337_0 == false) then + if (_336_0 == false) then return ast - elseif (nil ~= _337_0) then - local macro_2a = _337_0 + elseif (nil ~= _336_0) then + local macro_2a = _336_0 local old_scope = scopes.macro local _ = nil scopes.macro = scope _ = nil local ok, transformed = nil, nil - local function _339_() + local function _338_() return macro_2a(unpack(ast, 2)) end - local function _340_() + local function _339_() if built_in_3f(macro_2a) then return tostring else return debug.traceback end end - ok, transformed = xpcall(_339_, _340_()) - local function _341_(...) + ok, transformed = xpcall(_338_, _339_()) + local function _340_(...) return propagate_trace_info(ast, ...) end - utils["walk-tree"](transformed, comp(_341_, quote_literal_nils)) + utils["walk-tree"](transformed, comp(_340_, quote_literal_nils)) scopes.macro = old_scope assert_compile(ok, transformed, ast) utils.hook("macroexpand", ast, transformed, scope) @@ -3059,7 +3059,7 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return macroexpand_2a(transformed, scope) end else - local _ = _337_0 + local _ = _336_0 return ast end end @@ -3091,13 +3091,13 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct 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 = nil - local _347_ + local _346_ if (i ~= len) then - _347_ = 1 + _346_ = 1 else - _347_ = nil + _346_ = nil end - subexprs = compile1(ast[i], scope, parent, {nval = _347_}) + subexprs = compile1(ast[i], scope, parent, {nval = _346_}) table.insert(fargs, subexprs[1]) if (i == len) then for j = 2, #subexprs do @@ -3135,13 +3135,13 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end end local function compile_varg(ast, scope, parent, opts) - local _352_ + local _351_ if scope.hashfn then - _352_ = "use $... in hashfn" + _351_ = "use $... in hashfn" else - _352_ = "unexpected vararg" + _351_ = "unexpected vararg" end - assert_compile(scope.vararg, _352_, ast) + assert_compile(scope.vararg, _351_, ast) return handle_compile_opts({utils.expr("...", "varg")}, parent, opts, ast) end local function compile_sym(ast, scope, parent, opts) @@ -3156,20 +3156,20 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return handle_compile_opts({e}, parent, opts, ast) end local function serialize_number(n) - local _355_0 = string.gsub(tostring(n), ",", ".") - return _355_0 + local _354_0 = string.gsub(tostring(n), ",", ".") + return _354_0 end local function compile_scalar(ast, _scope, parent, opts) local serialize = nil do - local _356_0 = type(ast) - if (_356_0 == "nil") then + local _355_0 = type(ast) + if (_355_0 == "nil") then serialize = tostring - elseif (_356_0 == "boolean") then + elseif (_355_0 == "boolean") then serialize = tostring - elseif (_356_0 == "string") then + elseif (_355_0 == "string") then serialize = serialize_string - elseif (_356_0 == "number") then + elseif (_355_0 == "number") then serialize = serialize_number else serialize = nil @@ -3182,8 +3182,8 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct if ((type(k) == "string") and utils["valid-lua-identifier?"](k)) then return k else - local _358_ = compile1(k, scope, parent, {nval = 1}) - local compiled = _358_[1] + local _357_ = compile1(k, scope, parent, {nval = 1}) + local compiled = _357_[1] return ("[" .. tostring(compiled) .. "]") end end @@ -3212,8 +3212,8 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct for k in utils.stablepairs(ast) do local val_19_ = nil if not keys[k] then - local _361_ = compile1(ast[k], scope, parent, {nval = 1}) - local v = _361_[1] + local _360_ = compile1(ast[k], scope, parent, {nval = 1}) + local v = _360_[1] val_19_ = string.format("%s = %s", escape_key(k), tostring(v)) else val_19_ = nil @@ -3245,12 +3245,12 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end local function destructure(to, from, ast, scope, parent, opts) local opts0 = (opts or {}) - local _365_ = opts0 - local declaration = _365_["declaration"] - local forceglobal = _365_["forceglobal"] - local forceset = _365_["forceset"] - local isvar = _365_["isvar"] - local symtype = _365_["symtype"] + local _364_ = opts0 + local declaration = _364_["declaration"] + local forceglobal = _364_["forceglobal"] + local forceset = _364_["forceset"] + local isvar = _364_["isvar"] + local symtype = _364_["symtype"] local symtype0 = ("_" .. (symtype or "dst")) local setter = nil if declaration then @@ -3266,8 +3266,8 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return declare_local(symbol, nil, scope, symbol, new_manglings) else local parts = (utils["multi-sym?"](raw) or {raw}) - local _367_ = parts - local first = _367_[1] + local _366_ = parts + local first = _366_[1] local meta = scope.symmeta[first] assert_compile(not raw:find(":"), "cannot set method sym", symbol) if ((#parts == 1) and not forceset) then @@ -3288,14 +3288,14 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end local function compile_top_target(lvalues) local inits = nil - local function _372_(_241) + local function _371_(_241) if scope.manglings[_241] then return _241 else return "nil" end end - inits = utils.map(lvalues, _372_) + inits = utils.map(lvalues, _371_) local init = table.concat(inits, ", ") local lvalue = table.concat(lvalues, ", ") local plast = parent[#parent] @@ -3333,7 +3333,7 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct 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 = nil - local _379_ + local _378_ do local tbl_17_ = {} local i_18_ = #tbl_17_ @@ -3344,9 +3344,9 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct tbl_17_[i_18_] = val_19_ end end - _379_ = tbl_17_ + _378_ = tbl_17_ end - exclude_str = table.concat(_379_, ", ") + exclude_str = table.concat(_378_, ", ") 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 @@ -3361,16 +3361,16 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct local s = gensym(scope, symtype0) local right = nil do - local _381_0 = nil + local _380_0 = nil if top_3f then - _381_0 = exprs1(compile1(from, scope, parent)) + _380_0 = exprs1(compile1(from, scope, parent)) else - _381_0 = exprs1(rightexprs) + _380_0 = exprs1(rightexprs) end - if (_381_0 == "") then + if (_380_0 == "") then right = "nil" - elseif (nil ~= _381_0) then - local right0 = _381_0 + elseif (nil ~= _380_0) then + local right0 = _380_0 right = right0 else right = nil @@ -3478,8 +3478,8 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct if opts.assertAsRepl then scope.macros.assert = scope.macros["assert-repl"] end - local _396_ = utils.root - _396_["set-reset"](_396_) + local _395_ = utils.root + _395_["set-reset"](_395_) utils.root.chunk, utils.root.scope, utils.root.options = chunk, scope, opts for i = 1, #asts do local exprs = compile1(asts[i], scope, chunk, {nval = (((i < #asts) and 0) or nil), tail = (i == #asts)}) @@ -3531,14 +3531,14 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct info.currentline = (remap[info.currentline][2] or -1) end if (info.what == "Lua") then - local function _401_() + local function _400_() if info.name then return ("'" .. info.name .. "'") else return "?" end end - return string.format("\9%s:%d: in function %s", info.short_src, info.currentline, _401_()) + return string.format("\9%s:%d: in function %s", info.short_src, info.currentline, _400_()) elseif (info.short_src == "(tail call)") then return " (tail call)" else @@ -3562,11 +3562,11 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct local done_3f, level = false, (_3fstart or 2) while not done_3f do do - local _405_0 = debug.getinfo(level, "Sln") - if (_405_0 == nil) then + local _404_0 = debug.getinfo(level, "Sln") + if (_404_0 == nil) then done_3f = true - elseif (nil ~= _405_0) then - local info = _405_0 + elseif (nil ~= _404_0) then + local info = _404_0 table.insert(lines, traceback_frame(info)) end end @@ -3576,14 +3576,14 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct end end local function entry_transform(fk, fv) - local function _408_(k, v) + local function _407_(k, v) if (type(k) == "number") then return k, fv(v) else return fk(k), fv(v) end end - return _408_ + return _407_ end local function mixed_concat(t, joiner) local seen = {} @@ -3628,10 +3628,10 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct return res[1] elseif utils["list?"](form) then local mapped = nil - local function _413_() + local function _412_() return nil end - mapped = utils.kvmap(form, entry_transform(_413_, q)) + mapped = utils.kvmap(form, entry_transform(_412_, q)) local filename = nil if form.filename then filename = string.format("%q", form.filename) @@ -3649,13 +3649,13 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct else filename = "nil" end - local _416_ + local _415_ if source then - _416_ = source.line + _415_ = source.line else - _416_ = "nil" + _415_ = "nil" end - return string.format("setmetatable({%s}, {filename=%s, line=%s, sequence=%s})", mixed_concat(mapped, ", "), filename, _416_, "(getmetatable(sequence()))['sequence']") + return string.format("setmetatable({%s}, {filename=%s, line=%s, sequence=%s})", mixed_concat(mapped, ", "), filename, _415_, "(getmetatable(sequence()))['sequence']") elseif (type(form) == "table") then local mapped = utils.kvmap(form, entry_transform(q, q)) local source = getmetatable(form) @@ -3665,14 +3665,14 @@ package.preload["fennel.compiler"] = package.preload["fennel.compiler"] or funct else filename = "nil" end - local function _419_() + local function _418_() if source then return source.line else return "nil" end end - return string.format("setmetatable({%s}, {filename=%s, line=%s})", mixed_concat(mapped, ", "), filename, _419_()) + return string.format("setmetatable({%s}, {filename=%s, line=%s})", mixed_concat(mapped, ", "), filename, _418_()) elseif (type(form) == "string") then return serialize_string(form) else @@ -3725,13 +3725,13 @@ package.preload["fennel.friend"] = package.preload["fennel.friend"] or function( return error(..., 0) end end - local function _188_() + local function _187_() for _ = 2, line do f:read() end return f:read() end - return close_handlers_10_(_G.xpcall(_188_, (package.loaded.fennel or debug).traceback)) + return close_handlers_10_(_G.xpcall(_187_, (package.loaded.fennel or debug).traceback)) end end local function sub(str, start, _end) @@ -3747,8 +3747,8 @@ package.preload["fennel.friend"] = package.preload["fennel.friend"] or function( if ((opts and (false == opts["error-pinpoint"])) or (os and os.getenv and os.getenv("NO_COLOR"))) then return codeline else - local _191_ = (opts or {}) - local error_pinpoint = _191_["error-pinpoint"] + local _190_ = (opts or {}) + local error_pinpoint = _190_["error-pinpoint"] local endcol = (_3fendcol or col) local eol = nil if utf8_ok_3f then @@ -3756,19 +3756,19 @@ package.preload["fennel.friend"] = package.preload["fennel.friend"] or function( else eol = string.len(codeline) end - local _193_ = (error_pinpoint or {"\27[7m", "\27[0m"}) - local open = _193_[1] - local close = _193_[2] + local _192_ = (error_pinpoint or {"\27[7m", "\27[0m"}) + local open = _192_[1] + local close = _192_[2] return (sub(codeline, 1, col) .. open .. sub(codeline, (col + 1), (endcol + 1)) .. close .. sub(codeline, (endcol + 2), eol)) end end - local function friendly_msg(msg, _195_0, source, opts) - local _196_ = _195_0 - local col = _196_["col"] - local endcol = _196_["endcol"] - local endline = _196_["endline"] - local filename = _196_["filename"] - local line = _196_["line"] + local function friendly_msg(msg, _194_0, source, opts) + local _195_ = _194_0 + local col = _195_["col"] + local endcol = _195_["endcol"] + local endline = _195_["endline"] + local filename = _195_["filename"] + local line = _195_["line"] local ok, codeline = pcall(read_line, filename, line, source) local endcol0 = nil if (ok and codeline and (line ~= endline)) then @@ -3791,10 +3791,10 @@ package.preload["fennel.friend"] = package.preload["fennel.friend"] or function( end local function assert_compile(condition, msg, ast, source, opts) if not condition then - local _200_ = utils["ast-source"](ast) - local col = _200_["col"] - local filename = _200_["filename"] - local line = _200_["line"] + local _199_ = utils["ast-source"](ast) + local col = _199_["col"] + local filename = _199_["filename"] + local line = _199_["line"] error(friendly_msg(("%s:%s:%s: Compile error: %s"):format((filename or "unknown"), (line or "?"), (col or "?"), msg), utils["ast-source"](ast), source, opts), 0) end return condition @@ -3810,36 +3810,36 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( local unpack = (table.unpack or _G.unpack) local function granulate(getchunk) local c, index, done_3f = "", 1, false - local function _202_(parser_state) + local function _201_(parser_state) if not done_3f then if (index <= #c) then local b = c:byte(index) index = (index + 1) return b else - local _203_0 = getchunk(parser_state) - local function _204_() - local char = _203_0 + local _202_0 = getchunk(parser_state) + local function _203_() + local char = _202_0 return (char ~= "") end - if ((nil ~= _203_0) and _204_()) then - local char = _203_0 + if ((nil ~= _202_0) and _203_()) then + local char = _202_0 c = char index = 2 return c:byte() else - local _ = _203_0 + local _ = _202_0 done_3f = true return nil end end end end - local function _208_() + local function _207_() c = "" return nil end - return _202_, _208_ + return _201_, _207_ end local function string_stream(str, _3foptions) local str0 = str:gsub("^#!", ";;") @@ -3847,12 +3847,12 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( _3foptions.source = str0 end local index = 1 - local function _210_() + local function _209_() local r = str0:byte(index) index = (index + 1) return r end - return _210_ + return _209_ end local delims = {[123] = 125, [125] = true, [40] = 41, [41] = true, [91] = 93, [93] = true} local function sym_char_3f(b) @@ -3868,12 +3868,12 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( local function char_starter_3f(b) return (((1 < b) and (b < 127)) or ((192 < b) and (b < 247))) end - local function parser_fn(getbyte, filename, _212_0) - local _213_ = _212_0 - local options = _213_ - local comments = _213_["comments"] - local source = _213_["source"] - local unfriendly = _213_["unfriendly"] + local function parser_fn(getbyte, filename, _211_0) + local _212_ = _211_0 + local options = _212_ + local comments = _212_["comments"] + local source = _212_["source"] + local unfriendly = _212_["unfriendly"] local stack = {} local line, byteindex, col, prev_col, lastb = 1, 0, 0, 0, nil local function ungetb(ub) @@ -3906,14 +3906,14 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( return r end local function whitespace_3f(b) - local function _221_() - local _220_0 = options.whitespace - if (nil ~= _220_0) then - _220_0 = _220_0[b] + local function _220_() + local _219_0 = options.whitespace + if (nil ~= _219_0) then + _219_0 = _219_0[b] end - return _220_0 + return _219_0 end - return ((b == 32) or ((9 <= b) and (b <= 13)) or _221_()) + return ((b == 32) or ((9 <= b) and (b <= 13)) or _220_()) end local function parse_error(msg, _3fcol_adjust) local col0 = (col + (_3fcol_adjust or -1)) @@ -3933,38 +3933,38 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( return nil end local function dispatch(v) - local _225_0 = stack[#stack] - if (_225_0 == nil) then + local _224_0 = stack[#stack] + if (_224_0 == nil) then retval, done_3f, whitespace_since_dispatch = v, true, false return nil - elseif ((_G.type(_225_0) == "table") and (nil ~= _225_0.prefix)) then - local prefix = _225_0.prefix + elseif ((_G.type(_224_0) == "table") and (nil ~= _224_0.prefix)) then + local prefix = _224_0.prefix local source0 = nil do - local _226_0 = table.remove(stack) - set_source_fields(_226_0) - source0 = _226_0 + local _225_0 = table.remove(stack) + set_source_fields(_225_0) + source0 = _225_0 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 ~= _225_0) then - local top = _225_0 + elseif (nil ~= _224_0) then + local top = _224_0 whitespace_since_dispatch = false return table.insert(top, v) end end local function badend() local accum = utils.map(stack, "closer") - local _228_ + local _227_ if (#stack == 1) then - _228_ = "" + _227_ = "" else - _228_ = "s" + _227_ = "s" end - return parse_error(string.format("expected closing delimiter%s %s", _228_, string.char(unpack(accum)))) + return parse_error(string.format("expected closing delimiter%s %s", _227_, string.char(unpack(accum)))) end local function skip_whitespace(b, close_table) if (b and whitespace_3f(b)) then @@ -3982,11 +3982,11 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( end local function parse_comment(b, contents) if (b and (10 ~= b)) then - local function _231_() + local function _230_() table.insert(contents, string.char(b)) return contents end - return parse_comment(getb(), _231_()) + return parse_comment(getb(), _230_()) elseif comments then ungetb(10) return dispatch(utils.comment(table.concat(contents), {filename = filename, line = line})) @@ -4012,12 +4012,12 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( return dispatch(setmetatable(tbl, mt)) end local function add_comment_at(comments0, index, node) - local _235_0 = comments0[index] - if (nil ~= _235_0) then - local existing = _235_0 + local _234_0 = comments0[index] + if (nil ~= _234_0) then + local existing = _234_0 return table.insert(existing, node) else - local _ = _235_0 + local _ = _234_0 comments0[index] = {node} return nil end @@ -4096,16 +4096,16 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( end local state0 = nil do - local _246_0 = {state, b} - if ((_G.type(_246_0) == "table") and (_246_0[1] == "base") and (_246_0[2] == 92)) then + local _245_0 = {state, b} + if ((_G.type(_245_0) == "table") and (_245_0[1] == "base") and (_245_0[2] == 92)) then state0 = "backslash" - elseif ((_G.type(_246_0) == "table") and (_246_0[1] == "base") and (_246_0[2] == 34)) then + elseif ((_G.type(_245_0) == "table") and (_245_0[1] == "base") and (_245_0[2] == 34)) then state0 = "done" - elseif ((_G.type(_246_0) == "table") and (_246_0[1] == "backslash") and (_246_0[2] == 10)) then + elseif ((_G.type(_245_0) == "table") and (_245_0[1] == "backslash") and (_245_0[2] == 10)) then table.remove(chars, (#chars - 1)) state0 = "base" else - local _ = _246_0 + local _ = _245_0 state0 = "base" end end @@ -4127,11 +4127,11 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( table.remove(stack) local raw = table.concat(chars) local formatted = raw:gsub("[\7-\13]", escape_char) - local _250_0 = (rawget(_G, "loadstring") or load)(("return " .. formatted)) - if (nil ~= _250_0) then - local load_fn = _250_0 + local _249_0 = (rawget(_G, "loadstring") or load)(("return " .. formatted)) + if (nil ~= _249_0) then + local load_fn = _249_0 return dispatch(load_fn()) - elseif (_250_0 == nil) then + elseif (_249_0 == nil) then return parse_error(("Invalid string: " .. raw)) end end @@ -4164,13 +4164,13 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( dispatch((tonumber(number_with_stripped_underscores) or parse_error(("could not read number \"" .. rawstr .. "\"")))) return true else - local _256_0 = tonumber(number_with_stripped_underscores) - if (nil ~= _256_0) then - local x = _256_0 + local _255_0 = tonumber(number_with_stripped_underscores) + if (nil ~= _255_0) then + local x = _255_0 dispatch(x) return true else - local _ = _256_0 + local _ = _255_0 return false end end @@ -4233,11 +4233,11 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( end return parse_loop(skip_whitespace(getb(), close_table)) end - local function _263_() + local function _262_() stack, line, byteindex, col, lastb = {}, 1, 0, 0, ((lastb ~= 10) and lastb) return nil end - return parse_stream, _263_ + return parse_stream, _262_ end local function parser(stream_or_string, _3ffilename, _3foptions) local filename = (_3ffilename or "unknown") @@ -4253,7 +4253,7 @@ package.preload["fennel.parser"] = package.preload["fennel.parser"] or function( end package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) local type_order = {["function"] = 5, boolean = 2, number = 1, string = 3, table = 4, thread = 7, userdata = 6} - local default_opts = {["detect-cycles?"] = true, ["elide-syms?"] = false, ["empty-as-sequence?"] = false, ["escape-newlines?"] = false, ["line-length"] = 80, ["max-sparse-gap"] = 10, ["metamethod?"] = true, ["one-line?"] = false, ["prefer-colon?"] = false, ["utf8?"] = true, depth = 128} + local default_opts = {["detect-cycles?"] = true, ["empty-as-sequence?"] = false, ["escape-newlines?"] = false, ["line-length"] = 80, ["max-sparse-gap"] = 10, ["metamethod?"] = true, ["one-line?"] = false, ["prefer-colon?"] = false, ["utf8?"] = true, depth = 128} local lua_pairs = pairs local lua_ipairs = ipairs local function pairs(t) @@ -4552,11 +4552,7 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) local k0 = pp(k, options0, (indent0 + 1), true) local v0 = pp(v, options0, (indent0 + slength(k0) + 1)) multiline_3f = (multiline_3f or k0:find("\n") or v0:find("\n")) - if ((k0:sub(1, 1) == ":") and (k0:sub(2) == v0)) then - val_19_ = (": " .. v0) - else - val_19_ = (k0 .. " " .. v0) - end + val_19_ = (k0 .. " " .. v0) end if (nil ~= val_19_) then i_18_ = (i_18_ + 1) @@ -4591,10 +4587,10 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) local options0 = normalize_opts(options) local tbl_17_ = {} local i_18_ = #tbl_17_ - for _, _52_0 in ipairs(kv) do - local _53_ = _52_0 - local _0 = _53_[1] - local v = _53_[2] + for _, _51_0 in ipairs(kv) do + local _52_ = _51_0 + local _0 = _52_[1] + local v = _52_[2] local val_19_ = nil do local v0 = pp(v, options0, indent0) @@ -4620,7 +4616,7 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) end else local oneline = nil - local _57_ + local _56_ do local tbl_17_ = {} local i_18_ = #tbl_17_ @@ -4631,9 +4627,9 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) tbl_17_[i_18_] = val_19_ end end - _57_ = tbl_17_ + _56_ = tbl_17_ end - oneline = table.concat(_57_, " ") + oneline = table.concat(_56_, " ") if (not getopt(options, "one-line?") and (force_multi_line_3f or oneline:find("\n") or (options["line-length"] < (indent + length_2a(oneline))))) then return table.concat(lines, ("\n" .. string.rep(" ", indent))) else @@ -4650,10 +4646,10 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) end else local _ = nil - local function _62_(_241) + local function _61_(_241) return visible_cycle_3f(_241, options) end - options["visible-cycle?"] = _62_ + options["visible-cycle?"] = _61_ _ = nil local lines, force_multi_line_3f = nil, nil do @@ -4661,13 +4657,13 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) lines, force_multi_line_3f = metamethod(t, pp, options0, indent) end options["visible-cycle?"] = nil - local _63_0 = type(lines) - if (_63_0 == "string") then + local _62_0 = type(lines) + if (_62_0 == "string") then return lines - elseif (_63_0 == "table") then + elseif (_62_0 == "table") then return concat_lines(lines, options, indent, force_multi_line_3f) else - local _0 = _63_0 + local _0 = _62_0 return error("__fennelview metamethod must return a table of lines") end end @@ -4676,40 +4672,40 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) options.level = (options.level + 1) local x0 = nil do - local _66_0 = nil + local _65_0 = nil if getopt(options, "metamethod?") then - local _67_0 = x - if (nil ~= _67_0) then - local _68_0 = getmetatable(_67_0) - if (nil ~= _68_0) then - _66_0 = _68_0.__fennelview + local _66_0 = x + if (nil ~= _66_0) then + local _67_0 = getmetatable(_66_0) + if (nil ~= _67_0) then + _65_0 = _67_0.__fennelview else - _66_0 = _68_0 + _65_0 = _67_0 end else - _66_0 = _67_0 + _65_0 = _66_0 end else - _66_0 = nil + _65_0 = nil end - if (nil ~= _66_0) then - local metamethod = _66_0 + if (nil ~= _65_0) then + local metamethod = _65_0 x0 = pp_metamethod(x, metamethod, options, indent) else - local _ = _66_0 - local _72_0, _73_0 = table_kv_pairs(x, options) - if (true and (_73_0 == "empty")) then - local _0 = _72_0 + local _ = _65_0 + local _71_0, _72_0 = table_kv_pairs(x, options) + if (true and (_72_0 == "empty")) then + local _0 = _71_0 if getopt(options, "empty-as-sequence?") then x0 = "[]" else x0 = "{}" end - elseif ((nil ~= _72_0) and (_73_0 == "table")) then - local kv = _72_0 + elseif ((nil ~= _71_0) and (_72_0 == "table")) then + local kv = _71_0 x0 = pp_associative(x, kv, options, indent) - elseif ((nil ~= _72_0) and (_73_0 == "seq")) then - local kv = _72_0 + elseif ((nil ~= _71_0) and (_72_0 == "seq")) then + local kv = _71_0 x0 = pp_sequence(x, kv, options, indent) else x0 = nil @@ -4720,8 +4716,8 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) return x0 end local function number__3estring(n) - local _77_0 = string.gsub(tostring(n), ",", ".") - return _77_0 + local _76_0 = string.gsub(tostring(n), ",", ".") + return _76_0 end local function colon_string_3f(s) return s:find("^[-%w?^_!$%&*+./|<=>]+$") @@ -4739,12 +4735,12 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) local ret = nil for _, init0 in ipairs(inits) do if ret then break end - ret = (byte and (function(_78_,_79_,_80_) return (_78_ <= _79_) and (_79_ <= _80_) end)(init0["min-byte"],byte,init0["max-byte"]) and init0) + ret = (byte and (function(_77_,_78_,_79_) return (_77_ <= _78_) and (_78_ <= _79_) end)(init0["min-byte"],byte,init0["max-byte"]) and init0) end init = ret end local code = nil - local function _81_() + local function _80_() local code0 = nil if init then code0 = (byte - init["min-byte"]) @@ -4757,8 +4753,8 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) end return code0 end - code = (init and _81_()) - if (code and (function(_83_,_84_,_85_) return (_83_ <= _84_) and (_84_ <= _85_) end)(init["min-code"],code,init["max-code"]) and not ((55296 <= code) and (code <= 57343))) then + code = (init and _80_()) + if (code and (function(_82_,_83_,_84_) return (_82_ <= _83_) and (_83_ <= _84_) end)(init["min-code"],code,init["max-code"]) and not ((55296 <= code) and (code <= 57343))) then return init.len end end @@ -4785,16 +4781,16 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) local esc_newline_3f = ((len < 2) or (getopt(options, "escape-newlines?") and (len < (options["line-length"] - indent)))) local byte_escape = (getopt(options, "byte-escape") or default_byte_escape) local escs = nil - local _89_ + local _88_ if esc_newline_3f then - _89_ = "\\n" + _88_ = "\\n" else - _89_ = "\n" + _88_ = "\n" end - local function _91_(_241, _242) + local function _90_(_241, _242) return byte_escape(_242:byte(), options) end - escs = setmetatable({["\""] = "\\\"", ["\11"] = "\\v", ["\12"] = "\\f", ["\13"] = "\\r", ["\7"] = "\\a", ["\8"] = "\\b", ["\9"] = "\\t", ["\\"] = "\\\\", ["\n"] = _89_}, {__index = _91_}) + escs = setmetatable({["\""] = "\\\"", ["\11"] = "\\v", ["\12"] = "\\f", ["\13"] = "\\r", ["\7"] = "\\a", ["\8"] = "\\b", ["\9"] = "\\t", ["\\"] = "\\\\", ["\n"] = _88_}, {__index = _90_}) local str0 = ("\"" .. str:gsub("[%c\\\"]", escs) .. "\"") if getopt(options, "utf8?") then return utf8_escape(str0, options) @@ -4823,7 +4819,7 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) end return defaults end - local function _94_(x, options, indent, colon_3f) + local function _93_(x, options, indent, colon_3f) local indent0 = (indent or 0) local options0 = (options or make_options(x)) local x0 = nil @@ -4833,19 +4829,19 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) x0 = x end local tv = type(x0) - local function _97_() - local _96_0 = getmetatable(x0) - if ((_G.type(_96_0) == "table") and true) then - local __fennelview = _96_0.__fennelview + local function _96_() + local _95_0 = getmetatable(x0) + if ((_G.type(_95_0) == "table") and true) then + local __fennelview = _95_0.__fennelview return __fennelview end end - if ((tv == "table") or ((tv == "userdata") and _97_())) then + if ((tv == "table") or ((tv == "userdata") and _96_())) then return pp_table(x0, options0, indent0) elseif (tv == "number") then return number__3estring(x0) else - local function _99_() + local function _98_() if (colon_3f ~= nil) then return colon_3f elseif ("function" == type(options0["prefer-colon?"])) then @@ -4854,7 +4850,7 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) return getopt(options0, "prefer-colon?") end end - if ((tv == "string") and colon_string_3f(x0) and _99_()) then + if ((tv == "string") and colon_string_3f(x0) and _98_()) then return (":" .. x0) elseif (tv == "string") then return pp_string(x0, options0, indent0) @@ -4865,7 +4861,7 @@ package.preload["fennel.view"] = package.preload["fennel.view"] or function(...) end end end - pp = _94_ + pp = _93_ local function _view(x, _3foptions) return pp(x, make_options(x, _3foptions), 0) end @@ -4910,32 +4906,32 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. end local len = nil do - local _104_0, _105_0 = pcall(require, "utf8") - if ((_104_0 == true) and (nil ~= _105_0)) then - local utf8 = _105_0 + local _103_0, _104_0 = pcall(require, "utf8") + if ((_103_0 == true) and (nil ~= _104_0)) then + local utf8 = _104_0 len = utf8.len else - local _ = _104_0 + local _ = _103_0 len = string.len end end local kv_order = {boolean = 2, number = 1, string = 3, table = 4} local function kv_compare(a, b) - local _107_0, _108_0 = type(a), type(b) - if (((_107_0 == "number") and (_108_0 == "number")) or ((_107_0 == "string") and (_108_0 == "string"))) then + local _106_0, _107_0 = type(a), type(b) + if (((_106_0 == "number") and (_107_0 == "number")) or ((_106_0 == "string") and (_107_0 == "string"))) then return (a < b) else - local function _109_() - local a_t = _107_0 - local b_t = _108_0 + local function _108_() + local a_t = _106_0 + local b_t = _107_0 return (a_t ~= b_t) end - if (((nil ~= _107_0) and (nil ~= _108_0)) and _109_()) then - local a_t = _107_0 - local b_t = _108_0 + if (((nil ~= _106_0) and (nil ~= _107_0)) and _108_()) then + local a_t = _106_0 + local b_t = _107_0 return ((kv_order[a_t] or 5) < (kv_order[b_t] or 5)) else - local _ = _107_0 + local _ = _106_0 return (tostring(a) < tostring(b)) end end @@ -4967,20 +4963,20 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. local function stablepairs(t) local mt_keys = nil do - local _113_0 = getmetatable(t) - if (nil ~= _113_0) then - _113_0 = _113_0.keys + local _112_0 = getmetatable(t) + if (nil ~= _112_0) then + _112_0 = _112_0.keys end - mt_keys = _113_0 + mt_keys = _112_0 end local succ, prev, first_mt = nil, nil, nil - local function _115_(_241) + local function _114_(_241) return t[_241] end - succ, prev, first_mt = add_stable_keys({}, nil, (mt_keys or {}), _115_) + succ, prev, first_mt = add_stable_keys({}, nil, (mt_keys or {}), _114_) local pairs_keys = nil do - local _116_0 = nil + local _115_0 = nil do local tbl_17_ = {} local i_18_ = #tbl_17_ @@ -4991,10 +4987,10 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. tbl_17_[i_18_] = val_19_ end end - _116_0 = tbl_17_ + _115_0 = tbl_17_ end - table.sort(_116_0, kv_compare) - pairs_keys = _116_0 + table.sort(_115_0, kv_compare) + pairs_keys = _115_0 end local succ0, _, first_after_mt = add_stable_keys(succ, prev, pairs_keys) local first = nil @@ -5004,19 +5000,19 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. first = first_mt end local function stablenext(tbl, key) - local _119_0 = nil + local _118_0 = nil if (key == nil) then - _119_0 = first + _118_0 = first else - _119_0 = succ0[key] + _118_0 = succ0[key] end - if (nil ~= _119_0) then - local next_key = _119_0 - local _121_0 = tbl[next_key] - if (_121_0 ~= nil) then - return next_key, _121_0 + if (nil ~= _118_0) then + local next_key = _118_0 + local _120_0 = tbl[next_key] + if (_120_0 ~= nil) then + return next_key, _120_0 else - return _121_0 + return _120_0 end end end @@ -5027,25 +5023,25 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. if (0 == #path) then return _3ffallback else - local _124_0 = nil + local _123_0 = nil do local t = tbl for _, k in ipairs(path) do if (nil == t) then break end - local _125_0 = type(t) - if (_125_0 == "table") then + local _124_0 = type(t) + if (_124_0 == "table") then t = t[k] else t = nil end end - _124_0 = t + _123_0 = t end - if (nil ~= _124_0) then - local res = _124_0 + if (nil ~= _123_0) then + local res = _123_0 return res else - local _ = _124_0 + local _ = _123_0 return _3ffallback end end @@ -5056,15 +5052,15 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. if (type(f) == "function") then f0 = f else - local function _129_(_241) + local function _128_(_241) return _241[f] end - f0 = _129_ + f0 = _128_ end for _, x in ipairs(t) do - local _131_0 = f0(x) - if (nil ~= _131_0) then - local v = _131_0 + local _130_0 = f0(x) + if (nil ~= _130_0) then + local v = _130_0 table.insert(out, v) end end @@ -5076,19 +5072,19 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. if (type(f) == "function") then f0 = f else - local function _133_(_241) + local function _132_(_241) return _241[f] end - f0 = _133_ + f0 = _132_ end for k, x in stablepairs(t) do - local _135_0, _136_0 = f0(k, x) - if ((nil ~= _135_0) and (nil ~= _136_0)) then - local key = _135_0 - local value = _136_0 - out[key] = value - elseif (nil ~= _135_0) then + local _134_0, _135_0 = f0(k, x) + if ((nil ~= _134_0) and (nil ~= _135_0)) then + local key = _134_0 local value = _135_0 + out[key] = value + elseif (nil ~= _134_0) then + local value = _134_0 table.insert(out, value) end end @@ -5105,13 +5101,13 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. return tbl_14_ end local function member_3f(x, tbl, _3fn) - local _139_0 = tbl[(_3fn or 1)] - if (_139_0 == x) then + local _138_0 = tbl[(_3fn or 1)] + if (_138_0 == x) then return true - elseif (_139_0 == nil) then + elseif (_138_0 == nil) then return nil else - local _ = _139_0 + local _ = _138_0 return member_3f(x, tbl, ((_3fn or 1) + 1)) end end @@ -5146,9 +5142,9 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. seen[next_state] = true return next_state, value else - local _142_0 = getmetatable(t) - if ((_G.type(_142_0) == "table") and true) then - local __index = _142_0.__index + local _141_0 = getmetatable(t) + if ((_G.type(_141_0) == "table") and true) then + local __index = _141_0.__index if ("table" == type(__index)) then t = __index return allpairs_next(t) @@ -5166,10 +5162,10 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. local safe = {} local view0 = nil if _3fview then - local function _146_(_241) + local function _145_(_241) return _3fview(_241, _3foptions, _3findent) end - view0 = _146_ + view0 = _145_ else view0 = view end @@ -5190,19 +5186,19 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. end local symbol_mt = {"SYMBOL", __eq = sym_3d, __fennelview = deref, __lt = sym_3c, __tostring = deref} local expr_mt = nil - local function _148_(x) + local function _147_(x) return tostring(deref(x)) end - expr_mt = {"EXPR", __tostring = _148_} + expr_mt = {"EXPR", __tostring = _147_} local list_mt = {"LIST", __fennelview = list__3estring, __tostring = list__3estring} local comment_mt = {"COMMENT", __eq = sym_3d, __fennelview = comment_view, __lt = sym_3c, __tostring = deref} local sequence_marker = {"SEQUENCE"} local varg_mt = {"VARARG", __fennelview = deref, __tostring = deref} local getenv = nil - local function _149_() + local function _148_() return nil end - getenv = ((os and os.getenv) or _149_) + getenv = ((os and os.getenv) or _148_) local function debug_on_3f(flag) local level = (getenv("FENNEL_DEBUG") or "") return ((level == "all") or level:find(flag)) @@ -5211,7 +5207,7 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. return setmetatable({...}, list_mt) end local function sym(str, _3fsource) - local _150_ + local _149_ do local tbl_14_ = {str} for k, v in pairs((_3fsource or {})) do @@ -5225,13 +5221,13 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. tbl_14_[k_15_] = v_16_ end end - _150_ = tbl_14_ + _149_ = tbl_14_ end - return setmetatable(_150_, symbol_mt) + return setmetatable(_149_, symbol_mt) end nil_sym = sym("nil") local function sequence(...) - local function _153_(seq, view0, inspector, indent) + local function _152_(seq, view0, inspector, indent) local opts = nil do inspector["empty-as-sequence?"] = {after = inspector["empty-as-sequence?"], once = true} @@ -5240,19 +5236,19 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. end return view0(seq, opts, indent) end - return setmetatable({...}, {__fennelview = _153_, sequence = sequence_marker}) + return setmetatable({...}, {__fennelview = _152_, sequence = sequence_marker}) end local function expr(strcode, etype) return setmetatable({strcode, type = etype}, expr_mt) end local function comment_2a(contents, _3fsource) - local _154_ = (_3fsource or {}) - local filename = _154_["filename"] - local line = _154_["line"] + local _153_ = (_3fsource or {}) + local filename = _153_["filename"] + local line = _153_["line"] return setmetatable({contents, filename = filename, line = line}, comment_mt) end local function varg(_3fsource) - local _155_ + local _154_ do local tbl_14_ = {"..."} for k, v in pairs((_3fsource or {})) do @@ -5266,9 +5262,9 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. tbl_14_[k_15_] = v_16_ end end - _155_ = tbl_14_ + _154_ = tbl_14_ end - return setmetatable(_155_, varg_mt) + return setmetatable(_154_, varg_mt) end local function expr_3f(x) return ((type(x) == "table") and (getmetatable(x) == expr_mt) and x) @@ -5318,7 +5314,7 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. elseif (type(str) ~= "string") then return false else - local function _161_() + local function _160_() local parts = {} for part in str:gmatch("[^%.%:]+[%.%:]?") do local last_char = part:sub(-1) @@ -5333,7 +5329,7 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. end return (next(parts) and parts) end - return ((str:match("%.") or str:match(":")) and not str:match("%.%.") and (str:byte() ~= string.byte(".")) and (str:byte() ~= string.byte(":")) and (str:byte(-1) ~= string.byte(".")) and (str:byte(-1) ~= string.byte(":")) and _161_()) + return ((str:match("%.") or str:match(":")) and not str:match("%.%.") and (str:byte() ~= string.byte(".")) and (str:byte() ~= string.byte(":")) and (str:byte(-1) ~= string.byte(".")) and (str:byte(-1) ~= string.byte(":")) and _160_()) end end local function quoted_3f(symbol) @@ -5367,15 +5363,15 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. return subopts end local root = nil - local function _166_() + local function _165_() end - root = {chunk = nil, options = nil, reset = _166_, scope = nil} - root["set-reset"] = function(_167_0) - local _168_ = _167_0 - local chunk = _168_["chunk"] - local options = _168_["options"] - local reset = _168_["reset"] - local scope = _168_["scope"] + root = {chunk = nil, options = nil, reset = _165_, scope = nil} + root["set-reset"] = function(_166_0) + local _167_ = _166_0 + local chunk = _167_["chunk"] + local options = _167_["options"] + local reset = _167_["reset"] + local scope = _167_["scope"] root.reset = function() root.chunk, root.scope, root.options, root.reset = chunk, scope, options, reset return nil @@ -5395,13 +5391,13 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. if (_G.io and _G.io.stderr) then local loc = nil do - local _170_0 = ast_source(_3fast) - if ((_G.type(_170_0) == "table") and (nil ~= _170_0.filename) and (nil ~= _170_0.line)) then - local filename = _170_0.filename - local line = _170_0.line + local _169_0 = ast_source(_3fast) + if ((_G.type(_169_0) == "table") and (nil ~= _169_0.filename) and (nil ~= _169_0.line)) then + local filename = _169_0.filename + local line = _169_0.line loc = (filename .. ":" .. line .. ": ") else - local _ = _170_0 + local _ = _169_0 loc = "" end end @@ -5409,11 +5405,11 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. end end local warned = {} - local function check_plugin_version(_173_0) - local _174_ = _173_0 - local plugin = _174_ - local name = _174_["name"] - local versions = _174_["versions"] + local function check_plugin_version(_172_0) + local _173_ = _172_0 + local plugin = _173_ + local name = _173_["name"] + local versions = _173_["versions"] if (not member_3f(version:gsub("-dev", ""), (versions or {})) and not warned[plugin]) then warned[plugin] = true return warn(string.format("plugin %s does not support Fennel version %s", (name or "unknown"), version)) @@ -5421,29 +5417,29 @@ package.preload["fennel.utils"] = package.preload["fennel.utils"] or function(.. end local function hook_opts(event, _3foptions, ...) local plugins = nil - local function _177_(...) - local _176_0 = _3foptions - if (nil ~= _176_0) then - _176_0 = _176_0.plugins + local function _176_(...) + local _175_0 = _3foptions + if (nil ~= _175_0) then + _175_0 = _175_0.plugins end - return _176_0 + return _175_0 end - local function _180_(...) - local _179_0 = root.options - if (nil ~= _179_0) then - _179_0 = _179_0.plugins + local function _179_(...) + local _178_0 = root.options + if (nil ~= _178_0) then + _178_0 = _178_0.plugins end - return _179_0 + return _178_0 end - plugins = (_177_(...) or _180_(...)) + plugins = (_176_(...) or _179_(...)) if plugins then local result = nil for _, plugin in ipairs(plugins) do if result then break end check_plugin_version(plugin) - local _182_0 = plugin[event] - if (nil ~= _182_0) then - local f = _182_0 + local _181_0 = plugin[event] + if (nil ~= _181_0) then + local f = _181_0 result = f(...) else result = nil @@ -5493,14 +5489,14 @@ package.preload["fennel"] = package.preload["fennel"] or function(...) local env = eval_env(opts.env, opts) local lua_source = compiler["compile-string"](str, opts) local loader = nil - local function _751_(...) + local function _750_(...) if opts.filename then return ("@" .. opts.filename) else return str end end - loader = specials["load-code"](lua_source, env, _751_(...)) + loader = specials["load-code"](lua_source, env, _750_(...)) opts.filename = nil return loader(...) end @@ -5526,10 +5522,10 @@ package.preload["fennel"] = package.preload["fennel"] or function(...) out[k] = {["binding-form?"] = utils["member?"](k, binding_3f), ["body-form?"] = utils["member?"](k, body_3f), ["define?"] = utils["member?"](k, define_3f), ["macro?"] = true} end for k, v in pairs(_G) do - local _752_0 = type(v) - if (_752_0 == "function") then + local _751_0 = type(v) + if (_751_0 == "function") then out[k] = {["function?"] = true, ["global?"] = true} - elseif (_752_0 == "table") then + elseif (_751_0 == "table") then if not k:find("^_") then for k2, v2 in pairs(v) do if ("function" == type(v2)) then @@ -5551,18 +5547,18 @@ package.preload["fennel"] = package.preload["fennel"] or function(...) do local module_name = "fennel.macros" local _ = nil - local function _756_() + local function _755_() return mod end - package.preload[module_name] = _756_ + package.preload[module_name] = _755_ _ = nil local env = nil do - local _757_0 = specials["make-compiler-env"](nil, compiler.scopes.compiler, {}) - _757_0["utils"] = utils - _757_0["fennel"] = mod - _757_0["get-function-metadata"] = specials["get-function-metadata"] - env = _757_0 + local _756_0 = specials["make-compiler-env"](nil, compiler.scopes.compiler, {}) + _756_0["utils"] = utils + _756_0["fennel"] = mod + _756_0["get-function-metadata"] = specials["get-function-metadata"] + env = _756_0 end local built_ins = eval([===[;; fennel-ls: macro-file @@ -6411,17 +6407,17 @@ local unpack = (table.unpack or _G.unpack) local help = "Usage: fennel [FLAG] [FILE]\n\nRun fennel, a lisp programming language for the Lua runtime.\n\n --repl : Command to launch an interactive repl session\n --compile FILES (-c) : Command to AOT compile files, writing Lua to stdout\n --eval SOURCE (-e) : Command to evaluate source code and print result\n\n --correlate : Make Lua output line numbers match Fennel input\n --load FILE (-l) : Load the specified FILE before executing command\n --no-compiler-sandbox : Don't limit compiler environment to minimal sandbox\n --compile-binary FILE\n OUT LUA_LIB LUA_DIR : Compile FILE to standalone binary OUT\n --compile-binary --help : Display further help for compiling binaries\n --add-package-path PATH : Add PATH to package.path for finding Lua modules\n --add-package-cpath PATH : Add PATH to package.cpath for finding Lua modules\n --add-fennel-path PATH : Add PATH to fennel.path for finding Fennel modules\n --add-macro-path PATH : Add PATH to fennel.macro-path for macro modules\n --globals G1[,G2...] : Allow these globals in addition to standard ones\n --globals-only G1[,G2] : Same as above, but exclude standard ones\n --assert-as-repl : Replace assert calls with assert-repl\n --require-as-include : Inline required modules in the output\n --skip-include M1[,M2] : Omit certain modules from output when included\n --use-bit-lib : Use LuaJITs bit library instead of operators\n --metadata : Enable function metadata, even in compiled output\n --no-metadata : Disable function metadata, even in REPL\n --lua LUA_EXE : Run in a child process with LUA_EXE\n --plugin FILE : Activate the compiler plugin in FILE\n --raw-errors : Disable friendly compile error reporting\n --no-searcher : Skip installing package.searchers entry\n --no-fennelrc : Skip loading ~/.fennelrc when launching repl\n\n --help (-h) : Display this text\n --version (-v) : Show version\n\nGlobals are not checked when doing AOT (ahead-of-time) compilation unless\nthe --globals-only or --globals flag is provided. Use --globals \"*\" to disable\nstrict globals checking in other contexts.\n\nMetadata is typically considered a development feature and is not recommended\nfor production. It is used for docstrings and enabled by default in the REPL.\n\nWhen not given a command, runs the file given as the first argument.\nWhen given neither command nor file, launches a repl.\n\nUse the NO_COLOR environment variable to disable escape codes in error messages.\n\nIf ~/.fennelrc exists, it will be loaded before launching a repl." local options = {plugins = {}} local function pack(...) - local _758_0 = {...} - _758_0["n"] = select("#", ...) - return _758_0 + local _757_0 = {...} + _757_0["n"] = select("#", ...) + return _757_0 end local function dosafely(f, ...) local args = {...} local result = nil - local function _759_() + local function _758_() return f(unpack(args)) end - result = pack(xpcall(_759_, fennel.traceback)) + result = pack(xpcall(_758_, fennel.traceback)) if not result[1] then do end (io.stderr):write((result[2] .. "\n")) os.exit(1) @@ -6466,18 +6462,18 @@ local function handle_lua(i) if (nil == arg[-1]) then do end (io.stderr):write("WARNING: --lua argument only works from script, not binary.\n") end - local _764_0, _765_0 = os.execute(table.concat(cmd, " ")) - if (((_764_0 == true) and (_765_0 == "exit")) or (_764_0 == 0)) then + local _763_0, _764_0 = os.execute(table.concat(cmd, " ")) + if (((_763_0 == true) and (_764_0 == "exit")) or (_763_0 == 0)) then return os.exit(0, true) else - local _ = _764_0 + local _ = _763_0 return os.exit(1, true) end end assert(arg, "Using the launcher from non-CLI context; use fennel.lua instead.") for i = #arg, 1, -1 do - local _767_0 = arg[i] - if (_767_0 == "--lua") then + local _766_0 = arg[i] + if (_766_0 == "--lua") then handle_lua(i) end end @@ -6485,58 +6481,58 @@ do local commands = {["-"] = true, ["--compile"] = true, ["--compile-binary"] = true, ["--eval"] = true, ["--help"] = true, ["--repl"] = true, ["--version"] = true, ["-c"] = true, ["-e"] = true, ["-h"] = true, ["-v"] = true} local i = 1 while (arg[i] and not options["ignore-options"]) do - local _769_0 = arg[i] - if (_769_0 == "--no-searcher") then + local _768_0 = arg[i] + if (_768_0 == "--no-searcher") then options["no-searcher"] = true table.remove(arg, i) - elseif (_769_0 == "--indent") then + elseif (_768_0 == "--indent") then options.indent = table.remove(arg, (i + 1)) if (options.indent == "false") then options.indent = false end table.remove(arg, i) - elseif (_769_0 == "--add-package-path") then + elseif (_768_0 == "--add-package-path") then local entry = table.remove(arg, (i + 1)) package.path = (entry .. ";" .. package.path) table.remove(arg, i) - elseif (_769_0 == "--add-package-cpath") then + elseif (_768_0 == "--add-package-cpath") then local entry = table.remove(arg, (i + 1)) package.cpath = (entry .. ";" .. package.cpath) table.remove(arg, i) - elseif (_769_0 == "--add-fennel-path") then + elseif (_768_0 == "--add-fennel-path") then local entry = table.remove(arg, (i + 1)) fennel.path = (entry .. ";" .. fennel.path) table.remove(arg, i) - elseif (_769_0 == "--add-macro-path") then + elseif (_768_0 == "--add-macro-path") then local entry = table.remove(arg, (i + 1)) fennel["macro-path"] = (entry .. ";" .. fennel["macro-path"]) table.remove(arg, i) - elseif (_769_0 == "--load") then + elseif (_768_0 == "--load") then handle_load(i) - elseif (_769_0 == "-l") then + elseif (_768_0 == "-l") then handle_load(i) - elseif (_769_0 == "--no-fennelrc") then + elseif (_768_0 == "--no-fennelrc") then options.fennelrc = false table.remove(arg, i) - elseif (_769_0 == "--correlate") then + elseif (_768_0 == "--correlate") then options.correlate = true table.remove(arg, i) - elseif (_769_0 == "--check-unused-locals") then + elseif (_768_0 == "--check-unused-locals") then options.checkUnusedLocals = true table.remove(arg, i) - elseif (_769_0 == "--globals") then + elseif (_768_0 == "--globals") then allow_globals(table.remove(arg, (i + 1)), _G) table.remove(arg, i) - elseif (_769_0 == "--globals-only") then + elseif (_768_0 == "--globals-only") then allow_globals(table.remove(arg, (i + 1)), {}) table.remove(arg, i) - elseif (_769_0 == "--require-as-include") then + elseif (_768_0 == "--require-as-include") then options.requireAsInclude = true table.remove(arg, i) - elseif (_769_0 == "--assert-as-repl") then + elseif (_768_0 == "--assert-as-repl") then options.assertAsRepl = true table.remove(arg, i) - elseif (_769_0 == "--skip-include") then + elseif (_768_0 == "--skip-include") then local skip_names = table.remove(arg, (i + 1)) local skip = nil do @@ -6553,28 +6549,28 @@ do end options.skipInclude = skip table.remove(arg, i) - elseif (_769_0 == "--use-bit-lib") then + elseif (_768_0 == "--use-bit-lib") then options.useBitLib = true table.remove(arg, i) - elseif (_769_0 == "--metadata") then + elseif (_768_0 == "--metadata") then options.useMetadata = true table.remove(arg, i) - elseif (_769_0 == "--no-metadata") then + elseif (_768_0 == "--no-metadata") then options.useMetadata = false table.remove(arg, i) - elseif (_769_0 == "--no-compiler-sandbox") then + elseif (_768_0 == "--no-compiler-sandbox") then options["compiler-env"] = _G table.remove(arg, i) - elseif (_769_0 == "--raw-errors") then + elseif (_768_0 == "--raw-errors") then options.unfriendly = true table.remove(arg, i) - elseif (_769_0 == "--plugin") then + elseif (_768_0 == "--plugin") then local opts = {["compiler-env"] = _G, env = "_COMPILER", useMetadata = true} local plugin = fennel.dofile(table.remove(arg, (i + 1)), opts) table.insert(options.plugins, 1, plugin) table.remove(arg, i) else - local _ = _769_0 + local _ = _768_0 if not commands[arg[i]] then options["ignore-options"] = true i = (i + 1) @@ -6622,13 +6618,13 @@ local function repl() return fennel.repl(options) end local function eval(form) - local _779_ + local _778_ if (form == "-") then - _779_ = (io.stdin):read("*a") + _778_ = (io.stdin):read("*a") else - _779_ = form + _778_ = form end - return print(dosafely(fennel.eval, _779_, options)) + return print(dosafely(fennel.eval, _778_, options)) end local function compile(files) for _, filename in ipairs(files) do @@ -6640,17 +6636,17 @@ local function compile(files) f = assert(io.open(filename, "rb")) end do - local _782_0, _783_0 = nil, nil - local function _784_() + local _781_0, _782_0 = nil, nil + local function _783_() return fennel["compile-string"](f:read("*a"), options) end - _782_0, _783_0 = xpcall(_784_, fennel.traceback) - if ((_782_0 == true) and (nil ~= _783_0)) then - local val = _783_0 + _781_0, _782_0 = xpcall(_783_, fennel.traceback) + if ((_781_0 == true) and (nil ~= _782_0)) then + local val = _782_0 print(val) - elseif (true and (nil ~= _783_0)) then - local _0 = _782_0 - local msg = _783_0 + elseif (true and (nil ~= _782_0)) then + local _0 = _781_0 + local msg = _782_0 do end (io.stderr):write((msg .. "\n")) os.exit(1) end @@ -6659,56 +6655,56 @@ local function compile(files) end return nil end -local _786_0 = arg -local function _787_(...) +local _785_0 = arg +local function _786_(...) return (0 == #arg) end -if ((_G.type(_786_0) == "table") and _787_(...)) then +if ((_G.type(_785_0) == "table") and _786_(...)) then return repl() -elseif ((_G.type(_786_0) == "table") and (_786_0[1] == "--repl")) then +elseif ((_G.type(_785_0) == "table") and (_785_0[1] == "--repl")) then return repl() -elseif ((_G.type(_786_0) == "table") and (_786_0[1] == "--compile")) then - local files = {select(2, (table.unpack or _G.unpack)(_786_0))} +elseif ((_G.type(_785_0) == "table") and (_785_0[1] == "--compile")) then + local files = {select(2, (table.unpack or _G.unpack)(_785_0))} return compile(files) -elseif ((_G.type(_786_0) == "table") and (_786_0[1] == "-c")) then - local files = {select(2, (table.unpack or _G.unpack)(_786_0))} +elseif ((_G.type(_785_0) == "table") and (_785_0[1] == "-c")) then + local files = {select(2, (table.unpack or _G.unpack)(_785_0))} return compile(files) -elseif ((_G.type(_786_0) == "table") and (_786_0[1] == "--compile-binary") and (nil ~= _786_0[2]) and (nil ~= _786_0[3]) and (nil ~= _786_0[4]) and (nil ~= _786_0[5])) then - local filename = _786_0[2] - local out = _786_0[3] - local static_lua = _786_0[4] - local lua_include_dir = _786_0[5] - local args = {select(6, (table.unpack or _G.unpack)(_786_0))} +elseif ((_G.type(_785_0) == "table") and (_785_0[1] == "--compile-binary") and (nil ~= _785_0[2]) and (nil ~= _785_0[3]) and (nil ~= _785_0[4]) and (nil ~= _785_0[5])) then + local filename = _785_0[2] + local out = _785_0[3] + local static_lua = _785_0[4] + local lua_include_dir = _785_0[5] + local args = {select(6, (table.unpack or _G.unpack)(_785_0))} local bin = require("fennel.binary") options.filename = filename options.requireAsInclude = true return bin.compile(filename, out, static_lua, lua_include_dir, options, args) -elseif ((_G.type(_786_0) == "table") and (_786_0[1] == "--compile-binary")) then +elseif ((_G.type(_785_0) == "table") and (_785_0[1] == "--compile-binary")) then local cmd = (arg[0] or "fennel") return print((require("fennel.binary").help):format(cmd, cmd, cmd)) -elseif ((_G.type(_786_0) == "table") and (_786_0[1] == "--eval") and (nil ~= _786_0[2])) then - local form = _786_0[2] +elseif ((_G.type(_785_0) == "table") and (_785_0[1] == "--eval") and (nil ~= _785_0[2])) then + local form = _785_0[2] return eval(form) -elseif ((_G.type(_786_0) == "table") and (_786_0[1] == "-e") and (nil ~= _786_0[2])) then - local form = _786_0[2] +elseif ((_G.type(_785_0) == "table") and (_785_0[1] == "-e") and (nil ~= _785_0[2])) then + local form = _785_0[2] return eval(form) else - local function _817_(...) - local a = _786_0[1] + local function _816_(...) + local a = _785_0[1] return ((a == "-v") or (a == "--version")) end - if (((_G.type(_786_0) == "table") and (nil ~= _786_0[1])) and _817_(...)) then - local a = _786_0[1] + if (((_G.type(_785_0) == "table") and (nil ~= _785_0[1])) and _816_(...)) then + local a = _785_0[1] return print(fennel["runtime-version"]()) - elseif ((_G.type(_786_0) == "table") and (_786_0[1] == "--help")) then + elseif ((_G.type(_785_0) == "table") and (_785_0[1] == "--help")) then return print(help) - elseif ((_G.type(_786_0) == "table") and (_786_0[1] == "-h")) then + elseif ((_G.type(_785_0) == "table") and (_785_0[1] == "-h")) then return print(help) - elseif ((_G.type(_786_0) == "table") and (_786_0[1] == "-")) then + elseif ((_G.type(_785_0) == "table") and (_785_0[1] == "-")) then return dosafely(fennel.eval, (io.stdin):read("*a")) - elseif ((_G.type(_786_0) == "table") and (nil ~= _786_0[1])) then - local filename = _786_0[1] - local args = {select(2, (table.unpack or _G.unpack)(_786_0))} + elseif ((_G.type(_785_0) == "table") and (nil ~= _785_0[1])) then + local filename = _785_0[1] + local args = {select(2, (table.unpack or _G.unpack)(_785_0))} arg[-2] = arg[-1] arg[-1] = arg[0] arg[0] = table.remove(arg, 1) diff --git a/src/fennel-ls/json-rpc.fnl b/src/fennel-ls/json-rpc.fnl index 4dcb1a1..87bf42f 100644 --- a/src/fennel-ls/json-rpc.fnl +++ b/src/fennel-ls/json-rpc.fnl @@ -8,7 +8,7 @@ There are only two functions exposed here: It's probably not compliant yet, because serialization of [] and {} is the same. Luckily, I'm testing with Neovim, so I can pretend these problems don't exist for now." -(local {: encode : decode} (require :fennel-ls.json.json)) +(local {: encode : decode} (require :dkjson)) (λ read-header [in ?header] "Reads the header of a JSON-RPC message" @@ -43,11 +43,11 @@ If there aren't enough bytes, return nil" (λ read [in] "Reads and parses a JSON-RPC message from the input stream Returns a table with the message if it succeeded, or a string with the parse error if it fails." - (let [(_success? result) + (let [(?result _?err-pos ?err) (-?>> (read-header in) (read-content in) - (pcall decode))] - result)) + decode)] + (or ?result ?err))) (λ write [out msg] "Serializes and writes a JSON-RPC message to the given output stream" diff --git a/src/fennel-ls/json/.github/FUNDING.yml b/src/fennel-ls/json/.github/FUNDING.yml deleted file mode 100644 index f7c7672..0000000 --- a/src/fennel-ls/json/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -github: rxi diff --git a/src/fennel-ls/json/LICENSE b/src/fennel-ls/json/LICENSE deleted file mode 100644 index 9eb37b1..0000000 --- a/src/fennel-ls/json/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2020 rxi - - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/src/fennel-ls/json/json.lua b/src/fennel-ls/json/json.lua deleted file mode 100644 index eb36b42..0000000 --- a/src/fennel-ls/json/json.lua +++ /dev/null @@ -1,404 +0,0 @@ --- --- json.lua --- --- Copyright (c) 2020 rxi --- --- Permission is hereby granted, free of charge, to any person obtaining a copy of --- this software and associated documentation files (the "Software"), to deal in --- the Software without restriction, including without limitation the rights to --- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies --- of the Software, and to permit persons to whom the Software is furnished to do --- so, subject to the following conditions: --- --- The above copyright notice and this permission notice shall be included in all --- copies or substantial portions of the Software. --- --- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR --- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, --- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE --- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER --- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, --- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE --- SOFTWARE. --- - --- Modifications have been made to this file. The ORIGINAL code can be found at --- this URL: https://github.com/rxi/json.lua - -local json = { _version = "0.1.2" } - --- unique placeholder for "null" -json.null = { _ = "nil" } - -local view = require("fennel").view - -------------------------------------------------------------------------------- --- Encode -------------------------------------------------------------------------------- - -local encode - -local escape_char_map = { - [ "\\" ] = "\\", - [ "\"" ] = "\"", - [ "\b" ] = "b", - [ "\f" ] = "f", - [ "\n" ] = "n", - [ "\r" ] = "r", - [ "\t" ] = "t", -} - -local escape_char_map_inv = { [ "/" ] = "/" } -for k, v in pairs(escape_char_map) do - escape_char_map_inv[v] = k -end - - -local function escape_char(c) - return "\\" .. (escape_char_map[c] or string.format("u%04x", c:byte())) -end - - -local function encode_nil(val) - return "null" -end - - -local function encode_table(val, stack) - local res = {} - stack = stack or {} - - -- Circular reference? - if stack[val] then error("circular reference") end - - stack[val] = true - - if rawget(val, 1) ~= nil or next(val) == nil then - -- Treat as array -- check keys are valid and it is not sparse - local n = 0 - for k in pairs(val) do - if type(k) ~= "number" then - error("invalid table: mixed or invalid key types in " .. view(val)) - end - n = n + 1 - end - if n ~= #val then - error("invalid table: sparse array") - end - -- Encode - for i, v in ipairs(val) do - table.insert(res, encode(v, stack)) - end - stack[val] = nil - return "[" .. table.concat(res, ",") .. "]" - - else - -- Treat as an object - local mt = getmetatable(val) - local exclude = mt and mt.__json_exclude_keys - for k, v in pairs(val) do - if not (exclude and exclude[k]) then - if type(k) ~= "string" then - error("invalid table: mixed or invalid key types in " .. view(val)) - end - table.insert(res, encode(k, stack) .. ":" .. encode(v, stack)) - end - end - stack[val] = nil - return "{" .. table.concat(res, ",") .. "}" - end -end - - -local function encode_string(val) - return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"' -end - - -local function encode_number(val) - -- Check for NaN, -inf and inf - if val ~= val or val <= -math.huge or val >= math.huge then - error("unexpected number value '" .. tostring(val) .. "'") - end - return string.format("%.14g", val) -end - - -local type_func_map = { - [ "nil" ] = encode_nil, - [ "table" ] = encode_table, - [ "string" ] = encode_string, - [ "number" ] = encode_number, - [ "boolean" ] = tostring, -} - - -encode = function(val, stack) - if val == json.null then - return encode_nil(val) - end - - local t = type(val) - local f = type_func_map[t] - if f then - return f(val, stack) - end - error("unexpected type '" .. t .. "'") -end - - -function json.encode(val) - return ( encode(val) ) -end - - -------------------------------------------------------------------------------- --- Decode -------------------------------------------------------------------------------- - -local parse - -local function create_set(...) - local res = {} - for i = 1, select("#", ...) do - res[ select(i, ...) ] = true - end - return res -end - -local space_chars = create_set(" ", "\t", "\r", "\n") -local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",") -local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u") -local literals = create_set("true", "false", "null") - -local literal_map = { - [ "true" ] = true, - [ "false" ] = false, - [ "null" ] = json.null, -} - - -local function next_char(str, idx, set, negate) - for i = idx, #str do - if set[str:sub(i, i)] ~= negate then - return i - end - end - return #str + 1 -end - - -local function decode_error(str, idx, msg) - local line_count = 1 - local col_count = 1 - for i = 1, idx - 1 do - col_count = col_count + 1 - if str:sub(i, i) == "\n" then - line_count = line_count + 1 - col_count = 1 - end - end - error( string.format("%s at line %d col %d", msg, line_count, col_count) ) -end - - -local function codepoint_to_utf8(n) - -- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa - local f = math.floor - if n <= 0x7f then - return string.char(n) - elseif n <= 0x7ff then - return string.char(f(n / 64) + 192, n % 64 + 128) - elseif n <= 0xffff then - return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128) - elseif n <= 0x10ffff then - return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128, - f(n % 4096 / 64) + 128, n % 64 + 128) - end - error( string.format("invalid unicode codepoint '%x'", n) ) -end - - -local function parse_unicode_escape(s) - local n1 = tonumber( s:sub(1, 4), 16 ) - local n2 = tonumber( s:sub(7, 10), 16 ) - -- Surrogate pair? - if n2 then - return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000) - else - return codepoint_to_utf8(n1) - end -end - - -local function parse_string(str, i) - local res = "" - local j = i + 1 - local k = j - - while j <= #str do - local x = str:byte(j) - - if x < 32 then - decode_error(str, j, "control character in string") - - elseif x == 92 then -- `\`: Escape - res = res .. str:sub(k, j - 1) - j = j + 1 - local c = str:sub(j, j) - if c == "u" then - local hex = str:match("^[dD][89aAbB]%x%x\\u%x%x%x%x", j + 1) - or str:match("^%x%x%x%x", j + 1) - or decode_error(str, j - 1, "invalid unicode escape in string") - res = res .. parse_unicode_escape(hex) - j = j + #hex - else - if not escape_chars[c] then - decode_error(str, j - 1, "invalid escape char '" .. c .. "' in string") - end - res = res .. escape_char_map_inv[c] - end - k = j + 1 - - elseif x == 34 then -- `"`: End of string - res = res .. str:sub(k, j - 1) - return res, j + 1 - end - - j = j + 1 - end - - decode_error(str, i, "expected closing quote for string") -end - - -local function parse_number(str, i) - local x = next_char(str, i, delim_chars) - local s = str:sub(i, x - 1) - local n = tonumber(s) - if not n then - decode_error(str, i, "invalid number '" .. s .. "'") - end - return n, x -end - - -local function parse_literal(str, i) - local x = next_char(str, i, delim_chars) - local word = str:sub(i, x - 1) - if not literals[word] then - decode_error(str, i, "invalid literal '" .. word .. "'") - end - return literal_map[word], x -end - - -local function parse_array(str, i) - local res = {} - local n = 1 - i = i + 1 - while 1 do - local x - i = next_char(str, i, space_chars, true) - -- Empty / end of array? - if str:sub(i, i) == "]" then - i = i + 1 - break - end - -- Read token - x, i = parse(str, i) - res[n] = x - n = n + 1 - -- Next token - i = next_char(str, i, space_chars, true) - local chr = str:sub(i, i) - i = i + 1 - if chr == "]" then break end - if chr ~= "," then decode_error(str, i, "expected ']' or ','") end - end - return res, i -end - - -local function parse_object(str, i) - local res = {} - i = i + 1 - while 1 do - local key, val - i = next_char(str, i, space_chars, true) - -- Empty / end of object? - if str:sub(i, i) == "}" then - i = i + 1 - break - end - -- Read key - if str:sub(i, i) ~= '"' then - decode_error(str, i, "expected string for key") - end - key, i = parse(str, i) - -- Read ':' delimiter - i = next_char(str, i, space_chars, true) - if str:sub(i, i) ~= ":" then - decode_error(str, i, "expected ':' after key") - end - i = next_char(str, i + 1, space_chars, true) - -- Read value - val, i = parse(str, i) - -- Set - res[key] = val - -- Next token - i = next_char(str, i, space_chars, true) - local chr = str:sub(i, i) - i = i + 1 - if chr == "}" then break end - if chr ~= "," then decode_error(str, i, "expected '}' or ','") end - end - return res, i -end - - -local char_func_map = { - [ '"' ] = parse_string, - [ "0" ] = parse_number, - [ "1" ] = parse_number, - [ "2" ] = parse_number, - [ "3" ] = parse_number, - [ "4" ] = parse_number, - [ "5" ] = parse_number, - [ "6" ] = parse_number, - [ "7" ] = parse_number, - [ "8" ] = parse_number, - [ "9" ] = parse_number, - [ "-" ] = parse_number, - [ "t" ] = parse_literal, - [ "f" ] = parse_literal, - [ "n" ] = parse_literal, - [ "[" ] = parse_array, - [ "{" ] = parse_object, -} - - -parse = function(str, idx) - local chr = str:sub(idx, idx) - local f = char_func_map[chr] - if f then - return f(str, idx) - end - decode_error(str, idx, "unexpected character '" .. chr .. "'") -end - - -function json.decode(str) - if type(str) ~= "string" then - error("expected argument of type string, got " .. type(str)) - end - local res, idx = parse(str, next_char(str, 1, space_chars, true)) - idx = next_char(str, idx, space_chars, true) - if idx <= #str then - decode_error(str, idx, "trailing garbage") - end - return res -end - - -return json diff --git a/src/fennel-ls/lint.fnl b/src/fennel-ls/lint.fnl index 9d8b24c..cc24eba 100644 --- a/src/fennel-ls/lint.fnl +++ b/src/fennel-ls/lint.fnl @@ -9,9 +9,10 @@ the `file.diagnostics` field, filling it with diagnostics." (local {:scopes {:global {: specials}}} (require :fennel.compiler)) -(local diagnostic-mt {:__json_exclude_keys {:quickfix true}}) -(fn diagnostic [server] - (setmetatable server diagnostic-mt)) +(local dkjson (require :dkjson)) +(local diagnostic-mt {:__tojson (fn [self state] (dkjson.encode (. self :self) state)) :__index #(. $1 :self $2)}) +(fn diagnostic [self quickfix] + (setmetatable {: self : quickfix} diagnostic-mt)) (local ops {"+" 1 "-" 1 "*" 1 "/" 1 "//" 1 "%" 1 "^" 1 ">" 1 "<" 1 ">=" 1 "<=" 1 "=" 1 "not=" 1 ".." 1 "." 1 "and" 1 "or" 1 "band" 1 "bor" 1 "bxor" 1 "bnot" 1 "lshift" 1 "rshift" 1}) (fn special? [item] @@ -37,9 +38,9 @@ the `file.diagnostics` field, filling it with diagnostics." :message (.. "unused definition: " (tostring symbol)) :severity message.severity.WARN :code 301 - :codeDescription "unused-definition" - :quickfix #[{:range (message.ast->range symbol) - :newText (.. "_" (tostring symbol))}]}))) + :codeDescription "unused-definition"} + #[{:range (message.ast->range server file symbol) + :newText (.. "_" (tostring symbol))}]))) (λ unknown-module-field [server file] "any multisym whose definition can't be found through a (require) call" @@ -89,12 +90,12 @@ the `file.diagnostics` field, filling it with diagnostics." (.. " Use a loop when you have a dynamic number of arguments to (" (tostring op) ")"))) :severity message.severity.WARN :code 304 - :codeDescription "bad-unpack" - :quickfix (if (and (= (length call) 2) - (= (length (. call 2)) 2) - (sym? op "..")) - #[{:range (message.ast->range server file call) - :newText (.. "(table.concat " (view (. call 2 2)) ")")}])})))) + :codeDescription "bad-unpack"} + (if (and (= (length call) 2) + (= (length (. call 2)) 2) + (sym? op "..")) + #[{:range (message.ast->range server file call) + :newText (.. "(table.concat " (view (. call 2 2)) ")")}]))))) (λ var-never-set [server file symbol definition] (if (and definition.var? (not definition.var-set) (. file.lexical symbol)) @@ -117,9 +118,9 @@ the `file.diagnostics` field, filling it with diagnostics." :message (.. "write " (view identity) " instead of (" (tostring op) ")") :severity message.severity.WARN :code 306 - :codeDescription "op-with-no-arguments" - :quickfix #[{:range (message.ast->range server file call) - :newText (view identity)}]})))) + :codeDescription "op-with-no-arguments"} + #[{:range (message.ast->range server file call) + :newText (view identity)}])))) (λ multival-in-middle-of-call [server file fun call arg index] "generally, values and unpack are signs that the user is trying to do diff --git a/src/fennel-ls/message.fnl b/src/fennel-ls/message.fnl index 4989411..3fda276 100644 --- a/src/fennel-ls/message.fnl +++ b/src/fennel-ls/message.fnl @@ -7,7 +7,7 @@ LSP json objects." (local fennel (require :fennel)) (local utils (require :fennel-ls.utils)) -(local json (require :fennel-ls.json.json)) +(local json (require :dkjson)) (λ nullify [?value] (case ?value diff --git a/test/goto-definition.fnl b/test/goto-definition.fnl index bd53e93..87ca290 100644 --- a/test/goto-definition.fnl +++ b/test/goto-definition.fnl @@ -1,6 +1,6 @@ (local faith (require :faith)) (local {: create-client-with-files} (require :test.utils)) -(local {: null} (require :fennel-ls.json.json)) +(local {: null} (require :dkjson)) (local {: view} (require :fennel)) (fn check [file-contents] diff --git a/test/hover.fnl b/test/hover.fnl index d9e628c..f98661c 100644 --- a/test/hover.fnl +++ b/test/hover.fnl @@ -1,7 +1,7 @@ (local faith (require :faith)) (local {: view} (require :fennel)) (local {: create-client-with-files} (require :test.utils)) -(local {: null} (require :fennel-ls.json.json)) +(local {: null} (require :dkjson)) (fn check [file-contents ?response-string] (let [{: client : uri : cursor} (create-client-with-files file-contents) diff --git a/test/json-rpc.fnl b/test/json-rpc.fnl index 9205f2d..a9fa596 100644 --- a/test/json-rpc.fnl +++ b/test/json-rpc.fnl @@ -1,5 +1,5 @@ (local faith (require :faith)) -(local stringio (require :test.pl.stringio)) +(local stringio (require :pl.stringio)) (local json-rpc (require :fennel-ls.json-rpc)) (fn test-read [] diff --git a/test/references.fnl b/test/references.fnl index 4a5ad25..2a2b16f 100644 --- a/test/references.fnl +++ b/test/references.fnl @@ -1,6 +1,6 @@ (local faith (require :faith)) (local {: create-client-with-files} (require :test.utils)) -(local {: null} (require :fennel-ls.json.json)) +(local {: null} (require :dkjson)) (local {: view} (require :fennel)) (fn location-comparator [a b] diff --git a/test/rename.fnl b/test/rename.fnl index 62870ab..0190b81 100644 --- a/test/rename.fnl +++ b/test/rename.fnl @@ -1,6 +1,6 @@ (local faith (require :faith)) (local {: create-client-with-files} (require :test.utils)) -(local {: null} (require :fennel-ls.json.json)) +(local {: null} (require :dkjson)) (local {: apply-edits} (require :fennel-ls.utils)) (fn check [file-content new-name expected-file-content] diff --git a/tools/unvendor.fnl b/tools/unvendor.fnl index a24cfba..ccf14cb 100644 --- a/tools/unvendor.fnl +++ b/tools/unvendor.fnl @@ -1,19 +1,7 @@ (local {: sh} (require :tools.util.sh)) -(sh :rm :-f - ;; delete vendored "fennel" - "src/fennel.lua" +(sh :rm :-rf ;; delete vendored "fennel" (build dependency) "fennel" - ;; delete vendored "faith" (test dependency) - "test/faith/faith.fnl" - ;; delete vendored "penlight" (test dependency) - "test/pl/stringio.lua") - - ;; I can't delete rxi/json because fennel-ls has a forked version with custom patches. - ;; I'm working to address this. fennel-ls' forked version will not interfere with the normal version because its statically linked. - -;; write a dummy file so that the tests search for penlight on LUA_PATH -(doto (io.open "test/pl/stringio.lua" :w) - (: :write "(require :pl.stringio)") - (: :close)) + ;; delete deps folder + "deps/") diff --git a/tools/vendor.fnl b/tools/vendor.fnl index 147de65..900ee23 100644 --- a/tools/vendor.fnl +++ b/tools/vendor.fnl @@ -8,23 +8,39 @@ (local fennel-version "1.4.2") (local faith-version "0.1.2") (local penlight-version "1.14.0") +(local dkjson-version "2.7") +(local dkjson-md5sum "94320e64e95f9bb5b06d9955e5391a78 build/dkjson.lua") +(local dkjson-sha1sum "6926b65aa74ae8278b6c5923c0c5568af4f1fef1 build/dkjson.lua") -;; get && build fennel -(sh :mkdir :-p "build") +(sh :mkdir :-p "deps/") + +;; get fennel +(sh :mkdir :-p "build/") (when (not (io.open "build/fennel/fennel")) (git-clone "build/fennel" "https://git.sr.ht/~technomancy/fennel" fennel-version) (sh :make :-C "build/fennel")) -(sh :cp "build/fennel/fennel" ".") -(sh :cp "build/fennel/fennel.lua" "src") ;; get faith (when (not (io.open "build/faith/faith.fnl")) (git-clone "build/faith" "https://git.sr.ht/~technomancy/faith" faith-version)) -(sh :cp "build/faith/faith.fnl" "test/faith/faith.fnl") ;; get penlight.stringio (when (not (io.open "build/penlight/lua/pl/stringio.lua")) (git-clone "build/penlight" "https://github.com/lunarmodules/Penlight" penlight-version)) -(sh :cp "build/penlight/lua/pl/stringio.lua" "test/pl/stringio.lua") + + +(when (not (io.open "build/dkjson.lua")) + (sh :curl (.. "http://dkolf.de/dkjson-lua/dkjson-" dkjson-version ".lua") [:>] "build/dkjson.lua") + (assert (= 0 (sh :echo dkjson-md5sum [:|] :md5sum "--check --status"))) + (assert (= 0 (sh :echo dkjson-sha1sum [:|] :sha1sum "--check --status")))) + + +(sh :cp "build/fennel/fennel" ".") +(sh :cp "build/fennel/fennel.lua" "deps/") +(sh :cp "build/faith/faith.fnl" "deps/") +(sh :mkdir :-p "deps/pl") +(sh :cp "build/penlight/lua/pl/stringio.lua" "deps/pl/") +(sh :cp "build/penlight/LICENSE.md" "deps/pl/") +(sh :cp "build/dkjson.lua" "deps/")