From 72b4691afb7de2b6a6301cefa355e10e6fb3a632 Mon Sep 17 00:00:00 2001 From: SquidDev Date: Fri, 14 Apr 2017 21:30:50 +0000 Subject: [PATCH] Rebuild compiler --- tacky/cli.lua | 5245 +++++++++++++++++++++-------------------- tacky/logger/init.lua | 49 +- tacky/range.lua | 54 +- tacky/traceback.lua | 76 +- 4 files changed, 2698 insertions(+), 2726 deletions(-) diff --git a/tacky/cli.lua b/tacky/cli.lua index 9dad516..32d311d 100755 --- a/tacky/cli.lua +++ b/tacky/cli.lua @@ -16,7 +16,7 @@ end)() for k, v in pairs(_temp) do _libs["lua/basic-0/".. k] = v end local _temp = (function() -- A horrible hacky script to ensure that package.path is correct - local directory = arg[0]:gsub("urn/cli%.lisp", ""):gsub("urn/cli$", ""):gsub("tacky/cli%.lua$", "") + local directory = arg[0]:gsub("\\", "/"):gsub("urn/cli%.lisp", ""):gsub("urn/cli$", ""):gsub("tacky/cli%.lua$", "") if directory ~= "" and directory:sub(-1, -1) ~= "/" then directory = directory .. "/" end @@ -88,9 +88,6 @@ end) _2d_or1 = (function(a1, b1) return (a1 or b1) end) -_2d_and1 = (function(a2, b2) - return (a2 and b2) -end) pretty1 = (function(value1) local ty1 = type_23_1(value1) if (ty1 == "table") then @@ -158,8 +155,15 @@ constVal1 = (function(val1) return val1 end end) -nil_3f_1 = (function(x2) - return (x2 and (((type1(x2) == "list") and (x2["n"] == 0)) or (string_3f_1(x2) and (#(x2) == 0)))) +empty_3f_1 = (function(x2) + local xt1 = type1(x2) + if (xt1 == "list") then + return (x2["n"] == 0) + elseif (xt1 == "string") then + return (#(x2) == 0) + else + return false + end end) string_3f_1 = (function(x3) return ((type_23_1(x3) == "string") or ((type_23_1(x3) == "table") and (x3["tag"] == "string"))) @@ -189,18 +193,18 @@ eq_3f_1 = (function(x6, y1) local typeY1 = type1(y1) if ((typeX1 == "list") and ((typeY1 == "list") and (x6["n"] == y1["n"]))) then local equal1 = true - local r_321 = x6["n"] - local r_301 = nil - r_301 = (function(r_311) - if (r_311 <= r_321) then - if not eq_3f_1(x6[r_311], (y1[r_311])) then + local r_291 = x6["n"] + local r_271 = nil + r_271 = (function(r_281) + if (r_281 <= r_291) then + if not eq_3f_1(x6[r_281], (y1[r_281])) then equal1 = false end - return r_301((r_311 + 1)) + return r_271((r_281 + 1)) else end end) - r_301(1) + r_271(1) return equal1 elseif (("symbol" == typeX1) and ("symbol" == typeY1)) then return (x6["contents"] == y1["contents"]) @@ -222,139 +226,151 @@ end) abs1 = math.abs huge1 = math.huge max2 = math.max +min2 = math.min modf1 = math.modf car1 = (function(x7) - local r_571 = type1(x7) - if (r_571 ~= "list") then - error1(format1("bad argument %s (expected %s, got %s)", "x", "list", r_571), 2) + local r_531 = type1(x7) + if (r_531 ~= "list") then + error1(format1("bad argument %s (expected %s, got %s)", "x", "list", r_531), 2) end return x7[1] end) cdr1 = (function(x8) - local r_581 = type1(x8) - if (r_581 ~= "list") then - error1(format1("bad argument %s (expected %s, got %s)", "x", "list", r_581), 2) + local r_541 = type1(x8) + if (r_541 ~= "list") then + error1(format1("bad argument %s (expected %s, got %s)", "x", "list", r_541), 2) end - if nil_3f_1(x8) then + if empty_3f_1(x8) then return ({tag = "list", n = 0}) else return slice1(x8, 2) end end) foldr1 = (function(f1, z1, xs3) - local r_591 = type1(f1) - if (r_591 ~= "function") then - error1(format1("bad argument %s (expected %s, got %s)", "f", "function", r_591), 2) + local r_551 = type1(f1) + if (r_551 ~= "function") then + error1(format1("bad argument %s (expected %s, got %s)", "f", "function", r_551), 2) end - local r_601 = type1(xs3) - if (r_601 ~= "list") then - error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_601), 2) + local r_561 = type1(xs3) + if (r_561 ~= "list") then + error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_561), 2) end local accum1 = z1 - local r_631 = xs3["n"] + local r_591 = xs3["n"] + local r_571 = nil + r_571 = (function(r_581) + if (r_581 <= r_591) then + accum1 = f1(accum1, xs3[r_581]) + return r_571((r_581 + 1)) + else + end + end) + r_571(1) + return accum1 +end) +map1 = (function(fn1, ...) + local xss1 = _pack(...) xss1.tag = "list" + local lenghts1 + local out3 = ({tag = "list", n = 0}) + local r_631 = xss1["n"] local r_611 = nil r_611 = (function(r_621) if (r_621 <= r_631) then - accum1 = f1(accum1, xs3[r_621]) + pushCdr_21_1(out3, xss1[r_621]["n"]) return r_611((r_621 + 1)) else end end) r_611(1) - return accum1 -end) -map1 = (function(f2, xs4) - local r_651 = type1(f2) - if (r_651 ~= "function") then - error1(format1("bad argument %s (expected %s, got %s)", "f", "function", r_651), 2) - end - local r_661 = type1(xs4) - if (r_661 ~= "list") then - error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_661), 2) - end - local out3 = ({tag = "list", n = 0}) - local r_691 = xs4["n"] - local r_671 = nil - r_671 = (function(r_681) - if (r_681 <= r_691) then - pushCdr_21_1(out3, f2(xs4[r_681])) - return r_671((r_681 + 1)) + lenghts1 = out3 + local out4 = ({tag = "list", n = 0}) + local r_391 = min2(unpack1(lenghts1, 1, lenghts1["n"])) + local r_371 = nil + r_371 = (function(r_381) + if (r_381 <= r_391) then + pushCdr_21_1(out4, (function(xs4) + return fn1(unpack1(xs4, 1, xs4["n"])) + end)(nths1(xss1, r_381))) + return r_371((r_381 + 1)) else end end) - r_671(1) - return out3 + r_371(1) + return out4 end) any1 = (function(p1, xs5) - local r_771 = type1(p1) - if (r_771 ~= "function") then - error1(format1("bad argument %s (expected %s, got %s)", "p", "function", r_771), 2) + local r_711 = type1(p1) + if (r_711 ~= "function") then + error1(format1("bad argument %s (expected %s, got %s)", "p", "function", r_711), 2) end - local r_781 = type1(xs5) - if (r_781 ~= "list") then - error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_781), 2) + local r_721 = type1(xs5) + if (r_721 ~= "list") then + error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_721), 2) end return accumulateWith1(p1, _2d_or1, false, xs5) end) -all1 = (function(p2, xs6) - local r_791 = type1(p2) - if (r_791 ~= "function") then - error1(format1("bad argument %s (expected %s, got %s)", "p", "function", r_791), 2) - end - local r_801 = type1(xs6) - if (r_801 ~= "list") then - error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_801), 2) - end - return accumulateWith1(p2, _2d_and1, true, xs6) -end) -elem_3f_1 = (function(x9, xs7) - local r_811 = type1(xs7) - if (r_811 ~= "list") then - error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_811), 2) +elem_3f_1 = (function(x9, xs6) + local r_751 = type1(xs6) + if (r_751 ~= "list") then + error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_751), 2) end return any1((function(y2) return eq_3f_1(x9, y2) - end), xs7) + end), xs6) end) -last1 = (function(xs8) - local r_831 = type1(xs8) - if (r_831 ~= "list") then - error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_831), 2) +last1 = (function(xs7) + local r_781 = type1(xs7) + if (r_781 ~= "list") then + error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_781), 2) end - return xs8[xs8["n"]] + return xs7[xs7["n"]] end) -pushCdr_21_1 = (function(xs9, val4) - local r_841 = type1(xs9) - if (r_841 ~= "list") then - error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_841), 2) +nths1 = (function(xss2, idx1) + local out5 = ({tag = "list", n = 0}) + local r_431 = xss2["n"] + local r_411 = nil + r_411 = (function(r_421) + if (r_421 <= r_431) then + pushCdr_21_1(out5, xss2[r_421][idx1]) + return r_411((r_421 + 1)) + else + end + end) + r_411(1) + return out5 +end) +pushCdr_21_1 = (function(xs8, val4) + local r_791 = type1(xs8) + if (r_791 ~= "list") then + error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_791), 2) end - local len2 = (xs9["n"] + 1) - xs9["n"] = len2 - xs9[len2] = val4 - return xs9 + local len2 = (xs8["n"] + 1) + xs8["n"] = len2 + xs8[len2] = val4 + return xs8 end) -popLast_21_1 = (function(xs10) - local r_851 = type1(xs10) - if (r_851 ~= "list") then - error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_851), 2) +popLast_21_1 = (function(xs9) + local r_801 = type1(xs9) + if (r_801 ~= "list") then + error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_801), 2) end - local x10 = xs10[xs10["n"]] - xs10[xs10["n"]] = nil - xs10["n"] = (xs10["n"] - 1) + local x10 = xs9[xs9["n"]] + xs9[xs9["n"]] = nil + xs9["n"] = (xs9["n"] - 1) return x10 end) -removeNth_21_1 = (function(li1, idx1) - local r_861 = type1(li1) - if (r_861 ~= "list") then - error1(format1("bad argument %s (expected %s, got %s)", "li", "list", r_861), 2) +removeNth_21_1 = (function(li1, idx2) + local r_811 = type1(li1) + if (r_811 ~= "list") then + error1(format1("bad argument %s (expected %s, got %s)", "li", "list", r_811), 2) end li1["n"] = (li1["n"] - 1) - return remove1(li1, idx1) + return remove1(li1, idx2) end) -append1 = (function(xs11, ys1) +append1 = (function(xs10, ys1) return (function() local _offset, _result, _temp = 0, {tag="list",n=0} - _temp = xs11 + _temp = xs10 for _c = 1, _temp.n do _result[0 + _c + _offset] = _temp[_c] end _offset = _offset + _temp.n _temp = ys1 @@ -364,74 +380,77 @@ append1 = (function(xs11, ys1) return _result end)() end) -accumulateWith1 = (function(f3, ac1, z2, xs12) - local r_881 = type1(f3) - if (r_881 ~= "function") then - error1(format1("bad argument %s (expected %s, got %s)", "f", "function", r_881), 2) +accumulateWith1 = (function(f2, ac1, z2, xs11) + local r_831 = type1(f2) + if (r_831 ~= "function") then + error1(format1("bad argument %s (expected %s, got %s)", "f", "function", r_831), 2) end - local r_891 = type1(ac1) - if (r_891 ~= "function") then - error1(format1("bad argument %s (expected %s, got %s)", "ac", "function", r_891), 2) + local r_841 = type1(ac1) + if (r_841 ~= "function") then + error1(format1("bad argument %s (expected %s, got %s)", "ac", "function", r_841), 2) end - return foldr1(ac1, z2, map1(f3, xs12)) + return foldr1(ac1, z2, map1(f2, xs11)) end) _2e2e_2 = (function(...) local args1 = _pack(...) args1.tag = "list" return concat1(args1) end) split1 = (function(text1, pattern1, limit1) - local out4 = ({tag = "list", n = 0}) + local out6 = ({tag = "list", n = 0}) local loop1 = true local start1 = 1 - local r_961 = nil - r_961 = (function() + local r_891 = nil + r_891 = (function() if loop1 then local pos1 = list1(find1(text1, pattern1, start1)) local nstart1 = car1(pos1) local nend1 = car1(cdr1(pos1)) - if ((nstart1 == nil) or (limit1 and (out4["n"] >= limit1))) then + if ((nstart1 == nil) or (limit1 and (out6["n"] >= limit1))) then loop1 = false - pushCdr_21_1(out4, sub1(text1, start1, len1(text1))) + pushCdr_21_1(out6, sub1(text1, start1, len1(text1))) start1 = (len1(text1) + 1) elseif (nstart1 > len1(text1)) then if (start1 <= len1(text1)) then - pushCdr_21_1(out4, sub1(text1, start1, len1(text1))) + pushCdr_21_1(out6, sub1(text1, start1, len1(text1))) end loop1 = false elseif (nend1 < nstart1) then - pushCdr_21_1(out4, sub1(text1, start1, nstart1)) + pushCdr_21_1(out6, sub1(text1, start1, nstart1)) start1 = (nstart1 + 1) else - pushCdr_21_1(out4, sub1(text1, start1, (nstart1 - 1))) + pushCdr_21_1(out6, sub1(text1, start1, (nstart1 - 1))) start1 = (nend1 + 1) end - return r_961() + return r_891() else end end) - r_961() - return out4 + r_891() + return out6 +end) +trim1 = (function(str1) + return (gsub1(gsub1(str1, "^%s+", ""), "%s+$", "")) end) -local escapes1 = {} -local r_921 = nil -r_921 = (function(r_931) - if (r_931 <= 31) then - escapes1[char1(r_931)] = _2e2e_2("\\", tostring1(r_931)) - return r_921((r_931 + 1)) +local escapes1 = ({}) +local r_851 = nil +r_851 = (function(r_861) + if (r_861 <= 31) then + escapes1[char1(r_861)] = _2e2e_2("\\", tostring1(r_861)) + return r_851((r_861 + 1)) else end end) -r_921(0) +r_851(0) escapes1["\n"] = "n" -quoted1 = (function(str1) - return (gsub1(format1("%q", str1), ".", escapes1)) +quoted1 = (function(str2) + return (gsub1(format1("%q", str2), ".", escapes1)) end) clock1 = os.clock execute1 = os.execute exit1 = os.exit getenv1 = os.getenv assoc1 = (function(list2, key1, orVal1) - if (not (type1(list2) == "list") or nil_3f_1(list2)) then + if (not (type1(list2) == "list") or empty_3f_1(list2)) then return orVal1 elseif eq_3f_1(car1(car1(list2)), key1) then return car1(cdr1(car1(list2))) @@ -440,7 +459,7 @@ assoc1 = (function(list2, key1, orVal1) end end) assoc_3f_1 = (function(list3, key2) - if (not (type1(list3) == "list") or nil_3f_1(list3)) then + if (not (type1(list3) == "list") or empty_3f_1(list3)) then return false elseif eq_3f_1(car1(car1(list3)), key2) then return true @@ -453,14 +472,14 @@ struct1 = (function(...) if ((entries1["n"] % 2) == 1) then error1("Expected an even number of arguments to struct", 2) end - local out5 = {} - local r_1071 = entries1["n"] - local r_1051 = nil - r_1051 = (function(r_1061) - if (r_1061 <= r_1071) then - local key3 = entries1[r_1061] - local val5 = entries1[(1 + r_1061)] - out5[(function() + local out7 = ({}) + local r_1001 = entries1["n"] + local r_981 = nil + r_981 = (function(r_991) + if (r_991 <= r_1001) then + local key3 = entries1[r_991] + local val5 = entries1[(1 + r_991)] + out7[(function() if (type1(key3) == "key") then return key3["contents"] else @@ -468,32 +487,32 @@ struct1 = (function(...) end end)() ] = val5 - return r_1051((r_1061 + 2)) + return r_981((r_991 + 2)) else end end) - r_1051(1) - return out5 + r_981(1) + return out7 end) values1 = (function(st1) - local out6 = ({tag = "list", n = 0}) + local out8 = ({tag = "list", n = 0}) iterPairs1(st1, (function(_5f_1, v2) - return pushCdr_21_1(out6, v2) + return pushCdr_21_1(out8, v2) end)) - return out6 + return out8 end) createLookup1 = (function(values2) - local res1 = {} - local r_1191 = values2["n"] - local r_1171 = nil - r_1171 = (function(r_1181) - if (r_1181 <= r_1191) then - res1[values2[r_1181]] = r_1181 - return r_1171((r_1181 + 1)) + local res1 = ({}) + local r_1081 = values2["n"] + local r_1061 = nil + r_1061 = (function(r_1071) + if (r_1071 <= r_1081) then + res1[values2[r_1071]] = r_1071 + return r_1061((r_1071 + 1)) else end end) - r_1171(1) + r_1061(1) return res1 end) invokable_3f_1 = (function(x11) @@ -533,7 +552,7 @@ self1 = (function(x15, key4, ...) return x15[key4](x15, unpack1(args2, 1, args2["n"])) end) create1 = (function(description1) - return struct1("desc", description1, "flag-map", {}, "opt-map", {}, "opt", ({tag = "list", n = 0}), "pos", ({tag = "list", n = 0})) + return ({["desc"]=description1,["flag-map"]=({}),["opt-map"]=({}),["opt"]=({tag = "list", n = 0}),["pos"]=({tag = "list", n = 0})}) end) setAction1 = (function(arg2, data1, value2) data1[arg2["name"]] = value2 @@ -559,18 +578,18 @@ setNumAction1 = (function(aspec1, data3, value4, usage_21_1) end) addArgument_21_1 = (function(spec1, names1, ...) local options1 = _pack(...) options1.tag = "list" - local r_2121 = type1(names1) - if (r_2121 ~= "list") then - error1(format1("bad argument %s (expected %s, got %s)", "names", "list", r_2121), 2) + local r_2161 = type1(names1) + if (r_2161 ~= "list") then + error1(format1("bad argument %s (expected %s, got %s)", "names", "list", r_2161), 2) end - if nil_3f_1(names1) then + if empty_3f_1(names1) then error1("Names list is empty") end if ((options1["n"] % 2) == 0) then else error1("Options list should be a multiple of two") end - local result1 = struct1("names", names1, "action", nil, "narg", 0, "default", false, "help", "", "value", true) + local result1 = ({["names"]=names1,["action"]=nil,["narg"]=0,["default"]=false,["help"]="",["value"]=true}) local first1 = car1(names1) if (sub1(first1, 1, 2) == "--") then pushCdr_21_1(spec1["opt"], result1) @@ -584,32 +603,32 @@ addArgument_21_1 = (function(spec1, names1, ...) result1["default"] = ({tag = "list", n = 0}) pushCdr_21_1(spec1["pos"], result1) end - local r_2171 = names1["n"] - local r_2151 = nil - r_2151 = (function(r_2161) - if (r_2161 <= r_2171) then - local name1 = names1[r_2161] + local r_2211 = names1["n"] + local r_2191 = nil + r_2191 = (function(r_2201) + if (r_2201 <= r_2211) then + local name1 = names1[r_2201] if (sub1(name1, 1, 2) == "--") then spec1["opt-map"][sub1(name1, 3)] = result1 elseif (sub1(name1, 1, 1) == "-") then spec1["flag-map"][sub1(name1, 2)] = result1 end - return r_2151((r_2161 + 1)) + return r_2191((r_2201 + 1)) else end end) - r_2151(1) - local r_2211 = options1["n"] - local r_2191 = nil - r_2191 = (function(r_2201) - if (r_2201 <= r_2211) then - local key5 = options1[r_2201] - result1[key5] = (options1[((r_2201 + 1))]) - return r_2191((r_2201 + 2)) + r_2191(1) + local r_2251 = options1["n"] + local r_2231 = nil + r_2231 = (function(r_2241) + if (r_2241 <= r_2251) then + local key5 = options1[r_2241] + result1[key5] = (options1[((r_2241 + 1))]) + return r_2231((r_2241 + 2)) else end end) - r_2191(1) + r_2231(1) if result1["var"] then else result1["var"] = upper1(result1["name"]) @@ -639,23 +658,23 @@ addHelp_21_1 = (function(spec2) end)) end) helpNarg_21_1 = (function(buffer1, arg5) - local r_2641 = arg5["narg"] - if (r_2641 == "?") then + local r_2681 = arg5["narg"] + if (r_2681 == "?") then return pushCdr_21_1(buffer1, _2e2e_2(" [", arg5["var"], "]")) - elseif (r_2641 == "*") then + elseif (r_2681 == "*") then return pushCdr_21_1(buffer1, _2e2e_2(" [", arg5["var"], "...]")) - elseif (r_2641 == "+") then + elseif (r_2681 == "+") then return pushCdr_21_1(buffer1, _2e2e_2(" ", arg5["var"], " [", arg5["var"], "...]")) else - local r_2651 = nil - r_2651 = (function(r_2661) - if (r_2661 <= r_2641) then + local r_2691 = nil + r_2691 = (function(r_2701) + if (r_2701 <= r_2681) then pushCdr_21_1(buffer1, _2e2e_2(" ", arg5["var"])) - return r_2651((r_2661 + 1)) + return r_2691((r_2701 + 1)) else end end) - return r_2651(1) + return r_2691(1) end end) usage_21_2 = (function(spec3, name2) @@ -664,31 +683,31 @@ usage_21_2 = (function(spec3, name2) name2 = (arg1[0] or (arg1[-1] or "?")) end local usage1 = list1("usage: ", name2) - local r_2261 = spec3["opt"] - local r_2291 = r_2261["n"] - local r_2271 = nil - r_2271 = (function(r_2281) - if (r_2281 <= r_2291) then - local arg6 = r_2261[r_2281] + local r_2301 = spec3["opt"] + local r_2331 = r_2301["n"] + local r_2311 = nil + r_2311 = (function(r_2321) + if (r_2321 <= r_2331) then + local arg6 = r_2301[r_2321] pushCdr_21_1(usage1, _2e2e_2(" [", car1(arg6["names"]))) helpNarg_21_1(usage1, arg6) pushCdr_21_1(usage1, "]") - return r_2271((r_2281 + 1)) + return r_2311((r_2321 + 1)) else end end) - r_2271(1) - local r_2321 = spec3["pos"] - local r_2351 = r_2321["n"] - local r_2331 = nil - r_2331 = (function(r_2341) - if (r_2341 <= r_2351) then - helpNarg_21_1(usage1, (r_2321[r_2341])) - return r_2331((r_2341 + 1)) + r_2311(1) + local r_2361 = spec3["pos"] + local r_2391 = r_2361["n"] + local r_2371 = nil + r_2371 = (function(r_2381) + if (r_2381 <= r_2391) then + helpNarg_21_1(usage1, (r_2361[r_2381])) + return r_2371((r_2381 + 1)) else end end) - r_2331(1) + r_2371(1) return print1(concat1(usage1)) end) help_21_1 = (function(spec4, name3) @@ -702,70 +721,70 @@ help_21_1 = (function(spec4, name3) print1(spec4["desc"]) end local max3 = 0 - local r_2401 = spec4["pos"] - local r_2431 = r_2401["n"] - local r_2411 = nil - r_2411 = (function(r_2421) - if (r_2421 <= r_2431) then - local arg7 = r_2401[r_2421] + local r_2441 = spec4["pos"] + local r_2471 = r_2441["n"] + local r_2451 = nil + r_2451 = (function(r_2461) + if (r_2461 <= r_2471) then + local arg7 = r_2441[r_2461] local len3 = len1(arg7["var"]) if (len3 > max3) then max3 = len3 end - return r_2411((r_2421 + 1)) + return r_2451((r_2461 + 1)) else end end) - r_2411(1) - local r_2461 = spec4["opt"] - local r_2491 = r_2461["n"] - local r_2471 = nil - r_2471 = (function(r_2481) - if (r_2481 <= r_2491) then - local arg8 = r_2461[r_2481] + r_2451(1) + local r_2501 = spec4["opt"] + local r_2531 = r_2501["n"] + local r_2511 = nil + r_2511 = (function(r_2521) + if (r_2521 <= r_2531) then + local arg8 = r_2501[r_2521] local len4 = len1(concat1(arg8["names"], ", ")) if (len4 > max3) then max3 = len4 end - return r_2471((r_2481 + 1)) + return r_2511((r_2521 + 1)) else end end) - r_2471(1) + r_2511(1) local fmt1 = _2e2e_2(" %-", tostring1((max3 + 1)), "s %s") - if nil_3f_1(spec4["pos"]) then + if empty_3f_1(spec4["pos"]) then else print1() print1("Positional arguments") - local r_2521 = spec4["pos"] - local r_2551 = r_2521["n"] - local r_2531 = nil - r_2531 = (function(r_2541) - if (r_2541 <= r_2551) then - local arg9 = r_2521[r_2541] + local r_2561 = spec4["pos"] + local r_2591 = r_2561["n"] + local r_2571 = nil + r_2571 = (function(r_2581) + if (r_2581 <= r_2591) then + local arg9 = r_2561[r_2581] print1(format1(fmt1, arg9["var"], arg9["help"])) - return r_2531((r_2541 + 1)) + return r_2571((r_2581 + 1)) else end end) - r_2531(1) + r_2571(1) end - if nil_3f_1(spec4["opt"]) then + if empty_3f_1(spec4["opt"]) then else print1() print1("Optional arguments") - local r_2581 = spec4["opt"] - local r_2611 = r_2581["n"] - local r_2591 = nil - r_2591 = (function(r_2601) - if (r_2601 <= r_2611) then - local arg10 = r_2581[r_2601] + local r_2621 = spec4["opt"] + local r_2651 = r_2621["n"] + local r_2631 = nil + r_2631 = (function(r_2641) + if (r_2641 <= r_2651) then + local arg10 = r_2621[r_2641] print1(format1(fmt1, concat1(arg10["names"], ", "), arg10["help"])) - return r_2591((r_2601 + 1)) + return r_2631((r_2641 + 1)) else end end) - return r_2591(1) + return r_2631(1) end end) matcher1 = (function(pattern2) @@ -783,9 +802,9 @@ parse_21_1 = (function(spec5, args3) else args3 = arg1 end - local result3 = {} + local result3 = ({}) local pos2 = spec5["pos"] - local idx2 = 1 + local idx3 = 1 local len5 = args3["n"] local usage_21_3 = (function(msg1) usage_21_2(spec5, (args3[0])) @@ -793,17 +812,17 @@ parse_21_1 = (function(spec5, args3) return exit_21_1(1) end) local readArgs1 = (function(key6, arg11) - local r_3001 = arg11["narg"] - if (r_3001 == "+") then - idx2 = (idx2 + 1) - local elem1 = args3[idx2] + local r_3041 = arg11["narg"] + if (r_3041 == "+") then + idx3 = (idx3 + 1) + local elem1 = args3[idx3] if (elem1 == nil) then local msg2 = _2e2e_2("Expected ", arg11["var"], " after --", key6, ", got nothing") usage_21_2(spec5, (args3[0])) print1(msg2) exit_21_1(1) elseif (not arg11["all"] and find1(elem1, "^%-")) then - local msg3 = _2e2e_2("Expected ", arg11["var"], " after --", key6, ", got ", args3[idx2]) + local msg3 = _2e2e_2("Expected ", arg11["var"], " after --", key6, ", got ", args3[idx3]) usage_21_2(spec5, (args3[0])) print1(msg3) exit_21_1(1) @@ -811,11 +830,11 @@ parse_21_1 = (function(spec5, args3) arg11["action"](arg11, result3, elem1, usage_21_3) end local running1 = true - local r_3021 = nil - r_3021 = (function() + local r_3061 = nil + r_3061 = (function() if running1 then - idx2 = (idx2 + 1) - local elem2 = args3[idx2] + idx3 = (idx3 + 1) + local elem2 = args3[idx3] if (elem2 == nil) then running1 = false elseif (not arg11["all"] and find1(elem2, "^%-")) then @@ -823,18 +842,18 @@ parse_21_1 = (function(spec5, args3) else arg11["action"](arg11, result3, elem2, usage_21_3) end - return r_3021() + return r_3061() else end end) - return r_3021() - elseif (r_3001 == "*") then + return r_3061() + elseif (r_3041 == "*") then local running2 = true - local r_3041 = nil - r_3041 = (function() + local r_3081 = nil + r_3081 = (function() if running2 then - idx2 = (idx2 + 1) - local elem3 = args3[idx2] + idx3 = (idx3 + 1) + local elem3 = args3[idx3] if (elem3 == nil) then running2 = false elseif (not arg11["all"] and find1(elem3, "^%-")) then @@ -842,98 +861,98 @@ parse_21_1 = (function(spec5, args3) else arg11["action"](arg11, result3, elem3, usage_21_3) end - return r_3041() + return r_3081() else end end) - return r_3041() - elseif (r_3001 == "?") then - idx2 = (idx2 + 1) - local elem4 = args3[idx2] + return r_3081() + elseif (r_3041 == "?") then + idx3 = (idx3 + 1) + local elem4 = args3[idx3] if ((elem4 == nil) or (not arg11["all"] and find1(elem4, "^%-"))) then return arg11["action"](arg11, result3, arg11["value"]) else - idx2 = (idx2 + 1) + idx3 = (idx3 + 1) return arg11["action"](arg11, result3, elem4, usage_21_3) end - elseif (r_3001 == 0) then - idx2 = (idx2 + 1) + elseif (r_3041 == 0) then + idx3 = (idx3 + 1) local value6 = arg11["value"] return arg11["action"](arg11, result3, value6, usage_21_3) else - local r_3081 = nil - r_3081 = (function(r_3091) - if (r_3091 <= r_3001) then - idx2 = (idx2 + 1) - local elem5 = args3[idx2] + local r_3121 = nil + r_3121 = (function(r_3131) + if (r_3131 <= r_3041) then + idx3 = (idx3 + 1) + local elem5 = args3[idx3] if (elem5 == nil) then - local msg4 = _2e2e_2("Expected ", r_3001, " args for ", key6, ", got ", (r_3091 - 1)) + local msg4 = _2e2e_2("Expected ", r_3041, " args for ", key6, ", got ", (r_3131 - 1)) usage_21_2(spec5, (args3[0])) print1(msg4) exit_21_1(1) elseif (not arg11["all"] and find1(elem5, "^%-")) then - local msg5 = _2e2e_2("Expected ", r_3001, " for ", key6, ", got ", (r_3091 - 1)) + local msg5 = _2e2e_2("Expected ", r_3041, " for ", key6, ", got ", (r_3131 - 1)) usage_21_2(spec5, (args3[0])) print1(msg5) exit_21_1(1) else arg11["action"](arg11, result3, elem5, usage_21_3) end - return r_3081((r_3091 + 1)) + return r_3121((r_3131 + 1)) else end end) - r_3081(1) - idx2 = (idx2 + 1) + r_3121(1) + idx3 = (idx3 + 1) return nil end end) - local r_2631 = nil - r_2631 = (function() - if (idx2 <= len5) then - local r_2691 = args3[idx2] + local r_2671 = nil + r_2671 = (function() + if (idx3 <= len5) then + local r_2731 = args3[idx3] local temp2 - local r_2701 = matcher1("^%-%-([^=]+)=(.+)$")(r_2691) - temp2 = ((type1(r_2701) == "list") and ((r_2701["n"] >= 2) and ((r_2701["n"] <= 2) and true))) + local r_2741 = matcher1("^%-%-([^=]+)=(.+)$")(r_2731) + temp2 = ((type1(r_2741) == "list") and ((r_2741["n"] >= 2) and ((r_2741["n"] <= 2) and true))) if temp2 then - local key7 = matcher1("^%-%-([^=]+)=(.+)$")(r_2691)[1] - local val7 = matcher1("^%-%-([^=]+)=(.+)$")(r_2691)[2] + local key7 = matcher1("^%-%-([^=]+)=(.+)$")(r_2731)[1] + local val7 = matcher1("^%-%-([^=]+)=(.+)$")(r_2731)[2] local arg12 = spec5["opt-map"][key7] if (arg12 == nil) then - local msg6 = _2e2e_2("Unknown argument ", key7, " in ", args3[idx2]) + local msg6 = _2e2e_2("Unknown argument ", key7, " in ", args3[idx3]) usage_21_2(spec5, (args3[0])) print1(msg6) exit_21_1(1) elseif (not arg12["many"] and (nil ~= result3[arg12["name"]])) then - local msg7 = _2e2e_2("Too may values for ", key7, " in ", args3[idx2]) + local msg7 = _2e2e_2("Too may values for ", key7, " in ", args3[idx3]) usage_21_2(spec5, (args3[0])) print1(msg7) exit_21_1(1) else local narg1 = arg12["narg"] if (number_3f_1(narg1) and (narg1 ~= 1)) then - local msg8 = _2e2e_2("Expected ", tostring1(narg1), " values, got 1 in ", args3[idx2]) + local msg8 = _2e2e_2("Expected ", tostring1(narg1), " values, got 1 in ", args3[idx3]) usage_21_2(spec5, (args3[0])) print1(msg8) exit_21_1(1) end arg12["action"](arg12, result3, val7, usage_21_3) end - idx2 = (idx2 + 1) + idx3 = (idx3 + 1) else local temp3 - local r_2711 = matcher1("^%-%-(.*)$")(r_2691) - temp3 = ((type1(r_2711) == "list") and ((r_2711["n"] >= 1) and ((r_2711["n"] <= 1) and true))) + local r_2751 = matcher1("^%-%-(.*)$")(r_2731) + temp3 = ((type1(r_2751) == "list") and ((r_2751["n"] >= 1) and ((r_2751["n"] <= 1) and true))) if temp3 then - local key8 = matcher1("^%-%-(.*)$")(r_2691)[1] + local key8 = matcher1("^%-%-(.*)$")(r_2731)[1] local arg13 = spec5["opt-map"][key8] if (arg13 == nil) then - local msg9 = _2e2e_2("Unknown argument ", key8, " in ", args3[idx2]) + local msg9 = _2e2e_2("Unknown argument ", key8, " in ", args3[idx3]) usage_21_2(spec5, (args3[0])) print1(msg9) exit_21_1(1) elseif (not arg13["many"] and (nil ~= result3[arg13["name"]])) then - local msg10 = _2e2e_2("Too may values for ", key8, " in ", args3[idx2]) + local msg10 = _2e2e_2("Too may values for ", key8, " in ", args3[idx3]) usage_21_2(spec5, (args3[0])) print1(msg10) exit_21_1(1) @@ -942,26 +961,26 @@ parse_21_1 = (function(spec5, args3) end else local temp4 - local r_2721 = matcher1("^%-(.+)$")(r_2691) - temp4 = ((type1(r_2721) == "list") and ((r_2721["n"] >= 1) and ((r_2721["n"] <= 1) and true))) + local r_2761 = matcher1("^%-(.+)$")(r_2731) + temp4 = ((type1(r_2761) == "list") and ((r_2761["n"] >= 1) and ((r_2761["n"] <= 1) and true))) if temp4 then - local flags1 = matcher1("^%-(.+)$")(r_2691)[1] + local flags1 = matcher1("^%-(.+)$")(r_2731)[1] local i1 = 1 local s1 = len1(flags1) - local r_2861 = nil - r_2861 = (function() + local r_2901 = nil + r_2901 = (function() if (i1 <= s1) then local key9 local x17 = i1 key9 = sub1(flags1, x17, x17) local arg14 = spec5["flag-map"][key9] if (arg14 == nil) then - local msg11 = _2e2e_2("Unknown flag ", key9, " in ", args3[idx2]) + local msg11 = _2e2e_2("Unknown flag ", key9, " in ", args3[idx3]) usage_21_2(spec5, (args3[0])) print1(msg11) exit_21_1(1) elseif (not arg14["many"] and (nil ~= result3[arg14["name"]])) then - local msg12 = _2e2e_2("Too many occurances of ", key9, " in ", args3[idx2]) + local msg12 = _2e2e_2("Too many occurances of ", key9, " in ", args3[idx3]) usage_21_2(spec5, (args3[0])) print1(msg12) exit_21_1(1) @@ -976,62 +995,62 @@ parse_21_1 = (function(spec5, args3) local value8 = sub1(flags1, (i1 + 1)) arg14["action"](arg14, result3, value8, usage_21_3) i1 = (s1 + 1) - idx2 = (idx2 + 1) + idx3 = (idx3 + 1) end end i1 = (i1 + 1) - return r_2861() + return r_2901() else end end) - r_2861() + r_2901() else local arg15 = car1(spec5["pos"]) if arg15 then - arg15["action"](arg15, result3, r_2691, usage_21_3) + arg15["action"](arg15, result3, r_2731, usage_21_3) else local msg13 = _2e2e_2("Unknown argument ", arg15) usage_21_2(spec5, (args3[0])) print1(msg13) exit_21_1(1) end - idx2 = (idx2 + 1) + idx3 = (idx3 + 1) end end end - return r_2631() + return r_2671() else end end) - r_2631() - local r_2891 = spec5["opt"] - local r_2921 = r_2891["n"] - local r_2901 = nil - r_2901 = (function(r_2911) - if (r_2911 <= r_2921) then - local arg16 = r_2891[r_2911] + r_2671() + local r_2931 = spec5["opt"] + local r_2961 = r_2931["n"] + local r_2941 = nil + r_2941 = (function(r_2951) + if (r_2951 <= r_2961) then + local arg16 = r_2931[r_2951] if (result3[arg16["name"]] == nil) then result3[arg16["name"]] = arg16["default"] end - return r_2901((r_2911 + 1)) + return r_2941((r_2951 + 1)) else end end) - r_2901(1) - local r_2951 = spec5["pos"] - local r_2981 = r_2951["n"] - local r_2961 = nil - r_2961 = (function(r_2971) - if (r_2971 <= r_2981) then - local arg17 = r_2951[r_2971] + r_2941(1) + local r_2991 = spec5["pos"] + local r_3021 = r_2991["n"] + local r_3001 = nil + r_3001 = (function(r_3011) + if (r_3011 <= r_3021) then + local arg17 = r_2991[r_3011] if (result3[arg17["name"]] == nil) then result3[arg17["name"]] = arg17["default"] end - return r_2961((r_2971 + 1)) + return r_3001((r_3011 + 1)) else end end) - r_2961(1) + r_3001(1) return result3 end) builtins1 = require1("tacky.analysis.resolve")["builtins"] @@ -1072,13 +1091,13 @@ end) val_2d3e_urn1 = (function(val8) local ty3 = type_23_1(val8) if (ty3 == "string") then - return {["tag"]="string",["value"]=val8} + return ({["tag"]="string",["value"]=val8}) elseif (ty3 == "number") then - return {["tag"]="number",["value"]=val8} + return ({["tag"]="number",["value"]=val8}) elseif (ty3 == "nil") then - return {["tag"]="symbol",["contents"]="nil",["var"]=builtins1["nil"]} + return ({["tag"]="symbol",["contents"]="nil",["var"]=builtins1["nil"]}) elseif (ty3 == "boolean") then - return {["tag"]="symbol",["contents"]=tostring1(val8),["var"]=builtins1[tostring1(val8)]} + return ({["tag"]="symbol",["contents"]=tostring1(val8),["var"]=builtins1[tostring1(val8)]}) else _error("unmatched item") end @@ -1104,7 +1123,7 @@ makeProgn1 = (function(body1) return ({tag = "list", n = 1, (function() local _offset, _result, _temp = 0, {tag="list",n=0} _result[1 + _offset] = (function(var2) - return {["tag"]="symbol",["contents"]=var2["name"],["var"]=var2} + return ({["tag"]="symbol",["contents"]=var2["name"],["var"]=var2}) end)(builtins1["lambda"]) _result[2 + _offset] = ({tag = "list", n = 0}) _temp = body1 @@ -1116,17 +1135,17 @@ makeProgn1 = (function(body1) }) end) makeSymbol1 = (function(var3) - return {["tag"]="symbol",["contents"]=var3["name"],["var"]=var3} + return ({["tag"]="symbol",["contents"]=var3["name"],["var"]=var3}) end) -local r_3331 = builtins1["nil"] +local r_3371 = builtins1["nil"] makeNil1 = (function() - return {["tag"]="symbol",["contents"]=r_3331["name"],["var"]=r_3331} + return ({["tag"]="symbol",["contents"]=r_3371["name"],["var"]=r_3371}) end) -fastAll1 = (function(fn1, li2, i2) +fastAll1 = (function(fn2, li2, i2) if (i2 > li2["n"]) then return true - elseif fn1(li2[i2]) then - return fastAll1(fn1, li2, (i2 + 1)) + elseif fn2(li2[i2]) then + return fastAll1(fn2, li2, (i2 + 1)) else return false end @@ -1135,7 +1154,7 @@ startTimer_21_1 = (function(timer1, name5, level1) local instance1 = timer1["timers"][name5] if instance1 then else - instance1 = {["name"]=name5,["level"]=(level1 or 1),["running"]=false,["total"]=0} + instance1 = ({["name"]=name5,["level"]=(level1 or 1),["running"]=false,["total"]=0}) timer1["timers"][name5] = instance1 end if instance1["running"] then @@ -1173,8 +1192,8 @@ stopTimer_21_1 = (function(timer3, name7) instance3["total"] = ((clock1() - instance3["start"]) + instance3["total"]) return timer3["callback"](instance3["name"], instance3["total"], instance3["level"]) end) -void1 = {["callback"]=(function() -end),["timers"]={}} +void1 = ({["callback"]=(function() +end),["timers"]=({})}) config1 = package.config coloredAnsi1 = (function(col1, msg14) return _2e2e_2("\27[", col1, "m", msg14, "\27[0m") @@ -1233,28 +1252,29 @@ doNodeError_21_1 = (function(logger7, msg22, node8, explain3, ...) self1(logger7, "put-node-error!", msg22, node8, explain3, lines3) return error1((match1(msg22, "^([^\n]+)\n") or msg22), 0) end) -struct1("startTimer", startTimer_21_1, "pauseTimer", pauseTimer_21_1, "stopTimer", stopTimer_21_1, "putError", putError_21_1, "putWarning", putWarning_21_1, "putVerbose", putVerbose_21_1, "putDebug", putDebug_21_1, "putNodeError", putNodeError_21_1, "putNodeWarning", putNodeWarning_21_1, "doNodeError", doNodeError_21_1, "colored", colored1) +local _ = ({["startTimer"]=startTimer_21_1,["pauseTimer"]=pauseTimer_21_1,["stopTimer"]=stopTimer_21_1,["putError"]=putError_21_1,["putWarning"]=putWarning_21_1,["putVerbose"]=putVerbose_21_1,["putDebug"]=putDebug_21_1,["putNodeError"]=putNodeError_21_1,["putNodeWarning"]=putNodeWarning_21_1,["doNodeError"]=doNodeError_21_1,["colored"]=colored1}) passEnabled_3f_1 = (function(pass1, options2) local override1 = options2["override"] - local r_3361 = (options2["level"] >= (pass1["level"] or 1)) - if r_3361 then - local r_3371 - if (pass1["on"] == false) then - r_3371 = (override1[pass1["name"]] == true) - else - r_3371 = (override1[pass1["name"]] ~= false) - end - return (r_3371 and all1((function(cat1) - return (false ~= override1[cat1]) - end), pass1["cat"])) + if (override1[pass1["name"]] == true) then + return true + elseif (override1[pass1["name"]] == false) then + return false + elseif any1((function(cat1) + return (override1[cat1] == true) + end), pass1["cat"]) then + return true + elseif any1((function(cat2) + return (override1[cat2] == false) + end), pass1["cat"]) then + return false else - return r_3361 + return ((pass1["on"] ~= false) and (options2["level"] >= (pass1["level"] or 1))) end end) runPass1 = (function(pass2, options3, tracker1, ...) local args4 = _pack(...) args4.tag = "list" if passEnabled_3f_1(pass2, options3) then - local ptracker1 = struct1("changed", false) + local ptracker1 = ({["changed"]=false}) local name8 = _2e2e_2("[", concat1(pass2["cat"], " "), "] ", pass2["name"]) startTimer_21_1(options3["timer"], name8, 2) pass2["run"](ptracker1, options3, unpack1(args4, 1, args4["n"])) @@ -1289,29 +1309,29 @@ traverseQuote1 = (function(node9, visitor1, level2) node9[2] = traverseQuote1(node9[2], visitor1, (level2 + 1)) return node9 else - local r_3621 = node9["n"] - local r_3601 = nil - r_3601 = (function(r_3611) - if (r_3611 <= r_3621) then - node9[r_3611] = traverseQuote1(node9[r_3611], visitor1, level2) - return r_3601((r_3611 + 1)) + local r_3651 = node9["n"] + local r_3631 = nil + r_3631 = (function(r_3641) + if (r_3641 <= r_3651) then + node9[r_3641] = traverseQuote1(node9[r_3641], visitor1, level2) + return r_3631((r_3641 + 1)) else end end) - r_3601(1) + r_3631(1) return node9 end else - local r_3661 = node9["n"] - local r_3641 = nil - r_3641 = (function(r_3651) - if (r_3651 <= r_3661) then - node9[r_3651] = traverseQuote1(node9[r_3651], visitor1, level2) - return r_3641((r_3651 + 1)) + local r_3691 = node9["n"] + local r_3671 = nil + r_3671 = (function(r_3681) + if (r_3681 <= r_3691) then + node9[r_3681] = traverseQuote1(node9[r_3681], visitor1, level2) + return r_3671((r_3681 + 1)) else end end) - r_3641(1) + r_3671(1) return node9 end elseif error1 then @@ -1336,18 +1356,18 @@ traverseNode1 = (function(node10, visitor2) traverseBlock1(node10, 3, visitor2) return visitor2(node10, visitor2) elseif (func1 == builtins2["cond"]) then - local r_3701 = node10["n"] - local r_3681 = nil - r_3681 = (function(r_3691) - if (r_3691 <= r_3701) then - local case1 = node10[r_3691] + local r_3731 = node10["n"] + local r_3711 = nil + r_3711 = (function(r_3721) + if (r_3721 <= r_3731) then + local case1 = node10[r_3721] case1[1] = traverseNode1(case1[1], visitor2) traverseBlock1(case1, 2, visitor2) - return r_3681((r_3691 + 1)) + return r_3711((r_3721 + 1)) else end end) - r_3681(2) + r_3711(2) return visitor2(node10, visitor2) elseif (func1 == builtins2["set!"]) then node10[3] = traverseNode1(node10[3], visitor2) @@ -1384,29 +1404,29 @@ traverseNode1 = (function(node10, visitor2) end end) traverseBlock1 = (function(node11, start2, visitor3) - local r_3491 = node11["n"] - local r_3471 = nil - r_3471 = (function(r_3481) - if (r_3481 <= r_3491) then - node11[r_3481] = (traverseNode1(node11[((r_3481 + 0))], visitor3)) - return r_3471((r_3481 + 1)) + local r_3521 = node11["n"] + local r_3501 = nil + r_3501 = (function(r_3511) + if (r_3511 <= r_3521) then + node11[r_3511] = (traverseNode1(node11[((r_3511 + 0))], visitor3)) + return r_3501((r_3511 + 1)) else end end) - r_3471(start2) + r_3501(start2) return node11 end) traverseList1 = (function(node12, start3, visitor4) - local r_3531 = node12["n"] - local r_3511 = nil - r_3511 = (function(r_3521) - if (r_3521 <= r_3531) then - node12[r_3521] = traverseNode1(node12[r_3521], visitor4) - return r_3511((r_3521 + 1)) + local r_3561 = node12["n"] + local r_3541 = nil + r_3541 = (function(r_3551) + if (r_3551 <= r_3561) then + node12[r_3551] = traverseNode1(node12[r_3551], visitor4) + return r_3541((r_3551 + 1)) else end end) - r_3511(start3) + r_3541(start3) return node12 end) builtins3 = require1("tacky.analysis.resolve")["builtins"] @@ -1425,28 +1445,28 @@ visitQuote1 = (function(node13, visitor5, level3) elseif (first4["contents"] == "syntax-quote") then return visitQuote1(node13[2], visitor5, (level3 + 1)) else - local r_4011 = node13["n"] - local r_3991 = nil - r_3991 = (function(r_4001) - if (r_4001 <= r_4011) then - visitQuote1(node13[r_4001], visitor5, level3) - return r_3991((r_4001 + 1)) + local r_4041 = node13["n"] + local r_4021 = nil + r_4021 = (function(r_4031) + if (r_4031 <= r_4041) then + visitQuote1(node13[r_4031], visitor5, level3) + return r_4021((r_4031 + 1)) else end end) - return r_3991(1) + return r_4021(1) end else - local r_4071 = node13["n"] - local r_4051 = nil - r_4051 = (function(r_4061) - if (r_4061 <= r_4071) then - visitQuote1(node13[r_4061], visitor5, level3) - return r_4051((r_4061 + 1)) + local r_4101 = node13["n"] + local r_4081 = nil + r_4081 = (function(r_4091) + if (r_4091 <= r_4101) then + visitQuote1(node13[r_4091], visitor5, level3) + return r_4081((r_4091 + 1)) else end end) - return r_4051(1) + return r_4081(1) end elseif error1 then return _2e2e_2("Unknown tag ", tag6) @@ -1469,18 +1489,18 @@ visitNode1 = (function(node14, visitor6) if (func2 == builtins3["lambda"]) then return visitBlock1(node14, 3, visitor6) elseif (func2 == builtins3["cond"]) then - local r_4111 = node14["n"] - local r_4091 = nil - r_4091 = (function(r_4101) - if (r_4101 <= r_4111) then - local case2 = node14[r_4101] + local r_4141 = node14["n"] + local r_4121 = nil + r_4121 = (function(r_4131) + if (r_4131 <= r_4141) then + local case2 = node14[r_4131] visitNode1(case2[1], visitor6) visitBlock1(case2, 2, visitor6) - return r_4091((r_4101 + 1)) + return r_4121((r_4131 + 1)) else end end) - return r_4091(2) + return r_4121(2) elseif (func2 == builtins3["set!"]) then return visitNode1(node14[3], visitor6) elseif (func2 == builtins3["quote"]) then @@ -1508,22 +1528,22 @@ visitNode1 = (function(node14, visitor6) end end) visitBlock1 = (function(node15, start4, visitor7) - local r_3901 = node15["n"] - local r_3881 = nil - r_3881 = (function(r_3891) - if (r_3891 <= r_3901) then - visitNode1(node15[r_3891], visitor7) - return r_3881((r_3891 + 1)) + local r_3931 = node15["n"] + local r_3911 = nil + r_3911 = (function(r_3921) + if (r_3921 <= r_3931) then + visitNode1(node15[r_3921], visitor7) + return r_3911((r_3921 + 1)) else end end) - return r_3881(start4) + return r_3911(start4) end) getVar1 = (function(state1, var4) local entry1 = state1["vars"][var4] if entry1 then else - entry1 = {["var"]=var4,["usages"]=({tag = "list", n = 0}),["defs"]=({tag = "list", n = 0}),["active"]=false} + entry1 = ({["var"]=var4,["usages"]=({tag = "list", n = 0}),["defs"]=({tag = "list", n = 0}),["active"]=false}) state1["vars"][var4] = entry1 end return entry1 @@ -1535,24 +1555,24 @@ addUsage_21_1 = (function(state2, var5, node16) return nil end) addDefinition_21_1 = (function(state3, var6, node17, kind1, value9) - return pushCdr_21_1(getVar1(state3, var6)["defs"], {["tag"]=kind1,["node"]=node17,["value"]=value9}) + return pushCdr_21_1(getVar1(state3, var6)["defs"], ({["tag"]=kind1,["node"]=node17,["value"]=value9})) end) definitionsVisitor1 = (function(state4, node18, visitor8) if ((type1(node18) == "list") and (type1((car1(node18))) == "symbol")) then local func3 = car1(node18)["var"] if (func3 == builtins1["lambda"]) then - local r_4191 = node18[2] - local r_4221 = r_4191["n"] - local r_4201 = nil - r_4201 = (function(r_4211) - if (r_4211 <= r_4221) then - local arg18 = r_4191[r_4211] + local r_4221 = node18[2] + local r_4251 = r_4221["n"] + local r_4231 = nil + r_4231 = (function(r_4241) + if (r_4241 <= r_4251) then + local arg18 = r_4221[r_4241] addDefinition_21_1(state4, arg18["var"], arg18, "arg", arg18) - return r_4201((r_4211 + 1)) + return r_4231((r_4241 + 1)) else end end) - return r_4201(1) + return r_4231(1) elseif (func3 == builtins1["set!"]) then return addDefinition_21_1(state4, node18[2]["var"], node18, "set", node18[3]) elseif ((func3 == builtins1["define"]) or (func3 == builtins1["define-macro"])) then @@ -1565,12 +1585,12 @@ definitionsVisitor1 = (function(state4, node18, visitor8) local lam1 = car1(node18) local args5 = lam1[2] local offset1 = 1 - local r_4301 = args5["n"] - local r_4281 = nil - r_4281 = (function(r_4291) - if (r_4291 <= r_4301) then - local arg19 = args5[r_4291] - local val9 = node18[((r_4291 + offset1))] + local r_4331 = args5["n"] + local r_4311 = nil + r_4311 = (function(r_4321) + if (r_4321 <= r_4331) then + local arg19 = args5[r_4321] + local val9 = node18[((r_4321 + offset1))] if arg19["var"]["isVariadic"] then local count1 = (node18["n"] - args5["n"]) if (count1 < 0) then @@ -1579,13 +1599,13 @@ definitionsVisitor1 = (function(state4, node18, visitor8) offset1 = count1 addDefinition_21_1(state4, arg19["var"], arg19, "arg", arg19) else - addDefinition_21_1(state4, arg19["var"], arg19, "let", (val9 or {["tag"]="symbol",["contents"]="nil",["var"]=builtins1["nil"]})) + addDefinition_21_1(state4, arg19["var"], arg19, "let", (val9 or ({["tag"]="symbol",["contents"]="nil",["var"]=builtins1["nil"]}))) end - return r_4281((r_4291 + 1)) + return r_4311((r_4321 + 1)) else end end) - r_4281(1) + r_4311(1) visitBlock1(node18, 2, visitor8) visitBlock1(lam1, 3, visitor8) return false @@ -1593,8 +1613,8 @@ definitionsVisitor1 = (function(state4, node18, visitor8) end end) definitionsVisit1 = (function(state5, nodes1) - return visitBlock1(nodes1, 1, (function(r_4441, r_4451) - return definitionsVisitor1(state5, r_4441, r_4451) + return visitBlock1(nodes1, 1, (function(r_4471, r_4481) + return definitionsVisitor1(state5, r_4471, r_4481) end)) end) usagesVisit1 = (function(state6, nodes2, pred1) @@ -1605,26 +1625,26 @@ usagesVisit1 = (function(state6, nodes2, pred1) end) end local queue1 = ({tag = "list", n = 0}) - local visited1 = {} + local visited1 = ({}) local addUsage1 = (function(var7, user1) local varMeta2 = getVar1(state6, var7) if varMeta2["active"] then else - local r_4381 = varMeta2["defs"] - local r_4411 = r_4381["n"] - local r_4391 = nil - r_4391 = (function(r_4401) - if (r_4401 <= r_4411) then - local def1 = r_4381[r_4401] + local r_4411 = varMeta2["defs"] + local r_4441 = r_4411["n"] + local r_4421 = nil + r_4421 = (function(r_4431) + if (r_4431 <= r_4441) then + local def1 = r_4411[r_4431] local val10 = def1["value"] if (val10 and not visited1[val10]) then pushCdr_21_1(queue1, val10) end - return r_4391((r_4401 + 1)) + return r_4421((r_4431 + 1)) else end end) - r_4391(1) + r_4421(1) end return addUsage_21_1(state6, var7, user1) end) @@ -1652,30 +1672,30 @@ usagesVisit1 = (function(state6, nodes2, pred1) end end end) - local r_3821 = nodes2["n"] - local r_3801 = nil - r_3801 = (function(r_3811) - if (r_3811 <= r_3821) then - pushCdr_21_1(queue1, (nodes2[r_3811])) - return r_3801((r_3811 + 1)) + local r_3851 = nodes2["n"] + local r_3831 = nil + r_3831 = (function(r_3841) + if (r_3841 <= r_3851) then + pushCdr_21_1(queue1, (nodes2[r_3841])) + return r_3831((r_3841 + 1)) else end end) - r_3801(1) - local r_3841 = nil - r_3841 = (function() + r_3831(1) + local r_3871 = nil + r_3871 = (function() if (queue1["n"] > 0) then visitNode1(popLast_21_1(queue1), visit1) - return r_3841() + return r_3871() else end end) - return r_3841() + return r_3871() end) -tagUsage1 = {["name"]="tag-usage",["help"]="Gathers usage and definition data for all expressions in NODES, storing it in LOOKUP.",["cat"]=({tag = "list", n = 2, "tag", "usage"}),["run"]=(function(r_4461, state7, nodes3, lookup1) +tagUsage1 = ({["name"]="tag-usage",["help"]="Gathers usage and definition data for all expressions in NODES, storing it in LOOKUP.",["cat"]=({tag = "list", n = 2, "tag", "usage"}),["run"]=(function(r_4491, state7, nodes3, lookup1) definitionsVisit1(lookup1, nodes3) return usagesVisit1(lookup1, nodes3, sideEffect_3f_1) -end)} +end)}) formatPosition1 = (function(pos3) return _2e2e_2(pos3["line"], ":", pos3["column"]) end) @@ -1712,54 +1732,54 @@ formatNode1 = (function(node20) end) getSource1 = (function(node21) local result4 = nil - local r_4491 = nil - r_4491 = (function() + local r_4521 = nil + r_4521 = (function() if (node21 and not result4) then result4 = node21["range"] node21 = node21["parent"] - return r_4491() + return r_4521() else end end) - r_4491() + r_4521() return result4 end) -struct1("formatPosition", formatPosition1, "formatRange", formatRange1, "formatNode", formatNode1, "getSource", getSource1) -stripImport1 = {["name"]="strip-import",["help"]="Strip all import expressions in NODES",["cat"]=({tag = "list", n = 1, "opt"}),["run"]=(function(r_4462, state8, nodes4) - local r_4511 = nil - r_4511 = (function(r_4521) - if (r_4521 >= 1) then - local node22 = nodes4[r_4521] +local _ = ({["formatPosition"]=formatPosition1,["formatRange"]=formatRange1,["formatNode"]=formatNode1,["getSource"]=getSource1}) +stripImport1 = ({["name"]="strip-import",["help"]="Strip all import expressions in NODES",["cat"]=({tag = "list", n = 1, "opt"}),["run"]=(function(r_4492, state8, nodes4) + local r_4541 = nil + r_4541 = (function(r_4551) + if (r_4551 >= 1) then + local node22 = nodes4[r_4551] if ((type1(node22) == "list") and ((node22["n"] > 0) and ((type1((car1(node22))) == "symbol") and (car1(node22)["var"] == builtins1["import"])))) then - if (r_4521 == nodes4["n"]) then - nodes4[r_4521] = makeNil1() + if (r_4551 == nodes4["n"]) then + nodes4[r_4551] = makeNil1() else - removeNth_21_1(nodes4, r_4521) + removeNth_21_1(nodes4, r_4551) end - r_4462["changed"] = true + r_4492["changed"] = true end - return r_4511((r_4521 + -1)) + return r_4541((r_4551 + -1)) else end end) - return r_4511(nodes4["n"]) -end)} -stripPure1 = {["name"]="strip-pure",["help"]="Strip all pure expressions in NODES (apart from the last one).",["cat"]=({tag = "list", n = 1, "opt"}),["run"]=(function(r_4463, state9, nodes5) - local r_4581 = nil - r_4581 = (function(r_4591) - if (r_4591 >= 1) then - if sideEffect_3f_1((nodes5[r_4591])) then + return r_4541(nodes4["n"]) +end)}) +stripPure1 = ({["name"]="strip-pure",["help"]="Strip all pure expressions in NODES (apart from the last one).",["cat"]=({tag = "list", n = 1, "opt"}),["run"]=(function(r_4493, state9, nodes5) + local r_4611 = nil + r_4611 = (function(r_4621) + if (r_4621 >= 1) then + if sideEffect_3f_1((nodes5[r_4621])) then else - removeNth_21_1(nodes5, r_4591) - r_4463["changed"] = true + removeNth_21_1(nodes5, r_4621) + r_4493["changed"] = true end - return r_4581((r_4591 + -1)) + return r_4611((r_4621 + -1)) else end end) - return r_4581((nodes5["n"] - 1)) -end)} -constantFold1 = {["name"]="constant-fold",["help"]="A primitive constant folder\n\nThis simply finds function calls with constant functions and looks up the function.\nIf the function is native and pure then we'll execute it and replace the node with the\nresult. There are a couple of caveats:\n\n - If the function call errors then we will flag a warning and continue.\n - If this returns a decimal (or infinity or NaN) then we'll continue: we cannot correctly\n accurately handle this.\n - If this doesn't return exactly one value then we will stop. This might be a future enhancement.",["cat"]=({tag = "list", n = 1, "opt"}),["run"]=(function(r_4464, state10, nodes6) + return r_4611((nodes5["n"] - 1)) +end)}) +constantFold1 = ({["name"]="constant-fold",["help"]="A primitive constant folder\n\nThis simply finds function calls with constant functions and looks up the function.\nIf the function is native and pure then we'll execute it and replace the node with the\nresult. There are a couple of caveats:\n\n - If the function call errors then we will flag a warning and continue.\n - If this returns a decimal (or infinity or NaN) then we'll continue: we cannot correctly\n accurately handle this.\n - If this doesn't return exactly one value then we will stop. This might be a future enhancement.",["cat"]=({tag = "list", n = 1, "opt"}),["run"]=(function(r_4494, state10, nodes6) return traverseList1(nodes6, 1, (function(node23) if ((type1(node23) == "list") and fastAll1(constant_3f_1, node23, 2)) then local head1 = car1(node23) @@ -1772,7 +1792,7 @@ constantFold1 = {["name"]="constant-fold",["help"]="A primitive constant folder\ head1["folded"] = true return node23 else - r_4464["changed"] = true + r_4494["changed"] = true return val_2d3e_urn1(val11) end else @@ -1787,40 +1807,40 @@ constantFold1 = {["name"]="constant-fold",["help"]="A primitive constant folder\ return node23 end end)) -end)} -condFold1 = {["name"]="cond-fold",["help"]="Simplify all `cond` nodes, removing `false` branches and killing\nall branches after a `true` one.",["cat"]=({tag = "list", n = 1, "opt"}),["run"]=(function(r_4465, state11, nodes7) +end)}) +condFold1 = ({["name"]="cond-fold",["help"]="Simplify all `cond` nodes, removing `false` branches and killing\nall branches after a `true` one.",["cat"]=({tag = "list", n = 1, "opt"}),["run"]=(function(r_4495, state11, nodes7) return traverseList1(nodes7, 1, (function(node24) if ((type1(node24) == "list") and ((type1((car1(node24))) == "symbol") and (car1(node24)["var"] == builtins1["cond"]))) then local final1 = false local i3 = 2 - local r_4701 = nil - r_4701 = (function() + local r_4731 = nil + r_4731 = (function() if (i3 <= node24["n"]) then local elem6 = node24[i3] if final1 then - r_4465["changed"] = true + r_4495["changed"] = true removeNth_21_1(node24, i3) else - local r_4791 = urn_2d3e_bool1(car1(elem6)) - if eq_3f_1(r_4791, false) then - r_4465["changed"] = true + local r_4821 = urn_2d3e_bool1(car1(elem6)) + if eq_3f_1(r_4821, false) then + r_4495["changed"] = true removeNth_21_1(node24, i3) - elseif eq_3f_1(r_4791, true) then + elseif eq_3f_1(r_4821, true) then final1 = true i3 = (i3 + 1) - elseif eq_3f_1(r_4791, nil) then + elseif eq_3f_1(r_4821, nil) then i3 = (i3 + 1) else - error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_4791), ", but none matched.\n", " Tried: `false`\n Tried: `true`\n Tried: `nil`")) + error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_4821), ", but none matched.\n", " Tried: `false`\n Tried: `true`\n Tried: `nil`")) end end - return r_4701() + return r_4731() else end end) - r_4701() + r_4731() if ((node24["n"] == 2) and (urn_2d3e_bool1(car1(node24[2])) == true)) then - r_4465["changed"] = true + r_4495["changed"] = true local body2 = cdr1(node24[2]) if (body2["n"] == 1) then return car1(body2) @@ -1834,16 +1854,17 @@ condFold1 = {["name"]="cond-fold",["help"]="Simplify all `cond` nodes, removing return node24 end end)) -end)} -lambdaFold1 = {["name"]="lambda-fold",["help"]="Simplify all directly called lambdas, inlining them were appropriate.",["cat"]=({tag = "list", n = 1, "opt"}),["run"]=(function(r_4466, state12, nodes8) +end)}) +lambdaFold1 = ({["name"]="lambda-fold",["help"]="Simplify all directly called lambdas, inlining them were appropriate.",["cat"]=({tag = "list", n = 1, "opt"}),["run"]=(function(r_4496, state12, nodes8) return traverseList1(nodes8, 1, (function(node25) - if ((type1(node25) == "list") and ((node25["n"] == 1) and ((type1((car1(node25))) == "list") and (builtin_3f_1(car1(car1(node25)), "lambda") and ((car1(node25)["n"] == 3) and nil_3f_1(car1(node25)[2])))))) then + if ((type1(node25) == "list") and ((node25["n"] == 1) and ((type1((car1(node25))) == "list") and (builtin_3f_1(car1(car1(node25)), "lambda") and ((car1(node25)["n"] == 3) and empty_3f_1(car1(node25)[2])))))) then + r_4496["changed"] = true return car1(node25)[3] else return node25 end end)) -end)} +end)}) getConstantVal1 = (function(lookup2, sym1) local var8 = sym1["var"] local def2 = getVar1(lookup2, sym1["var"]) @@ -1868,39 +1889,39 @@ getConstantVal1 = (function(lookup2, sym1) return nil end end) -stripDefs1 = {["name"]="strip-defs",["help"]="Strip all unused top level definitions.",["cat"]=({tag = "list", n = 2, "opt", "usage"}),["run"]=(function(r_4467, state13, nodes9, lookup3) - local r_4871 = nil - r_4871 = (function(r_4881) - if (r_4881 >= 1) then - local node26 = nodes9[r_4881] +stripDefs1 = ({["name"]="strip-defs",["help"]="Strip all unused top level definitions.",["cat"]=({tag = "list", n = 2, "opt", "usage"}),["run"]=(function(r_4497, state13, nodes9, lookup3) + local r_4901 = nil + r_4901 = (function(r_4911) + if (r_4911 >= 1) then + local node26 = nodes9[r_4911] if (node26["defVar"] and not getVar1(lookup3, node26["defVar"])["active"]) then - if (r_4881 == nodes9["n"]) then - nodes9[r_4881] = makeNil1() + if (r_4911 == nodes9["n"]) then + nodes9[r_4911] = makeNil1() else - removeNth_21_1(nodes9, r_4881) + removeNth_21_1(nodes9, r_4911) end - r_4467["changed"] = true + r_4497["changed"] = true end - return r_4871((r_4881 + -1)) + return r_4901((r_4911 + -1)) else end end) - return r_4871(nodes9["n"]) -end)} -stripArgs1 = {["name"]="strip-args",["help"]="Strip all unused, pure arguments in directly called lambdas.",["cat"]=({tag = "list", n = 2, "opt", "usage"}),["run"]=(function(r_4468, state14, nodes10, lookup4) + return r_4901(nodes9["n"]) +end)}) +stripArgs1 = ({["name"]="strip-args",["help"]="Strip all unused, pure arguments in directly called lambdas.",["cat"]=({tag = "list", n = 2, "opt", "usage"}),["run"]=(function(r_4498, state14, nodes10, lookup4) return visitBlock1(nodes10, 1, (function(node27) if ((type1(node27) == "list") and ((type1((car1(node27))) == "list") and ((type1((car1(car1(node27)))) == "symbol") and (car1(car1(node27))["var"] == builtins1["lambda"])))) then local lam2 = car1(node27) local args6 = lam2[2] local offset2 = 1 local remOffset1 = 0 - local removed1 = {} - local r_4971 = args6["n"] - local r_4951 = nil - r_4951 = (function(r_4961) - if (r_4961 <= r_4971) then - local arg20 = args6[((r_4961 - remOffset1))] - local val13 = node27[(((r_4961 + offset2) - remOffset1))] + local removed1 = ({}) + local r_5001 = args6["n"] + local r_4981 = nil + r_4981 = (function(r_4991) + if (r_4991 <= r_5001) then + local arg20 = args6[((r_4991 - remOffset1))] + local val13 = node27[(((r_4991 + offset2) - remOffset1))] if arg20["var"]["isVariadic"] then local count2 = (node27["n"] - args6["n"]) if (count2 < 0) then @@ -1911,17 +1932,17 @@ stripArgs1 = {["name"]="strip-args",["help"]="Strip all unused, pure arguments i elseif sideEffect_3f_1(val13) then elseif (getVar1(lookup4, arg20["var"])["usages"]["n"] > 0) then else - r_4468["changed"] = true - removed1[args6[((r_4961 - remOffset1))]["var"]] = true - removeNth_21_1(args6, (r_4961 - remOffset1)) - removeNth_21_1(node27, ((r_4961 + offset2) - remOffset1)) + r_4498["changed"] = true + removed1[args6[((r_4991 - remOffset1))]["var"]] = true + removeNth_21_1(args6, (r_4991 - remOffset1)) + removeNth_21_1(node27, ((r_4991 + offset2) - remOffset1)) remOffset1 = (remOffset1 + 1) end - return r_4951((r_4961 + 1)) + return r_4981((r_4991 + 1)) else end end) - r_4951(1) + r_4981(1) if (remOffset1 > 0) then return traverseList1(lam2, 3, (function(node28) if ((type1(node28) == "list") and (builtin_3f_1(car1(node28), "set!") and removed1[node28[2]["var"]])) then @@ -1940,13 +1961,13 @@ stripArgs1 = {["name"]="strip-args",["help"]="Strip all unused, pure arguments i else end end)) -end)} -variableFold1 = {["name"]="variable-fold",["help"]="Folds constant variable accesses",["cat"]=({tag = "list", n = 2, "opt", "usage"}),["run"]=(function(r_4469, state15, nodes11, lookup5) +end)}) +variableFold1 = ({["name"]="variable-fold",["help"]="Folds constant variable accesses",["cat"]=({tag = "list", n = 2, "opt", "usage"}),["run"]=(function(r_4499, state15, nodes11, lookup5) return traverseList1(nodes11, 1, (function(node29) if (type1(node29) == "symbol") then local var9 = getConstantVal1(lookup5, node29) if (var9 and (var9 ~= node29)) then - r_4469["changed"] = true + r_4499["changed"] = true return var9 else return node29 @@ -1955,8 +1976,8 @@ variableFold1 = {["name"]="variable-fold",["help"]="Folds constant variable acce return node29 end end)) -end)} -expressionFold1 = {["name"]="expression-fold",["help"]="Folds basic variable accesses where execution order will not change.\n\nFor instance, converts ((lambda (x) (+ x 1)) (Y)) to (+ Y 1) in the case\nwhere Y is an arbitrary expression.\n\nThere are a couple of complexities in the implementation here. Firstly, we\nwant to ensure that the arguments are executed in the correct order and only\nonce.\n\nIn order to achieve this, we find the lambda forms and visit the body, stopping\nif we visit arguments in the wrong order or non-constant terms such as mutable\nvariables or other function calls. For simplicities sake, we fail if we hit\nother lambdas or conds as that makes analysing control flow significantly more\ncomplex.\n\nAnother source of added complexity is the case where where Y could return multiple\nvalues: namely in the last argument to function calls. Here it is an invalid optimisation\nto just place Y, as that could result in additional values being passed to the function.\n\nIn order to avoid this, Y will get converted to the form ((lambda () ) Y).\nThis is understood by the codegen and so is not as inefficient as it looks. However, we do\nhave to take additional steps to avoid trying to fold the above again and again.",["cat"]=({tag = "list", n = 2, "opt", "usage"}),["run"]=(function(r_44610, state16, nodes12, lookup6) +end)}) +expressionFold1 = ({["name"]="expression-fold",["help"]="Folds basic variable accesses where execution order will not change.\n\nFor instance, converts ((lambda (x) (+ x 1)) (Y)) to (+ Y 1) in the case\nwhere Y is an arbitrary expression.\n\nThere are a couple of complexities in the implementation here. Firstly, we\nwant to ensure that the arguments are executed in the correct order and only\nonce.\n\nIn order to achieve this, we find the lambda forms and visit the body, stopping\nif we visit arguments in the wrong order or non-constant terms such as mutable\nvariables or other function calls. For simplicities sake, we fail if we hit\nother lambdas or conds as that makes analysing control flow significantly more\ncomplex.\n\nAnother source of added complexity is the case where where Y could return multiple\nvalues: namely in the last argument to function calls. Here it is an invalid optimisation\nto just place Y, as that could result in additional values being passed to the function.\n\nIn order to avoid this, Y will get converted to the form ((lambda () ) Y).\nThis is understood by the codegen and so is not as inefficient as it looks. However, we do\nhave to take additional steps to avoid trying to fold the above again and again.",["cat"]=({tag = "list", n = 2, "opt", "usage"}),["run"]=(function(r_44910, state16, nodes12, lookup6) return visitBlock1(nodes12, 1, (function(root1) if ((type1(root1) == "list") and ((type1((car1(root1))) == "list") and ((type1((car1(car1(root1)))) == "symbol") and (car1(car1(root1))["var"] == builtins1["lambda"])))) then local lam3 @@ -1986,35 +2007,35 @@ expressionFold1 = {["name"]="expression-fold",["help"]="Folds basic variable acc end) if ((len6 > 0) and (((root1["n"] ~= 2) or ((len6 ~= 1) or ((lam3["n"] ~= 3) or (atom_3f_1(root1[2]) or (not (type1((lam3[3])) == "symbol") or (lam3[3]["var"] ~= car1(args7)["var"])))))) and validate1(1))) then local currentIdx1 = 1 - local argMap1 = {} - local wrapMap1 = {} + local argMap1 = ({}) + local wrapMap1 = ({}) local ok1 = true local finished1 = false - local r_5441 = args7["n"] - local r_5421 = nil - r_5421 = (function(r_5431) - if (r_5431 <= r_5441) then - argMap1[args7[r_5431]["var"]] = r_5431 - return r_5421((r_5431 + 1)) + local r_5471 = args7["n"] + local r_5451 = nil + r_5451 = (function(r_5461) + if (r_5461 <= r_5471) then + argMap1[args7[r_5461]["var"]] = r_5461 + return r_5451((r_5461 + 1)) else end end) - r_5421(1) + r_5451(1) visitBlock1(lam3, 3, (function(node30, visitor9) if ok1 then - local r_5461 = type1(node30) - if (r_5461 == "string") then - elseif (r_5461 == "number") then - elseif (r_5461 == "key") then - elseif (r_5461 == "symbol") then - local idx3 = argMap1[node30["var"]] - if (idx3 == nil) then + local r_5491 = type1(node30) + if (r_5491 == "string") then + elseif (r_5491 == "number") then + elseif (r_5491 == "key") then + elseif (r_5491 == "symbol") then + local idx4 = argMap1[node30["var"]] + if (idx4 == nil) then if (getVar1(lookup6, node30["var"])["defs"]["n"] > 1) then ok1 = false return false else end - elseif (idx3 == currentIdx1) then + elseif (idx4 == currentIdx1) then currentIdx1 = (currentIdx1 + 1) if (currentIdx1 > len6) then finished1 = true @@ -2025,7 +2046,7 @@ expressionFold1 = {["name"]="expression-fold",["help"]="Folds basic variable acc ok1 = false return false end - elseif (r_5461 == "list") then + elseif (r_5491 == "list") then local head2 = car1(node30) if (type1(head2) == "symbol") then local var11 = head2["var"] @@ -2051,10 +2072,10 @@ expressionFold1 = {["name"]="expression-fold",["help"]="Folds basic variable acc if (node30["n"] > 1) then local last2 = node30[(node30["n"])] if (type1(last2) == "symbol") then - local idx4 = argMap1[last2["var"]] - if idx4 then - if (type1(((root1[(idx4 + 1)]))) == "list") then - wrapMap1[idx4] = true + local idx5 = argMap1[last2["var"]] + if idx5 then + if (type1(((root1[(idx5 + 1)]))) == "list") then + wrapMap1[idx5] = true end end end @@ -2075,14 +2096,14 @@ expressionFold1 = {["name"]="expression-fold",["help"]="Folds basic variable acc return false end else - return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_5461), ", but none matched.\n", " Tried: `\"string\"`\n Tried: `\"number\"`\n Tried: `\"key\"`\n Tried: `\"symbol\"`\n Tried: `\"list\"`")) + return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_5491), ", but none matched.\n", " Tried: `\"string\"`\n Tried: `\"number\"`\n Tried: `\"key\"`\n Tried: `\"symbol\"`\n Tried: `\"list\"`")) end else return false end end)) if (ok1 and finished1) then - r_44610["changed"] = true + r_44910["changed"] = true traverseList1(root1, 1, (function(child1) if (type1(child1) == "symbol") then local var12 = child1["var"] @@ -2090,8 +2111,8 @@ expressionFold1 = {["name"]="expression-fold",["help"]="Folds basic variable acc if i5 then if wrapMap1[i5] then return ({tag = "list", n = 2, ({tag = "list", n = 3, (function(var13) - return {["tag"]="symbol",["contents"]=var13["name"],["var"]=var13} - end)(builtins1["lambda"]), ({tag = "list", n = 1, {["tag"]="symbol",["contents"]=var12["name"],["var"]=var12}}), {["tag"]="symbol",["contents"]=var12["name"],["var"]=var12}}), root1[((i5 + 1))]}) + return ({["tag"]="symbol",["contents"]=var13["name"],["var"]=var13}) + end)(builtins1["lambda"]), ({tag = "list", n = 1, ({["tag"]="symbol",["contents"]=var12["name"],["var"]=var12})}), ({["tag"]="symbol",["contents"]=var12["name"],["var"]=var12})}), root1[((i5 + 1))]}) else return (root1[((i5 + 1))] or makeNil1()) end @@ -2102,24 +2123,24 @@ expressionFold1 = {["name"]="expression-fold",["help"]="Folds basic variable acc return child1 end end)) - local r_5491 = nil - r_5491 = (function(r_5501) - if (r_5501 >= 2) then - removeNth_21_1(root1, r_5501) - return r_5491((r_5501 + -1)) + local r_5521 = nil + r_5521 = (function(r_5531) + if (r_5531 >= 2) then + removeNth_21_1(root1, r_5531) + return r_5521((r_5531 + -1)) else end end) - r_5491(root1["n"]) - local r_5531 = nil - r_5531 = (function(r_5541) - if (r_5541 >= 1) then - removeNth_21_1(args7, r_5541) - return r_5531((r_5541 + -1)) + r_5521(root1["n"]) + local r_5561 = nil + r_5561 = (function(r_5571) + if (r_5571 >= 1) then + removeNth_21_1(args7, r_5571) + return r_5561((r_5571 + -1)) else end end) - return r_5531(args7["n"]) + return r_5561(args7["n"]) else end else @@ -2127,36 +2148,36 @@ expressionFold1 = {["name"]="expression-fold",["help"]="Folds basic variable acc else end end)) -end)} -condEliminate1 = {["name"]="cond-eliminate",["help"]="Replace variables with known truthy/falsey values with `true` or `false` when used in branches.",["cat"]=({tag = "list", n = 2, "opt", "usage"}),["run"]=(function(r_44611, state17, nodes13, varLookup1) - local lookup7 = {} +end)}) +condEliminate1 = ({["name"]="cond-eliminate",["help"]="Replace variables with known truthy/falsey values with `true` or `false` when used in branches.",["cat"]=({tag = "list", n = 2, "opt", "usage"}),["run"]=(function(r_44911, state17, nodes13, varLookup1) + local lookup7 = ({}) return visitBlock1(nodes13, 1, (function(node31, visitor10, isCond1) - local r_5051 = type1(node31) - if (r_5051 == "symbol") then + local r_5081 = type1(node31) + if (r_5081 == "symbol") then if isCond1 then - local r_5061 = lookup7[node31["var"]] - if eq_3f_1(r_5061, false) then + local r_5091 = lookup7[node31["var"]] + if eq_3f_1(r_5091, false) then local var14 = builtins1["false"] - return {["tag"]="symbol",["contents"]=var14["name"],["var"]=var14} - elseif eq_3f_1(r_5061, true) then + return ({["tag"]="symbol",["contents"]=var14["name"],["var"]=var14}) + elseif eq_3f_1(r_5091, true) then local var15 = builtins1["true"] - return {["tag"]="symbol",["contents"]=var15["name"],["var"]=var15} + return ({["tag"]="symbol",["contents"]=var15["name"],["var"]=var15}) else return nil end else end - elseif (r_5051 == "list") then + elseif (r_5081 == "list") then local head3 = car1(node31) - local r_5071 = type1(head3) - if (r_5071 == "symbol") then + local r_5101 = type1(head3) + if (r_5101 == "symbol") then if builtin_3f_1(head3, "cond") then local vars1 = ({tag = "list", n = 0}) - local r_5101 = node31["n"] - local r_5081 = nil - r_5081 = (function(r_5091) - if (r_5091 <= r_5101) then - local entry3 = node31[r_5091] + local r_5131 = node31["n"] + local r_5111 = nil + r_5111 = (function(r_5121) + if (r_5121 <= r_5131) then + local entry3 = node31[r_5121] local test1 = car1(entry3) local len7 = entry3["n"] local var16 = ((type1(test1) == "symbol") and test1["var"]) @@ -2167,89 +2188,92 @@ condEliminate1 = {["name"]="cond-eliminate",["help"]="Replace variables with kno var16 = nil end end - local r_5121 = visitor10(test1, visitor10, true) - if eq_3f_1(r_5121, nil) then + local r_5151 = visitor10(test1, visitor10, true) + if eq_3f_1(r_5151, nil) then visitNode1(test1, visitor10) - elseif eq_3f_1(r_5121, false) then + elseif eq_3f_1(r_5151, false) then else - entry3[1] = r_5121 + r_44911["changed"] = true + entry3[1] = r_5151 end if var16 then pushCdr_21_1(vars1, var16) lookup7[var16] = true end - local r_5151 = (len7 - 1) - local r_5131 = nil - r_5131 = (function(r_5141) - if (r_5141 <= r_5151) then - visitNode1(entry3[r_5141], visitor10) - return r_5131((r_5141 + 1)) + local r_5181 = (len7 - 1) + local r_5161 = nil + r_5161 = (function(r_5171) + if (r_5171 <= r_5181) then + visitNode1(entry3[r_5171], visitor10) + return r_5161((r_5171 + 1)) else end end) - r_5131(2) + r_5161(2) if (len7 > 1) then local last3 = entry3[len7] - local r_5171 = visitor10(last3, visitor10, isCond1) - if eq_3f_1(r_5171, nil) then + local r_5201 = visitor10(last3, visitor10, isCond1) + if eq_3f_1(r_5201, nil) then visitNode1(last3, visitor10) - elseif eq_3f_1(r_5171, false) then + elseif eq_3f_1(r_5201, false) then else - entry3[len7] = r_5171 + r_44911["changed"] = true + entry3[len7] = r_5201 end end if var16 then lookup7[var16] = false end - return r_5081((r_5091 + 1)) + return r_5111((r_5121 + 1)) else end end) - r_5081(2) - local r_5231 = vars1["n"] - local r_5211 = nil - r_5211 = (function(r_5221) - if (r_5221 <= r_5231) then - lookup7[vars1[r_5221]] = nil - return r_5211((r_5221 + 1)) + r_5111(2) + local r_5261 = vars1["n"] + local r_5241 = nil + r_5241 = (function(r_5251) + if (r_5251 <= r_5261) then + lookup7[vars1[r_5251]] = nil + return r_5241((r_5251 + 1)) else end end) - r_5211(1) + r_5241(1) return false else end - elseif (r_5071 == "list") then + elseif (r_5101 == "list") then if (isCond1 and builtin_3f_1(car1(head3), "lambda")) then - local r_5281 = node31["n"] - local r_5261 = nil - r_5261 = (function(r_5271) - if (r_5271 <= r_5281) then - visitNode1(node31[r_5271], visitor10) - return r_5261((r_5271 + 1)) + local r_5311 = node31["n"] + local r_5291 = nil + r_5291 = (function(r_5301) + if (r_5301 <= r_5311) then + visitNode1(node31[r_5301], visitor10) + return r_5291((r_5301 + 1)) else end end) - r_5261(2) + r_5291(2) local len8 = head3["n"] - local r_5321 = (len8 - 1) - local r_5301 = nil - r_5301 = (function(r_5311) - if (r_5311 <= r_5321) then - visitNode1(head3[r_5311], visitor10) - return r_5301((r_5311 + 1)) + local r_5351 = (len8 - 1) + local r_5331 = nil + r_5331 = (function(r_5341) + if (r_5341 <= r_5351) then + visitNode1(head3[r_5341], visitor10) + return r_5331((r_5341 + 1)) else end end) - r_5301(3) + r_5331(3) if (len8 > 2) then local last4 = head3[len8] - local r_5341 = visitor10(last4, visitor10, isCond1) - if eq_3f_1(r_5341, nil) then + local r_5371 = visitor10(last4, visitor10, isCond1) + if eq_3f_1(r_5371, nil) then visitNode1(last4, visitor10) - elseif eq_3f_1(r_5341, false) then + elseif eq_3f_1(r_5371, false) then else - node31[head3] = r_5341 + r_44911["changed"] = true + node31[head3] = r_5371 end end return false @@ -2260,11 +2284,11 @@ condEliminate1 = {["name"]="cond-eliminate",["help"]="Replace variables with kno else end end)) -end)} +end)}) scope_2f_child1 = require1("tacky.analysis.scope")["child"] scope_2f_add_21_1 = require1("tacky.analysis.scope")["add"] copyOf1 = (function(x18) - local res4 = {} + local res4 = ({}) iterPairs1(x18, (function(k2, v3) res4[k2] = v3 return nil @@ -2285,14 +2309,14 @@ getVar2 = (function(var17, lookup9) return (lookup9["vars"][var17] or var17) end) copyNode1 = (function(node32, lookup10) - local r_5581 = type1(node32) - if (r_5581 == "string") then + local r_5611 = type1(node32) + if (r_5611 == "string") then return copyOf1(node32) - elseif (r_5581 == "key") then + elseif (r_5611 == "key") then return copyOf1(node32) - elseif (r_5581 == "number") then + elseif (r_5611 == "number") then return copyOf1(node32) - elseif (r_5581 == "symbol") then + elseif (r_5611 == "symbol") then local copy1 = copyOf1(node32) local oldVar1 = node32["var"] local newVar1 = getVar2(oldVar1, lookup10) @@ -2301,55 +2325,55 @@ copyNode1 = (function(node32, lookup10) end copy1["var"] = newVar1 return copy1 - elseif (r_5581 == "list") then + elseif (r_5611 == "list") then if builtin_3f_1(car1(node32), "lambda") then local args8 = car1(cdr1(node32)) - if nil_3f_1(args8) then + if empty_3f_1(args8) then else local newScope3 = scope_2f_child1(getScope1(car1(args8)["var"]["scope"], lookup10, node32)) - local r_5721 = args8["n"] - local r_5701 = nil - r_5701 = (function(r_5711) - if (r_5711 <= r_5721) then - local arg22 = args8[r_5711] + local r_5751 = args8["n"] + local r_5731 = nil + r_5731 = (function(r_5741) + if (r_5741 <= r_5751) then + local arg22 = args8[r_5741] local var18 = arg22["var"] local newVar2 = scope_2f_add_21_1(newScope3, var18["name"], var18["tag"], nil) newVar2["isVariadic"] = var18["isVariadic"] lookup10["vars"][var18] = newVar2 - return r_5701((r_5711 + 1)) + return r_5731((r_5741 + 1)) else end end) - r_5701(1) + r_5731(1) end end local res5 = copyOf1(node32) - local r_5761 = res5["n"] - local r_5741 = nil - r_5741 = (function(r_5751) - if (r_5751 <= r_5761) then - res5[r_5751] = copyNode1(res5[r_5751], lookup10) - return r_5741((r_5751 + 1)) + local r_5791 = res5["n"] + local r_5771 = nil + r_5771 = (function(r_5781) + if (r_5781 <= r_5791) then + res5[r_5781] = copyNode1(res5[r_5781], lookup10) + return r_5771((r_5781 + 1)) else end end) - r_5741(1) + r_5771(1) return res5 else - return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_5581), ", but none matched.\n", " Tried: `\"string\"`\n Tried: `\"key\"`\n Tried: `\"number\"`\n Tried: `\"symbol\"`\n Tried: `\"list\"`")) + return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_5611), ", but none matched.\n", " Tried: `\"string\"`\n Tried: `\"key\"`\n Tried: `\"number\"`\n Tried: `\"symbol\"`\n Tried: `\"list\"`")) end end) scoreNode1 = (function(node33) - local r_5601 = type1(node33) - if (r_5601 == "string") then + local r_5631 = type1(node33) + if (r_5631 == "string") then return 0 - elseif (r_5601 == "key") then + elseif (r_5631 == "key") then return 0 - elseif (r_5601 == "number") then + elseif (r_5631 == "number") then return 0 - elseif (r_5601 == "symbol") then + elseif (r_5631 == "symbol") then return 1 - elseif (r_5601 == "list") then + elseif (r_5631 == "list") then if (type1(car1(node33)) == "symbol") then local func5 = car1(node33)["var"] if (func5 == builtins1["lambda"]) then @@ -2371,26 +2395,26 @@ scoreNode1 = (function(node33) return scoreNodes1(node33, 1, (node33["n"] + 1)) end else - return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_5601), ", but none matched.\n", " Tried: `\"string\"`\n Tried: `\"key\"`\n Tried: `\"number\"`\n Tried: `\"symbol\"`\n Tried: `\"list\"`")) + return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_5631), ", but none matched.\n", " Tried: `\"string\"`\n Tried: `\"key\"`\n Tried: `\"number\"`\n Tried: `\"symbol\"`\n Tried: `\"list\"`")) end end) getScore1 = (function(lookup11, node34) local score1 = lookup11[node34] if (score1 == nil) then score1 = 0 - local r_5631 = node34[2] - local r_5661 = r_5631["n"] - local r_5641 = nil - r_5641 = (function(r_5651) - if (r_5651 <= r_5661) then - if r_5631[r_5651]["var"]["isVariadic"] then + local r_5661 = node34[2] + local r_5691 = r_5661["n"] + local r_5671 = nil + r_5671 = (function(r_5681) + if (r_5681 <= r_5691) then + if r_5661[r_5681]["var"]["isVariadic"] then score1 = false end - return r_5641((r_5651 + 1)) + return r_5671((r_5681 + 1)) else end end) - r_5641(1) + r_5671(1) if score1 then score1 = scoreNodes1(node34, 3, score1) end @@ -2414,8 +2438,8 @@ scoreNodes1 = (function(nodes14, start5, sum1) end end end) -inline1 = {["name"]="inline",["help"]="Inline simple functions.",["cat"]=({tag = "list", n = 2, "opt", "usage"}),["on"]=false,["run"]=(function(r_44612, state18, nodes15, usage2) - local scoreLookup1 = {} +inline1 = ({["name"]="inline",["help"]="Inline simple functions.",["cat"]=({tag = "list", n = 2, "opt", "usage"}),["level"]=2,["run"]=(function(r_44912, state18, nodes15, usage2) + local scoreLookup1 = ({}) return visitBlock1(nodes15, 1, (function(node35) if ((type1(node35) == "list") and (type1((car1(node35))) == "symbol")) then local func6 = car1(node35)["var"] @@ -2424,9 +2448,9 @@ inline1 = {["name"]="inline",["help"]="Inline simple functions.",["cat"]=({tag = local ent2 = car1(def3["defs"]) local val15 = ent2["value"] if ((type1(val15) == "list") and (builtin_3f_1(car1(val15), "lambda") and (getScore1(scoreLookup1, val15) <= 20))) then - local copy2 = copyNode1(val15, struct1("scopes", {}, "vars", {}, "root", func6["scope"])) + local copy2 = copyNode1(val15, ({["scopes"]=({}),["vars"]=({}),["root"]=func6["scope"]})) node35[1] = copy2 - r_44612["changed"] = true + r_44912["changed"] = true return nil else end @@ -2435,33 +2459,33 @@ inline1 = {["name"]="inline",["help"]="Inline simple functions.",["cat"]=({tag = else end end)) -end)} +end)}) optimiseOnce1 = (function(nodes16, state19) - local tracker2 = struct1("changed", false) - local r_3141 = state19["pass"]["normal"] - local r_3171 = r_3141["n"] - local r_3151 = nil - r_3151 = (function(r_3161) - if (r_3161 <= r_3171) then - runPass1(r_3141[r_3161], state19, tracker2, nodes16) - return r_3151((r_3161 + 1)) + local tracker2 = ({["changed"]=false}) + local r_3181 = state19["pass"]["normal"] + local r_3211 = r_3181["n"] + local r_3191 = nil + r_3191 = (function(r_3201) + if (r_3201 <= r_3211) then + runPass1(r_3181[r_3201], state19, tracker2, nodes16) + return r_3191((r_3201 + 1)) else end end) - r_3151(1) - local lookup12 = {["vars"]={},["nodes"]={}} + r_3191(1) + local lookup12 = ({["vars"]=({}),["nodes"]=({})}) runPass1(tagUsage1, state19, tracker2, nodes16, lookup12) - local r_5821 = state19["pass"]["usage"] - local r_5851 = r_5821["n"] - local r_5831 = nil - r_5831 = (function(r_5841) - if (r_5841 <= r_5851) then - runPass1(r_5821[r_5841], state19, tracker2, nodes16, lookup12) - return r_5831((r_5841 + 1)) + local r_5851 = state19["pass"]["usage"] + local r_5881 = r_5851["n"] + local r_5861 = nil + r_5861 = (function(r_5871) + if (r_5871 <= r_5881) then + runPass1(r_5851[r_5871], state19, tracker2, nodes16, lookup12) + return r_5861((r_5871 + 1)) else end end) - r_5831(1) + r_5861(1) return tracker2["changed"] end) optimise1 = (function(nodes17, state20) @@ -2470,34 +2494,96 @@ optimise1 = (function(nodes17, state20) local iteration1 = 0 local finish1 = (clock1() + maxT1) local changed1 = true - local r_3191 = nil - r_3191 = (function() + local r_3231 = nil + r_3231 = (function() if (changed1 and (((maxN1 < 0) or (iteration1 < maxN1)) and ((maxT1 < 0) or (clock1() < finish1)))) then changed1 = optimiseOnce1(nodes17, state20) iteration1 = (iteration1 + 1) - return r_3191() + return r_3231() else end end) - return r_3191() + return r_3231() end) default1 = (function() - return {["normal"]=list1(stripImport1, stripPure1, constantFold1, condFold1, lambdaFold1),["usage"]=list1(stripDefs1, stripArgs1, variableFold1, condEliminate1, expressionFold1, inline1)} + return ({["normal"]=list1(stripImport1, stripPure1, constantFold1, condFold1, lambdaFold1),["usage"]=list1(stripDefs1, stripArgs1, variableFold1, condEliminate1, expressionFold1, inline1)}) end) -checkArity1 = {["name"]="check-arity",["help"]="Produce a warning if any NODE in NODES calls a function with too many arguments.\n\nLOOKUP is the variable usage lookup table.",["cat"]=({tag = "list", n = 2, "warn", "usage"}),["run"]=(function(r_44613, state21, nodes18, lookup13) +builtins4 = require1("tacky.analysis.resolve")["builtins"] +tokens1 = ({tag = "list", n = 7, ({tag = "list", n = 2, "arg", "(%f[%a]%u+%f[%A])"}), ({tag = "list", n = 2, "mono", "```[a-z]*\n([^`]*)\n```"}), ({tag = "list", n = 2, "mono", "`([^`]*)`"}), ({tag = "list", n = 2, "bolic", "(%*%*%*%w.-%w%*%*%*)"}), ({tag = "list", n = 2, "bold", "(%*%*%w.-%w%*%*)"}), ({tag = "list", n = 2, "italic", "(%*%w.-%w%*)"}), ({tag = "list", n = 2, "link", "%[%[(.-)%]%]"})}) +extractSignature1 = (function(var19) + local ty5 = type1(var19) + if ((ty5 == "macro") or (ty5 == "defined")) then + local root2 = var19["node"] + local node36 = root2[(root2["n"])] + if ((type1(node36) == "list") and ((type1((car1(node36))) == "symbol") and (car1(node36)["var"] == builtins4["lambda"]))) then + return node36[2] + else + return nil + end + else + return nil + end +end) +parseDocstring1 = (function(str3) + local out9 = ({tag = "list", n = 0}) + local pos7 = 1 + local len9 = len1(str3) + local r_6001 = nil + r_6001 = (function() + if (pos7 <= len9) then + local spos1 = len9 + local epos1 = nil + local name9 = nil + local ptrn1 = nil + local r_6051 = tokens1["n"] + local r_6031 = nil + r_6031 = (function(r_6041) + if (r_6041 <= r_6051) then + local tok1 = tokens1[r_6041] + local npos1 = list1(find1(str3, tok1[2], pos7)) + if (car1(npos1) and (car1(npos1) < spos1)) then + spos1 = car1(npos1) + epos1 = npos1[2] + name9 = car1(tok1) + ptrn1 = tok1[2] + end + return r_6031((r_6041 + 1)) + else + end + end) + r_6031(1) + if name9 then + if (pos7 < spos1) then + pushCdr_21_1(out9, ({["tag"]="text",["contents"]=sub1(str3, pos7, (spos1 - 1))})) + end + pushCdr_21_1(out9, ({["tag"]=name9,["whole"]=sub1(str3, spos1, epos1),["contents"]=match1(sub1(str3, spos1, epos1), ptrn1)})) + pos7 = (epos1 + 1) + else + pushCdr_21_1(out9, ({["tag"]="text",["contents"]=sub1(str3, pos7, len9)})) + pos7 = (len9 + 1) + end + return r_6001() + else + end + end) + r_6001() + return out9 +end) +Scope1 = require1("tacky.analysis.scope") +checkArity1 = ({["name"]="check-arity",["help"]="Produce a warning if any NODE in NODES calls a function with too many arguments.\n\nLOOKUP is the variable usage lookup table.",["cat"]=({tag = "list", n = 2, "warn", "usage"}),["run"]=(function(r_44913, state21, nodes18, lookup13) local arity1 local getArity1 - arity1 = {} + arity1 = ({}) getArity1 = (function(symbol1) - local var19 = getVar1(lookup13, symbol1["var"]) - local ari1 = arity1[var19] + local var20 = getVar1(lookup13, symbol1["var"]) + local ari1 = arity1[var20] if (ari1 ~= nil) then return ari1 - elseif (var19["defs"]["n"] ~= 1) then + elseif (var20["defs"]["n"] ~= 1) then return false else - arity1[var19] = false - local defData1 = car1(var19["defs"]) + arity1[var20] = false + local defData1 = car1(var20["defs"]) local def4 = defData1["value"] if (defData1["tag"] == "arg") then ari1 = false @@ -2517,64 +2603,131 @@ checkArity1 = {["name"]="check-arity",["help"]="Produce a warning if any NODE in ari1 = false end end - arity1[var19] = ari1 + arity1[var20] = ari1 return ari1 end end) - return visitBlock1(nodes18, 1, (function(node36) - if ((type1(node36) == "list") and (type1((car1(node36))) == "symbol")) then - local arity2 = getArity1(car1(node36)) - if (arity2 and (arity2 < (node36["n"] - 1))) then - return putNodeWarning_21_1(state21["logger"], _2e2e_2("Calling ", symbol_2d3e_string1(car1(node36)), " with ", tonumber1((node36["n"] - 1)), " arguments, expected ", tonumber1(arity2)), node36, nil, getSource1(node36), "Called here") + return visitBlock1(nodes18, 1, (function(node37) + if ((type1(node37) == "list") and (type1((car1(node37))) == "symbol")) then + local arity2 = getArity1(car1(node37)) + if (arity2 and (arity2 < (node37["n"] - 1))) then + return putNodeWarning_21_1(state21["logger"], _2e2e_2("Calling ", symbol_2d3e_string1(car1(node37)), " with ", tonumber1((node37["n"] - 1)), " arguments, expected ", tonumber1(arity2)), node37, nil, getSource1(node37), "Called here") else end else end end)) -end)} -analyse1 = (function(nodes19, state22) - local r_5891 = state22["pass"]["normal"] - local r_5921 = r_5891["n"] - local r_5901 = nil - r_5901 = (function(r_5911) - if (r_5911 <= r_5921) then - runPass1(r_5891[r_5911], state22, nil, nodes19) - return r_5901((r_5911 + 1)) +end)}) +deprecated1 = ({["name"]="deprecated",["help"]="Produce a warning whenever a deprecated variable is used.",["cat"]=({tag = "list", n = 2, "warn", "usage"}),["run"]=(function(r_44914, state22, nodes19, lookup14) + local r_6161 = nodes19["n"] + local r_6141 = nil + r_6141 = (function(r_6151) + if (r_6151 <= r_6161) then + local node38 = nodes19[r_6151] + local defVar1 = node38["defVar"] + visitNode1(node38, (function(node39) + if (type1(node39) == "symbol") then + local var21 = node39["var"] + if ((var21 ~= defVar1) and var21["deprecated"]) then + return putNodeWarning_21_1(state22["logger"], (function() + if string_3f_1(var21["deprecated"]) then + return format1("%s is deprecated: %s", node39["contents"], var21["deprecated"]) + else + return format1("%s is deprecated.", node39["contents"]) + end + end)() + , node39, nil, getSource1(node39), "") + else + end + else + end + end)) + return r_6141((r_6151 + 1)) else end end) - r_5901(1) - local lookup14 = {["vars"]={},["nodes"]={}} - runPass1(tagUsage1, state22, nil, nodes19, lookup14) - local r_5991 = state22["pass"]["usage"] - local r_6021 = r_5991["n"] - local r_6001 = nil - r_6001 = (function(r_6011) - if (r_6011 <= r_6021) then - runPass1(r_5991[r_6011], state22, nil, nodes19, lookup14) - return r_6001((r_6011 + 1)) + return r_6141(1) +end)}) +documentation1 = ({["name"]="documentation",["help"]="Ensure doc comments are valid.",["cat"]=({tag = "list", n = 1, "warn"}),["run"]=(function(r_44915, state23, nodes20) + local r_6231 = nodes20["n"] + local r_6211 = nil + r_6211 = (function(r_6221) + if (r_6221 <= r_6231) then + local node40 = nodes20[r_6221] + local var22 = node40["defVar"] + if var22 then + local doc1 = var22["doc"] + if doc1 then + local r_6321 = parseDocstring1(doc1) + local r_6351 = r_6321["n"] + local r_6331 = nil + r_6331 = (function(r_6341) + if (r_6341 <= r_6351) then + local tok2 = r_6321[r_6341] + if (type1(tok2) == "link") then + if Scope1["get"](var22["scope"], tok2["contents"]) then + else + putNodeWarning_21_1(state23["logger"], format1("%s is not defined.", quoted1(tok2["contents"])), node40, nil, getSource1(node40), "Referenced in docstring.") + end + end + return r_6331((r_6341 + 1)) + else + end + end) + r_6331(1) + else + end + else + end + return r_6211((r_6221 + 1)) + else + end + end) + return r_6211(1) +end)}) +analyse1 = (function(nodes21, state24) + local r_5921 = state24["pass"]["normal"] + local r_5951 = r_5921["n"] + local r_5931 = nil + r_5931 = (function(r_5941) + if (r_5941 <= r_5951) then + runPass1(r_5921[r_5941], state24, nil, nodes21) + return r_5931((r_5941 + 1)) + else + end + end) + r_5931(1) + local lookup15 = ({["vars"]=({}),["nodes"]=({})}) + runPass1(tagUsage1, state24, nil, nodes21, lookup15) + local r_6261 = state24["pass"]["usage"] + local r_6291 = r_6261["n"] + local r_6271 = nil + r_6271 = (function(r_6281) + if (r_6281 <= r_6291) then + runPass1(r_6261[r_6281], state24, nil, nodes21, lookup15) + return r_6271((r_6281 + 1)) else end end) - return r_6001(1) + return r_6271(1) end) create2 = (function() - return struct1("out", ({tag = "list", n = 0}), "indent", 0, "tabs-pending", false, "line", 1, "lines", {}, "node-stack", ({tag = "list", n = 0}), "active-pos", nil) + return ({["out"]=({tag = "list", n = 0}),["indent"]=0,["tabs-pending"]=false,["line"]=1,["lines"]=({}),["node-stack"]=({tag = "list", n = 0}),["active-pos"]=nil}) end) append_21_1 = (function(writer1, text2) - local r_6151 = type1(text2) - if (r_6151 ~= "string") then - error1(format1("bad argument %s (expected %s, got %s)", "text", "string", r_6151), 2) + local r_6481 = type1(text2) + if (r_6481 ~= "string") then + error1(format1("bad argument %s (expected %s, got %s)", "text", "string", r_6481), 2) end - local pos7 = writer1["active-pos"] - if pos7 then + local pos8 = writer1["active-pos"] + if pos8 then local line1 = writer1["lines"][writer1["line"]] if line1 then else - line1 = {} + line1 = ({}) writer1["lines"][writer1["line"]] = line1 end - line1[pos7] = true + line1[pos8] = true end if writer1["tabs-pending"] then writer1["tabs-pending"] = false @@ -2616,20 +2769,20 @@ endBlock_21_1 = (function(writer7, text6) writer7["indent"] = (writer7["indent"] - 1) return line_21_1(writer7, text6) end) -pushNode_21_1 = (function(writer8, node37) - local range2 = getSource1(node37) +pushNode_21_1 = (function(writer8, node41) + local range2 = getSource1(node41) if range2 then - pushCdr_21_1(writer8["node-stack"], node37) + pushCdr_21_1(writer8["node-stack"], node41) writer8["active-pos"] = range2 return nil else end end) -popNode_21_1 = (function(writer9, node38) - if getSource1(node38) then +popNode_21_1 = (function(writer9, node42) + if getSource1(node42) then local stack1 = writer9["node-stack"] local previous1 = last1(stack1) - if (previous1 == node38) then + if (previous1 == node42) then else error1("Incorrect node popped") end @@ -2639,58 +2792,58 @@ popNode_21_1 = (function(writer9, node38) else end end) -estimateLength1 = (function(node39, max4) - local tag8 = node39["tag"] +estimateLength1 = (function(node43, max4) + local tag8 = node43["tag"] if ((tag8 == "string") or ((tag8 == "number") or ((tag8 == "symbol") or (tag8 == "key")))) then - return len1(tostring1(node39["contents"])) + return len1(tostring1(node43["contents"])) elseif (tag8 == "list") then local sum2 = 2 local i6 = 1 - local r_6071 = nil - r_6071 = (function() - if ((sum2 <= max4) and (i6 <= node39["n"])) then - sum2 = (sum2 + estimateLength1(node39[i6], (max4 - sum2))) + local r_6401 = nil + r_6401 = (function() + if ((sum2 <= max4) and (i6 <= node43["n"])) then + sum2 = (sum2 + estimateLength1(node43[i6], (max4 - sum2))) if (i6 > 1) then sum2 = (sum2 + 1) end i6 = (i6 + 1) - return r_6071() + return r_6401() else end end) - r_6071() + r_6401() return sum2 else return error1(_2e2e_2("Unknown tag ", tag8), 0) end end) -expression1 = (function(node40, writer10) - local tag9 = node40["tag"] +expression1 = (function(node44, writer10) + local tag9 = node44["tag"] if (tag9 == "string") then - return append_21_1(writer10, quoted1(node40["value"])) + return append_21_1(writer10, quoted1(node44["value"])) elseif (tag9 == "number") then - return append_21_1(writer10, tostring1(node40["value"])) + return append_21_1(writer10, tostring1(node44["value"])) elseif (tag9 == "key") then - return append_21_1(writer10, _2e2e_2(":", node40["value"])) + return append_21_1(writer10, _2e2e_2(":", node44["value"])) elseif (tag9 == "symbol") then - return append_21_1(writer10, node40["contents"]) + return append_21_1(writer10, node44["contents"]) elseif (tag9 == "list") then append_21_1(writer10, "(") - if nil_3f_1(node40) then + if empty_3f_1(node44) then return append_21_1(writer10, ")") else local newline1 = false - local max5 = (60 - estimateLength1(car1(node40), 60)) - expression1(car1(node40), writer10) + local max5 = (60 - estimateLength1(car1(node44), 60)) + expression1(car1(node44), writer10) if (max5 <= 0) then newline1 = true writer10["indent"] = (writer10["indent"] + 1) end - local r_6191 = node40["n"] - local r_6171 = nil - r_6171 = (function(r_6181) - if (r_6181 <= r_6191) then - local entry4 = node40[r_6181] + local r_6521 = node44["n"] + local r_6501 = nil + r_6501 = (function(r_6511) + if (r_6511 <= r_6521) then + local entry4 = node44[r_6511] if (not newline1 and (max5 > 0)) then max5 = (max5 - estimateLength1(entry4, max5)) if (max5 <= 0) then @@ -2704,11 +2857,11 @@ expression1 = (function(node40, writer10) append_21_1(writer10, " ") end expression1(entry4, writer10) - return r_6171((r_6181 + 1)) + return r_6501((r_6511 + 1)) else end end) - r_6171(2) + r_6501(2) if newline1 then writer10["indent"] = (writer10["indent"] - 1) end @@ -2719,71 +2872,71 @@ expression1 = (function(node40, writer10) end end) block1 = (function(list4, writer11) - local r_6131 = list4["n"] - local r_6111 = nil - r_6111 = (function(r_6121) - if (r_6121 <= r_6131) then - expression1(list4[r_6121], writer11) + local r_6461 = list4["n"] + local r_6441 = nil + r_6441 = (function(r_6451) + if (r_6451 <= r_6461) then + expression1(list4[r_6451], writer11) line_21_1(writer11) - return r_6111((r_6121 + 1)) + return r_6441((r_6451 + 1)) else end end) - return r_6111(1) + return r_6441(1) end) -cat2 = (function(category1, ...) +cat3 = (function(category1, ...) local args10 = _pack(...) args10.tag = "list" return struct1("category", category1, unpack1(args10, 1, args10["n"])) end) -partAll1 = (function(xs13, i7, e1, f4) +partAll1 = (function(xs12, i7, e1, f3) if (i7 > e1) then return true - elseif f4(xs13[i7]) then - return partAll1(xs13, (i7 + 1), e1, f4) + elseif f3(xs12[i7]) then + return partAll1(xs12, (i7 + 1), e1, f3) else return false end end) -visitNode2 = (function(lookup15, node41, stmt1, test2) - local cat3 - local r_6311 = type1(node41) - if (r_6311 == "string") then - cat3 = cat2("const") - elseif (r_6311 == "number") then - cat3 = cat2("const") - elseif (r_6311 == "key") then - cat3 = cat2("const") - elseif (r_6311 == "symbol") then - cat3 = cat2("const") - elseif (r_6311 == "list") then - local head4 = car1(node41) - local r_6321 = type1(head4) - if (r_6321 == "symbol") then +visitNode2 = (function(lookup16, node45, stmt1, test2) + local cat4 + local r_6641 = type1(node45) + if (r_6641 == "string") then + cat4 = cat3("const") + elseif (r_6641 == "number") then + cat4 = cat3("const") + elseif (r_6641 == "key") then + cat4 = cat3("const") + elseif (r_6641 == "symbol") then + cat4 = cat3("const") + elseif (r_6641 == "list") then + local head4 = car1(node45) + local r_6651 = type1(head4) + if (r_6651 == "symbol") then local func7 = head4["var"] local funct3 = func7["tag"] if (func7 == builtins1["lambda"]) then - visitNodes1(lookup15, node41, 3, true) - cat3 = cat2("lambda") + visitNodes1(lookup16, node45, 3, true) + cat4 = cat3("lambda") elseif (func7 == builtins1["cond"]) then - local r_6471 = node41["n"] - local r_6451 = nil - r_6451 = (function(r_6461) - if (r_6461 <= r_6471) then - local case3 = node41[r_6461] - visitNode2(lookup15, car1(case3), true, true) - visitNodes1(lookup15, case3, 2, true, test2) - return r_6451((r_6461 + 1)) + local r_6801 = node45["n"] + local r_6781 = nil + r_6781 = (function(r_6791) + if (r_6791 <= r_6801) then + local case3 = node45[r_6791] + visitNode2(lookup16, car1(case3), true, true) + visitNodes1(lookup16, case3, 2, true, test2) + return r_6781((r_6791 + 1)) else end end) - r_6451(2) + r_6781(2) local temp6 - if (node41["n"] == 3) then + if (node45["n"] == 3) then local temp7 - local sub2 = node41[2] + local sub2 = node45[2] temp7 = ((sub2["n"] == 2) and builtin_3f_1(sub2[2], "false")) if temp7 then - local sub3 = node41[3] + local sub3 = node45[3] temp6 = ((sub3["n"] == 2) and (builtin_3f_1(sub3[1], "true") and builtin_3f_1(sub3[2], "true"))) else temp6 = false @@ -2792,30 +2945,30 @@ visitNode2 = (function(lookup15, node41, stmt1, test2) temp6 = false end if temp6 then - cat3 = cat2("not", "stmt", lookup15[car1(node41[2])]["stmt"]) + cat4 = cat3("not", "stmt", lookup16[car1(node45[2])]["stmt"]) else local temp8 - if (node41["n"] == 3) then - local first6 = node41[2] - local second1 = node41[3] + if (node45["n"] == 3) then + local first6 = node45[2] + local second1 = node45[3] local branch1 = car1(first6) local last5 = second1[2] - temp8 = ((first6["n"] == 2) and ((second1["n"] == 2) and (not lookup15[first6[2]]["stmt"] and (builtin_3f_1(car1(second1), "true") and ((type1(last5) == "symbol") and (((type1(branch1) == "symbol") and (branch1["var"] == last5["var"])) or (test2 and (not lookup15[branch1]["stmt"] and (last5["var"] == builtins1["false"]))))))))) + temp8 = ((first6["n"] == 2) and ((second1["n"] == 2) and (not lookup16[first6[2]]["stmt"] and (builtin_3f_1(car1(second1), "true") and ((type1(last5) == "symbol") and (((type1(branch1) == "symbol") and (branch1["var"] == last5["var"])) or (test2 and (not lookup16[branch1]["stmt"] and (last5["var"] == builtins1["false"]))))))))) else temp8 = false end if temp8 then - cat3 = cat2("and") + cat4 = cat3("and") else local temp9 - if (node41["n"] >= 3) then - if partAll1(node41, 2, (node41["n"] - 1), (function(branch2) + if (node45["n"] >= 3) then + if partAll1(node45, 2, (node45["n"] - 1), (function(branch2) local head5 = car1(branch2) local tail1 = branch2[2] - return ((branch2["n"] == 2) and ((type1(tail1) == "symbol") and (((type1(head5) == "symbol") and (head5["var"] == tail1["var"])) or (test2 and (not lookup15[head5]["stmt"] and (tail1["var"] == builtins1["true"])))))) + return ((branch2["n"] == 2) and ((type1(tail1) == "symbol") and (((type1(head5) == "symbol") and (head5["var"] == tail1["var"])) or (test2 and (not lookup16[head5]["stmt"] and (tail1["var"] == builtins1["true"])))))) end)) then - local branch3 = last1(node41) - temp9 = ((branch3["n"] == 2) and (builtin_3f_1(car1(branch3), "true") and not lookup15[branch3[2]]["stmt"])) + local branch3 = last1(node45) + temp9 = ((branch3["n"] == 2) and (builtin_3f_1(car1(branch3), "true") and not lookup16[branch3[2]]["stmt"])) else temp9 = false end @@ -2823,819 +2976,765 @@ visitNode2 = (function(lookup15, node41, stmt1, test2) temp9 = false end if temp9 then - cat3 = cat2("or") + cat4 = cat3("or") else - cat3 = cat2("cond", "stmt", true) + cat4 = cat3("cond", "stmt", true) end end end elseif (func7 == builtins1["set!"]) then - visitNode2(lookup15, node41[3], true) - cat3 = cat2("set!") + visitNode2(lookup16, node45[3], true) + cat4 = cat3("set!") elseif (func7 == builtins1["quote"]) then - cat3 = cat2("quote") + cat4 = cat3("quote") elseif (func7 == builtins1["syntax-quote"]) then - visitQuote2(lookup15, node41[2], 1) - cat3 = cat2("syntax-quote") + visitQuote2(lookup16, node45[2], 1) + cat4 = cat3("syntax-quote") elseif (func7 == builtins1["unquote"]) then - cat3 = error1("unquote should never appear", 0) + cat4 = error1("unquote should never appear", 0) elseif (func7 == builtins1["unquote-splice"]) then - cat3 = error1("unquote should never appear", 0) + cat4 = error1("unquote should never appear", 0) elseif (func7 == builtins1["define"]) then - visitNode2(lookup15, node41[(node41["n"])], true) - cat3 = cat2("define") + visitNode2(lookup16, node45[(node45["n"])], true) + cat4 = cat3("define") elseif (func7 == builtins1["define-macro"]) then - visitNode2(lookup15, node41[(node41["n"])], true) - cat3 = cat2("define") + visitNode2(lookup16, node45[(node45["n"])], true) + cat4 = cat3("define") elseif (func7 == builtins1["define-native"]) then - cat3 = cat2("define-native") + cat4 = cat3("define-native") elseif (func7 == builtins1["import"]) then - cat3 = cat2("import") + cat4 = cat3("import") elseif (func7 == builtins1["struct-literal"]) then - visitNodes1(lookup15, node41, 2, false) - cat3 = cat2("struct-literal") + visitNodes1(lookup16, node45, 2, false) + cat4 = cat3("struct-literal") elseif (func7 == builtins1["true"]) then - visitNodes1(lookup15, node41, 1, false) - cat3 = cat2("call-literal") + visitNodes1(lookup16, node45, 1, false) + cat4 = cat3("call-literal") elseif (func7 == builtins1["false"]) then - visitNodes1(lookup15, node41, 1, false) - cat3 = cat2("call-literal") + visitNodes1(lookup16, node45, 1, false) + cat4 = cat3("call-literal") elseif (func7 == builtins1["nil"]) then - visitNodes1(lookup15, node41, 1, false) - cat3 = cat2("call-literal") - else - visitNodes1(lookup15, node41, 1, false) - cat3 = cat2("call-symbol") - end - elseif (r_6321 == "list") then - local temp10 - if (node41["n"] == 2) then - if builtin_3f_1(car1(head4), "lambda") then - if (head4[2]["n"] == 1) then - local temp11 - local val16 = node41[2] - temp11 = ((type1(arg1) == "list") and ((val16["n"] == 1) and eq_3f_1(car1(val16), ({ tag="symbol", contents="empty-struct"})))) - if temp11 then - local arg23 = car1(head4[2]) - local last6 = last1(head4) - temp10 = (not arg23["isVariadic"] and ((type1(last6) == "symbol") and ((arg23["var"] == last6["var"]) and partAll1(head4, 3, (head4["n"] - 1), (function(node42) - return ((type1(node42) == "list") and ((node42["n"] == 4) and (eq_3f_1(car1(node42), ({ tag="symbol", contents="set-idx!"})) and ((type1((node42[2])) == "symbol") and (node42[2]["var"] == arg23["var"]))))) - end))))) - else - temp10 = false - end - else - temp10 = false - end - else - temp10 = false - end + visitNodes1(lookup16, node45, 1, false) + cat4 = cat3("call-literal") else - temp10 = false + visitNodes1(lookup16, node45, 1, false) + cat4 = cat3("call-symbol") end - if temp10 then - visitNodes1(lookup15, car1(node41), 3, false) - cat3 = cat2("make-struct") - elseif ((node41["n"] == 2) and (builtin_3f_1(car1(head4), "lambda") and ((head4["n"] == 3) and ((head4[2]["n"] == 1) and ((type1((head4[3])) == "symbol") and (head4[3]["var"] == car1(head4[2])["var"])))))) then - if visitNode2(lookup15, node41[2], stmt1, test2)["stmt"] then - visitNode2(lookup15, head4, true) + elseif (r_6651 == "list") then + if ((node45["n"] == 2) and (builtin_3f_1(car1(head4), "lambda") and ((head4["n"] == 3) and ((head4[2]["n"] == 1) and ((type1((head4[3])) == "symbol") and (head4[3]["var"] == car1(head4[2])["var"])))))) then + if visitNode2(lookup16, node45[2], stmt1, test2)["stmt"] then + visitNode2(lookup16, head4, true) if stmt1 then - cat3 = cat2("call-lambda", "stmt", true) + cat4 = cat3("call-lambda", "stmt", true) else - cat3 = cat2("call") + cat4 = cat3("call") end else - cat3 = cat2("wrap-value") + cat4 = cat3("wrap-value") end else - local temp12 - if (node41["n"] == 2) then + local temp10 + if (node45["n"] == 2) then if builtin_3f_1(car1(head4), "lambda") then if (head4["n"] == 3) then if (head4[2]["n"] == 1) then local elem7 = head4[3] - temp12 = ((type1(elem7) == "list") and (builtin_3f_1(car1(elem7), "cond") and ((type1((car1(elem7[2]))) == "symbol") and (car1(elem7[2])["var"] == car1(head4[2])["var"])))) + temp10 = ((type1(elem7) == "list") and (builtin_3f_1(car1(elem7), "cond") and ((type1((car1(elem7[2]))) == "symbol") and (car1(elem7[2])["var"] == car1(head4[2])["var"])))) else - temp12 = false + temp10 = false end else - temp12 = false + temp10 = false end else - temp12 = false + temp10 = false end else - temp12 = false + temp10 = false end - if temp12 then - if visitNode2(lookup15, node41[2], stmt1, test2)["stmt"] then - lookup15[head4] = cat2("lambda") - local r_7011 = head4["n"] - local r_6991 = nil - r_6991 = (function(r_7001) - if (r_7001 <= r_7011) then - visitNode2(lookup15, head4[r_7001], true, test2) - return r_6991((r_7001 + 1)) + if temp10 then + if visitNode2(lookup16, node45[2], stmt1, test2)["stmt"] then + lookup16[head4] = cat3("lambda") + local r_7211 = head4["n"] + local r_7191 = nil + r_7191 = (function(r_7201) + if (r_7201 <= r_7211) then + visitNode2(lookup16, head4[r_7201], true, test2) + return r_7191((r_7201 + 1)) else end end) - r_6991(3) + r_7191(3) if stmt1 then - cat3 = cat2("call-lambda", "stmt", true) + cat4 = cat3("call-lambda", "stmt", true) else - cat3 = cat2("call") + cat4 = cat3("call") end else - local res6 = visitNode2(lookup15, head4[3], true, test2) - local ty5 = res6["category"] - lookup15[head4] = cat2("lambda") - if (ty5 == "and") then - cat3 = cat2("and-lambda") - elseif (ty5 == "or") then - cat3 = cat2("or-lambda") + local res6 = visitNode2(lookup16, head4[3], true, test2) + local ty6 = res6["category"] + lookup16[head4] = cat3("lambda") + if (ty6 == "and") then + cat4 = cat3("and-lambda") + elseif (ty6 == "or") then + cat4 = cat3("or-lambda") elseif stmt1 then - cat3 = cat2("call-lambda", "stmt", true) + cat4 = cat3("call-lambda", "stmt", true) else - cat3 = cat2("call") + cat4 = cat3("call") end end elseif (stmt1 and builtin_3f_1(car1(head4), "lambda")) then - visitNodes1(lookup15, car1(node41), 3, true, test2) - local lam4 = car1(node41) + visitNodes1(lookup16, car1(node45), 3, true, test2) + local lam4 = car1(node45) local args11 = lam4[2] local offset3 = 1 - local r_7061 = args11["n"] - local r_7041 = nil - r_7041 = (function(r_7051) - if (r_7051 <= r_7061) then - if args11[r_7051]["var"]["isVariadic"] then - local count3 = (node41["n"] - args11["n"]) + local r_7261 = args11["n"] + local r_7241 = nil + r_7241 = (function(r_7251) + if (r_7251 <= r_7261) then + if args11[r_7251]["var"]["isVariadic"] then + local count3 = (node45["n"] - args11["n"]) if (count3 < 0) then count3 = 0 end - local r_7101 = count3 - local r_7081 = nil - r_7081 = (function(r_7091) - if (r_7091 <= r_7101) then - visitNode2(lookup15, node41[((r_7051 + r_7091))], false) - return r_7081((r_7091 + 1)) + local r_7301 = count3 + local r_7281 = nil + r_7281 = (function(r_7291) + if (r_7291 <= r_7301) then + visitNode2(lookup16, node45[((r_7251 + r_7291))], false) + return r_7281((r_7291 + 1)) else end end) - r_7081(1) + r_7281(1) offset3 = count3 else - local val17 = node41[((r_7051 + offset3))] - if val17 then - visitNode2(lookup15, val17, true) + local val16 = node45[((r_7251 + offset3))] + if val16 then + visitNode2(lookup16, val16, true) end end - return r_7041((r_7051 + 1)) + return r_7241((r_7251 + 1)) else end end) - r_7041(1) - local r_7141 = node41["n"] - local r_7121 = nil - r_7121 = (function(r_7131) - if (r_7131 <= r_7141) then - visitNode2(lookup15, node41[r_7131], true) - return r_7121((r_7131 + 1)) + r_7241(1) + local r_7341 = node45["n"] + local r_7321 = nil + r_7321 = (function(r_7331) + if (r_7331 <= r_7341) then + visitNode2(lookup16, node45[r_7331], true) + return r_7321((r_7331 + 1)) else end end) - r_7121((args11["n"] + (offset3 + 1))) - cat3 = cat2("call-lambda", "stmt", true) + r_7321((args11["n"] + (offset3 + 1))) + cat4 = cat3("call-lambda", "stmt", true) elseif (builtin_3f_1(car1(head4), "quote") or builtin_3f_1(car1(head4), "syntax-quote")) then - visitNodes1(lookup15, node41, 1, false) - cat3 = cat2("call-literal") + visitNodes1(lookup16, node45, 1, false) + cat4 = cat3("call-literal") else - visitNodes1(lookup15, node41, 1, false) - cat3 = cat2("call") + visitNodes1(lookup16, node45, 1, false) + cat4 = cat3("call") end end - elseif eq_3f_1(r_6321, true) then - visitNodes1(lookup15, node41, 1, false) - cat3 = cat2("call-literal") + elseif eq_3f_1(r_6651, true) then + visitNodes1(lookup16, node45, 1, false) + cat4 = cat3("call-literal") else - cat3 = error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_6321), ", but none matched.\n", " Tried: `\"symbol\"`\n Tried: `\"list\"`\n Tried: `true`")) + cat4 = error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_6651), ", but none matched.\n", " Tried: `\"symbol\"`\n Tried: `\"list\"`\n Tried: `true`")) end else - cat3 = error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_6311), ", but none matched.\n", " Tried: `\"string\"`\n Tried: `\"number\"`\n Tried: `\"key\"`\n Tried: `\"symbol\"`\n Tried: `\"list\"`")) + cat4 = error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_6641), ", but none matched.\n", " Tried: `\"string\"`\n Tried: `\"number\"`\n Tried: `\"key\"`\n Tried: `\"symbol\"`\n Tried: `\"list\"`")) end - if (cat3 == nil) then - error1(_2e2e_2("Node returned nil ", pretty1(node41)), 0) + if (cat4 == nil) then + error1(_2e2e_2("Node returned nil ", pretty1(node45)), 0) end - lookup15[node41] = cat3 - return cat3 + lookup16[node45] = cat4 + return cat4 end) -visitNodes1 = (function(lookup16, nodes20, start6, stmt2, test3) - local len9 = nodes20["n"] - local r_6331 = nil - r_6331 = (function(r_6341) - if (r_6341 <= len9) then - visitNode2(lookup16, nodes20[r_6341], stmt2, (test3 and (r_6341 == len9))) - return r_6331((r_6341 + 1)) +visitNodes1 = (function(lookup17, nodes22, start6, stmt2, test3) + local len10 = nodes22["n"] + local r_6661 = nil + r_6661 = (function(r_6671) + if (r_6671 <= len10) then + visitNode2(lookup17, nodes22[r_6671], stmt2, (test3 and (r_6671 == len10))) + return r_6661((r_6671 + 1)) else end end) - return r_6331(start6) + return r_6661(start6) end) -visitQuote2 = (function(lookup17, node43, level4) +visitQuote2 = (function(lookup18, node46, level4) if (level4 == 0) then - return visitNode2(lookup17, node43, false) + return visitNode2(lookup18, node46, false) else - if (type1(node43) == "list") then - local r_6381 = car1(node43) - if eq_3f_1(r_6381, ({ tag="symbol", contents="unquote"})) then - return visitQuote2(lookup17, node43[2], (level4 - 1)) - elseif eq_3f_1(r_6381, ({ tag="symbol", contents="unquote-splice"})) then - return visitQuote2(lookup17, node43[2], (level4 - 1)) - elseif eq_3f_1(r_6381, ({ tag="symbol", contents="syntax-quote"})) then - return visitQuote2(lookup17, node43[2], (level4 + 1)) + if (type1(node46) == "list") then + local r_6711 = car1(node46) + if eq_3f_1(r_6711, ({ tag="symbol", contents="unquote"})) then + return visitQuote2(lookup18, node46[2], (level4 - 1)) + elseif eq_3f_1(r_6711, ({ tag="symbol", contents="unquote-splice"})) then + return visitQuote2(lookup18, node46[2], (level4 - 1)) + elseif eq_3f_1(r_6711, ({ tag="symbol", contents="syntax-quote"})) then + return visitQuote2(lookup18, node46[2], (level4 + 1)) else - local r_6431 = node43["n"] - local r_6411 = nil - r_6411 = (function(r_6421) - if (r_6421 <= r_6431) then - visitQuote2(lookup17, node43[r_6421], level4) - return r_6411((r_6421 + 1)) + local r_6761 = node46["n"] + local r_6741 = nil + r_6741 = (function(r_6751) + if (r_6751 <= r_6761) then + visitQuote2(lookup18, node46[r_6751], level4) + return r_6741((r_6751 + 1)) else end end) - return r_6411(1) + return r_6741(1) end else end end end) -categoriseNodes1 = {["name"]="categorise-nodes",["help"]="Categorise a group of NODES, annotating their appropriate node type.",["cat"]=({tag = "list", n = 1, "categorise"}),["run"]=(function(r_44614, state23, nodes21, lookup18) - return visitNodes1(lookup18, nodes21, 1, true) -end)} -categoriseNode1 = {["name"]="categorise-node",["help"]="Categorise a NODE, annotating it's appropriate node type.",["cat"]=({tag = "list", n = 1, "categorise"}),["run"]=(function(r_44615, state24, node44, lookup19, stmt3) - return visitNode2(lookup19, node44, stmt3) -end)} +categoriseNodes1 = ({["name"]="categorise-nodes",["help"]="Categorise a group of NODES, annotating their appropriate node type.",["cat"]=({tag = "list", n = 1, "categorise"}),["run"]=(function(r_44916, state25, nodes23, lookup19) + return visitNodes1(lookup19, nodes23, 1, true) +end)}) +categoriseNode1 = ({["name"]="categorise-node",["help"]="Categorise a NODE, annotating it's appropriate node type.",["cat"]=({tag = "list", n = 1, "categorise"}),["run"]=(function(r_44917, state26, node47, lookup20, stmt3) + return visitNode2(lookup20, node47, stmt3) +end)}) keywords1 = createLookup1(({tag = "list", n = 21, "and", "break", "do", "else", "elseif", "end", "false", "for", "function", "if", "in", "local", "nil", "not", "or", "repeat", "return", "then", "true", "until", "while"})) -escape1 = (function(name9) - if (name9 == "") then +escape1 = (function(name10) + if (name10 == "") then return "_e" - elseif keywords1[name9] then - return _2e2e_2("_e", name9) - elseif find1(name9, "^%w[_%w%d]*$") then - return name9 + elseif keywords1[name10] then + return _2e2e_2("_e", name10) + elseif find1(name10, "^%w[_%w%d]*$") then + return name10 else - local out7 - if find1(sub1(name9, 1, 1), "%d") then - out7 = "_e" + local out10 + if find1(sub1(name10, 1, 1), "%d") then + out10 = "_e" else - out7 = "" + out10 = "" end local upper2 = false local esc1 = false - local r_7191 = len1(name9) - local r_7171 = nil - r_7171 = (function(r_7181) - if (r_7181 <= r_7191) then - local char2 = sub1(name9, r_7181, r_7181) + local r_7391 = len1(name10) + local r_7371 = nil + r_7371 = (function(r_7381) + if (r_7381 <= r_7391) then + local char2 = sub1(name10, r_7381, r_7381) if ((char2 == "-") and (find1((function(x20) - return sub1(name9, x20, x20) - end)((r_7181 - 1)), "[%a%d']") and find1((function(x21) - return sub1(name9, x21, x21) - end)((r_7181 + 1)), "[%a%d']"))) then + return sub1(name10, x20, x20) + end)((r_7381 - 1)), "[%a%d']") and find1((function(x21) + return sub1(name10, x21, x21) + end)((r_7381 + 1)), "[%a%d']"))) then upper2 = true elseif find1(char2, "[^%w%d]") then char2 = format1("%02x", (byte1(char2))) if esc1 then else esc1 = true - out7 = _2e2e_2(out7, "_") + out10 = _2e2e_2(out10, "_") end - out7 = _2e2e_2(out7, char2) + out10 = _2e2e_2(out10, char2) else if esc1 then esc1 = false - out7 = _2e2e_2(out7, "_") + out10 = _2e2e_2(out10, "_") end if upper2 then upper2 = false char2 = upper1(char2) end - out7 = _2e2e_2(out7, char2) + out10 = _2e2e_2(out10, char2) end - return r_7171((r_7181 + 1)) + return r_7371((r_7381 + 1)) else end end) - r_7171(1) + r_7371(1) if esc1 then - out7 = _2e2e_2(out7, "_") + out10 = _2e2e_2(out10, "_") end - return out7 + return out10 end end) -escapeVar1 = (function(var20, state25) - if builtinVars1[var20] then - return var20["name"] +escapeVar1 = (function(var23, state27) + if builtinVars1[var23] then + return var23["name"] else - local v4 = escape1(var20["name"]) - local id2 = state25["var-lookup"][var20] + local v4 = escape1(var23["name"]) + local id2 = state27["var-lookup"][var23] if id2 then else - id2 = ((state25["ctr-lookup"][v4] or 0) + 1) - state25["ctr-lookup"][v4] = id2 - state25["var-lookup"][var20] = id2 + id2 = ((state27["ctr-lookup"][v4] or 0) + 1) + state27["ctr-lookup"][v4] = id2 + state27["var-lookup"][var23] = id2 end return _2e2e_2(v4, tostring1(id2)) end end) -truthy_3f_1 = (function(node45) - return ((type1(node45) == "symbol") and (builtins1["true"] == node45["var"])) +truthy_3f_1 = (function(node48) + return ((type1(node48) == "symbol") and (builtins1["true"] == node48["var"])) end) -boringCategories1 = {["const"]=true,["quote"]=true,["not"]=true,["cond"]=true} -compileQuote1 = (function(node46, out8, state26, level5) +boringCategories1 = ({["const"]=true,["quote"]=true,["not"]=true,["cond"]=true}) +compileQuote1 = (function(node49, out11, state28, level5) if (level5 == 0) then - return compileExpression1(node46, out8, state26) + return compileExpression1(node49, out11, state28) else - local ty6 = type1(node46) - if (ty6 == "string") then - return append_21_1(out8, quoted1(node46["value"])) - elseif (ty6 == "number") then - return append_21_1(out8, tostring1(node46["value"])) - elseif (ty6 == "symbol") then - append_21_1(out8, _2e2e_2("({ tag=\"symbol\", contents=", quoted1(node46["contents"]))) - if node46["var"] then - append_21_1(out8, _2e2e_2(", var=", quoted1(tostring1(node46["var"])))) + local ty7 = type1(node49) + if (ty7 == "string") then + return append_21_1(out11, quoted1(node49["value"])) + elseif (ty7 == "number") then + return append_21_1(out11, tostring1(node49["value"])) + elseif (ty7 == "symbol") then + append_21_1(out11, _2e2e_2("({ tag=\"symbol\", contents=", quoted1(node49["contents"]))) + if node49["var"] then + append_21_1(out11, _2e2e_2(", var=", quoted1(tostring1(node49["var"])))) end - return append_21_1(out8, "})") - elseif (ty6 == "key") then - return append_21_1(out8, _2e2e_2("({tag=\"key\", value=", quoted1(node46["value"]), "})")) - elseif (ty6 == "list") then - local first7 = car1(node46) + return append_21_1(out11, "})") + elseif (ty7 == "key") then + return append_21_1(out11, _2e2e_2("({tag=\"key\", value=", quoted1(node49["value"]), "})")) + elseif (ty7 == "list") then + local first7 = car1(node49) if ((type1(first7) == "symbol") and ((first7["var"] == builtins1["unquote"]) or ("var" == builtins1["unquote-splice"]))) then - return compileQuote1(node46[2], out8, state26, (level5 and (level5 - 1))) + return compileQuote1(node49[2], out11, state28, (level5 and (level5 - 1))) elseif ((type1(first7) == "symbol") and (first7["var"] == builtins1["syntax-quote"])) then - return compileQuote1(node46[2], out8, state26, (level5 and (level5 + 1))) + return compileQuote1(node49[2], out11, state28, (level5 and (level5 + 1))) else - pushNode_21_1(out8, node46) + pushNode_21_1(out11, node49) local containsUnsplice1 = false - local r_7411 = node46["n"] - local r_7391 = nil - r_7391 = (function(r_7401) - if (r_7401 <= r_7411) then - local sub4 = node46[r_7401] + local r_7611 = node49["n"] + local r_7591 = nil + r_7591 = (function(r_7601) + if (r_7601 <= r_7611) then + local sub4 = node49[r_7601] if ((type1(sub4) == "list") and ((type1((car1(sub4))) == "symbol") and (sub4[1]["var"] == builtins1["unquote-splice"]))) then containsUnsplice1 = true end - return r_7391((r_7401 + 1)) + return r_7591((r_7601 + 1)) else end end) - r_7391(1) + r_7591(1) if containsUnsplice1 then local offset4 = 0 - line_21_1(out8, "(function()") - out8["indent"] = (out8["indent"] + 1) - line_21_1(out8, "local _offset, _result, _temp = 0, {tag=\"list\",n=0}") - local r_7471 = node46["n"] - local r_7451 = nil - r_7451 = (function(r_7461) - if (r_7461 <= r_7471) then - local sub5 = node46[r_7461] + line_21_1(out11, "(function()") + out11["indent"] = (out11["indent"] + 1) + line_21_1(out11, "local _offset, _result, _temp = 0, {tag=\"list\",n=0}") + local r_7671 = node49["n"] + local r_7651 = nil + r_7651 = (function(r_7661) + if (r_7661 <= r_7671) then + local sub5 = node49[r_7661] if ((type1(sub5) == "list") and ((type1((car1(sub5))) == "symbol") and (sub5[1]["var"] == builtins1["unquote-splice"]))) then offset4 = (offset4 + 1) - append_21_1(out8, "_temp = ") - compileQuote1(sub5[2], out8, state26, (level5 - 1)) - line_21_1(out8) - line_21_1(out8, _2e2e_2("for _c = 1, _temp.n do _result[", tostring1((r_7461 - offset4)), " + _c + _offset] = _temp[_c] end")) - line_21_1(out8, "_offset = _offset + _temp.n") + append_21_1(out11, "_temp = ") + compileQuote1(sub5[2], out11, state28, (level5 - 1)) + line_21_1(out11) + line_21_1(out11, _2e2e_2("for _c = 1, _temp.n do _result[", tostring1((r_7661 - offset4)), " + _c + _offset] = _temp[_c] end")) + line_21_1(out11, "_offset = _offset + _temp.n") else - append_21_1(out8, _2e2e_2("_result[", tostring1((r_7461 - offset4)), " + _offset] = ")) - compileQuote1(sub5, out8, state26, level5) - line_21_1(out8) + append_21_1(out11, _2e2e_2("_result[", tostring1((r_7661 - offset4)), " + _offset] = ")) + compileQuote1(sub5, out11, state28, level5) + line_21_1(out11) end - return r_7451((r_7461 + 1)) + return r_7651((r_7661 + 1)) else end end) - r_7451(1) - line_21_1(out8, _2e2e_2("_result.n = _offset + ", tostring1((node46["n"] - offset4)))) - line_21_1(out8, "return _result") - out8["indent"] = (out8["indent"] - 1) - line_21_1(out8, "end)()") + r_7651(1) + line_21_1(out11, _2e2e_2("_result.n = _offset + ", tostring1((node49["n"] - offset4)))) + line_21_1(out11, "return _result") + out11["indent"] = (out11["indent"] - 1) + line_21_1(out11, "end)()") else - append_21_1(out8, _2e2e_2("({tag = \"list\", n = ", tostring1(node46["n"]))) - local r_7551 = node46["n"] - local r_7531 = nil - r_7531 = (function(r_7541) - if (r_7541 <= r_7551) then - local sub6 = node46[r_7541] - append_21_1(out8, ", ") - compileQuote1(sub6, out8, state26, level5) - return r_7531((r_7541 + 1)) + append_21_1(out11, _2e2e_2("({tag = \"list\", n = ", tostring1(node49["n"]))) + local r_7751 = node49["n"] + local r_7731 = nil + r_7731 = (function(r_7741) + if (r_7741 <= r_7751) then + local sub6 = node49[r_7741] + append_21_1(out11, ", ") + compileQuote1(sub6, out11, state28, level5) + return r_7731((r_7741 + 1)) else end end) - r_7531(1) - append_21_1(out8, "})") + r_7731(1) + append_21_1(out11, "})") end - return popNode_21_1(out8, node46) + return popNode_21_1(out11, node49) end else - return error1(_2e2e_2("Unknown type ", ty6)) + return error1(_2e2e_2("Unknown type ", ty7)) end end end) -compileExpression1 = (function(node47, out9, state27, ret1) - local catLookup1 = state27["cat-lookup"] - local cat4 = catLookup1[node47] +compileExpression1 = (function(node50, out12, state29, ret1) + local catLookup1 = state29["cat-lookup"] + local cat5 = catLookup1[node50] local _5f_2 - if cat4 then + if cat5 then else - _5f_2 = print1("Cannot find", pretty1(node47), formatNode1(node47)) + _5f_2 = print1("Cannot find", pretty1(node50), formatNode1(node50)) end - local catTag1 = cat4["category"] + local catTag1 = cat5["category"] if boringCategories1[catTag1] then else - pushNode_21_1(out9, node47) + pushNode_21_1(out12, node50) end if (catTag1 == "const") then if (ret1 == "") then else if ret1 then - append_21_1(out9, ret1) + append_21_1(out12, ret1) end - if (type1(node47) == "symbol") then - append_21_1(out9, escapeVar1(node47["var"], state27)) - elseif string_3f_1(node47) then - append_21_1(out9, quoted1(node47["value"])) - elseif number_3f_1(node47) then - append_21_1(out9, tostring1(node47["value"])) - elseif (type1(node47) == "key") then - append_21_1(out9, quoted1(node47["value"])) + if (type1(node50) == "symbol") then + append_21_1(out12, escapeVar1(node50["var"], state29)) + elseif string_3f_1(node50) then + append_21_1(out12, quoted1(node50["value"])) + elseif number_3f_1(node50) then + append_21_1(out12, tostring1(node50["value"])) + elseif (type1(node50) == "key") then + append_21_1(out12, quoted1(node50["value"])) else - error1(_2e2e_2("Unknown type: ", type1(node47))) + error1(_2e2e_2("Unknown type: ", type1(node50))) end end elseif (catTag1 == "lambda") then if (ret1 == "") then else if ret1 then - append_21_1(out9, ret1) + append_21_1(out12, ret1) end - local args12 = node47[2] + local args12 = node50[2] local variadic1 = nil local i8 = 1 - append_21_1(out9, "(function(") - local r_7581 = nil - r_7581 = (function() + append_21_1(out12, "(function(") + local r_7781 = nil + r_7781 = (function() if ((i8 <= args12["n"]) and not variadic1) then if (i8 > 1) then - append_21_1(out9, ", ") + append_21_1(out12, ", ") end - local var21 = args12[i8]["var"] - if var21["isVariadic"] then - append_21_1(out9, "...") + local var24 = args12[i8]["var"] + if var24["isVariadic"] then + append_21_1(out12, "...") variadic1 = i8 else - append_21_1(out9, escapeVar1(var21, state27)) + append_21_1(out12, escapeVar1(var24, state29)) end i8 = (i8 + 1) - return r_7581() + return r_7781() else end end) - r_7581() - line_21_1(out9, ")") - out9["indent"] = (out9["indent"] + 1) + r_7781() + line_21_1(out12, ")") + out12["indent"] = (out12["indent"] + 1) if variadic1 then - local argsVar1 = escapeVar1(args12[variadic1]["var"], state27) + local argsVar1 = escapeVar1(args12[variadic1]["var"], state29) if (variadic1 == args12["n"]) then - line_21_1(out9, _2e2e_2("local ", argsVar1, " = _pack(...) ", argsVar1, ".tag = \"list\"")) + line_21_1(out12, _2e2e_2("local ", argsVar1, " = _pack(...) ", argsVar1, ".tag = \"list\"")) else local remaining1 = (args12["n"] - variadic1) - line_21_1(out9, _2e2e_2("local _n = _select(\"#\", ...) - ", tostring1(remaining1))) - append_21_1(out9, _2e2e_2("local ", argsVar1)) - local r_7621 = args12["n"] - local r_7601 = nil - r_7601 = (function(r_7611) - if (r_7611 <= r_7621) then - append_21_1(out9, ", ") - append_21_1(out9, escapeVar1(args12[r_7611]["var"], state27)) - return r_7601((r_7611 + 1)) + line_21_1(out12, _2e2e_2("local _n = _select(\"#\", ...) - ", tostring1(remaining1))) + append_21_1(out12, _2e2e_2("local ", argsVar1)) + local r_7821 = args12["n"] + local r_7801 = nil + r_7801 = (function(r_7811) + if (r_7811 <= r_7821) then + append_21_1(out12, ", ") + append_21_1(out12, escapeVar1(args12[r_7811]["var"], state29)) + return r_7801((r_7811 + 1)) else end end) - r_7601((variadic1 + 1)) - line_21_1(out9) - line_21_1(out9, "if _n > 0 then") - out9["indent"] = (out9["indent"] + 1) - append_21_1(out9, argsVar1) - line_21_1(out9, " = { tag=\"list\", n=_n, _unpack(_pack(...), 1, _n)}") - local r_7661 = args12["n"] - local r_7641 = nil - r_7641 = (function(r_7651) - if (r_7651 <= r_7661) then - append_21_1(out9, escapeVar1(args12[r_7651]["var"], state27)) - if (r_7651 < args12["n"]) then - append_21_1(out9, ", ") + r_7801((variadic1 + 1)) + line_21_1(out12) + line_21_1(out12, "if _n > 0 then") + out12["indent"] = (out12["indent"] + 1) + append_21_1(out12, argsVar1) + line_21_1(out12, " = { tag=\"list\", n=_n, _unpack(_pack(...), 1, _n)}") + local r_7861 = args12["n"] + local r_7841 = nil + r_7841 = (function(r_7851) + if (r_7851 <= r_7861) then + append_21_1(out12, escapeVar1(args12[r_7851]["var"], state29)) + if (r_7851 < args12["n"]) then + append_21_1(out12, ", ") end - return r_7641((r_7651 + 1)) + return r_7841((r_7851 + 1)) else end end) - r_7641((variadic1 + 1)) - line_21_1(out9, " = select(_n + 1, ...)") - out9["indent"] = (out9["indent"] - 1) - line_21_1(out9, "else") - out9["indent"] = (out9["indent"] + 1) - append_21_1(out9, argsVar1) - line_21_1(out9, " = { tag=\"list\", n=0}") - local r_7701 = args12["n"] - local r_7681 = nil - r_7681 = (function(r_7691) - if (r_7691 <= r_7701) then - append_21_1(out9, escapeVar1(args12[r_7691]["var"], state27)) - if (r_7691 < args12["n"]) then - append_21_1(out9, ", ") + r_7841((variadic1 + 1)) + line_21_1(out12, " = select(_n + 1, ...)") + out12["indent"] = (out12["indent"] - 1) + line_21_1(out12, "else") + out12["indent"] = (out12["indent"] + 1) + append_21_1(out12, argsVar1) + line_21_1(out12, " = { tag=\"list\", n=0}") + local r_7901 = args12["n"] + local r_7881 = nil + r_7881 = (function(r_7891) + if (r_7891 <= r_7901) then + append_21_1(out12, escapeVar1(args12[r_7891]["var"], state29)) + if (r_7891 < args12["n"]) then + append_21_1(out12, ", ") end - return r_7681((r_7691 + 1)) + return r_7881((r_7891 + 1)) else end end) - r_7681((variadic1 + 1)) - line_21_1(out9, " = ...") - out9["indent"] = (out9["indent"] - 1) - line_21_1(out9, "end") + r_7881((variadic1 + 1)) + line_21_1(out12, " = ...") + out12["indent"] = (out12["indent"] - 1) + line_21_1(out12, "end") end end - compileBlock1(node47, out9, state27, 3, "return ") - out9["indent"] = (out9["indent"] - 1) - append_21_1(out9, "end)") + compileBlock1(node50, out12, state29, 3, "return ") + out12["indent"] = (out12["indent"] - 1) + append_21_1(out12, "end)") end elseif (catTag1 == "cond") then local closure1 = not ret1 local hadFinal1 = false local ends1 = 1 if closure1 then - line_21_1(out9, "(function()") - out9["indent"] = (out9["indent"] + 1) + line_21_1(out12, "(function()") + out12["indent"] = (out12["indent"] + 1) ret1 = "return " end local i9 = 2 - local r_7721 = nil - r_7721 = (function() - if (not hadFinal1 and (i9 <= node47["n"])) then - local item1 = node47[i9] + local r_7921 = nil + r_7921 = (function() + if (not hadFinal1 and (i9 <= node50["n"])) then + local item1 = node50[i9] local case4 = item1[1] local isFinal1 = truthy_3f_1(case4) if ((i9 > 2) and (not isFinal1 or ((ret1 ~= "") or (item1["n"] ~= 1)))) then - append_21_1(out9, "else") + append_21_1(out12, "else") end if isFinal1 then if (i9 == 2) then - append_21_1(out9, "do") + append_21_1(out12, "do") end elseif catLookup1[case4]["stmt"] then if (i9 > 2) then - out9["indent"] = (out9["indent"] + 1) - line_21_1(out9) + out12["indent"] = (out12["indent"] + 1) + line_21_1(out12) ends1 = (ends1 + 1) end - local tmp1 = escapeVar1(struct1("name", "temp"), state27) - line_21_1(out9, _2e2e_2("local ", tmp1)) - compileExpression1(case4, out9, state27, _2e2e_2(tmp1, " = ")) - line_21_1(out9) - line_21_1(out9, _2e2e_2("if ", tmp1, " then")) + local tmp1 = escapeVar1(({["name"]="temp"}), state29) + line_21_1(out12, _2e2e_2("local ", tmp1)) + compileExpression1(case4, out12, state29, _2e2e_2(tmp1, " = ")) + line_21_1(out12) + line_21_1(out12, _2e2e_2("if ", tmp1, " then")) else - append_21_1(out9, "if ") - compileExpression1(case4, out9, state27) - append_21_1(out9, " then") + append_21_1(out12, "if ") + compileExpression1(case4, out12, state29) + append_21_1(out12, " then") end - out9["indent"] = (out9["indent"] + 1) - line_21_1(out9) - compileBlock1(item1, out9, state27, 2, ret1) - out9["indent"] = (out9["indent"] - 1) + out12["indent"] = (out12["indent"] + 1) + line_21_1(out12) + compileBlock1(item1, out12, state29, 2, ret1) + out12["indent"] = (out12["indent"] - 1) if isFinal1 then hadFinal1 = true end i9 = (i9 + 1) - return r_7721() + return r_7921() else end end) - r_7721() + r_7921() if hadFinal1 then else - append_21_1(out9, "else") - out9["indent"] = (out9["indent"] + 1) - line_21_1(out9) - append_21_1(out9, "_error(\"unmatched item\")") - out9["indent"] = (out9["indent"] - 1) - line_21_1(out9) - end - local r_7791 = ends1 - local r_7771 = nil - r_7771 = (function(r_7781) - if (r_7781 <= r_7791) then - append_21_1(out9, "end") - if (r_7781 < ends1) then - out9["indent"] = (out9["indent"] - 1) - line_21_1(out9) + append_21_1(out12, "else") + out12["indent"] = (out12["indent"] + 1) + line_21_1(out12) + append_21_1(out12, "_error(\"unmatched item\")") + out12["indent"] = (out12["indent"] - 1) + line_21_1(out12) + end + local r_7991 = ends1 + local r_7971 = nil + r_7971 = (function(r_7981) + if (r_7981 <= r_7991) then + append_21_1(out12, "end") + if (r_7981 < ends1) then + out12["indent"] = (out12["indent"] - 1) + line_21_1(out12) end - return r_7771((r_7781 + 1)) + return r_7971((r_7981 + 1)) else end end) - r_7771(1) + r_7971(1) if closure1 then - line_21_1(out9) - out9["indent"] = (out9["indent"] - 1) - line_21_1(out9, "end)()") + line_21_1(out12) + out12["indent"] = (out12["indent"] - 1) + line_21_1(out12, "end)()") end elseif (catTag1 == "not") then if ret1 then ret1 = _2e2e_2(ret1, "not ") else - append_21_1(out9, "not ") + append_21_1(out12, "not ") end - compileExpression1(car1(node47[2]), out9, state27, ret1) + compileExpression1(car1(node50[2]), out12, state29, ret1) elseif (catTag1 == "or") then if ret1 then - append_21_1(out9, ret1) - end - append_21_1(out9, "(") - local len10 = node47["n"] - local r_7811 = nil - r_7811 = (function(r_7821) - if (r_7821 <= len10) then - if (r_7821 > 2) then - append_21_1(out9, " or ") + append_21_1(out12, ret1) + end + append_21_1(out12, "(") + local len11 = node50["n"] + local r_8011 = nil + r_8011 = (function(r_8021) + if (r_8021 <= len11) then + if (r_8021 > 2) then + append_21_1(out12, " or ") end - compileExpression1(node47[r_7821][(function(idx5) - return idx5 + compileExpression1(node50[r_8021][(function(idx6) + return idx6 end)((function() - if (r_7821 == len10) then + if (r_8021 == len11) then return 2 else return 1 end end)() - )], out9, state27) - return r_7811((r_7821 + 1)) + )], out12, state29) + return r_8011((r_8021 + 1)) else end end) - r_7811(2) - append_21_1(out9, ")") + r_8011(2) + append_21_1(out12, ")") elseif (catTag1 == "or-lambda") then if ret1 then - append_21_1(out9, ret1) - end - append_21_1(out9, "(") - compileExpression1(node47[2], out9, state27) - local branch4 = car1(node47)[3] - local len11 = branch4["n"] - local r_7851 = nil - r_7851 = (function(r_7861) - if (r_7861 <= len11) then - append_21_1(out9, " or ") - compileExpression1(branch4[r_7861][(function(idx6) - return idx6 + append_21_1(out12, ret1) + end + append_21_1(out12, "(") + compileExpression1(node50[2], out12, state29) + local branch4 = car1(node50)[3] + local len12 = branch4["n"] + local r_8051 = nil + r_8051 = (function(r_8061) + if (r_8061 <= len12) then + append_21_1(out12, " or ") + compileExpression1(branch4[r_8061][(function(idx7) + return idx7 end)((function() - if (r_7861 == len11) then + if (r_8061 == len12) then return 2 else return 1 end end)() - )], out9, state27) - return r_7851((r_7861 + 1)) + )], out12, state29) + return r_8051((r_8061 + 1)) else end end) - r_7851(3) - append_21_1(out9, ")") + r_8051(3) + append_21_1(out12, ")") elseif (catTag1 == "and") then if ret1 then - append_21_1(out9, ret1) + append_21_1(out12, ret1) end - append_21_1(out9, "(") - compileExpression1(node47[2][1], out9, state27) - append_21_1(out9, " and ") - compileExpression1(node47[2][2], out9, state27) - append_21_1(out9, ")") + append_21_1(out12, "(") + compileExpression1(node50[2][1], out12, state29) + append_21_1(out12, " and ") + compileExpression1(node50[2][2], out12, state29) + append_21_1(out12, ")") elseif (catTag1 == "and-lambda") then if ret1 then - append_21_1(out9, ret1) + append_21_1(out12, ret1) end - append_21_1(out9, "(") - compileExpression1(node47[2], out9, state27) - append_21_1(out9, " and ") - compileExpression1(car1(node47)[3][2][2], out9, state27) - append_21_1(out9, ")") + append_21_1(out12, "(") + compileExpression1(node50[2], out12, state29) + append_21_1(out12, " and ") + compileExpression1(car1(node50)[3][2][2], out12, state29) + append_21_1(out12, ")") elseif (catTag1 == "set!") then - compileExpression1(node47[3], out9, state27, _2e2e_2(escapeVar1(node47[2]["var"], state27), " = ")) + compileExpression1(node50[3], out12, state29, _2e2e_2(escapeVar1(node50[2]["var"], state29), " = ")) if (ret1 and (ret1 ~= "")) then - line_21_1(out9) - append_21_1(out9, ret1) - append_21_1(out9, "nil") + line_21_1(out12) + append_21_1(out12, ret1) + append_21_1(out12, "nil") end - elseif (catTag1 == "make-struct") then - if (ret1 == "") then - append_21_1(out9, "local _ = ") - elseif ret1 then - append_21_1(out9, ret1) - end - append_21_1(out9, "{") - local body3 = car1(node47) - local r_7921 = (body3["n"] - 1) - local r_7901 = nil - r_7901 = (function(r_7911) - if (r_7911 <= r_7921) then - if (r_7911 > 3) then - append_21_1(out9, ",") - end - local entry5 = body3[r_7911] - append_21_1(out9, "[") - compileExpression1(entry5[3], out9, state27) - append_21_1(out9, "]=") - compileExpression1(entry5[4], out9, state27) - return r_7901((r_7911 + 1)) - else - end - end) - r_7901(3) - append_21_1(out9, "}") elseif (catTag1 == "struct-literal") then if (ret1 == "") then - append_21_1(out9, "local _ = ") + append_21_1(out12, "local _ = ") elseif ret1 then - append_21_1(out9, ret1) - end - append_21_1(out9, "{") - local r_7961 = node47["n"] - local r_7941 = nil - r_7941 = (function(r_7951) - if (r_7951 <= r_7961) then - if (r_7951 > 2) then - append_21_1(out9, ",") + append_21_1(out12, ret1) + end + append_21_1(out12, "({") + local r_8121 = node50["n"] + local r_8101 = nil + r_8101 = (function(r_8111) + if (r_8111 <= r_8121) then + if (r_8111 > 2) then + append_21_1(out12, ",") end - append_21_1(out9, "[") - compileExpression1(node47[r_7951], out9, state27) - append_21_1(out9, "]=") - compileExpression1(node47[((r_7951 + 1))], out9, state27) - return r_7941((r_7951 + 2)) + append_21_1(out12, "[") + compileExpression1(node50[r_8111], out12, state29) + append_21_1(out12, "]=") + compileExpression1(node50[((r_8111 + 1))], out12, state29) + return r_8101((r_8111 + 2)) else end end) - r_7941(2) - append_21_1(out9, "}") + r_8101(2) + append_21_1(out12, "})") elseif (catTag1 == "define") then - compileExpression1(node47[(node47["n"])], out9, state27, _2e2e_2(escapeVar1(node47["defVar"], state27), " = ")) + compileExpression1(node50[(node50["n"])], out12, state29, _2e2e_2(escapeVar1(node50["defVar"], state29), " = ")) elseif (catTag1 == "define-native") then - local meta2 = state27["meta"][node47["defVar"]["fullName"]] - local ty7 = type1(meta2) - if (ty7 == "nil") then - append_21_1(out9, format1("%s = _libs[%q]", escapeVar1(node47["defVar"], state27), node47["defVar"]["fullName"])) - elseif (ty7 == "var") then - append_21_1(out9, format1("%s = %s", escapeVar1(node47["defVar"], state27), meta2["contents"])) - elseif ((ty7 == "expr") or (ty7 == "stmt")) then + local meta2 = state29["meta"][node50["defVar"]["fullName"]] + local ty8 = type1(meta2) + if (ty8 == "nil") then + append_21_1(out12, format1("%s = _libs[%q]", escapeVar1(node50["defVar"], state29), node50["defVar"]["fullName"])) + elseif (ty8 == "var") then + append_21_1(out12, format1("%s = %s", escapeVar1(node50["defVar"], state29), meta2["contents"])) + elseif ((ty8 == "expr") or (ty8 == "stmt")) then local count4 = meta2["count"] - append_21_1(out9, format1("%s = function(", escapeVar1(node47["defVar"], state27))) - local r_7991 = nil - r_7991 = (function(r_8001) - if (r_8001 <= count4) then - if (r_8001 == 1) then + append_21_1(out12, format1("%s = function(", escapeVar1(node50["defVar"], state29))) + local r_8151 = nil + r_8151 = (function(r_8161) + if (r_8161 <= count4) then + if (r_8161 == 1) then else - append_21_1(out9, ", ") + append_21_1(out12, ", ") end - append_21_1(out9, _2e2e_2("v", tonumber1(r_8001))) - return r_7991((r_8001 + 1)) + append_21_1(out12, _2e2e_2("v", tonumber1(r_8161))) + return r_8151((r_8161 + 1)) else end end) - r_7991(1) - append_21_1(out9, ") ") - if (ty7 == "expr") then - append_21_1(out9, "return ") + r_8151(1) + append_21_1(out12, ") ") + if (ty8 == "expr") then + append_21_1(out12, "return ") end - local r_8041 = meta2["contents"] - local r_8071 = r_8041["n"] - local r_8051 = nil - r_8051 = (function(r_8061) - if (r_8061 <= r_8071) then - local entry6 = r_8041[r_8061] - if number_3f_1(entry6) then - append_21_1(out9, _2e2e_2("v", tonumber1(entry6))) + local r_8201 = meta2["contents"] + local r_8231 = r_8201["n"] + local r_8211 = nil + r_8211 = (function(r_8221) + if (r_8221 <= r_8231) then + local entry5 = r_8201[r_8221] + if number_3f_1(entry5) then + append_21_1(out12, _2e2e_2("v", tonumber1(entry5))) else - append_21_1(out9, entry6) + append_21_1(out12, entry5) end - return r_8051((r_8061 + 1)) + return r_8211((r_8221 + 1)) else end end) - r_8051(1) - append_21_1(out9, " end") + r_8211(1) + append_21_1(out12, " end") else _error("unmatched item") end @@ -3643,27 +3742,27 @@ compileExpression1 = (function(node47, out9, state27, ret1) if (ret1 == "") then else if ret1 then - append_21_1(out9, ret1) + append_21_1(out12, ret1) end - compileQuote1(node47[2], out9, state27) + compileQuote1(node50[2], out12, state29) end elseif (catTag1 == "syntax-quote") then if (ret1 == "") then - append_21_1(out9, "local _ =") + append_21_1(out12, "local _ =") elseif ret1 then - append_21_1(out9, ret1) + append_21_1(out12, ret1) end - compileQuote1(node47[2], out9, state27, 1) + compileQuote1(node50[2], out12, state29, 1) elseif (catTag1 == "import") then if (ret1 == nil) then - append_21_1(out9, "nil") + append_21_1(out12, "nil") elseif (ret1 ~= "") then - append_21_1(out9, ret1) - append_21_1(out9, "nil") + append_21_1(out12, ret1) + append_21_1(out12, "nil") end elseif (catTag1 == "call-symbol") then - local head6 = car1(node47) - local meta3 = ((type1(head6) == "symbol") and ((head6["var"]["tag"] == "native") and state27["meta"][head6["var"]["fullName"]])) + local head6 = car1(node50) + local meta3 = ((type1(head6) == "symbol") and ((head6["var"]["tag"] == "native") and state29["meta"][head6["var"]["fullName"]])) local metaTy1 = type1(meta3) if (metaTy1 == "nil") then elseif (metaTy1 == "boolean") then @@ -3678,232 +3777,232 @@ compileExpression1 = (function(node47, out9, state27, ret1) else _error("unmatched item") end - if (meta3 and ((node47["n"] - 1) == meta3["count"])) then + if (meta3 and ((node50["n"] - 1) == meta3["count"])) then if (meta3["tag"] == "expr") then if (ret1 == "") then - append_21_1(out9, "local _ = ") + append_21_1(out12, "local _ = ") elseif ret1 then - append_21_1(out9, ret1) + append_21_1(out12, ret1) end end local contents1 = meta3["contents"] - local r_8121 = contents1["n"] - local r_8101 = nil - r_8101 = (function(r_8111) - if (r_8111 <= r_8121) then - local entry7 = contents1[r_8111] - if number_3f_1(entry7) then - compileExpression1(node47[((entry7 + 1))], out9, state27) + local r_8281 = contents1["n"] + local r_8261 = nil + r_8261 = (function(r_8271) + if (r_8271 <= r_8281) then + local entry6 = contents1[r_8271] + if number_3f_1(entry6) then + compileExpression1(node50[((entry6 + 1))], out12, state29) else - append_21_1(out9, entry7) + append_21_1(out12, entry6) end - return r_8101((r_8111 + 1)) + return r_8261((r_8271 + 1)) else end end) - r_8101(1) + r_8261(1) if ((meta3["tag"] ~= "expr") and (ret1 ~= "")) then - line_21_1(out9) - append_21_1(out9, ret1) - append_21_1(out9, "nil") - line_21_1(out9) + line_21_1(out12) + append_21_1(out12, ret1) + append_21_1(out12, "nil") + line_21_1(out12) end else if ret1 then - append_21_1(out9, ret1) + append_21_1(out12, ret1) end - compileExpression1(head6, out9, state27) - append_21_1(out9, "(") - local r_8171 = node47["n"] - local r_8151 = nil - r_8151 = (function(r_8161) - if (r_8161 <= r_8171) then - if (r_8161 > 2) then - append_21_1(out9, ", ") + compileExpression1(head6, out12, state29) + append_21_1(out12, "(") + local r_8331 = node50["n"] + local r_8311 = nil + r_8311 = (function(r_8321) + if (r_8321 <= r_8331) then + if (r_8321 > 2) then + append_21_1(out12, ", ") end - compileExpression1(node47[r_8161], out9, state27) - return r_8151((r_8161 + 1)) + compileExpression1(node50[r_8321], out12, state29) + return r_8311((r_8321 + 1)) else end end) - r_8151(2) - append_21_1(out9, ")") + r_8311(2) + append_21_1(out12, ")") end elseif (catTag1 == "wrap-value") then if ret1 then - append_21_1(out9, ret1) + append_21_1(out12, ret1) end - append_21_1(out9, "(") - compileExpression1(node47[2], out9, state27) - append_21_1(out9, ")") + append_21_1(out12, "(") + compileExpression1(node50[2], out12, state29) + append_21_1(out12, ")") elseif (catTag1 == "call-lambda") then if (ret1 == nil) then - print1(pretty1(node47), " marked as call-lambda for ", ret1) + print1(pretty1(node50), " marked as call-lambda for ", ret1) end - local head7 = car1(node47) + local head7 = car1(node50) local args13 = head7[2] local offset5 = 1 - local r_8231 = args13["n"] - local r_8211 = nil - r_8211 = (function(r_8221) - if (r_8221 <= r_8231) then - local var22 = args13[r_8221]["var"] - local esc2 = escapeVar1(var22, state27) - append_21_1(out9, _2e2e_2("local ", esc2)) - if var22["isVariadic"] then - local count5 = (node47["n"] - args13["n"]) + local r_8391 = args13["n"] + local r_8371 = nil + r_8371 = (function(r_8381) + if (r_8381 <= r_8391) then + local var25 = args13[r_8381]["var"] + local esc2 = escapeVar1(var25, state29) + append_21_1(out12, _2e2e_2("local ", esc2)) + if var25["isVariadic"] then + local count5 = (node50["n"] - args13["n"]) if (count5 < 0) then count5 = 0 end - if ((count5 <= 0) or atom_3f_1(node47[((r_8221 + count5))])) then - append_21_1(out9, " = { tag=\"list\", n=") - append_21_1(out9, tostring1(count5)) - local r_8281 = count5 - local r_8261 = nil - r_8261 = (function(r_8271) - if (r_8271 <= r_8281) then - append_21_1(out9, ", ") - compileExpression1(node47[((r_8221 + r_8271))], out9, state27) - return r_8261((r_8271 + 1)) + if ((count5 <= 0) or atom_3f_1(node50[((r_8381 + count5))])) then + append_21_1(out12, " = { tag=\"list\", n=") + append_21_1(out12, tostring1(count5)) + local r_8441 = count5 + local r_8421 = nil + r_8421 = (function(r_8431) + if (r_8431 <= r_8441) then + append_21_1(out12, ", ") + compileExpression1(node50[((r_8381 + r_8431))], out12, state29) + return r_8421((r_8431 + 1)) else end end) - r_8261(1) - line_21_1(out9, "}") + r_8421(1) + line_21_1(out12, "}") else - append_21_1(out9, " = _pack(") - local r_8321 = count5 - local r_8301 = nil - r_8301 = (function(r_8311) - if (r_8311 <= r_8321) then - if (r_8311 > 1) then - append_21_1(out9, ", ") + append_21_1(out12, " = _pack(") + local r_8481 = count5 + local r_8461 = nil + r_8461 = (function(r_8471) + if (r_8471 <= r_8481) then + if (r_8471 > 1) then + append_21_1(out12, ", ") end - compileExpression1(node47[((r_8221 + r_8311))], out9, state27) - return r_8301((r_8311 + 1)) + compileExpression1(node50[((r_8381 + r_8471))], out12, state29) + return r_8461((r_8471 + 1)) else end end) - r_8301(1) - line_21_1(out9, ")") - line_21_1(out9, _2e2e_2(esc2, ".tag = \"list\"")) + r_8461(1) + line_21_1(out12, ")") + line_21_1(out12, _2e2e_2(esc2, ".tag = \"list\"")) end offset5 = count5 else - local expr1 = node47[((r_8221 + offset5))] - local name10 = escapeVar1(var22, state27) + local expr1 = node50[((r_8381 + offset5))] + local name11 = escapeVar1(var25, state29) local ret2 = nil if expr1 then if catLookup1[expr1]["stmt"] then - ret2 = _2e2e_2(name10, " = ") - line_21_1(out9) + ret2 = _2e2e_2(name11, " = ") + line_21_1(out12) else - append_21_1(out9, " = ") + append_21_1(out12, " = ") end - compileExpression1(expr1, out9, state27, ret2) - line_21_1(out9) + compileExpression1(expr1, out12, state29, ret2) + line_21_1(out12) else - line_21_1(out9) + line_21_1(out12) end end - return r_8211((r_8221 + 1)) + return r_8371((r_8381 + 1)) else end end) - r_8211(1) - local r_8361 = node47["n"] - local r_8341 = nil - r_8341 = (function(r_8351) - if (r_8351 <= r_8361) then - compileExpression1(node47[r_8351], out9, state27, "") - line_21_1(out9) - return r_8341((r_8351 + 1)) + r_8371(1) + local r_8521 = node50["n"] + local r_8501 = nil + r_8501 = (function(r_8511) + if (r_8511 <= r_8521) then + compileExpression1(node50[r_8511], out12, state29, "") + line_21_1(out12) + return r_8501((r_8511 + 1)) else end end) - r_8341((args13["n"] + (offset5 + 1))) - compileBlock1(head7, out9, state27, 3, ret1) + r_8501((args13["n"] + (offset5 + 1))) + compileBlock1(head7, out12, state29, 3, ret1) elseif (catTag1 == "call-literal") then if ret1 then - append_21_1(out9, ret1) - end - append_21_1(out9, "(") - compileExpression1(car1(node47), out9, state27) - append_21_1(out9, ")(") - local r_8401 = node47["n"] - local r_8381 = nil - r_8381 = (function(r_8391) - if (r_8391 <= r_8401) then - if (r_8391 > 2) then - append_21_1(out9, ", ") + append_21_1(out12, ret1) + end + append_21_1(out12, "(") + compileExpression1(car1(node50), out12, state29) + append_21_1(out12, ")(") + local r_8561 = node50["n"] + local r_8541 = nil + r_8541 = (function(r_8551) + if (r_8551 <= r_8561) then + if (r_8551 > 2) then + append_21_1(out12, ", ") end - compileExpression1(node47[r_8391], out9, state27) - return r_8381((r_8391 + 1)) + compileExpression1(node50[r_8551], out12, state29) + return r_8541((r_8551 + 1)) else end end) - r_8381(2) - append_21_1(out9, ")") + r_8541(2) + append_21_1(out12, ")") elseif (catTag1 == "call") then if ret1 then - append_21_1(out9, ret1) - end - compileExpression1(car1(node47), out9, state27) - append_21_1(out9, "(") - local r_8441 = node47["n"] - local r_8421 = nil - r_8421 = (function(r_8431) - if (r_8431 <= r_8441) then - if (r_8431 > 2) then - append_21_1(out9, ", ") + append_21_1(out12, ret1) + end + compileExpression1(car1(node50), out12, state29) + append_21_1(out12, "(") + local r_8601 = node50["n"] + local r_8581 = nil + r_8581 = (function(r_8591) + if (r_8591 <= r_8601) then + if (r_8591 > 2) then + append_21_1(out12, ", ") end - compileExpression1(node47[r_8431], out9, state27) - return r_8421((r_8431 + 1)) + compileExpression1(node50[r_8591], out12, state29) + return r_8581((r_8591 + 1)) else end end) - r_8421(2) - append_21_1(out9, ")") + r_8581(2) + append_21_1(out12, ")") else - error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(catTag1), ", but none matched.\n", " Tried: `\"const\"`\n Tried: `\"lambda\"`\n Tried: `\"cond\"`\n Tried: `\"not\"`\n Tried: `\"or\"`\n Tried: `\"or-lambda\"`\n Tried: `\"and\"`\n Tried: `\"and-lambda\"`\n Tried: `\"set!\"`\n Tried: `\"make-struct\"`\n Tried: `\"struct-literal\"`\n Tried: `\"define\"`\n Tried: `\"define-native\"`\n Tried: `\"quote\"`\n Tried: `\"syntax-quote\"`\n Tried: `\"import\"`\n Tried: `\"call-symbol\"`\n Tried: `\"wrap-value\"`\n Tried: `\"call-lambda\"`\n Tried: `\"call-literal\"`\n Tried: `\"call\"`")) + error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(catTag1), ", but none matched.\n", " Tried: `\"const\"`\n Tried: `\"lambda\"`\n Tried: `\"cond\"`\n Tried: `\"not\"`\n Tried: `\"or\"`\n Tried: `\"or-lambda\"`\n Tried: `\"and\"`\n Tried: `\"and-lambda\"`\n Tried: `\"set!\"`\n Tried: `\"struct-literal\"`\n Tried: `\"define\"`\n Tried: `\"define-native\"`\n Tried: `\"quote\"`\n Tried: `\"syntax-quote\"`\n Tried: `\"import\"`\n Tried: `\"call-symbol\"`\n Tried: `\"wrap-value\"`\n Tried: `\"call-lambda\"`\n Tried: `\"call-literal\"`\n Tried: `\"call\"`")) end if boringCategories1[catTag1] then else - return popNode_21_1(out9, node47) + return popNode_21_1(out12, node50) end end) -compileBlock1 = (function(nodes22, out10, state28, start7, ret3) - local r_6291 = nodes22["n"] - local r_6271 = nil - r_6271 = (function(r_6281) - if (r_6281 <= r_6291) then +compileBlock1 = (function(nodes24, out13, state30, start7, ret3) + local r_6621 = nodes24["n"] + local r_6601 = nil + r_6601 = (function(r_6611) + if (r_6611 <= r_6621) then local ret_27_1 - if (r_6281 == nodes22["n"]) then + if (r_6611 == nodes24["n"]) then ret_27_1 = ret3 else ret_27_1 = "" end - compileExpression1(nodes22[r_6281], out10, state28, ret_27_1) - line_21_1(out10) - return r_6271((r_6281 + 1)) + compileExpression1(nodes24[r_6611], out13, state30, ret_27_1) + line_21_1(out13) + return r_6601((r_6611 + 1)) else end end) - return r_6271(start7) + return r_6601(start7) end) -prelude1 = (function(out11) - line_21_1(out11, "if not table.pack then table.pack = function(...) return { n = select(\"#\", ...), ... } end end") - line_21_1(out11, "if not table.unpack then table.unpack = unpack end") - line_21_1(out11, "local load = load if _VERSION:find(\"5.1\") then load = function(x, n, _, env) local f, e = loadstring(x, n) if not f then error(e, 2) end if env then setfenv(f, env) end return f end end") - return line_21_1(out11, "local _select, _unpack, _pack, _error = select, table.unpack, table.pack, error") +prelude1 = (function(out14) + line_21_1(out14, "if not table.pack then table.pack = function(...) return { n = select(\"#\", ...), ... } end end") + line_21_1(out14, "if not table.unpack then table.unpack = unpack end") + line_21_1(out14, "local load = load if _VERSION:find(\"5.1\") then load = function(x, n, _, env) local f, e = loadstring(x, n) if not f then error(e, 2) end if env then setfenv(f, env) end return f end end") + return line_21_1(out14, "local _select, _unpack, _pack, _error = select, table.unpack, table.pack, error") end) -expression2 = (function(node48, out12, state29, ret4) - runPass1(categoriseNode1, state29, nil, node48, state29["cat-lookup"], (ret4 ~= nil)) - return compileExpression1(node48, out12, state29, ret4) +expression2 = (function(node51, out15, state31, ret4) + runPass1(categoriseNode1, state31, nil, node51, state31["cat-lookup"], (ret4 ~= nil)) + return compileExpression1(node51, out15, state31, ret4) end) -block2 = (function(nodes23, out13, state30, start8, ret5) - runPass1(categoriseNodes1, state30, nil, nodes23, state30["cat-lookup"]) - return compileBlock1(nodes23, out13, state30, start8, ret5) +block2 = (function(nodes25, out16, state32, start8, ret5) + runPass1(categoriseNodes1, state32, nil, nodes25, state32["cat-lookup"]) + return compileBlock1(nodes25, out16, state32, start8, ret5) end) getinfo1 = debug.getinfo sethook1 = debug.sethook @@ -3916,30 +4015,30 @@ unmangleIdent1 = (function(ident1) return sub1(ident1, 3) else local buffer2 = ({tag = "list", n = 0}) - local pos8 = 0 - local len12 = len1(esc3) - local r_8461 = nil - r_8461 = (function() - if (pos8 <= len12) then + local pos9 = 0 + local len13 = len1(esc3) + local r_8621 = nil + r_8621 = (function() + if (pos9 <= len13) then local char3 - local x22 = pos8 + local x22 = pos9 char3 = sub1(esc3, x22, x22) if (char3 == "_") then - local r_8471 = list1(find1(esc3, "^_[%da-z]+_", pos8)) - if ((type1(r_8471) == "list") and ((r_8471["n"] >= 2) and ((r_8471["n"] <= 2) and true))) then - local start9 = r_8471[1] - local _eend1 = r_8471[2] - pos8 = (pos8 + 1) - local r_8531 = nil - r_8531 = (function() - if (pos8 < _eend1) then - pushCdr_21_1(buffer2, char1(tonumber1(sub1(esc3, pos8, (pos8 + 1)), 16))) - pos8 = (pos8 + 2) - return r_8531() + local r_8631 = list1(find1(esc3, "^_[%da-z]+_", pos9)) + if ((type1(r_8631) == "list") and ((r_8631["n"] >= 2) and ((r_8631["n"] <= 2) and true))) then + local start9 = r_8631[1] + local _eend1 = r_8631[2] + pos9 = (pos9 + 1) + local r_8691 = nil + r_8691 = (function() + if (pos9 < _eend1) then + pushCdr_21_1(buffer2, char1(tonumber1(sub1(esc3, pos9, (pos9 + 1)), 16))) + pos9 = (pos9 + 2) + return r_8691() else end end) - r_8531() + r_8691() else pushCdr_21_1(buffer2, "_") end @@ -3949,12 +4048,12 @@ unmangleIdent1 = (function(ident1) else pushCdr_21_1(buffer2, char3) end - pos8 = (pos8 + 1) - return r_8461() + pos9 = (pos9 + 1) + return r_8621() else end end) - r_8461() + r_8621() return concat1(buffer2) end end) @@ -3970,11 +4069,11 @@ remapError1 = (function(msg23) end))) end) remapMessage1 = (function(mappings1, msg24) - local r_8581 = list1(match1(msg24, "^(.-):(%d+)(.*)$")) - if ((type1(r_8581) == "list") and ((r_8581["n"] >= 3) and ((r_8581["n"] <= 3) and true))) then - local file1 = r_8581[1] - local line2 = r_8581[2] - local extra1 = r_8581[3] + local r_8741 = list1(match1(msg24, "^(.-):(%d+)(.*)$")) + if ((type1(r_8741) == "list") and ((r_8741["n"] >= 3) and ((r_8741["n"] <= 3) and true))) then + local file1 = r_8741[1] + local line2 = r_8741[2] + local extra1 = r_8741[3] local mapping1 = mappings1[file1] if mapping1 then local range3 = mapping1[tonumber1(line2)] @@ -3991,8 +4090,8 @@ remapMessage1 = (function(mappings1, msg24) end end) remapTraceback1 = (function(mappings2, msg25) - return gsub1(gsub1(gsub1(gsub1(gsub1(gsub1(gsub1(msg25, "^([^\n:]-:%d+:[^\n]*)", (function(r_8721) - return remapMessage1(mappings2, r_8721) + return gsub1(gsub1(gsub1(gsub1(gsub1(gsub1(gsub1(msg25, "^([^\n:]-:%d+:[^\n]*)", (function(r_8881) + return remapMessage1(mappings2, r_8881) end)), "\9([^\n:]-:%d+:)", (function(msg26) return _2e2e_2("\9", remapMessage1(mappings2, msg26)) end)), "<([^\n:]-:%d+)>\n", (function(msg27) @@ -4008,44 +4107,44 @@ remapTraceback1 = (function(mappings2, msg25) end)) end) generateMappings1 = (function(lines4) - local outLines1 = {} + local outLines1 = ({}) iterPairs1(lines4, (function(line3, ranges1) - local rangeLists1 = {} - iterPairs1(ranges1, (function(pos9) - local file2 = pos9["name"] + local rangeLists1 = ({}) + iterPairs1(ranges1, (function(pos10) + local file2 = pos10["name"] local rangeList1 = rangeLists1["file"] if rangeList1 then else - rangeList1 = struct1("n", 0, "min", huge1, "max", (0 - huge1)) + rangeList1 = ({["n"]=0,["min"]=huge1,["max"]=(0 - huge1)}) rangeLists1[file2] = rangeList1 end - local r_8751 = pos9["finish"]["line"] - local r_8731 = nil - r_8731 = (function(r_8741) - if (r_8741 <= r_8751) then - if rangeList1[r_8741] then + local r_8911 = pos10["finish"]["line"] + local r_8891 = nil + r_8891 = (function(r_8901) + if (r_8901 <= r_8911) then + if rangeList1[r_8901] then else rangeList1["n"] = (rangeList1["n"] + 1) - rangeList1[r_8741] = true - if (r_8741 < rangeList1["min"]) then - rangeList1["min"] = r_8741 + rangeList1[r_8901] = true + if (r_8901 < rangeList1["min"]) then + rangeList1["min"] = r_8901 end - if (r_8741 > rangeList1["max"]) then - rangeList1["max"] = r_8741 + if (r_8901 > rangeList1["max"]) then + rangeList1["max"] = r_8901 end end - return r_8731((r_8741 + 1)) + return r_8891((r_8901 + 1)) else end end) - return r_8731(pos9["start"]["line"]) + return r_8891(pos10["start"]["line"]) end)) local bestName1 = nil local bestLines1 = nil local bestCount1 = 0 - iterPairs1(rangeLists1, (function(name11, lines5) + iterPairs1(rangeLists1, (function(name12, lines5) if (lines5["n"] > bestCount1) then - bestName1 = name11 + bestName1 = name12 bestLines1 = lines5 bestCount1 = lines5["n"] return nil @@ -4063,234 +4162,234 @@ generateMappings1 = (function(lines4) end)) return outLines1 end) -struct1("remapTraceback", remapTraceback1) +local _ = ({["remapTraceback"]=remapTraceback1}) createState1 = (function(meta4) - return struct1("level", 1, "override", {}, "timer", void1, "count", 0, "mappings", {}, "cat-lookup", {}, "ctr-lookup", {}, "var-lookup", {}, "meta", (meta4 or {})) + return ({["level"]=1,["override"]=({}),["timer"]=void1,["count"]=0,["mappings"]=({}),["cat-lookup"]=({}),["ctr-lookup"]=({}),["var-lookup"]=({}),["meta"]=(meta4 or ({}))}) end) file3 = (function(compiler1, shebang1) - local state31 = createState1(compiler1["libMeta"]) - local out14 = create2() + local state33 = createState1(compiler1["libMeta"]) + local out17 = create2() if shebang1 then - line_21_1(out14, _2e2e_2("#!/usr/bin/env ", shebang1)) - end - state31["trace"] = true - prelude1(out14) - line_21_1(out14, "local _libs = {}") - local r_8991 = compiler1["libs"] - local r_9021 = r_8991["n"] - local r_9001 = nil - r_9001 = (function(r_9011) - if (r_9011 <= r_9021) then - local lib1 = r_8991[r_9011] + line_21_1(out17, _2e2e_2("#!/usr/bin/env ", shebang1)) + end + state33["trace"] = true + prelude1(out17) + line_21_1(out17, "local _libs = {}") + local r_9141 = compiler1["libs"] + local r_9171 = r_9141["n"] + local r_9151 = nil + r_9151 = (function(r_9161) + if (r_9161 <= r_9171) then + local lib1 = r_9141[r_9161] local prefix1 = quoted1(lib1["prefix"]) local native1 = lib1["native"] if native1 then - line_21_1(out14, "local _temp = (function()") - local r_9051 = split1(native1, "\n") - local r_9081 = r_9051["n"] - local r_9061 = nil - r_9061 = (function(r_9071) - if (r_9071 <= r_9081) then - local line4 = r_9051[r_9071] + line_21_1(out17, "local _temp = (function()") + local r_9201 = split1(native1, "\n") + local r_9231 = r_9201["n"] + local r_9211 = nil + r_9211 = (function(r_9221) + if (r_9221 <= r_9231) then + local line4 = r_9201[r_9221] if (line4 ~= "") then - append_21_1(out14, "\9") - line_21_1(out14, line4) + append_21_1(out17, "\9") + line_21_1(out17, line4) end - return r_9061((r_9071 + 1)) + return r_9211((r_9221 + 1)) else end end) - r_9061(1) - line_21_1(out14, "end)()") - line_21_1(out14, _2e2e_2("for k, v in pairs(_temp) do _libs[", prefix1, ".. k] = v end")) + r_9211(1) + line_21_1(out17, "end)()") + line_21_1(out17, _2e2e_2("for k, v in pairs(_temp) do _libs[", prefix1, ".. k] = v end")) end - return r_9001((r_9011 + 1)) + return r_9151((r_9161 + 1)) else end end) - r_9001(1) + r_9151(1) local count6 = 0 - local r_9111 = compiler1["out"] - local r_9141 = r_9111["n"] - local r_9121 = nil - r_9121 = (function(r_9131) - if (r_9131 <= r_9141) then - if r_9111[r_9131]["defVar"] then + local r_9261 = compiler1["out"] + local r_9291 = r_9261["n"] + local r_9271 = nil + r_9271 = (function(r_9281) + if (r_9281 <= r_9291) then + if r_9261[r_9281]["defVar"] then count6 = (count6 + 1) end - return r_9121((r_9131 + 1)) + return r_9271((r_9281 + 1)) else end end) - r_9121(1) + r_9271(1) if between_3f_1(count6, 1, 150) then - append_21_1(out14, "local ") + append_21_1(out17, "local ") local first8 = true - local r_9171 = compiler1["out"] - local r_9201 = r_9171["n"] - local r_9181 = nil - r_9181 = (function(r_9191) - if (r_9191 <= r_9201) then - local node49 = r_9171[r_9191] - local var23 = node49["defVar"] - if var23 then + local r_9321 = compiler1["out"] + local r_9351 = r_9321["n"] + local r_9331 = nil + r_9331 = (function(r_9341) + if (r_9341 <= r_9351) then + local node52 = r_9321[r_9341] + local var26 = node52["defVar"] + if var26 then if first8 then first8 = false else - append_21_1(out14, ", ") + append_21_1(out17, ", ") end - append_21_1(out14, escapeVar1(var23, state31)) + append_21_1(out17, escapeVar1(var26, state33)) end - return r_9181((r_9191 + 1)) + return r_9331((r_9341 + 1)) else end end) - r_9181(1) - line_21_1(out14) + r_9331(1) + line_21_1(out17) else - line_21_1(out14, "local _ENV = setmetatable({}, {__index=ENV or (getfenv and getfenv()) or _G}) if setfenv then setfenv(0, _ENV) end") + line_21_1(out17, "local _ENV = setmetatable({}, {__index=ENV or (getfenv and getfenv()) or _G}) if setfenv then setfenv(0, _ENV) end") end - block2(compiler1["out"], out14, state31, 1, "return ") - return out14 + block2(compiler1["out"], out17, state33, 1, "return ") + return out17 end) executeStates1 = (function(backState1, states1, global1, logger8) local stateList1 = ({tag = "list", n = 0}) local nameList1 = ({tag = "list", n = 0}) local exportList1 = ({tag = "list", n = 0}) local escapeList1 = ({tag = "list", n = 0}) - local r_6221 = nil - r_6221 = (function(r_6231) - if (r_6231 >= 1) then - local state32 = states1[r_6231] - if (state32["stage"] == "executed") then + local r_6551 = nil + r_6551 = (function(r_6561) + if (r_6561 >= 1) then + local state34 = states1[r_6561] + if (state34["stage"] == "executed") then else - local node50 - if state32["node"] then + local node53 + if state34["node"] then else - node50 = error1(_2e2e_2("State is in ", state32["stage"], " instead"), 0) + node53 = error1(_2e2e_2("State is in ", state34["stage"], " instead"), 0) end - local var24 = (state32["var"] or struct1("name", "temp")) - local escaped1 = escapeVar1(var24, backState1) - local name12 = var24["name"] - pushCdr_21_1(stateList1, state32) + local var27 = (state34["var"] or ({["name"]="temp"})) + local escaped1 = escapeVar1(var27, backState1) + local name13 = var27["name"] + pushCdr_21_1(stateList1, state34) pushCdr_21_1(exportList1, _2e2e_2(escaped1, " = ", escaped1)) - pushCdr_21_1(nameList1, name12) + pushCdr_21_1(nameList1, name13) pushCdr_21_1(escapeList1, escaped1) end - return r_6221((r_6231 + -1)) + return r_6551((r_6561 + -1)) else end end) - r_6221(states1["n"]) - if nil_3f_1(stateList1) then + r_6551(states1["n"]) + if empty_3f_1(stateList1) then else - local out15 = create2() + local out18 = create2() local id3 = backState1["count"] - local name13 = concat1(nameList1, ",") + local name14 = concat1(nameList1, ",") backState1["count"] = (id3 + 1) - if (len1(name13) > 20) then - name13 = _2e2e_2(sub1(name13, 1, 17), "...") - end - name13 = _2e2e_2("compile#", id3, "{", name13, "}") - prelude1(out15) - line_21_1(out15, _2e2e_2("local ", concat1(escapeList1, ", "))) - local r_9251 = stateList1["n"] - local r_9231 = nil - r_9231 = (function(r_9241) - if (r_9241 <= r_9251) then - local state33 = stateList1[r_9241] - expression2(state33["node"], out15, backState1, (function() - if state33["var"] then + if (len1(name14) > 20) then + name14 = _2e2e_2(sub1(name14, 1, 17), "...") + end + name14 = _2e2e_2("compile#", id3, "{", name14, "}") + prelude1(out18) + line_21_1(out18, _2e2e_2("local ", concat1(escapeList1, ", "))) + local r_9401 = stateList1["n"] + local r_9381 = nil + r_9381 = (function(r_9391) + if (r_9391 <= r_9401) then + local state35 = stateList1[r_9391] + expression2(state35["node"], out18, backState1, (function() + if state35["var"] then return "" else - return _2e2e_2(escapeList1[r_9241], "= ") + return _2e2e_2(escapeList1[r_9391], "= ") end end)() ) - line_21_1(out15) - return r_9231((r_9241 + 1)) + line_21_1(out18) + return r_9381((r_9391 + 1)) else end end) - r_9231(1) - line_21_1(out15, _2e2e_2("return { ", concat1(exportList1, ", "), "}")) - local str2 = concat1(out15["out"]) - backState1["mappings"][name13] = generateMappings1(out15["lines"]) - local r_9271 = list1(load1(str2, _2e2e_2("=", name13), "t", global1)) - if ((type1(r_9271) == "list") and ((r_9271["n"] >= 2) and ((r_9271["n"] <= 2) and (eq_3f_1(r_9271[1], nil) and true)))) then - local msg28 = r_9271[2] + r_9381(1) + line_21_1(out18, _2e2e_2("return { ", concat1(exportList1, ", "), "}")) + local str4 = concat1(out18["out"]) + backState1["mappings"][name14] = generateMappings1(out18["lines"]) + local r_9421 = list1(load1(str4, _2e2e_2("=", name14), "t", global1)) + if ((type1(r_9421) == "list") and ((r_9421["n"] >= 2) and ((r_9421["n"] <= 2) and (eq_3f_1(r_9421[1], nil) and true)))) then + local msg28 = r_9421[2] local buffer3 = ({tag = "list", n = 0}) - local lines6 = split1(str2, "\n") + local lines6 = split1(str4, "\n") local format2 = _2e2e_2("%", len1(tostring1(lines6["n"])), "d | %s") - local r_9361 = lines6["n"] - local r_9341 = nil - r_9341 = (function(r_9351) - if (r_9351 <= r_9361) then - pushCdr_21_1(buffer3, format1(format2, r_9351, lines6[r_9351])) - return r_9341((r_9351 + 1)) + local r_9511 = lines6["n"] + local r_9491 = nil + r_9491 = (function(r_9501) + if (r_9501 <= r_9511) then + pushCdr_21_1(buffer3, format1(format2, r_9501, lines6[r_9501])) + return r_9491((r_9501 + 1)) else end end) - r_9341(1) + r_9491(1) return error1(_2e2e_2(msg28, ":\n", concat1(buffer3, "\n")), 0) - elseif ((type1(r_9271) == "list") and ((r_9271["n"] >= 1) and ((r_9271["n"] <= 1) and true))) then - local fun1 = r_9271[1] - local r_9411 = list1(xpcall1(fun1, traceback1)) - if ((type1(r_9411) == "list") and ((r_9411["n"] >= 2) and ((r_9411["n"] <= 2) and (eq_3f_1(r_9411[1], false) and true)))) then - local msg29 = r_9411[2] + elseif ((type1(r_9421) == "list") and ((r_9421["n"] >= 1) and ((r_9421["n"] <= 1) and true))) then + local fun1 = r_9421[1] + local r_9561 = list1(xpcall1(fun1, traceback1)) + if ((type1(r_9561) == "list") and ((r_9561["n"] >= 2) and ((r_9561["n"] <= 2) and (eq_3f_1(r_9561[1], false) and true)))) then + local msg29 = r_9561[2] return error1(remapTraceback1(backState1["mappings"], msg29), 0) - elseif ((type1(r_9411) == "list") and ((r_9411["n"] >= 2) and ((r_9411["n"] <= 2) and (eq_3f_1(r_9411[1], true) and true)))) then - local tbl1 = r_9411[2] - local r_9541 = stateList1["n"] - local r_9521 = nil - r_9521 = (function(r_9531) - if (r_9531 <= r_9541) then - local state34 = stateList1[r_9531] - local escaped2 = escapeList1[r_9531] + elseif ((type1(r_9561) == "list") and ((r_9561["n"] >= 2) and ((r_9561["n"] <= 2) and (eq_3f_1(r_9561[1], true) and true)))) then + local tbl1 = r_9561[2] + local r_9691 = stateList1["n"] + local r_9671 = nil + r_9671 = (function(r_9681) + if (r_9681 <= r_9691) then + local state36 = stateList1[r_9681] + local escaped2 = escapeList1[r_9681] local res7 = tbl1[escaped2] - self1(state34, "executed", res7) - if state34["var"] then + self1(state36, "executed", res7) + if state36["var"] then global1[escaped2] = res7 end - return r_9521((r_9531 + 1)) + return r_9671((r_9681 + 1)) else end end) - return r_9521(1) + return r_9671(1) else - return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_9411), ", but none matched.\n", " Tried: `(false ?msg)`\n Tried: `(true ?tbl)`")) + return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_9561), ", but none matched.\n", " Tried: `(false ?msg)`\n Tried: `(true ?tbl)`")) end else - return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_9271), ", but none matched.\n", " Tried: `(nil ?msg)`\n Tried: `(?fun)`")) + return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_9421), ", but none matched.\n", " Tried: `(nil ?msg)`\n Tried: `(?fun)`")) end end end) -emitLua1 = struct1("name", "emit-lua", "setup", (function(spec6) +emitLua1 = ({["name"]="emit-lua",["setup"]=(function(spec6) addArgument_21_1(spec6, ({tag = "list", n = 1, "--emit-lua"}), "help", "Emit a Lua file.") addArgument_21_1(spec6, ({tag = "list", n = 1, "--shebang"}), "value", (arg1[-1] or (arg1[0] or "lua")), "help", "Set the executable to use for the shebang.", "narg", "?") return addArgument_21_1(spec6, ({tag = "list", n = 1, "--chmod"}), "help", "Run chmod +x on the resulting file") -end), "pred", (function(args14) +end),["pred"]=(function(args14) return args14["emit-lua"] -end), "run", (function(compiler2, args15) - if nil_3f_1(args15["input"]) then +end),["run"]=(function(compiler2, args15) + if empty_3f_1(args15["input"]) then self1(compiler2["log"], "put-error!", "No inputs to compile.") exit_21_1(1) end - local out16 = file3(compiler2, args15["shebang"]) + local out19 = file3(compiler2, args15["shebang"]) local handle1 = open1(_2e2e_2(args15["output"], ".lua"), "w") - self1(handle1, "write", concat1(out16["out"])) + self1(handle1, "write", concat1(out19["out"])) self1(handle1, "close") if args15["chmod"] then return execute1(_2e2e_2("chmod +x ", quoted1(_2e2e_2(args15["output"], ".lua")))) else end -end)) -emitLisp1 = struct1("name", "emit-lisp", "setup", (function(spec7) +end)}) +emitLisp1 = ({["name"]="emit-lisp",["setup"]=(function(spec7) return addArgument_21_1(spec7, ({tag = "list", n = 1, "--emit-lisp"}), "help", "Emit a Lisp file.") -end), "pred", (function(args16) +end),["pred"]=(function(args16) return args16["emit-lisp"] -end), "run", (function(compiler3, args17) - if nil_3f_1(args17["input"]) then +end),["run"]=(function(compiler3, args17) + if empty_3f_1(args17["input"]) then self1(compiler3["log"], "put-error!", "No inputs to compile.") exit_21_1(1) end @@ -4299,18 +4398,18 @@ end), "run", (function(compiler3, args17) local handle2 = open1(_2e2e_2(args17["output"], ".lisp"), "w") self1(handle2, "write", concat1(writer12["out"])) return self1(handle2, "close") -end)) -passArg1 = (function(arg24, data4, value10, usage_21_4) - local val18 = tonumber1(value10) - local name14 = _2e2e_2(arg24["name"], "-override") - local override2 = data4[name14] +end)}) +passArg1 = (function(arg23, data4, value10, usage_21_4) + local val17 = tonumber1(value10) + local name15 = _2e2e_2(arg23["name"], "-override") + local override2 = data4[name15] if override2 then else - override2 = {} - data4[name14] = override2 + override2 = ({}) + data4[name15] = override2 end - if val18 then - data4[arg24["name"]] = val18 + if val17 then + data4[arg23["name"]] = val17 return nil elseif (sub1(value10, 1, 1) == "-") then override2[sub1(value10, 2)] = false @@ -4319,244 +4418,194 @@ passArg1 = (function(arg24, data4, value10, usage_21_4) override2[sub1(value10, 2)] = true return nil else - return usage_21_4(_2e2e_2("Expected number or enable/disable flag for --", arg24["name"], " , got ", value10)) + return usage_21_4(_2e2e_2("Expected number or enable/disable flag for --", arg23["name"], " , got ", value10)) end end) -passRun1 = (function(fun2, name15, passes1) +passRun1 = (function(fun2, name16, passes1) return (function(compiler4, args18) - return fun2(compiler4["out"], struct1("track", true, "level", args18[name15], "override", (args18[_2e2e_2(name15, "-override")] or {}), "pass", compiler4[name15], "max-n", args18[_2e2e_2(name15, "-n")], "max-time", args18[_2e2e_2(name15, "-time")], "meta", compiler4["libMeta"], "libs", compiler4["libs"], "logger", compiler4["log"], "timer", compiler4["timer"])) + return fun2(compiler4["out"], ({["track"]=true,["level"]=args18[name16],["override"]=(args18[_2e2e_2(name16, "-override")] or ({})),["pass"]=compiler4[name16],["max-n"]=args18[_2e2e_2(name16, "-n")],["max-time"]=args18[_2e2e_2(name16, "-time")],["meta"]=compiler4["libMeta"],["libs"]=compiler4["libs"],["logger"]=compiler4["log"],["timer"]=compiler4["timer"]})) end) end) -warning1 = struct1("name", "warning", "setup", (function(spec8) +warning1 = ({["name"]="warning",["setup"]=(function(spec8) return addArgument_21_1(spec8, ({tag = "list", n = 2, "--warning", "-W"}), "help", "Either the warning level to use or an enable/disable flag for a pass.", "default", 1, "narg", 1, "var", "LEVEL", "action", passArg1) -end), "pred", (function(args19) +end),["pred"]=(function(args19) return (args19["warning"] > 0) -end), "run", passRun1(analyse1, "warning")) -optimise2 = struct1("name", "optimise", "setup", (function(spec9) +end),["run"]=passRun1(analyse1, "warning")}) +optimise2 = ({["name"]="optimise",["setup"]=(function(spec9) addArgument_21_1(spec9, ({tag = "list", n = 2, "--optimise", "-O"}), "help", "Either the optimiation level to use or an enable/disable flag for a pass.", "default", 1, "narg", 1, "var", "LEVEL", "action", passArg1) addArgument_21_1(spec9, ({tag = "list", n = 2, "--optimise-n", "--optn"}), "help", "The maximum number of iterations the optimiser should run for.", "default", 10, "narg", 1, "action", setNumAction1) return addArgument_21_1(spec9, ({tag = "list", n = 2, "--optimise-time", "--optt"}), "help", "The maximum time the optimiser should run for.", "default", -1, "narg", 1, "action", setNumAction1) -end), "pred", (function(args20) +end),["pred"]=(function(args20) return (args20["optimise"] > 0) -end), "run", passRun1(optimise1, "optimise")) -builtins4 = require1("tacky.analysis.resolve")["builtins"] -tokens1 = ({tag = "list", n = 7, ({tag = "list", n = 2, "arg", "(%f[%a]%u+%f[%A])"}), ({tag = "list", n = 2, "mono", "```[a-z]*\n([^`]*)\n```"}), ({tag = "list", n = 2, "mono", "`([^`]*)`"}), ({tag = "list", n = 2, "bolic", "(%*%*%*%w.-%w%*%*%*)"}), ({tag = "list", n = 2, "bold", "(%*%*%w.-%w%*%*)"}), ({tag = "list", n = 2, "italic", "(%*%w.-%w%*)"}), ({tag = "list", n = 2, "link", "%[%[(.-)%]%]"})}) -extractSignature1 = (function(var25) - local ty8 = type1(var25) - if ((ty8 == "macro") or (ty8 == "defined")) then - local root2 = var25["node"] - local node51 = root2[(root2["n"])] - if ((type1(node51) == "list") and ((type1((car1(node51))) == "symbol") and (car1(node51)["var"] == builtins4["lambda"]))) then - return node51[2] - else - return nil - end - else - return nil - end -end) -parseDocstring1 = (function(str3) - local out17 = ({tag = "list", n = 0}) - local pos10 = 1 - local len13 = len1(str3) - local r_9681 = nil - r_9681 = (function() - if (pos10 <= len13) then - local spos1 = len13 - local epos1 = nil - local name16 = nil - local ptrn1 = nil - local r_9731 = tokens1["n"] - local r_9711 = nil - r_9711 = (function(r_9721) - if (r_9721 <= r_9731) then - local tok1 = tokens1[r_9721] - local npos1 = list1(find1(str3, tok1[2], pos10)) - if (car1(npos1) and (car1(npos1) < spos1)) then - spos1 = car1(npos1) - epos1 = npos1[2] - name16 = car1(tok1) - ptrn1 = tok1[2] - end - return r_9711((r_9721 + 1)) - else - end - end) - r_9711(1) - if name16 then - if (pos10 < spos1) then - pushCdr_21_1(out17, struct1("tag", "text", "contents", sub1(str3, pos10, (spos1 - 1)))) - end - pushCdr_21_1(out17, struct1("tag", name16, "whole", sub1(str3, spos1, epos1), "contents", match1(sub1(str3, spos1, epos1), ptrn1))) - pos10 = (epos1 + 1) - else - pushCdr_21_1(out17, struct1("tag", "text", "contents", sub1(str3, pos10, len13))) - pos10 = (len13 + 1) - end - return r_9681() - else - end - end) - r_9681() - return out17 -end) -Scope1 = require1("tacky.analysis.scope") +end),["run"]=passRun1(optimise1, "optimise")}) +Scope2 = require1("tacky.analysis.scope") formatRange2 = (function(range4) return format1("%s:%s", range4["name"], (function(pos11) return _2e2e_2(pos11["line"], ":", pos11["column"]) end)(range4["start"])) end) sortVars_21_1 = (function(list5) - return sort1(list5, (function(a3, b3) - return (car1(a3) < car1(b3)) + return sort1(list5, (function(a2, b2) + return (car1(a2) < car1(b2)) end)) end) -formatDefinition1 = (function(var26) - local ty9 = type1(var26) +formatDefinition1 = (function(var28) + local ty9 = type1(var28) if (ty9 == "builtin") then return "Builtin term" elseif (ty9 == "macro") then - return _2e2e_2("Macro defined at ", formatRange2(getSource1(var26["node"]))) + return _2e2e_2("Macro defined at ", formatRange2(getSource1(var28["node"]))) elseif (ty9 == "native") then - return _2e2e_2("Native defined at ", formatRange2(getSource1(var26["node"]))) + return _2e2e_2("Native defined at ", formatRange2(getSource1(var28["node"]))) elseif (ty9 == "defined") then - return _2e2e_2("Defined at ", formatRange2(getSource1(var26["node"]))) + return _2e2e_2("Defined at ", formatRange2(getSource1(var28["node"]))) else _error("unmatched item") end end) -formatSignature1 = (function(name17, var27) - local sig1 = extractSignature1(var27) +formatSignature1 = (function(name17, var29) + local sig1 = extractSignature1(var29) if (sig1 == nil) then return name17 - elseif nil_3f_1(sig1) then + elseif empty_3f_1(sig1) then return _2e2e_2("(", name17, ")") else - return _2e2e_2("(", name17, " ", concat1(map1((function(r_9581) - return r_9581["contents"] + return _2e2e_2("(", name17, " ", concat1(map1((function(r_9731) + return r_9731["contents"] end), sig1), " "), ")") end end) -writeDocstring1 = (function(out18, str4, scope2) - local r_9601 = parseDocstring1(str4) - local r_9631 = r_9601["n"] - local r_9611 = nil - r_9611 = (function(r_9621) - if (r_9621 <= r_9631) then - local tok2 = r_9601[r_9621] - local ty10 = type1(tok2) +writeDocstring1 = (function(out20, str5, scope2) + local r_9751 = parseDocstring1(str5) + local r_9781 = r_9751["n"] + local r_9761 = nil + r_9761 = (function(r_9771) + if (r_9771 <= r_9781) then + local tok3 = r_9751[r_9771] + local ty10 = type1(tok3) if (ty10 == "text") then - append_21_1(out18, tok2["contents"]) + append_21_1(out20, tok3["contents"]) elseif (ty10 == "boldic") then - append_21_1(out18, tok2["contents"]) + append_21_1(out20, tok3["contents"]) elseif (ty10 == "bold") then - append_21_1(out18, tok2["contents"]) + append_21_1(out20, tok3["contents"]) elseif (ty10 == "italic") then - append_21_1(out18, tok2["contents"]) + append_21_1(out20, tok3["contents"]) elseif (ty10 == "arg") then - append_21_1(out18, _2e2e_2("`", tok2["contents"], "`")) + append_21_1(out20, _2e2e_2("`", tok3["contents"], "`")) elseif (ty10 == "mono") then - append_21_1(out18, tok2["whole"]) + append_21_1(out20, tok3["whole"]) elseif (ty10 == "link") then - local name18 = tok2["contents"] - local ovar1 = Scope1["get"](scope2, name18) + local name18 = tok3["contents"] + local ovar1 = Scope2["get"](scope2, name18) if (ovar1 and ovar1["node"]) then local loc1 = gsub1(gsub1(getSource1((ovar1["node"]))["name"], "%.lisp$", ""), "/", ".") local sig2 = extractSignature1(ovar1) - append_21_1(out18, format1("[`%s`](%s.md#%s)", name18, loc1, gsub1((function() + append_21_1(out20, format1("[`%s`](%s.md#%s)", name18, loc1, gsub1((function() if (sig2 == nil) then return ovar1["name"] - elseif nil_3f_1(sig2) then + elseif empty_3f_1(sig2) then return ovar1["name"] else - return _2e2e_2(name18, " ", concat1(map1((function(r_9771) - return r_9771["contents"] + return _2e2e_2(name18, " ", concat1(map1((function(r_9811) + return r_9811["contents"] end), sig2), " ")) end end)() , "%A+", "-"))) else - append_21_1(out18, format1("`%s`", name18)) + append_21_1(out20, format1("`%s`", name18)) end else _error("unmatched item") end - return r_9611((r_9621 + 1)) + return r_9761((r_9771 + 1)) else end end) - r_9611(1) - return line_21_1(out18) + r_9761(1) + return line_21_1(out20) end) -exported1 = (function(out19, title1, primary1, vars2, scope3) +exported1 = (function(out21, title1, primary1, vars2, scope3) local documented1 = ({tag = "list", n = 0}) local undocumented1 = ({tag = "list", n = 0}) - iterPairs1(vars2, (function(name19, var28) + iterPairs1(vars2, (function(name19, var30) return pushCdr_21_1((function() - if var28["doc"] then + if var30["doc"] then return documented1 else return undocumented1 end end)() - , list1(name19, var28)) + , list1(name19, var30)) end)) sortVars_21_1(documented1) sortVars_21_1(undocumented1) - line_21_1(out19, "---") - line_21_1(out19, _2e2e_2("title: ", title1)) - line_21_1(out19, "---") - line_21_1(out19, _2e2e_2("# ", title1)) + line_21_1(out21, "---") + line_21_1(out21, _2e2e_2("title: ", title1)) + line_21_1(out21, "---") + line_21_1(out21, _2e2e_2("# ", title1)) if primary1 then - writeDocstring1(out19, primary1, scope3) - line_21_1(out19, "", true) - end - local r_9861 = documented1["n"] - local r_9841 = nil - r_9841 = (function(r_9851) - if (r_9851 <= r_9861) then - local entry8 = documented1[r_9851] - local name20 = car1(entry8) - local var29 = entry8[2] - line_21_1(out19, _2e2e_2("## `", formatSignature1(name20, var29), "`")) - line_21_1(out19, _2e2e_2("*", formatDefinition1(var29), "*")) - line_21_1(out19, "", true) - writeDocstring1(out19, var29["doc"], var29["scope"]) - line_21_1(out19, "", true) - return r_9841((r_9851 + 1)) + writeDocstring1(out21, primary1, scope3) + line_21_1(out21, "", true) + end + local r_9901 = documented1["n"] + local r_9881 = nil + r_9881 = (function(r_9891) + if (r_9891 <= r_9901) then + local entry7 = documented1[r_9891] + local name20 = car1(entry7) + local var31 = entry7[2] + line_21_1(out21, _2e2e_2("## `", formatSignature1(name20, var31), "`")) + line_21_1(out21, _2e2e_2("*", formatDefinition1(var31), "*")) + line_21_1(out21, "", true) + if var31["deprecated"] then + line_21_1(out21, (function() + if string_3f_1(var31["deprecated"]) then + return format1("> **Warning:** %s is deprecated: %s", name20, var31["deprecated"]) + else + return format1("> **Warning:** %s is deprecated.", name20) + end + end)() + ) + line_21_1(out21, "", true) + end + writeDocstring1(out21, var31["doc"], var31["scope"]) + line_21_1(out21, "", true) + return r_9881((r_9891 + 1)) else end end) - r_9841(1) - if nil_3f_1(undocumented1) then + r_9881(1) + if empty_3f_1(undocumented1) then else - line_21_1(out19, "## Undocumented symbols") + line_21_1(out21, "## Undocumented symbols") end - local r_9921 = undocumented1["n"] - local r_9901 = nil - r_9901 = (function(r_9911) - if (r_9911 <= r_9921) then - local entry9 = undocumented1[r_9911] - local name21 = car1(entry9) - local var30 = entry9[2] - line_21_1(out19, _2e2e_2(" - `", formatSignature1(name21, var30), "` *", formatDefinition1(var30), "*")) - return r_9901((r_9911 + 1)) + local r_9961 = undocumented1["n"] + local r_9941 = nil + r_9941 = (function(r_9951) + if (r_9951 <= r_9961) then + local entry8 = undocumented1[r_9951] + local name21 = car1(entry8) + local var32 = entry8[2] + line_21_1(out21, _2e2e_2(" - `", formatSignature1(name21, var32), "` *", formatDefinition1(var32), "*")) + return r_9941((r_9951 + 1)) else end end) - return r_9901(1) + return r_9941(1) end) docs1 = (function(compiler5, args21) - if nil_3f_1(args21["input"]) then + if empty_3f_1(args21["input"]) then self1(compiler5["log"], "put-error!", "No inputs to generate documentation for.") exit_21_1(1) end - local r_9951 = args21["input"] - local r_9981 = r_9951["n"] - local r_9961 = nil - r_9961 = (function(r_9971) - if (r_9971 <= r_9981) then - local path1 = r_9951[r_9971] + local r_9991 = args21["input"] + local r_10021 = r_9991["n"] + local r_10001 = nil + r_10001 = (function(r_10011) + if (r_10011 <= r_10021) then + local path1 = r_9991[r_10011] if (sub1(path1, -5) == ".lisp") then path1 = sub1(path1, 1, -6) end @@ -4566,24 +4615,24 @@ docs1 = (function(compiler5, args21) local handle3 = open1(_2e2e_2(args21["docs"], "/", gsub1(path1, "/", "."), ".md"), "w") self1(handle3, "write", concat1(writer13["out"])) self1(handle3, "close") - return r_9961((r_9971 + 1)) + return r_10001((r_10011 + 1)) else end end) - return r_9961(1) + return r_10001(1) end) -task1 = struct1("name", "docs", "setup", (function(spec10) +task1 = ({["name"]="docs",["setup"]=(function(spec10) return addArgument_21_1(spec10, ({tag = "list", n = 1, "--docs"}), "help", "Specify the folder to emit documentation to.", "default", nil, "narg", 1) -end), "pred", (function(args22) +end),["pred"]=(function(args22) return (nil ~= args22["docs"]) -end), "run", docs1) +end),["run"]=docs1}) create3 = coroutine.create resume1 = coroutine.resume status1 = coroutine.status yield1 = coroutine.yield local discard1 = (function() end) -void2 = struct1("put-error!", discard1, "put-warning!", discard1, "put-verbose!", discard1, "put-debug!", discard1, "put-time!", discard1, "put-node-error!", discard1, "put-node-warning!", discard1) +void2 = ({["put-error!"]=discard1,["put-warning!"]=discard1,["put-verbose!"]=discard1,["put-debug!"]=discard1,["put-time!"]=discard1,["put-node-error!"]=discard1,["put-node-warning!"]=discard1}) hexDigit_3f_1 = (function(char4) return (between_3f_1(char4, "0", "9") or (between_3f_1(char4, "a", "f") or between_3f_1(char4, "A", "F"))) end) @@ -4603,18 +4652,26 @@ digitError_21_1 = (function(logger9, pos12, name22, char7) end)() ), pos12, nil, pos12, "Invalid digit here") end) -lex1 = (function(logger10, str5, name23) - str5 = gsub1(str5, "\13\n?", "\n") - local lines7 = split1(str5, "\n") +eofError_21_1 = (function(cont1, logger10, msg30, node54, explain4, ...) + local lines7 = _pack(...) lines7.tag = "list" + if cont1 then + return error1(({["msg"]=msg30,["cont"]=true}), 0) + else + return doNodeError_21_1(logger10, msg30, node54, explain4, unpack1(lines7, 1, lines7["n"])) + end +end) +lex1 = (function(logger11, str6, name23, cont2) + str6 = gsub1(str6, "\13\n?", "\n") + local lines8 = split1(str6, "\n") local line5 = 1 local column1 = 1 local offset6 = 1 - local length1 = len1(str5) - local out20 = ({tag = "list", n = 0}) + local length1 = len1(str6) + local out22 = ({tag = "list", n = 0}) local consume_21_1 = (function() - if ((function(xs14, x31) - return sub1(xs14, x31, x31) - end)(str5, offset6) == "\n") then + if ((function(xs13, x31) + return sub1(xs13, x31, x31) + end)(str6, offset6) == "\n") then line5 = (line5 + 1) column1 = 1 else @@ -4624,202 +4681,202 @@ lex1 = (function(logger10, str5, name23) return nil end) local range5 = (function(start10, finish2) - return {["start"]=start10,["finish"]=(finish2 or start10),["lines"]=lines7,["name"]=name23} + return ({["start"]=start10,["finish"]=(finish2 or start10),["lines"]=lines8,["name"]=name23}) end) local appendWith_21_1 = (function(data5, start11, finish3) - local start12 = (start11 or {["line"]=line5,["column"]=column1,["offset"]=offset6}) - local finish4 = (finish3 or {["line"]=line5,["column"]=column1,["offset"]=offset6}) + local start12 = (start11 or ({["line"]=line5,["column"]=column1,["offset"]=offset6})) + local finish4 = (finish3 or ({["line"]=line5,["column"]=column1,["offset"]=offset6})) data5["range"] = range5(start12, finish4) - data5["contents"] = sub1(str5, start12["offset"], finish4["offset"]) - return pushCdr_21_1(out20, data5) + data5["contents"] = sub1(str6, start12["offset"], finish4["offset"]) + return pushCdr_21_1(out22, data5) end) - local parseBase1 = (function(name24, p3, base1) + local parseBase1 = (function(name24, p2, base1) local start13 = offset6 local char8 - local xs15 = str5 + local xs14 = str6 local x32 = offset6 - char8 = sub1(xs15, x32, x32) - if p3(char8) then + char8 = sub1(xs14, x32, x32) + if p2(char8) then else - digitError_21_1(logger10, range5({["line"]=line5,["column"]=column1,["offset"]=offset6}), name24, char8) + digitError_21_1(logger11, range5(({["line"]=line5,["column"]=column1,["offset"]=offset6})), name24, char8) end - local xs16 = str5 + local xs15 = str6 local x33 = (offset6 + 1) - char8 = sub1(xs16, x33, x33) - local r_10511 = nil - r_10511 = (function() - if p3(char8) then + char8 = sub1(xs15, x33, x33) + local r_10711 = nil + r_10711 = (function() + if p2(char8) then consume_21_1() - local xs17 = str5 + local xs16 = str6 local x34 = (offset6 + 1) - char8 = sub1(xs17, x34, x34) - return r_10511() + char8 = sub1(xs16, x34, x34) + return r_10711() else end end) - r_10511() - return tonumber1(sub1(str5, start13, offset6), base1) + r_10711() + return tonumber1(sub1(str6, start13, offset6), base1) end) - local r_10221 = nil - r_10221 = (function() + local r_10421 = nil + r_10421 = (function() if (offset6 <= length1) then local char9 - local xs18 = str5 + local xs17 = str6 local x35 = offset6 - char9 = sub1(xs18, x35, x35) + char9 = sub1(xs17, x35, x35) if ((char9 == "\n") or ((char9 == "\9") or (char9 == " "))) then elseif (char9 == "(") then - appendWith_21_1({["tag"]="open",["close"]=")"}) + appendWith_21_1(({["tag"]="open",["close"]=")"})) elseif (char9 == ")") then - appendWith_21_1({["tag"]="close",["open"]="("}) + appendWith_21_1(({["tag"]="close",["open"]="("})) elseif (char9 == "[") then - appendWith_21_1({["tag"]="open",["close"]="]"}) + appendWith_21_1(({["tag"]="open",["close"]="]"})) elseif (char9 == "]") then - appendWith_21_1({["tag"]="close",["open"]="["}) + appendWith_21_1(({["tag"]="close",["open"]="["})) elseif (char9 == "{") then - appendWith_21_1({["tag"]="open-struct",["close"]="}"}) + appendWith_21_1(({["tag"]="open-struct",["close"]="}"})) elseif (char9 == "}") then - appendWith_21_1({["tag"]="close",["open"]="{"}) + appendWith_21_1(({["tag"]="close",["open"]="{"})) elseif (char9 == "'") then local start14 local finish5 - appendWith_21_1({["tag"]="quote"}, nil, nil) + appendWith_21_1(({["tag"]="quote"}), nil, nil) elseif (char9 == "`") then local start15 local finish6 - appendWith_21_1({["tag"]="syntax-quote"}, nil, nil) + appendWith_21_1(({["tag"]="syntax-quote"}), nil, nil) elseif (char9 == "~") then local start16 local finish7 - appendWith_21_1({["tag"]="quasiquote"}, nil, nil) + appendWith_21_1(({["tag"]="quasiquote"}), nil, nil) elseif (char9 == ",") then - if ((function(xs19, x36) - return sub1(xs19, x36, x36) - end)(str5, (offset6 + 1)) == "@") then - local start17 = {["line"]=line5,["column"]=column1,["offset"]=offset6} + if ((function(xs18, x36) + return sub1(xs18, x36, x36) + end)(str6, (offset6 + 1)) == "@") then + local start17 = ({["line"]=line5,["column"]=column1,["offset"]=offset6}) consume_21_1() local finish8 - appendWith_21_1({["tag"]="unquote-splice"}, start17, nil) + appendWith_21_1(({["tag"]="unquote-splice"}), start17, nil) else local start18 local finish9 - appendWith_21_1({["tag"]="unquote"}, nil, nil) + appendWith_21_1(({["tag"]="unquote"}), nil, nil) end - elseif find1(str5, "^%-?%.?[0-9]", offset6) then - local start19 = {["line"]=line5,["column"]=column1,["offset"]=offset6} + elseif find1(str6, "^%-?%.?[0-9]", offset6) then + local start19 = ({["line"]=line5,["column"]=column1,["offset"]=offset6}) local negative1 = (char9 == "-") if negative1 then consume_21_1() - local xs20 = str5 + local xs19 = str6 local x37 = offset6 - char9 = sub1(xs20, x37, x37) + char9 = sub1(xs19, x37, x37) end - local val19 - if ((char9 == "0") and (lower1((function(xs21, x38) - return sub1(xs21, x38, x38) - end)(str5, (offset6 + 1))) == "x")) then + local val18 + if ((char9 == "0") and (lower1((function(xs20, x38) + return sub1(xs20, x38, x38) + end)(str6, (offset6 + 1))) == "x")) then consume_21_1() consume_21_1() local res8 = parseBase1("hexadecimal", hexDigit_3f_1, 16) if negative1 then res8 = (0 - res8) end - val19 = res8 - elseif ((char9 == "0") and (lower1((function(xs22, x39) - return sub1(xs22, x39, x39) - end)(str5, (offset6 + 1))) == "b")) then + val18 = res8 + elseif ((char9 == "0") and (lower1((function(xs21, x39) + return sub1(xs21, x39, x39) + end)(str6, (offset6 + 1))) == "b")) then consume_21_1() consume_21_1() local res9 = parseBase1("binary", binDigit_3f_1, 2) if negative1 then res9 = (0 - res9) end - val19 = res9 + val18 = res9 else - local r_10351 = nil - r_10351 = (function() - if between_3f_1((function(xs23, x40) - return sub1(xs23, x40, x40) - end)(str5, (offset6 + 1)), "0", "9") then + local r_10551 = nil + r_10551 = (function() + if between_3f_1((function(xs22, x40) + return sub1(xs22, x40, x40) + end)(str6, (offset6 + 1)), "0", "9") then consume_21_1() - return r_10351() + return r_10551() else end end) - r_10351() - if ((function(xs24, x41) - return sub1(xs24, x41, x41) - end)(str5, (offset6 + 1)) == ".") then + r_10551() + if ((function(xs23, x41) + return sub1(xs23, x41, x41) + end)(str6, (offset6 + 1)) == ".") then consume_21_1() - local r_10361 = nil - r_10361 = (function() - if between_3f_1((function(xs25, x42) - return sub1(xs25, x42, x42) - end)(str5, (offset6 + 1)), "0", "9") then + local r_10561 = nil + r_10561 = (function() + if between_3f_1((function(xs24, x42) + return sub1(xs24, x42, x42) + end)(str6, (offset6 + 1)), "0", "9") then consume_21_1() - return r_10361() + return r_10561() else end end) - r_10361() + r_10561() end - local xs26 = str5 + local xs25 = str6 local x43 = (offset6 + 1) - char9 = sub1(xs26, x43, x43) + char9 = sub1(xs25, x43, x43) if ((char9 == "e") or (char9 == "E")) then consume_21_1() - local xs27 = str5 + local xs26 = str6 local x44 = (offset6 + 1) - char9 = sub1(xs27, x44, x44) + char9 = sub1(xs26, x44, x44) if ((char9 == "-") or (char9 == "+")) then consume_21_1() end - local r_10391 = nil - r_10391 = (function() - if between_3f_1((function(xs28, x45) - return sub1(xs28, x45, x45) - end)(str5, (offset6 + 1)), "0", "9") then + local r_10591 = nil + r_10591 = (function() + if between_3f_1((function(xs27, x45) + return sub1(xs27, x45, x45) + end)(str6, (offset6 + 1)), "0", "9") then consume_21_1() - return r_10391() + return r_10591() else end end) - r_10391() + r_10591() end - val19 = tonumber1(sub1(str5, start19["offset"], offset6)) + val18 = tonumber1(sub1(str6, start19["offset"], offset6)) end - appendWith_21_1({["tag"]="number",["value"]=val19}, start19) - local xs29 = str5 + appendWith_21_1(({["tag"]="number",["value"]=val18}), start19) + local xs28 = str6 local x46 = (offset6 + 1) - char9 = sub1(xs29, x46, x46) + char9 = sub1(xs28, x46, x46) if terminator_3f_1(char9) then else consume_21_1() - doNodeError_21_1(logger10, format1("Expected digit, got %s", (function() + doNodeError_21_1(logger11, format1("Expected digit, got %s", (function() if (char9 == "") then return "eof" else return char9 end end)() - ), range5({["line"]=line5,["column"]=column1,["offset"]=offset6}), nil, range5({["line"]=line5,["column"]=column1,["offset"]=offset6}), "Illegal character here. Are you missing whitespace?") + ), range5(({["line"]=line5,["column"]=column1,["offset"]=offset6})), nil, range5(({["line"]=line5,["column"]=column1,["offset"]=offset6})), "Illegal character here. Are you missing whitespace?") end elseif (char9 == "\"") then - local start20 = {["line"]=line5,["column"]=column1,["offset"]=offset6} + local start20 = ({["line"]=line5,["column"]=column1,["offset"]=offset6}) local startCol1 = (column1 + 1) local buffer4 = ({tag = "list", n = 0}) consume_21_1() - local xs30 = str5 + local xs29 = str6 local x47 = offset6 - char9 = sub1(xs30, x47, x47) - local r_10401 = nil - r_10401 = (function() + char9 = sub1(xs29, x47, x47) + local r_10601 = nil + r_10601 = (function() if (char9 ~= "\"") then if (column1 == 1) then local running3 = true local lineOff1 = offset6 - local r_10411 = nil - r_10411 = (function() + local r_10611 = nil + r_10611 = (function() if (running3 and (column1 < startCol1)) then if (char9 == " ") then consume_21_1() @@ -4830,28 +4887,28 @@ lex1 = (function(logger10, str5, name23) elseif (char9 == "") then running3 = false else - putNodeWarning_21_1(logger10, format1("Expected leading indent, got %q", char9), range5({["line"]=line5,["column"]=column1,["offset"]=offset6}), "You should try to align multi-line strings at the initial quote\nmark. This helps keep programs neat and tidy.", range5(start20), "String started with indent here", range5({["line"]=line5,["column"]=column1,["offset"]=offset6}), "Mis-aligned character here") - pushCdr_21_1(buffer4, sub1(str5, lineOff1, (offset6 - 1))) + putNodeWarning_21_1(logger11, format1("Expected leading indent, got %q", char9), range5(({["line"]=line5,["column"]=column1,["offset"]=offset6})), "You should try to align multi-line strings at the initial quote\nmark. This helps keep programs neat and tidy.", range5(start20), "String started with indent here", range5(({["line"]=line5,["column"]=column1,["offset"]=offset6})), "Mis-aligned character here") + pushCdr_21_1(buffer4, sub1(str6, lineOff1, (offset6 - 1))) running3 = false end - local xs31 = str5 + local xs30 = str6 local x48 = offset6 - char9 = sub1(xs31, x48, x48) - return r_10411() + char9 = sub1(xs30, x48, x48) + return r_10611() else end end) - r_10411() + r_10611() end if (char9 == "") then local start21 = range5(start20) - local finish10 = range5({["line"]=line5,["column"]=column1,["offset"]=offset6}) - doNodeError_21_1(logger10, "Expected '\"', got eof", finish10, nil, start21, "string started here", finish10, "end of file here") + local finish10 = range5(({["line"]=line5,["column"]=column1,["offset"]=offset6})) + eofError_21_1(cont2, logger11, "Expected '\"', got eof", finish10, nil, start21, "string started here", finish10, "end of file here") elseif (char9 == "\\") then consume_21_1() - local xs32 = str5 + local xs31 = str6 local x49 = offset6 - char9 = sub1(xs32, x49, x49) + char9 = sub1(xs31, x49, x49) if (char9 == "\n") then elseif (char9 == "a") then pushCdr_21_1(buffer4, "\7") @@ -4872,122 +4929,122 @@ lex1 = (function(logger10, str5, name23) elseif (char9 == "\\") then pushCdr_21_1(buffer4, "\\") elseif ((char9 == "x") or ((char9 == "X") or between_3f_1(char9, "0", "9"))) then - local start22 = {["line"]=line5,["column"]=column1,["offset"]=offset6} - local val20 + local start22 = ({["line"]=line5,["column"]=column1,["offset"]=offset6}) + local val19 if ((char9 == "x") or (char9 == "X")) then consume_21_1() local start23 = offset6 - if hexDigit_3f_1((function(xs33, x50) - return sub1(xs33, x50, x50) - end)(str5, offset6)) then + if hexDigit_3f_1((function(xs32, x50) + return sub1(xs32, x50, x50) + end)(str6, offset6)) then else - digitError_21_1(logger10, range5({["line"]=line5,["column"]=column1,["offset"]=offset6}), "hexadecimal", (function(xs34, x51) - return sub1(xs34, x51, x51) - end)(str5, offset6)) + digitError_21_1(logger11, range5(({["line"]=line5,["column"]=column1,["offset"]=offset6})), "hexadecimal", (function(xs33, x51) + return sub1(xs33, x51, x51) + end)(str6, offset6)) end - if hexDigit_3f_1((function(xs35, x52) - return sub1(xs35, x52, x52) - end)(str5, (offset6 + 1))) then + if hexDigit_3f_1((function(xs34, x52) + return sub1(xs34, x52, x52) + end)(str6, (offset6 + 1))) then consume_21_1() end - val20 = tonumber1(sub1(str5, start23, offset6), 16) + val19 = tonumber1(sub1(str6, start23, offset6), 16) else - local start24 = {["line"]=line5,["column"]=column1,["offset"]=offset6} + local start24 = ({["line"]=line5,["column"]=column1,["offset"]=offset6}) local ctr1 = 0 - local xs36 = str5 + local xs35 = str6 local x53 = (offset6 + 1) - char9 = sub1(xs36, x53, x53) - local r_10461 = nil - r_10461 = (function() + char9 = sub1(xs35, x53, x53) + local r_10661 = nil + r_10661 = (function() if ((ctr1 < 2) and between_3f_1(char9, "0", "9")) then consume_21_1() - local xs37 = str5 + local xs36 = str6 local x54 = (offset6 + 1) - char9 = sub1(xs37, x54, x54) + char9 = sub1(xs36, x54, x54) ctr1 = (ctr1 + 1) - return r_10461() + return r_10661() else end end) - r_10461() - val20 = tonumber1(sub1(str5, start24["offset"], offset6)) + r_10661() + val19 = tonumber1(sub1(str6, start24["offset"], offset6)) end - if (val20 >= 256) then - doNodeError_21_1(logger10, "Invalid escape code", range5(start22), nil, range5(start22, {["line"]=line5,["column"]=column1,["offset"]=offset6}), _2e2e_2("Must be between 0 and 255, is ", val20)) + if (val19 >= 256) then + doNodeError_21_1(logger11, "Invalid escape code", range5(start22), nil, range5(start22, ({["line"]=line5,["column"]=column1,["offset"]=offset6})), _2e2e_2("Must be between 0 and 255, is ", val19)) end - pushCdr_21_1(buffer4, char1(val20)) + pushCdr_21_1(buffer4, char1(val19)) elseif (char9 == "") then - doNodeError_21_1(logger10, "Expected escape code, got eof", range5({["line"]=line5,["column"]=column1,["offset"]=offset6}), nil, range5({["line"]=line5,["column"]=column1,["offset"]=offset6}), "end of file here") + eofError_21_1(cont2, logger11, "Expected escape code, got eof", range5(({["line"]=line5,["column"]=column1,["offset"]=offset6})), nil, range5(({["line"]=line5,["column"]=column1,["offset"]=offset6})), "end of file here") else - doNodeError_21_1(logger10, "Illegal escape character", range5({["line"]=line5,["column"]=column1,["offset"]=offset6}), nil, range5({["line"]=line5,["column"]=column1,["offset"]=offset6}), "Unknown escape character") + doNodeError_21_1(logger11, "Illegal escape character", range5(({["line"]=line5,["column"]=column1,["offset"]=offset6})), nil, range5(({["line"]=line5,["column"]=column1,["offset"]=offset6})), "Unknown escape character") end else pushCdr_21_1(buffer4, char9) end consume_21_1() - local xs38 = str5 + local xs37 = str6 local x55 = offset6 - char9 = sub1(xs38, x55, x55) - return r_10401() + char9 = sub1(xs37, x55, x55) + return r_10601() else end end) - r_10401() - appendWith_21_1({["tag"]="string",["value"]=concat1(buffer4)}, start20) + r_10601() + appendWith_21_1(({["tag"]="string",["value"]=concat1(buffer4)}), start20) elseif (char9 == ";") then - local r_10481 = nil - r_10481 = (function() - if ((offset6 <= length1) and ((function(xs39, x56) - return sub1(xs39, x56, x56) - end)(str5, (offset6 + 1)) ~= "\n")) then + local r_10681 = nil + r_10681 = (function() + if ((offset6 <= length1) and ((function(xs38, x56) + return sub1(xs38, x56, x56) + end)(str6, (offset6 + 1)) ~= "\n")) then consume_21_1() - return r_10481() + return r_10681() else end end) - r_10481() + r_10681() else - local start25 = {["line"]=line5,["column"]=column1,["offset"]=offset6} + local start25 = ({["line"]=line5,["column"]=column1,["offset"]=offset6}) local key10 = (char9 == ":") - local xs40 = str5 + local xs39 = str6 local x57 = (offset6 + 1) - char9 = sub1(xs40, x57, x57) - local r_10501 = nil - r_10501 = (function() + char9 = sub1(xs39, x57, x57) + local r_10701 = nil + r_10701 = (function() if not terminator_3f_1(char9) then consume_21_1() - local xs41 = str5 + local xs40 = str6 local x58 = (offset6 + 1) - char9 = sub1(xs41, x58, x58) - return r_10501() + char9 = sub1(xs40, x58, x58) + return r_10701() else end end) - r_10501() + r_10701() if key10 then - appendWith_21_1({["tag"]="key",["value"]=sub1(str5, (start25["offset"] + 1), offset6)}, start25) + appendWith_21_1(({["tag"]="key",["value"]=sub1(str6, (start25["offset"] + 1), offset6)}), start25) else local finish11 - appendWith_21_1({["tag"]="symbol"}, start25, nil) + appendWith_21_1(({["tag"]="symbol"}), start25, nil) end end consume_21_1() - return r_10221() + return r_10421() else end end) - r_10221() + r_10421() local start26 local finish12 - appendWith_21_1({["tag"]="eof"}, nil, nil) - return out20 + appendWith_21_1(({["tag"]="eof"}), nil, nil) + return out22 end) -parse1 = (function(logger11, toks1) +parse1 = (function(logger12, toks1, cont3) local head8 = ({tag = "list", n = 0}) local stack2 = ({tag = "list", n = 0}) - local append_21_2 = (function(node52) - pushCdr_21_1(head8, node52) - node52["parent"] = head8 + local append_21_2 = (function(node55) + pushCdr_21_1(head8, node55) + node55["parent"] = head8 return nil end) local push_21_1 = (function() @@ -5005,111 +5062,129 @@ parse1 = (function(logger11, toks1) head8 = last1(stack2) return popLast_21_1(stack2) end) - local r_10291 = toks1["n"] - local r_10271 = nil - r_10271 = (function(r_10281) - if (r_10281 <= r_10291) then - local tok3 = toks1[r_10281] - local tag10 = tok3["tag"] + local r_10491 = toks1["n"] + local r_10471 = nil + r_10471 = (function(r_10481) + if (r_10481 <= r_10491) then + local tok4 = toks1[r_10481] + local tag10 = tok4["tag"] local autoClose1 = false local previous2 = head8["last-node"] - local tokPos1 = tok3["range"] - local temp13 + local tokPos1 = tok4["range"] + local temp11 if (tag10 ~= "eof") then if (tag10 ~= "close") then if head8["range"] then - temp13 = (tokPos1["start"]["line"] ~= head8["range"]["start"]["line"]) + temp11 = (tokPos1["start"]["line"] ~= head8["range"]["start"]["line"]) else - temp13 = true + temp11 = true end else - temp13 = false + temp11 = false end else - temp13 = false + temp11 = false end - if temp13 then + if temp11 then if previous2 then local prevPos1 = previous2["range"] if (tokPos1["start"]["line"] ~= prevPos1["start"]["line"]) then - head8["last-node"] = tok3 + head8["last-node"] = tok4 if (tokPos1["start"]["column"] ~= prevPos1["start"]["column"]) then - putNodeWarning_21_1(logger11, "Different indent compared with previous expressions.", tok3, "You should try to maintain consistent indentation across a program,\ntry to ensure all expressions are lined up.\nIf this looks OK to you, check you're not missing a closing ')'.", prevPos1, "", tokPos1, "") + putNodeWarning_21_1(logger12, "Different indent compared with previous expressions.", tok4, "You should try to maintain consistent indentation across a program,\ntry to ensure all expressions are lined up.\nIf this looks OK to you, check you're not missing a closing ')'.", prevPos1, "", tokPos1, "") end end else - head8["last-node"] = tok3 + head8["last-node"] = tok4 end end if ((tag10 == "string") or ((tag10 == "number") or ((tag10 == "symbol") or (tag10 == "key")))) then - append_21_2(tok3) + append_21_2(tok4) elseif (tag10 == "open") then push_21_1() - head8["open"] = tok3["contents"] - head8["close"] = tok3["close"] - head8["range"] = {["start"]=tok3["range"]["start"],["name"]=tok3["range"]["name"],["lines"]=tok3["range"]["lines"]} + head8["open"] = tok4["contents"] + head8["close"] = tok4["close"] + head8["range"] = ({["start"]=tok4["range"]["start"],["name"]=tok4["range"]["name"],["lines"]=tok4["range"]["lines"]}) elseif (tag10 == "open-struct") then push_21_1() - head8["open"] = tok3["contents"] - head8["close"] = tok3["close"] - head8["range"] = {["start"]=tok3["range"]["start"],["name"]=tok3["range"]["name"],["lines"]=tok3["range"]["lines"]} - append_21_2({["tag"]="symbol",["contents"]="struct-literal",["range"]=head8["range"]}) + head8["open"] = tok4["contents"] + head8["close"] = tok4["close"] + head8["range"] = ({["start"]=tok4["range"]["start"],["name"]=tok4["range"]["name"],["lines"]=tok4["range"]["lines"]}) + append_21_2(({["tag"]="symbol",["contents"]="struct-literal",["range"]=head8["range"]})) elseif (tag10 == "close") then - if nil_3f_1(stack2) then - doNodeError_21_1(logger11, format1("'%s' without matching '%s'", tok3["contents"], tok3["open"]), tok3, nil, getSource1(tok3), "") + if empty_3f_1(stack2) then + doNodeError_21_1(logger12, format1("'%s' without matching '%s'", tok4["contents"], tok4["open"]), tok4, nil, getSource1(tok4), "") elseif head8["auto-close"] then - doNodeError_21_1(logger11, format1("'%s' without matching '%s' inside quote", tok3["contents"], tok3["open"]), tok3, nil, head8["range"], "quote opened here", tok3["range"], "attempting to close here") - elseif (head8["close"] ~= tok3["contents"]) then - doNodeError_21_1(logger11, format1("Expected '%s', got '%s'", head8["close"], tok3["contents"]), tok3, nil, head8["range"], format1("block opened with '%s'", head8["open"]), tok3["range"], format1("'%s' used here", tok3["contents"])) + doNodeError_21_1(logger12, format1("'%s' without matching '%s' inside quote", tok4["contents"], tok4["open"]), tok4, nil, head8["range"], "quote opened here", tok4["range"], "attempting to close here") + elseif (head8["close"] ~= tok4["contents"]) then + doNodeError_21_1(logger12, format1("Expected '%s', got '%s'", head8["close"], tok4["contents"]), tok4, nil, head8["range"], format1("block opened with '%s'", head8["open"]), tok4["range"], format1("'%s' used here", tok4["contents"])) else - head8["range"]["finish"] = tok3["range"]["finish"] + head8["range"]["finish"] = tok4["range"]["finish"] pop_21_1() end elseif ((tag10 == "quote") or ((tag10 == "unquote") or ((tag10 == "syntax-quote") or ((tag10 == "unquote-splice") or (tag10 == "quasiquote"))))) then push_21_1() - head8["range"] = {["start"]=tok3["range"]["start"],["name"]=tok3["range"]["name"],["lines"]=tok3["range"]["lines"]} - append_21_2({["tag"]="symbol",["contents"]=tag10,["range"]=tok3["range"]}) + head8["range"] = ({["start"]=tok4["range"]["start"],["name"]=tok4["range"]["name"],["lines"]=tok4["range"]["lines"]}) + append_21_2(({["tag"]="symbol",["contents"]=tag10,["range"]=tok4["range"]})) autoClose1 = true head8["auto-close"] = true elseif (tag10 == "eof") then if (0 ~= stack2["n"]) then - doNodeError_21_1(logger11, format1("Expected '%s', got 'eof'", head8["close"]), tok3, nil, head8["range"], "block opened here", tok3["range"], "end of file here") + eofError_21_1(cont3, logger12, format1("Expected '%s', got 'eof'", head8["close"]), tok4, nil, head8["range"], "block opened here", tok4["range"], "end of file here") end else error1(_2e2e_2("Unsupported type", tag10)) end if autoClose1 then else - local r_10621 = nil - r_10621 = (function() + local r_10821 = nil + r_10821 = (function() if head8["auto-close"] then - if nil_3f_1(stack2) then - doNodeError_21_1(logger11, format1("'%s' without matching '%s'", tok3["contents"], tok3["open"]), tok3, nil, getSource1(tok3), "") + if empty_3f_1(stack2) then + doNodeError_21_1(logger12, format1("'%s' without matching '%s'", tok4["contents"], tok4["open"]), tok4, nil, getSource1(tok4), "") end - head8["range"]["finish"] = tok3["range"]["finish"] + head8["range"]["finish"] = tok4["range"]["finish"] pop_21_1() - return r_10621() + return r_10821() else end end) - r_10621() + r_10821() end - return r_10271((r_10281 + 1)) + return r_10471((r_10481 + 1)) else end end) - r_10271(1) + r_10471(1) return head8 end) read2 = (function(x59, path2) return parse1(void2, lex1(void2, x59, (path2 or ""))) end) compile1 = require1("tacky.compile")["compile"] -Scope2 = require1("tacky.analysis.scope") -doParse1 = (function(compiler6, scope4, str6) - local logger12 = compiler6["log"] - local lexed1 = lex1(logger12, str6, "") - return car1(cdr1((list1(compile1(compiler6, executeStates1, parse1(logger12, lexed1), scope4))))) +Scope3 = require1("tacky.analysis.scope") +requiresInput1 = (function(str7) + local r_10041 = list1(pcall1((function() + return parse1(void2, lex1(void2, str7, "", true), true) + end))) + if ((type1(r_10041) == "list") and ((r_10041["n"] >= 2) and ((r_10041["n"] <= 2) and (eq_3f_1(r_10041[1], true) and true)))) then + return false + elseif ((type1(r_10041) == "list") and ((r_10041["n"] >= 2) and ((r_10041["n"] <= 2) and (eq_3f_1(r_10041[1], false) and (type_23_1((r_10041[2])) == "table"))))) then + if r_10041[2]["cont"] then + return true + else + return false + end + elseif ((type1(r_10041) == "list") and ((r_10041["n"] >= 2) and ((r_10041["n"] <= 2) and (eq_3f_1(r_10041[1], false) and true)))) then + return nil + else + return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_10041), ", but none matched.\n", " Tried: `(true _)`\n Tried: `(false (as table? ?x))`\n Tried: `(false _)`")) + end +end) +doResolve1 = (function(compiler6, scope4, str8) + local logger13 = compiler6["log"] + local lexed1 = lex1(logger13, str8, "") + return car1(cdr1((list1(compile1(compiler6, executeStates1, parse1(logger13, lexed1), scope4))))) end) local clrs1 = getenv1("URN_COLOURS") if clrs1 then @@ -5118,8 +5193,8 @@ else replColourScheme1 = nil end colourFor1 = (function(elem8) - if assoc_3f_1(replColourScheme1, struct1("tag", "symbol", "contents", elem8)) then - return constVal1(assoc1(replColourScheme1, struct1("tag", "symbol", "contents", elem8))) + if assoc_3f_1(replColourScheme1, ({["tag"]="symbol",["contents"]=elem8})) then + return constVal1(assoc1(replColourScheme1, ({["tag"]="symbol",["contents"]=elem8}))) else if (elem8 == "text") then return 0 @@ -5138,68 +5213,68 @@ colourFor1 = (function(elem8) end end end) -printDocs_21_1 = (function(str7) - local docs2 = parseDocstring1(str7) - local r_10051 = docs2["n"] - local r_10031 = nil - r_10031 = (function(r_10041) - if (r_10041 <= r_10051) then - local tok4 = docs2[r_10041] - local tag11 = tok4["tag"] +printDocs_21_1 = (function(str9) + local docs2 = parseDocstring1(str9) + local r_10251 = docs2["n"] + local r_10231 = nil + r_10231 = (function(r_10241) + if (r_10241 <= r_10251) then + local tok5 = docs2[r_10241] + local tag11 = tok5["tag"] if (tag11 == "bolic") then - write1(colored1(colourFor1("bold"), colored1(colourFor1("italic"), tok4["contents"]))) + write1(colored1(colourFor1("bold"), colored1(colourFor1("italic"), tok5["contents"]))) else - write1(colored1(colourFor1(tag11), tok4["contents"])) + write1(colored1(colourFor1(tag11), tok5["contents"])) end - return r_10031((r_10041 + 1)) + return r_10231((r_10241 + 1)) else end end) - r_10031(1) + r_10231(1) return print1() end) execCommand1 = (function(compiler7, scope5, args23) - local logger13 = compiler7["log"] + local logger14 = compiler7["log"] local command1 = car1(args23) if ((command1 == "help") or (command1 == "h")) then return print1("REPL commands:\n[:d]oc NAME Get documentation about a symbol\n:scope Print out all variables in the scope\n[:s]earch QUERY Search the current scope for symbols and documentation containing a string.\n:module NAME Display a loaded module's docs and definitions.") elseif ((command1 == "doc") or (command1 == "d")) then local name25 = args23[2] if name25 then - local var31 = Scope2["get"](scope5, name25) - if (var31 == nil) then - return self1(logger13, "put-error!", (_2e2e_2("Cannot find '", name25, "'"))) - elseif not var31["doc"] then - return self1(logger13, "put-error!", (_2e2e_2("No documentation for '", name25, "'"))) + local var33 = Scope3["get"](scope5, name25) + if (var33 == nil) then + return self1(logger14, "put-error!", (_2e2e_2("Cannot find '", name25, "'"))) + elseif not var33["doc"] then + return self1(logger14, "put-error!", (_2e2e_2("No documentation for '", name25, "'"))) else - local sig3 = extractSignature1(var31) - local name26 = var31["fullName"] + local sig3 = extractSignature1(var33) + local name26 = var33["fullName"] if sig3 then local buffer5 = list1(name26) - local r_10701 = sig3["n"] - local r_10681 = nil - r_10681 = (function(r_10691) - if (r_10691 <= r_10701) then - pushCdr_21_1(buffer5, sig3[r_10691]["contents"]) - return r_10681((r_10691 + 1)) + local r_10901 = sig3["n"] + local r_10881 = nil + r_10881 = (function(r_10891) + if (r_10891 <= r_10901) then + pushCdr_21_1(buffer5, sig3[r_10891]["contents"]) + return r_10881((r_10891 + 1)) else end end) - r_10681(1) + r_10881(1) name26 = _2e2e_2("(", concat1(buffer5, " "), ")") end print1(colored1(96, name26)) - return printDocs_21_1(var31["doc"]) + return printDocs_21_1(var33["doc"]) end else - return self1(logger13, "put-error!", ":doc ") + return self1(logger14, "put-error!", ":doc ") end elseif (command1 == "module") then local name27 = args23[2] if name27 then local mod1 = compiler7["libNames"][name27] if (mod1 == nil) then - return self1(logger13, "put-error!", (_2e2e_2("Cannot find '", name27, "'"))) + return self1(logger14, "put-error!", (_2e2e_2("Cannot find '", name27, "'"))) else print1(colored1(96, mod1["name"])) if mod1["docs"] then @@ -5215,16 +5290,16 @@ execCommand1 = (function(compiler7, scope5, args23) return print1(concat1(vars3, " ")) end else - return self1(logger13, "put-error!", ":module ") + return self1(logger14, "put-error!", ":module ") end elseif (command1 == "scope") then local vars4 = ({tag = "list", n = 0}) - local varsSet1 = {} + local varsSet1 = ({}) local current1 = scope5 - local r_10721 = nil - r_10721 = (function() + local r_10921 = nil + r_10921 = (function() if current1 then - iterPairs1(current1["variables"], (function(name29, var32) + iterPairs1(current1["variables"], (function(name29, var34) if varsSet1[name29] then else pushCdr_21_1(vars4, name29) @@ -5233,11 +5308,11 @@ execCommand1 = (function(compiler7, scope5, args23) end end)) current1 = current1["parent"] - return r_10721() + return r_10921() else end end) - r_10721() + r_10921() sort1(vars4) return print1(concat1(vars4, " ")) elseif ((command1 == "search") or (command1 == "s")) then @@ -5246,12 +5321,12 @@ execCommand1 = (function(compiler7, scope5, args23) local nameResults1 = ({tag = "list", n = 0}) local docsResults1 = ({tag = "list", n = 0}) local vars5 = ({tag = "list", n = 0}) - local varsSet2 = {} + local varsSet2 = ({}) local current2 = scope5 - local r_10741 = nil - r_10741 = (function() + local r_10941 = nil + r_10941 = (function() if current2 then - iterPairs1(current2["variables"], (function(name30, var33) + iterPairs1(current2["variables"], (function(name30, var35) if varsSet2[name30] then else pushCdr_21_1(vars5, name30) @@ -5260,29 +5335,29 @@ execCommand1 = (function(compiler7, scope5, args23) end end)) current2 = current2["parent"] - return r_10741() + return r_10941() else end end) - r_10741() - local r_10791 = vars5["n"] - local r_10771 = nil - r_10771 = (function(r_10781) - if (r_10781 <= r_10791) then - local var34 = vars5[r_10781] - local r_10851 = keywords2["n"] - local r_10831 = nil - r_10831 = (function(r_10841) - if (r_10841 <= r_10851) then - if find1(var34, (keywords2[r_10841])) then - pushCdr_21_1(nameResults1, var34) + r_10941() + local r_10991 = vars5["n"] + local r_10971 = nil + r_10971 = (function(r_10981) + if (r_10981 <= r_10991) then + local var36 = vars5[r_10981] + local r_11051 = keywords2["n"] + local r_11031 = nil + r_11031 = (function(r_11041) + if (r_11041 <= r_11051) then + if find1(var36, (keywords2[r_11041])) then + pushCdr_21_1(nameResults1, var36) end - return r_10831((r_10841 + 1)) + return r_11031((r_11041 + 1)) else end end) - r_10831(1) - local docVar1 = Scope2["get"](scope5, var34) + r_11031(1) + local docVar1 = Scope3["get"](scope5, var36) if docVar1 then local tempDocs1 = docVar1["doc"] if tempDocs1 then @@ -5290,20 +5365,20 @@ execCommand1 = (function(compiler7, scope5, args23) if docs3 then local keywordsFound1 = 0 if keywordsFound1 then - local r_10911 = keywords2["n"] - local r_10891 = nil - r_10891 = (function(r_10901) - if (r_10901 <= r_10911) then - if find1(docs3, (keywords2[r_10901])) then + local r_11111 = keywords2["n"] + local r_11091 = nil + r_11091 = (function(r_11101) + if (r_11101 <= r_11111) then + if find1(docs3, (keywords2[r_11101])) then keywordsFound1 = (keywordsFound1 + 1) end - return r_10891((r_10901 + 1)) + return r_11091((r_11101 + 1)) else end end) - r_10891(1) + r_11091(1) if eq_3f_1(keywordsFound1, keywords2["n"]) then - pushCdr_21_1(docsResults1, var34) + pushCdr_21_1(docsResults1, var36) end else end @@ -5313,15 +5388,15 @@ execCommand1 = (function(compiler7, scope5, args23) end else end - return r_10771((r_10781 + 1)) + return r_10971((r_10981 + 1)) else end end) - r_10771(1) - if (nil_3f_1(nameResults1) and nil_3f_1(docsResults1)) then - return self1(logger13, "put-error!", "No results") + r_10971(1) + if (empty_3f_1(nameResults1) and empty_3f_1(docsResults1)) then + return self1(logger14, "put-error!", "No results") else - if not nil_3f_1(nameResults1) then + if not empty_3f_1(nameResults1) then print1(colored1(92, "Search by function name:")) if (nameResults1["n"] > 20) then print1(_2e2e_2(concat1(slice1(nameResults1, 1, 20), " "), " ...")) @@ -5329,7 +5404,7 @@ execCommand1 = (function(compiler7, scope5, args23) print1(concat1(nameResults1, " ")) end end - if not nil_3f_1(docsResults1) then + if not empty_3f_1(docsResults1) then print1(colored1(92, "Search by function docs:")) if (docsResults1["n"] > 20) then return print1(_2e2e_2(concat1(slice1(docsResults1, 1, 20), " "), " ...")) @@ -5340,54 +5415,54 @@ execCommand1 = (function(compiler7, scope5, args23) end end else - return self1(logger13, "put-error!", ":search ") + return self1(logger14, "put-error!", ":search ") end else - return self1(logger13, "put-error!", (_2e2e_2("Unknown command '", command1, "'"))) + return self1(logger14, "put-error!", (_2e2e_2("Unknown command '", command1, "'"))) end end) execString1 = (function(compiler8, scope6, string1) - local state35 = doParse1(compiler8, scope6, string1) - if (state35["n"] > 0) then + local state37 = doResolve1(compiler8, scope6, string1) + if (state37["n"] > 0) then local current3 = 0 local exec1 = create3((function() - local r_11161 = state35["n"] - local r_11141 = nil - r_11141 = (function(r_11151) - if (r_11151 <= r_11161) then - local elem9 = state35[r_11151] + local r_11361 = state37["n"] + local r_11341 = nil + r_11341 = (function(r_11351) + if (r_11351 <= r_11361) then + local elem9 = state37[r_11351] current3 = elem9 self1(current3, "get") - return r_11141((r_11151 + 1)) + return r_11341((r_11351 + 1)) else end end) - return r_11141(1) + return r_11341(1) end)) local compileState1 = compiler8["compileState"] local rootScope1 = compiler8["rootScope"] local global2 = compiler8["global"] - local logger14 = compiler8["log"] + local logger15 = compiler8["log"] local run1 = true - local r_10071 = nil - r_10071 = (function() + local r_10271 = nil + r_10271 = (function() if run1 then local res10 = list1(resume1(exec1)) if not car1(res10) then - self1(logger14, "put-error!", (car1(cdr1(res10)))) + self1(logger15, "put-error!", (car1(cdr1(res10)))) run1 = false elseif (status1(exec1) == "dead") then - local lvl1 = self1(last1(state35), "get") + local lvl1 = self1(last1(state37), "get") print1(_2e2e_2("out = ", colored1(96, pretty1(lvl1)))) - global2[escapeVar1(Scope2["add"](scope6, "out", "defined", lvl1), compileState1)] = lvl1 + global2[escapeVar1(Scope3["add"](scope6, "out", "defined", lvl1), compileState1)] = lvl1 run1 = false else local states2 = car1(cdr1(res10))["states"] local latest1 = car1(states2) local co1 = create3(executeStates1) local task2 = nil - local r_10941 = nil - r_10941 = (function() + local r_11141 = nil + r_11141 = (function() if (run1 and (status1(co1) ~= "dead")) then compiler8["active-node"] = latest1["node"] compiler8["active-scope"] = latest1["scope"] @@ -5395,7 +5470,7 @@ execString1 = (function(compiler8, scope6, string1) if task2 then res11 = list1(resume1(co1)) else - res11 = list1(resume1(co1, compileState1, states2, global2, logger14)) + res11 = list1(resume1(co1, compileState1, states2, global2, logger15)) end compiler8["active-node"] = nil compiler8["active-scope"] = nil @@ -5403,43 +5478,43 @@ execString1 = (function(compiler8, scope6, string1) error1((res11[2]), 0) elseif ((type1(res11) == "list") and ((res11["n"] >= 1) and ((res11["n"] <= 1) and eq_3f_1(res11[1], true)))) then elseif ((type1(res11) == "list") and ((res11["n"] >= 2) and ((res11["n"] <= 2) and (eq_3f_1(res11[1], true) and true)))) then - local arg25 = res11[2] + local arg24 = res11[2] if (status1(co1) ~= "dead") then - task2 = arg25 - local r_11111 = task2["tag"] - if (r_11111 == "execute") then - executeStates1(compileState1, task2["states"], global2, logger14) + task2 = arg24 + local r_11311 = task2["tag"] + if (r_11311 == "execute") then + executeStates1(compileState1, task2["states"], global2, logger15) else - _2e2e_2("Cannot handle ", r_11111) + _2e2e_2("Cannot handle ", r_11311) end end else error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(res11), ", but none matched.\n", " Tried: `(false ?msg)`\n Tried: `(true)`\n Tried: `(true ?arg)`")) end - return r_10941() + return r_11141() else end end) - r_10941() + r_11141() end - return r_10071() + return r_10271() else end end) - return r_10071() + return r_10271() else end end) repl1 = (function(compiler9) local scope7 = compiler9["rootScope"] - local logger15 = compiler9["log"] - local buffer6 = ({tag = "list", n = 0}) + local logger16 = compiler9["log"] + local buffer6 = "" local running4 = true - local r_10081 = nil - r_10081 = (function() + local r_10281 = nil + r_10281 = (function() if running4 then write1(colored1(92, (function() - if nil_3f_1(buffer6) then + if empty_3f_1(buffer6) then return "> " else return ". " @@ -5448,60 +5523,62 @@ repl1 = (function(compiler9) )) flush1() local line6 = read1("*l") - if (not line6 and nil_3f_1(buffer6)) then + if (not line6 and empty_3f_1(buffer6)) then running4 = false - elseif (line6 and ((function(x60) - return sub1(line6, x60, x60) - end)(len1(line6)) == "\\")) then - pushCdr_21_1(buffer6, _2e2e_2(sub1(line6, 1, (len1(line6) - 1)), "\n")) - elseif (line6 and ((buffer6["n"] > 0) and (len1(line6) > 0))) then - pushCdr_21_1(buffer6, _2e2e_2(line6, "\n")) else - local data6 = _2e2e_2(concat1(buffer6), (line6 or "")) - buffer6 = ({tag = "list", n = 0}) + local data6 + if line6 then + data6 = _2e2e_2(buffer6, line6, "\n") + else + data6 = buffer6 + end if (sub1(data6, 1, 1) == ":") then - execCommand1(compiler9, scope7, split1(sub1(data6, 2), " ")) + buffer6 = "" + execCommand1(compiler9, scope7, map1(trim1, split1(sub1(data6, 2), " "))) + elseif (line6 and ((len1(line6) > 0) and requiresInput1(data6))) then + buffer6 = data6 else - scope7 = Scope2["child"](scope7) + buffer6 = "" + scope7 = Scope3["child"](scope7) scope7["isRoot"] = true local res12 = list1(pcall1(execString1, compiler9, scope7, data6)) compiler9["active-node"] = nil compiler9["active-scope"] = nil if car1(res12) then else - self1(logger15, "put-error!", (car1(cdr1(res12)))) + self1(logger16, "put-error!", (car1(cdr1(res12)))) end end end - return r_10081() + return r_10281() else end end) - return r_10081() + return r_10281() end) exec2 = (function(compiler10) local data7 = read1("*a") local scope8 = compiler10["rootScope"] - local logger16 = compiler10["log"] + local logger17 = compiler10["log"] local res13 = list1(pcall1(execString1, compiler10, scope8, data7)) if car1(res13) then else - self1(logger16, "put-error!", (car1(cdr1(res13)))) + self1(logger17, "put-error!", (car1(cdr1(res13)))) end return exit1(0) end) -replTask1 = struct1("name", "repl", "setup", (function(spec11) +replTask1 = ({["name"]="repl",["setup"]=(function(spec11) return addArgument_21_1(spec11, ({tag = "list", n = 1, "--repl"}), "help", "Start an interactive session.") -end), "pred", (function(args24) +end),["pred"]=(function(args24) return args24["repl"] -end), "run", repl1) -execTask1 = struct1("name", "exec", "setup", (function(spec12) +end),["run"]=repl1}) +execTask1 = ({["name"]="exec",["setup"]=(function(spec12) return addArgument_21_1(spec12, ({tag = "list", n = 1, "--exec"}), "help", "Execute a program without compiling it.") -end), "pred", (function(args25) +end),["pred"]=(function(args25) return args25["exec"] -end), "run", exec2) -profileCalls1 = (function(fn2, mappings3) - local stats1 = {} +end),["run"]=exec2}) +profileCalls1 = (function(fn3, mappings3) + local stats1 = ({}) local callStack1 = ({tag = "list", n = 0}) sethook1((function(action1) local info1 = getinfo1(2, "Sn") @@ -5513,27 +5590,19 @@ profileCalls1 = (function(fn2, mappings3) end end if (action1 ~= "call") then - if nil_3f_1(callStack1) then + if empty_3f_1(callStack1) then else local current4 = popLast_21_1(callStack1) local hash1 = (current4["source"] .. current4["linedefined"]) - local entry10 = stats1[hash1] - if entry10 then + local entry9 = stats1[hash1] + if entry9 then else - local r_11781 = {} - r_11781["source"] = current4["source"] - r_11781["short-src"] = current4["short_src"] - r_11781["line"] = current4["linedefined"] - r_11781["name"] = current4["name"] - r_11781["calls"] = 0 - r_11781["totalTime"] = 0 - r_11781["innerTime"] = 0 - entry10 = r_11781 - stats1[hash1] = entry10 + entry9 = ({["source"]=current4["source"],["short-src"]=current4["short_src"],["line"]=current4["linedefined"],["name"]=current4["name"],["calls"]=0,["totalTime"]=0,["innerTime"]=0}) + stats1[hash1] = entry9 end - entry10["calls"] = (1 + entry10["calls"]) - entry10["totalTime"] = (entry10["totalTime"] + (start27 - current4["totalStart"])) - entry10["innerTime"] = (entry10["innerTime"] + (current4["sum"] + (start27 - current4["innerStart"]))) + entry9["calls"] = (1 + entry9["calls"]) + entry9["totalTime"] = (entry9["totalTime"] + (start27 - current4["totalStart"])) + entry9["innerTime"] = (entry9["innerTime"] + (current4["sum"] + (start27 - current4["innerStart"]))) end end if (action1 ~= "return") then @@ -5552,32 +5621,32 @@ profileCalls1 = (function(fn2, mappings3) else end end), "cr") - fn2() + fn3() sethook1() - local out21 = values1(stats1) - sort1(out21, (function(a4, b4) - return (a4["innerTime"] > b4["innerTime"]) + local out23 = values1(stats1) + sort1(out23, (function(a3, b3) + return (a3["innerTime"] > b3["innerTime"]) end)) print1("| Method | Location | Total | Inner | Calls |") print1("| -------------------- | ------------------------------------------------------------ | -------- | -------- | ------- |") - local r_11831 = out21["n"] - local r_11811 = nil - r_11811 = (function(r_11821) - if (r_11821 <= r_11831) then - local entry11 = out21[r_11821] + local r_11541 = out23["n"] + local r_11521 = nil + r_11521 = (function(r_11531) + if (r_11531 <= r_11541) then + local entry10 = out23[r_11531] print1(format1("| %20s | %-60s | %8.5f | %8.5f | %7d | ", (function() - if entry11["name"] then - return unmangleIdent1(entry11["name"]) + if entry10["name"] then + return unmangleIdent1(entry10["name"]) else return "" end end)() - , remapMessage1(mappings3, _2e2e_2(entry11["short-src"], ":", entry11["line"])), entry11["totalTime"], entry11["innerTime"], entry11["calls"])) - return r_11811((r_11821 + 1)) + , remapMessage1(mappings3, _2e2e_2(entry10["short-src"], ":", entry10["line"])), entry10["totalTime"], entry10["innerTime"], entry10["calls"])) + return r_11521((r_11531 + 1)) else end end) - r_11811(1) + r_11521(1) return stats1 end) buildStack1 = (function(parent1, stack3, i10, history1, fold1) @@ -5648,23 +5717,23 @@ finishStack1 = (function(element1) else end end)) - sort1(children1, (function(a5, b5) - return (a5["n"] > b5["n"]) + sort1(children1, (function(a4, b4) + return (a4["n"] > b4["n"]) end)) element1["children"] = children1 - local r_11361 = children1["n"] - local r_11341 = nil - r_11341 = (function(r_11351) - if (r_11351 <= r_11361) then - finishStack1((children1[r_11351])) - return r_11341((r_11351 + 1)) + local r_11601 = children1["n"] + local r_11581 = nil + r_11581 = (function(r_11591) + if (r_11591 <= r_11601) then + finishStack1((children1[r_11591])) + return r_11581((r_11591 + 1)) else end end) - return r_11341(1) + return r_11581(1) end) -showStack_21_1 = (function(out22, mappings4, total1, stack5, remaining2) - line_21_1(out22, format1("└ %s %s %d (%2.5f%%)", (function() +showStack_21_1 = (function(out24, mappings4, total1, stack5, remaining2) + line_21_1(out24, format1("└ %s %s %d (%2.5f%%)", (function() if stack5["name"] then return unmangleIdent1(stack5["name"]) else @@ -5672,26 +5741,26 @@ showStack_21_1 = (function(out22, mappings4, total1, stack5, remaining2) end end)() , remapMessage1(mappings4, _2e2e_2(stack5["short_src"], ":", stack5["linedefined"])), stack5["n"], ((stack5["n"] / total1) * 100))) - local temp14 + local temp12 if remaining2 then - temp14 = (remaining2 >= 1) + temp12 = (remaining2 >= 1) else - temp14 = true - end - if temp14 then - out22["indent"] = (out22["indent"] + 1) - local r_11391 = stack5["children"] - local r_11421 = r_11391["n"] - local r_11401 = nil - r_11401 = (function(r_11411) - if (r_11411 <= r_11421) then - showStack_21_1(out22, mappings4, total1, r_11391[r_11411], (remaining2 and (remaining2 - 1))) - return r_11401((r_11411 + 1)) + temp12 = true + end + if temp12 then + out24["indent"] = (out24["indent"] + 1) + local r_11631 = stack5["children"] + local r_11661 = r_11631["n"] + local r_11641 = nil + r_11641 = (function(r_11651) + if (r_11651 <= r_11661) then + showStack_21_1(out24, mappings4, total1, r_11631[r_11651], (remaining2 and (remaining2 - 1))) + return r_11641((r_11651 + 1)) else end end) - r_11401(1) - out22["indent"] = (out22["indent"] - 1) + r_11641(1) + out24["indent"] = (out24["indent"] - 1) return nil else end @@ -5706,37 +5775,37 @@ showFlame_21_1 = (function(mappings5, stack6, before1, remaining3) end)() , "`", remapMessage1(mappings5, _2e2e_2(stack6["short_src"], ":", stack6["linedefined"]))) print1(format1("%s%s %d", before1, renamed1, stack6["n"])) - local temp15 + local temp13 if remaining3 then - temp15 = (remaining3 >= 1) + temp13 = (remaining3 >= 1) else - temp15 = true + temp13 = true end - if temp15 then + if temp13 then local whole1 = _2e2e_2(before1, renamed1, ";") - local r_11261 = stack6["children"] - local r_11291 = r_11261["n"] - local r_11271 = nil - r_11271 = (function(r_11281) - if (r_11281 <= r_11291) then - showFlame_21_1(mappings5, r_11261[r_11281], whole1, (remaining3 and (remaining3 - 1))) - return r_11271((r_11281 + 1)) + local r_11441 = stack6["children"] + local r_11471 = r_11441["n"] + local r_11451 = nil + r_11451 = (function(r_11461) + if (r_11461 <= r_11471) then + showFlame_21_1(mappings5, r_11441[r_11461], whole1, (remaining3 and (remaining3 - 1))) + return r_11451((r_11461 + 1)) else end end) - return r_11271(1) + return r_11451(1) else end end) -profileStack1 = (function(fn3, mappings6, args26) +profileStack1 = (function(fn4, mappings6, args26) local stacks1 = ({tag = "list", n = 0}) local top1 = getinfo1(2, "S") sethook1((function(action2) local pos13 = 3 local stack7 = ({tag = "list", n = 0}) local info2 = getinfo1(2, "Sn") - local r_11451 = nil - r_11451 = (function() + local r_11691 = nil + r_11691 = (function() if info2 then if ((info2["source"] == top1["source"]) and (info2["linedefined"] == top1["linedefined"])) then info2 = nil @@ -5745,35 +5814,31 @@ profileStack1 = (function(fn3, mappings6, args26) pos13 = (pos13 + 1) info2 = getinfo1(pos13, "Sn") end - return r_11451() + return r_11691() else end end) - r_11451() + r_11691() return pushCdr_21_1(stacks1, stack7) end), "", 100000.0) - fn3() + fn4() sethook1() - local folded1 - local r_11851 = {} - r_11851["n"] = 0 - r_11851["name"] = "" - folded1 = r_11851 - local r_11511 = stacks1["n"] - local r_11491 = nil - r_11491 = (function(r_11501) - if (r_11501 <= r_11511) then - local stack8 = stacks1[r_11501] + local folded1 = ({["n"]=0,["name"]=""}) + local r_11751 = stacks1["n"] + local r_11731 = nil + r_11731 = (function(r_11741) + if (r_11741 <= r_11751) then + local stack8 = stacks1[r_11741] if (args26["stack-kind"] == "reverse") then - buildRevStack1(folded1, stack8, 1, {}, args26["stack-fold"]) + buildRevStack1(folded1, stack8, 1, ({}), args26["stack-fold"]) else - buildStack1(folded1, stack8, stack8["n"], {}, args26["stack-fold"]) + buildStack1(folded1, stack8, stack8["n"], ({}), args26["stack-fold"]) end - return r_11491((r_11501 + 1)) + return r_11731((r_11741 + 1)) else end end) - r_11491(1) + r_11731(1) finishStack1(folded1) if (args26["stack-show"] == "flame") then return showFlame_21_1(mappings6, folded1, "", (args26["stack-limit"] or 30)) @@ -5784,56 +5849,56 @@ profileStack1 = (function(fn3, mappings6, args26) end end) runLua1 = (function(compiler11, args27) - if nil_3f_1(args27["input"]) then + if empty_3f_1(args27["input"]) then self1(compiler11["log"], "put-error!", "No inputs to run.") exit_21_1(1) end - local out23 = file3(compiler11, false) - local lines8 = generateMappings1(out23["lines"]) - local logger17 = compiler11["log"] + local out25 = file3(compiler11, false) + local lines9 = generateMappings1(out25["lines"]) + local logger18 = compiler11["log"] local name31 = _2e2e_2((args27["output"] or "out"), ".lua") - local r_11551 = list1(load1(concat1(out23["out"]), _2e2e_2("=", name31))) - if ((type1(r_11551) == "list") and ((r_11551["n"] >= 2) and ((r_11551["n"] <= 2) and (eq_3f_1(r_11551[1], nil) and true)))) then - local msg30 = r_11551[2] - self1(logger17, "put-error!", "Cannot load compiled source.") - print1(msg30) - print1(concat1(out23["out"])) + local r_11791 = list1(load1(concat1(out25["out"]), _2e2e_2("=", name31))) + if ((type1(r_11791) == "list") and ((r_11791["n"] >= 2) and ((r_11791["n"] <= 2) and (eq_3f_1(r_11791[1], nil) and true)))) then + local msg31 = r_11791[2] + self1(logger18, "put-error!", "Cannot load compiled source.") + print1(msg31) + print1(concat1(out25["out"])) return exit_21_1(1) - elseif ((type1(r_11551) == "list") and ((r_11551["n"] >= 1) and ((r_11551["n"] <= 1) and true))) then - local fun3 = r_11551[1] + elseif ((type1(r_11791) == "list") and ((r_11791["n"] >= 1) and ((r_11791["n"] <= 1) and true))) then + local fun3 = r_11791[1] _5f_G1["arg"] = args27["script-args"] _5f_G1["arg"][0] = car1(args27["input"]) local exec3 = (function() - local r_11661 = list1(xpcall1(fun3, traceback1)) - if ((type1(r_11661) == "list") and ((r_11661["n"] >= 1) and (eq_3f_1(r_11661[1], true) and true))) then - local res14 = slice1(r_11661, 2) - elseif ((type1(r_11661) == "list") and ((r_11661["n"] >= 2) and ((r_11661["n"] <= 2) and (eq_3f_1(r_11661[1], false) and true)))) then - local msg31 = r_11661[2] - self1(logger17, "put-error!", "Execution failed.") - print1(remapTraceback1(struct1(name31, lines8), msg31)) + local r_11901 = list1(xpcall1(fun3, traceback1)) + if ((type1(r_11901) == "list") and ((r_11901["n"] >= 1) and (eq_3f_1(r_11901[1], true) and true))) then + local res14 = slice1(r_11901, 2) + elseif ((type1(r_11901) == "list") and ((r_11901["n"] >= 2) and ((r_11901["n"] <= 2) and (eq_3f_1(r_11901[1], false) and true)))) then + local msg32 = r_11901[2] + self1(logger18, "put-error!", "Execution failed.") + print1(remapTraceback1(({[name31]=lines9}), msg32)) return exit_21_1(1) else - return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_11661), ", but none matched.\n", " Tried: `(true . ?res)`\n Tried: `(false ?msg)`")) + return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_11901), ", but none matched.\n", " Tried: `(true . ?res)`\n Tried: `(false ?msg)`")) end end) - local r_11651 = args27["profile"] - if (r_11651 == "none") then + local r_11891 = args27["profile"] + if (r_11891 == "none") then return exec3() - elseif eq_3f_1(r_11651, nil) then + elseif eq_3f_1(r_11891, nil) then return exec3() - elseif (r_11651 == "call") then - return profileCalls1(exec3, struct1(name31, lines8)) - elseif (r_11651 == "stack") then - return profileStack1(exec3, struct1(name31, lines8), args27) + elseif (r_11891 == "call") then + return profileCalls1(exec3, ({[name31]=lines9})) + elseif (r_11891 == "stack") then + return profileStack1(exec3, ({[name31]=lines9}), args27) else - self1(logger17, "put-error!", (_2e2e_2("Unknown profiler '", r_11651, "'"))) + self1(logger18, "put-error!", (_2e2e_2("Unknown profiler '", r_11891, "'"))) return exit_21_1(1) end else - return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_11551), ", but none matched.\n", " Tried: `(nil ?msg)`\n Tried: `(?fun)`")) + return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_11791), ", but none matched.\n", " Tried: `(nil ?msg)`\n Tried: `(?fun)`")) end end) -task3 = struct1("name", "run", "setup", (function(spec13) +task3 = ({["name"]="run",["setup"]=(function(spec13) addArgument_21_1(spec13, ({tag = "list", n = 2, "--run", "-r"}), "help", "Run the compiled code.") addArgument_21_1(spec13, ({tag = "list", n = 2, "--profile", "-p"}), "help", "Run the compiled code with the profiler.", "var", "none|call|stack", "default", nil, "value", "stack", "narg", "?") addArgument_21_1(spec13, ({tag = "list", n = 1, "--stack-kind"}), "help", "The kind of stack to emit when using the stack profiler. A reverse stack shows callers of that method instead.", "var", "forward|reverse", "default", "forward", "narg", 1) @@ -5841,18 +5906,18 @@ task3 = struct1("name", "run", "setup", (function(spec13) addArgument_21_1(spec13, ({tag = "list", n = 1, "--stack-limit"}), "help", "The maximum number of call frames to emit.", "var", "LIMIT", "default", nil, "action", setNumAction1, "narg", 1) addArgument_21_1(spec13, ({tag = "list", n = 1, "--stack-fold"}), "help", "Whether to fold recursive functions into themselves. This hopefully makes deep graphs easier to understand, but may result in less accurate graphs.", "value", true, "default", false) return addArgument_21_1(spec13, ({tag = "list", n = 1, "--"}), "name", "script-args", "help", "Arguments to pass to the compiled script.", "var", "ARG", "all", true, "default", ({tag = "list", n = 0}), "action", addAction1, "narg", "*") -end), "pred", (function(args28) +end),["pred"]=(function(args28) return (args28["run"] or args28["profile"]) -end), "run", runLua1) +end),["run"]=runLua1}) dotQuote1 = (function(prefix2, name32) if find1(name32, "^[%w_][%d%w_]*$") then - if prefix2 then + if string_3f_1(prefix2) then return _2e2e_2(prefix2, ".", name32) else return name32 end else - if prefix2 then + if string_3f_1(prefix2) then return _2e2e_2(prefix2, "[", quoted1(name32), "]") else return _2e2e_2("_ENV[", quoted1(name32), "]") @@ -5866,28 +5931,34 @@ genNative1 = (function(compiler12, args29) end local prefix3 = args29["gen-native"] local lib3 = compiler12["libCache"][gsub1(last1(args29["input"]), "%.lisp$", "")] + local escaped3 + if string_3f_1(prefix3) then + escaped3 = escape1(last1(split1(lib3["name"], "/"))) + else + escaped3 = nil + end local maxName1 = 0 local maxQuot1 = 0 local maxPref1 = 0 local natives1 = ({tag = "list", n = 0}) - local r_11871 = lib3["out"] - local r_11901 = r_11871["n"] - local r_11881 = nil - r_11881 = (function(r_11891) - if (r_11891 <= r_11901) then - local node53 = r_11871[r_11891] - if ((type1(node53) == "list") and ((type1((car1(node53))) == "symbol") and (car1(node53)["contents"] == "define-native"))) then - local name33 = node53[2]["contents"] + local r_12031 = lib3["out"] + local r_12061 = r_12031["n"] + local r_12041 = nil + r_12041 = (function(r_12051) + if (r_12051 <= r_12061) then + local node56 = r_12031[r_12051] + if ((type1(node56) == "list") and ((type1((car1(node56))) == "symbol") and (car1(node56)["contents"] == "define-native"))) then + local name33 = node56[2]["contents"] pushCdr_21_1(natives1, name33) maxName1 = max2(maxName1, len1(quoted1(name33))) maxQuot1 = max2(maxQuot1, len1(quoted1(dotQuote1(prefix3, name33)))) - maxPref1 = max2(maxPref1, len1(dotQuote1(prefix3, name33))) + maxPref1 = max2(maxPref1, len1(dotQuote1(escaped3, name33))) end - return r_11881((r_11891 + 1)) + return r_12041((r_12051 + 1)) else end end) - r_11881(1) + r_12041(1) sort1(natives1) local handle4 = open1(_2e2e_2(lib3["path"], ".meta.lua"), "w") local format3 = _2e2e_2("\9[%-", tostring1((maxName1 + 3)), "s { tag = \"var\", contents = %-", tostring1((maxQuot1 + 1)), "s value = %-", tostring1((maxPref1 + 1)), "s },\n") @@ -5897,91 +5968,100 @@ genNative1 = (function(compiler12, args29) exit_21_1(1) end if string_3f_1(prefix3) then - self1(handle4, "write", format1("local %s = %s or {}\n", prefix3, prefix3)) + self1(handle4, "write", format1("local %s = %s or {}\n", escaped3, prefix3)) end self1(handle4, "write", "return {\n") - local r_11981 = natives1["n"] - local r_11961 = nil - r_11961 = (function(r_11971) - if (r_11971 <= r_11981) then - local native2 = natives1[r_11971] - self1(handle4, "write", format1(format3, _2e2e_2(quoted1(native2), "] ="), _2e2e_2(quoted1(dotQuote1(prefix3, native2)), ","), _2e2e_2(dotQuote1(prefix3, native2), ","))) - return r_11961((r_11971 + 1)) + local r_12141 = natives1["n"] + local r_12121 = nil + r_12121 = (function(r_12131) + if (r_12131 <= r_12141) then + local native2 = natives1[r_12131] + self1(handle4, "write", format1(format3, _2e2e_2(quoted1(native2), "] ="), _2e2e_2(quoted1(dotQuote1(prefix3, native2)), ","), _2e2e_2(dotQuote1(escaped3, native2), ","))) + return r_12121((r_12131 + 1)) else end end) - r_11961(1) + r_12121(1) self1(handle4, "write", "}\n") return self1(handle4, "close") end) -task4 = struct1("name", "gen-native", "setup", (function(spec14) +task4 = ({["name"]="gen-native",["setup"]=(function(spec14) return addArgument_21_1(spec14, ({tag = "list", n = 1, "--gen-native"}), "help", "Generate native bindings for a file", "var", "PREFIX", "narg", "?") -end), "pred", (function(args30) +end),["pred"]=(function(args30) return args30["gen-native"] -end), "run", genNative1) +end),["run"]=genNative1}) scope_2f_child2 = require1("tacky.analysis.scope")["child"] compile2 = require1("tacky.compile")["compile"] simplifyPath1 = (function(path3, paths1) local current5 = path3 - local r_12041 = paths1["n"] - local r_12021 = nil - r_12021 = (function(r_12031) - if (r_12031 <= r_12041) then - local search1 = paths1[r_12031] + local r_12201 = paths1["n"] + local r_12181 = nil + r_12181 = (function(r_12191) + if (r_12191 <= r_12201) then + local search1 = paths1[r_12191] local sub7 = match1(path3, _2e2e_2("^", gsub1(search1, "%?", "(.*)"), "$")) if (sub7 and (len1(sub7) < len1(current5))) then current5 = sub7 end - return r_12021((r_12031 + 1)) + return r_12181((r_12191 + 1)) else end end) - r_12021(1) + r_12181(1) return current5 end) -readMeta1 = (function(state36, name34, entry12) - if (((entry12["tag"] == "expr") or (entry12["tag"] == "stmt")) and string_3f_1(entry12["contents"])) then +readMeta1 = (function(state38, name34, entry11) + if (((entry11["tag"] == "expr") or (entry11["tag"] == "stmt")) and string_3f_1(entry11["contents"])) then local buffer7 = ({tag = "list", n = 0}) - local str8 = entry12["contents"] - local idx7 = 0 - local len14 = len1(str8) - local r_12091 = nil - r_12091 = (function() - if (idx7 <= len14) then - local r_12101 = list1(find1(str8, "%${(%d+)}", idx7)) - if ((type1(r_12101) == "list") and ((r_12101["n"] >= 2) and true)) then - local start28 = r_12101[1] - local finish13 = r_12101[2] - if (start28 > idx7) then - pushCdr_21_1(buffer7, sub1(str8, idx7, (start28 - 1))) + local str10 = entry11["contents"] + local idx8 = 0 + local max6 = 0 + local len14 = len1(str10) + local r_12251 = nil + r_12251 = (function() + if (idx8 <= len14) then + local r_12261 = list1(find1(str10, "%${(%d+)}", idx8)) + if ((type1(r_12261) == "list") and ((r_12261["n"] >= 2) and true)) then + local start28 = r_12261[1] + local finish13 = r_12261[2] + if (start28 > idx8) then + pushCdr_21_1(buffer7, sub1(str10, idx8, (start28 - 1))) end - pushCdr_21_1(buffer7, tonumber1(sub1(str8, (start28 + 2), (finish13 - 1)))) - idx7 = (finish13 + 1) + local val20 = tonumber1(sub1(str10, (start28 + 2), (finish13 - 1))) + pushCdr_21_1(buffer7, val20) + if (val20 > max6) then + max6 = val20 + end + idx8 = (finish13 + 1) else - pushCdr_21_1(buffer7, sub1(str8, idx7, len14)) - idx7 = (len14 + 1) + pushCdr_21_1(buffer7, sub1(str10, idx8, len14)) + idx8 = (len14 + 1) end - return r_12091() + return r_12251() else end end) - r_12091() - entry12["contents"] = buffer7 + r_12251() + if entry11["count"] then + else + entry11["count"] = max6 + end + entry11["contents"] = buffer7 end - if (entry12["value"] == nil) then - entry12["value"] = state36["libEnv"][name34] - elseif (state36["libEnv"][name34] ~= nil) then + if (entry11["value"] == nil) then + entry11["value"] = state38["libEnv"][name34] + elseif (state38["libEnv"][name34] ~= nil) then error1(_2e2e_2("Duplicate value for ", name34, ": in native and meta file"), 0) else - state36["libEnv"][name34] = entry12["value"] + state38["libEnv"][name34] = entry11["value"] end - state36["libMeta"][name34] = entry12 - return entry12 + state38["libMeta"][name34] = entry11 + return entry11 end) -readLibrary1 = (function(state37, name35, path4, lispHandle1) - self1(state37["log"], "put-verbose!", (_2e2e_2("Loading ", path4, " into ", name35))) - local prefix4 = _2e2e_2(name35, "-", state37["libs"]["n"], "/") - local lib4 = struct1("name", name35, "prefix", prefix4, "path", path4) +readLibrary1 = (function(state39, name35, path4, lispHandle1) + self1(state39["log"], "put-verbose!", (_2e2e_2("Loading ", path4, " into ", name35))) + local prefix4 = _2e2e_2(name35, "-", state39["libs"]["n"], "/") + local lib4 = ({["name"]=name35,["prefix"]=prefix4,["path"]=path4}) local contents2 = self1(lispHandle1, "read", "*a") self1(lispHandle1, "close") local handle5 = open1(_2e2e_2(path4, ".lua"), "r") @@ -5989,95 +6069,95 @@ readLibrary1 = (function(state37, name35, path4, lispHandle1) local contents3 = self1(handle5, "read", "*a") self1(handle5, "close") lib4["native"] = contents3 - local r_12171 = list1(load1(contents3, _2e2e_2("@", name35))) - if ((type1(r_12171) == "list") and ((r_12171["n"] >= 2) and ((r_12171["n"] <= 2) and (eq_3f_1(r_12171[1], nil) and true)))) then - error1((r_12171[2]), 0) - elseif ((type1(r_12171) == "list") and ((r_12171["n"] >= 1) and ((r_12171["n"] <= 1) and true))) then - local fun4 = r_12171[1] + local r_12331 = list1(load1(contents3, _2e2e_2("@", name35))) + if ((type1(r_12331) == "list") and ((r_12331["n"] >= 2) and ((r_12331["n"] <= 2) and (eq_3f_1(r_12331[1], nil) and true)))) then + error1((r_12331[2]), 0) + elseif ((type1(r_12331) == "list") and ((r_12331["n"] >= 1) and ((r_12331["n"] <= 1) and true))) then + local fun4 = r_12331[1] local res15 = fun4() if (type_23_1(res15) == "table") then iterPairs1(res15, (function(k4, v5) - state37["libEnv"][_2e2e_2(prefix4, k4)] = v5 + state39["libEnv"][_2e2e_2(prefix4, k4)] = v5 return nil end)) else error1(_2e2e_2(path4, ".lua returned a non-table value"), 0) end else - error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_12171), ", but none matched.\n", " Tried: `(nil ?msg)`\n Tried: `(?fun)`")) + error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_12331), ", but none matched.\n", " Tried: `(nil ?msg)`\n Tried: `(?fun)`")) end end local handle6 = open1(_2e2e_2(path4, ".meta.lua"), "r") if handle6 then local contents4 = self1(handle6, "read", "*a") self1(handle6, "close") - local r_12271 = list1(load1(contents4, _2e2e_2("@", name35))) - if ((type1(r_12271) == "list") and ((r_12271["n"] >= 2) and ((r_12271["n"] <= 2) and (eq_3f_1(r_12271[1], nil) and true)))) then - error1((r_12271[2]), 0) - elseif ((type1(r_12271) == "list") and ((r_12271["n"] >= 1) and ((r_12271["n"] <= 1) and true))) then - local fun5 = r_12271[1] + local r_12431 = list1(load1(contents4, _2e2e_2("@", name35))) + if ((type1(r_12431) == "list") and ((r_12431["n"] >= 2) and ((r_12431["n"] <= 2) and (eq_3f_1(r_12431[1], nil) and true)))) then + error1((r_12431[2]), 0) + elseif ((type1(r_12431) == "list") and ((r_12431["n"] >= 1) and ((r_12431["n"] <= 1) and true))) then + local fun5 = r_12431[1] local res16 = fun5() if (type_23_1(res16) == "table") then iterPairs1(res16, (function(k5, v6) - return readMeta1(state37, _2e2e_2(prefix4, k5), v6) + return readMeta1(state39, _2e2e_2(prefix4, k5), v6) end)) else error1(_2e2e_2(path4, ".meta.lua returned a non-table value"), 0) end else - error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_12271), ", but none matched.\n", " Tried: `(nil ?msg)`\n Tried: `(?fun)`")) + error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_12431), ", but none matched.\n", " Tried: `(nil ?msg)`\n Tried: `(?fun)`")) end end - startTimer_21_1(state37["timer"], _2e2e_2("[parse] ", path4), 2) - local lexed2 = lex1(state37["log"], contents2, _2e2e_2(path4, ".lisp")) - local parsed1 = parse1(state37["log"], lexed2) - local scope9 = scope_2f_child2(state37["rootScope"]) + startTimer_21_1(state39["timer"], _2e2e_2("[parse] ", path4), 2) + local lexed2 = lex1(state39["log"], contents2, _2e2e_2(path4, ".lisp")) + local parsed1 = parse1(state39["log"], lexed2) + local scope9 = scope_2f_child2(state39["rootScope"]) scope9["isRoot"] = true scope9["prefix"] = prefix4 lib4["scope"] = scope9 - stopTimer_21_1(state37["timer"], _2e2e_2("[parse] ", path4)) - local compiled1 = compile2(state37, executeStates1, parsed1, scope9, path4) - pushCdr_21_1(state37["libs"], lib4) + stopTimer_21_1(state39["timer"], _2e2e_2("[parse] ", path4)) + local compiled1 = compile2(state39, executeStates1, parsed1, scope9, path4) + pushCdr_21_1(state39["libs"], lib4) if string_3f_1(car1(compiled1)) then lib4["docs"] = constVal1(car1(compiled1)) removeNth_21_1(compiled1, 1) end lib4["out"] = compiled1 - local r_12411 = compiled1["n"] - local r_12391 = nil - r_12391 = (function(r_12401) - if (r_12401 <= r_12411) then - local node54 = compiled1[r_12401] - pushCdr_21_1(state37["out"], node54) - return r_12391((r_12401 + 1)) + local r_12571 = compiled1["n"] + local r_12551 = nil + r_12551 = (function(r_12561) + if (r_12561 <= r_12571) then + local node57 = compiled1[r_12561] + pushCdr_21_1(state39["out"], node57) + return r_12551((r_12561 + 1)) else end end) - r_12391(1) - self1(state37["log"], "put-verbose!", (_2e2e_2("Loaded ", path4, " into ", name35))) + r_12551(1) + self1(state39["log"], "put-verbose!", (_2e2e_2("Loaded ", path4, " into ", name35))) return lib4 end) -pathLocator1 = (function(state38, name36) +pathLocator1 = (function(state40, name36) local searched1 local paths2 local searcher1 searched1 = ({tag = "list", n = 0}) - paths2 = state38["paths"] + paths2 = state40["paths"] searcher1 = (function(i12) if (i12 > paths2["n"]) then return list1(nil, _2e2e_2("Cannot find ", quoted1(name36), ".\nLooked in ", concat1(searched1, ", "))) else local path5 = gsub1(paths2[i12], "%?", name36) - local cached1 = state38["libCache"][path5] + local cached1 = state40["libCache"][path5] pushCdr_21_1(searched1, path5) if (cached1 == nil) then local handle7 = open1(_2e2e_2(path5, ".lisp"), "r") if handle7 then - state38["libCache"][path5] = true - state38["libNames"][name36] = true - local lib5 = readLibrary1(state38, simplifyPath1(path5, paths2), path5, handle7) - state38["libCache"][path5] = lib5 - state38["libNames"][name36] = lib5 + state40["libCache"][path5] = true + state40["libNames"][name36] = true + local lib5 = readLibrary1(state40, simplifyPath1(path5, paths2), path5, handle7) + state40["libCache"][path5] = lib5 + state40["libNames"][name36] = lib5 return list1(lib5) else return searcher1((i12 + 1)) @@ -6091,11 +6171,11 @@ pathLocator1 = (function(state38, name36) end) return searcher1(1) end) -loader1 = (function(state39, name37, shouldResolve1) +loader1 = (function(state41, name37, shouldResolve1) if shouldResolve1 then - local cached2 = state39["libNames"][name37] + local cached2 = state41["libNames"][name37] if (cached2 == nil) then - return pathLocator1(state39, name37) + return pathLocator1(state41, name37) elseif (cached2 == true) then return list1(nil, _2e2e_2("Already loading ", name37)) else @@ -6103,53 +6183,53 @@ loader1 = (function(state39, name37, shouldResolve1) end else name37 = gsub1(name37, "%.lisp$", "") - local r_12161 = state39["libCache"][name37] - if eq_3f_1(r_12161, nil) then + local r_12321 = state41["libCache"][name37] + if eq_3f_1(r_12321, nil) then local handle8 = open1(_2e2e_2(name37, ".lisp")) if handle8 then - state39["libCache"][name37] = true - local lib6 = readLibrary1(state39, simplifyPath1(name37, state39["paths"]), name37, handle8) - state39["libCache"][name37] = lib6 + state41["libCache"][name37] = true + local lib6 = readLibrary1(state41, simplifyPath1(name37, state41["paths"]), name37, handle8) + state41["libCache"][name37] = lib6 return list1(lib6) else return list1(nil, _2e2e_2("Cannot find ", quoted1(name37))) end - elseif eq_3f_1(r_12161, true) then + elseif eq_3f_1(r_12321, true) then return list1(nil, _2e2e_2("Already loading ", name37)) else - return list1(r_12161) + return list1(r_12321) end end end) -printError_21_1 = (function(msg32) - if string_3f_1(msg32) then +printError_21_1 = (function(msg33) + if string_3f_1(msg33) then else - msg32 = pretty1(msg32) + msg33 = pretty1(msg33) end - local lines9 = split1(msg32, "\n", 1) - print1(colored1(31, _2e2e_2("[ERROR] ", car1(lines9)))) - if car1(cdr1(lines9)) then - return print1(car1(cdr1(lines9))) - else - end -end) -printWarning_21_1 = (function(msg33) local lines10 = split1(msg33, "\n", 1) - print1(colored1(33, _2e2e_2("[WARN] ", car1(lines10)))) + print1(colored1(31, _2e2e_2("[ERROR] ", car1(lines10)))) if car1(cdr1(lines10)) then return print1(car1(cdr1(lines10))) else end end) -printVerbose_21_1 = (function(verbosity1, msg34) +printWarning_21_1 = (function(msg34) + local lines11 = split1(msg34, "\n", 1) + print1(colored1(33, _2e2e_2("[WARN] ", car1(lines11)))) + if car1(cdr1(lines11)) then + return print1(car1(cdr1(lines11))) + else + end +end) +printVerbose_21_1 = (function(verbosity1, msg35) if (verbosity1 > 0) then - return print1(_2e2e_2("[VERBOSE] ", msg34)) + return print1(_2e2e_2("[VERBOSE] ", msg35)) else end end) -printDebug_21_1 = (function(verbosity2, msg35) +printDebug_21_1 = (function(verbosity2, msg36) if (verbosity2 > 1) then - return print1(_2e2e_2("[DEBUG] ", msg35)) + return print1(_2e2e_2("[DEBUG] ", msg36)) else end end) @@ -6159,58 +6239,58 @@ printTime_21_1 = (function(maximum1, name38, time1, level6) else end end) -printExplain_21_1 = (function(explain4, lines11) - if explain4 then - local r_12511 = split1(lines11, "\n") - local r_12541 = r_12511["n"] - local r_12521 = nil - r_12521 = (function(r_12531) - if (r_12531 <= r_12541) then - print1(_2e2e_2(" ", (r_12511[r_12531]))) - return r_12521((r_12531 + 1)) +printExplain_21_1 = (function(explain5, lines12) + if explain5 then + local r_12671 = split1(lines12, "\n") + local r_12701 = r_12671["n"] + local r_12681 = nil + r_12681 = (function(r_12691) + if (r_12691 <= r_12701) then + print1(_2e2e_2(" ", (r_12671[r_12691]))) + return r_12681((r_12691 + 1)) else end end) - return r_12521(1) + return r_12681(1) else end end) -create4 = (function(verbosity3, explain5, time2) - return struct1("verbosity", (verbosity3 or 0), "explain", (explain5 == true), "time", (time2 or 0), "put-error!", putError_21_2, "put-warning!", putWarning_21_2, "put-verbose!", putVerbose_21_2, "put-debug!", putDebug_21_2, "put-time!", putTime_21_1, "put-node-error!", putNodeError_21_2, "put-node-warning!", putNodeWarning_21_2) +create4 = (function(verbosity3, explain6, time2) + return ({["verbosity"]=(verbosity3 or 0),["explain"]=(explain6 == true),["time"]=(time2 or 0),["put-error!"]=putError_21_2,["put-warning!"]=putWarning_21_2,["put-verbose!"]=putVerbose_21_2,["put-debug!"]=putDebug_21_2,["put-time!"]=putTime_21_1,["put-node-error!"]=putNodeError_21_2,["put-node-warning!"]=putNodeWarning_21_2}) end) -putError_21_2 = (function(logger18, msg36) - return printError_21_1(msg36) +putError_21_2 = (function(logger19, msg37) + return printError_21_1(msg37) end) -putWarning_21_2 = (function(logger19, msg37) - return printWarning_21_1(msg37) +putWarning_21_2 = (function(logger20, msg38) + return printWarning_21_1(msg38) end) -putVerbose_21_2 = (function(logger20, msg38) - return printVerbose_21_1(logger20["verbosity"], msg38) +putVerbose_21_2 = (function(logger21, msg39) + return printVerbose_21_1(logger21["verbosity"], msg39) end) -putDebug_21_2 = (function(logger21, msg39) - return printDebug_21_1(logger21["verbosity"], msg39) +putDebug_21_2 = (function(logger22, msg40) + return printDebug_21_1(logger22["verbosity"], msg40) end) -putTime_21_1 = (function(logger22, name39, time3, level7) - return printTime_21_1(logger22["time"], name39, time3, level7) -end) -putNodeError_21_2 = (function(logger23, msg40, node55, explain6, lines12) - printError_21_1(msg40) - putTrace_21_1(node55) - if explain6 then - printExplain_21_1(logger23["explain"], explain6) - end - return putLines_21_1(true, lines12) +putTime_21_1 = (function(logger23, name39, time3, level7) + return printTime_21_1(logger23["time"], name39, time3, level7) end) -putNodeWarning_21_2 = (function(logger24, msg41, node56, explain7, lines13) - printWarning_21_1(msg41) - putTrace_21_1(node56) +putNodeError_21_2 = (function(logger24, msg41, node58, explain7, lines13) + printError_21_1(msg41) + putTrace_21_1(node58) if explain7 then printExplain_21_1(logger24["explain"], explain7) end return putLines_21_1(true, lines13) end) +putNodeWarning_21_2 = (function(logger25, msg42, node59, explain8, lines14) + printWarning_21_1(msg42) + putTrace_21_1(node59) + if explain8 then + printExplain_21_1(logger25["explain"], explain8) + end + return putLines_21_1(true, lines14) +end) putLines_21_1 = (function(range6, entries2) - if nil_3f_1(entries2) then + if empty_3f_1(entries2) then error1("Positions cannot be empty") end if ((entries2["n"] % 2) ~= 0) then @@ -6218,20 +6298,20 @@ putLines_21_1 = (function(range6, entries2) end local previous6 = -1 local file4 = entries2[1]["name"] - local maxLine1 = foldr1((function(max6, node57) - if string_3f_1(node57) then - return max6 + local maxLine1 = foldr1((function(max7, node60) + if string_3f_1(node60) then + return max7 else - return max2(max6, node57["start"]["line"]) + return max2(max7, node60["start"]["line"]) end end), 0, entries2) local code3 = _2e2e_2(colored1(92, _2e2e_2(" %", len1(tostring1(maxLine1)), "s │")), " %s") - local r_12471 = entries2["n"] - local r_12451 = nil - r_12451 = (function(r_12461) - if (r_12461 <= r_12471) then - local position1 = entries2[r_12461] - local message1 = entries2[(r_12461 + 1)] + local r_12631 = entries2["n"] + local r_12611 = nil + r_12611 = (function(r_12621) + if (r_12621 <= r_12631) then + local position1 = entries2[r_12621] + local message1 = entries2[(r_12621 + 1)] if (file4 ~= position1["name"]) then file4 = position1["name"] print1(colored1(95, _2e2e_2(" ", file4))) @@ -6249,18 +6329,18 @@ putLines_21_1 = (function(range6, entries2) pointer1 = "^..." end print1(format1(code3, "", _2e2e_2(rep1(" ", (position1["start"]["column"] - 1)), pointer1, " ", message1))) - return r_12451((r_12461 + 2)) + return r_12611((r_12621 + 2)) else end end) - return r_12451(1) + return r_12611(1) end) -putTrace_21_1 = (function(node58) +putTrace_21_1 = (function(node61) local previous7 = nil - local r_12491 = nil - r_12491 = (function() - if node58 then - local formatted1 = formatNode1(node58) + local r_12651 = nil + r_12651 = (function() + if node61 then + local formatted1 = formatNode1(node61) if (previous7 == nil) then print1(colored1(96, _2e2e_2(" => ", formatted1))) elseif (previous7 ~= formatted1) then @@ -6268,19 +6348,19 @@ putTrace_21_1 = (function(node58) else end previous7 = formatted1 - node58 = node58["parent"] - return r_12491() + node61 = node61["parent"] + return r_12651() else end end) - return r_12491() + return r_12651() end) -Scope3 = require1("tacky.analysis.scope") +Scope4 = require1("tacky.analysis.scope") createPluginState1 = (function(compiler13) - local logger25 = compiler13["log"] + local logger26 = compiler13["log"] local variables1 = compiler13["variables"] local states3 = compiler13["states"] - local warnings1 = compiler13["warnings"] + local warnings1 = compiler13["warning"] local optimise3 = compiler13["optimise"] local activeScope1 = (function() return compiler13["active-scope"] @@ -6288,38 +6368,38 @@ createPluginState1 = (function(compiler13) local activeNode1 = (function() return compiler13["active-node"] end) - return {["add-categoriser!"]=(function() + return ({["add-categoriser!"]=(function() return error1("add-categoriser! is not yet implemented", 0) - end),["categorise-node"]=visitNode2,["categorise-nodes"]=visitNodes1,["cat"]=cat2,["writer/append!"]=append_21_1,["writer/line!"]=line_21_1,["writer/indent!"]=indent_21_1,["writer/unindent!"]=unindent_21_1,["writer/begin-block!"]=beginBlock_21_1,["writer/next-block!"]=nextBlock_21_1,["writer/end-block!"]=endBlock_21_1,["add-emitter!"]=(function() + end),["categorise-node"]=visitNode2,["categorise-nodes"]=visitNodes1,["cat"]=cat3,["writer/append!"]=append_21_1,["writer/line!"]=line_21_1,["writer/indent!"]=indent_21_1,["writer/unindent!"]=unindent_21_1,["writer/begin-block!"]=beginBlock_21_1,["writer/next-block!"]=nextBlock_21_1,["writer/end-block!"]=endBlock_21_1,["add-emitter!"]=(function() return error1("add-emitter! is not yet implemented", 0) - end),["emit-node"]=expression2,["emit-block"]=block2,["logger/put-error!"]=(function(r_12581) - return self1(logger25, "put-error!", r_12581) - end),["logger/put-warning!"]=(function(r_12591) - return self1(logger25, "put-warning!", r_12591) - end),["logger/put-verbose!"]=(function(r_12601) - return self1(logger25, "put-verbose!", r_12601) - end),["logger/put-debug!"]=(function(r_12611) - return self1(logger25, "put-debug!", r_12611) - end),["logger/put-node-error!"]=(function(msg42, node59, explain8, ...) - local lines14 = _pack(...) lines14.tag = "list" - return putNodeError_21_1(logger25, msg42, node59, explain8, unpack1(lines14, 1, lines14["n"])) - end),["logger/put-node-warning!"]=(function(msg43, node60, explain9, ...) + end),["emit-node"]=expression2,["emit-block"]=block2,["logger/put-error!"]=(function(r_12741) + return self1(logger26, "put-error!", r_12741) + end),["logger/put-warning!"]=(function(r_12751) + return self1(logger26, "put-warning!", r_12751) + end),["logger/put-verbose!"]=(function(r_12761) + return self1(logger26, "put-verbose!", r_12761) + end),["logger/put-debug!"]=(function(r_12771) + return self1(logger26, "put-debug!", r_12771) + end),["logger/put-node-error!"]=(function(msg43, node62, explain9, ...) local lines15 = _pack(...) lines15.tag = "list" - return putNodeWarning_21_1(logger25, msg43, node60, explain9, unpack1(lines15, 1, lines15["n"])) - end),["logger/do-node-error!"]=(function(msg44, node61, explain10, ...) + return putNodeError_21_1(logger26, msg43, node62, explain9, unpack1(lines15, 1, lines15["n"])) + end),["logger/put-node-warning!"]=(function(msg44, node63, explain10, ...) local lines16 = _pack(...) lines16.tag = "list" - return doNodeError_21_1(logger25, msg44, node61, explain10, unpack1(lines16, 1, lines16["n"])) - end),["visit-node"]=visitNode1,["visit-nodes"]=visitBlock1,["traverse-nodes"]=traverseNode1,["traverse-nodes"]=traverseList1,["symbol->var"]=(function(x61) - local var35 = x61["var"] - if string_3f_1(var35) then - return variables1[var35] + return putNodeWarning_21_1(logger26, msg44, node63, explain10, unpack1(lines16, 1, lines16["n"])) + end),["logger/do-node-error!"]=(function(msg45, node64, explain11, ...) + local lines17 = _pack(...) lines17.tag = "list" + return doNodeError_21_1(logger26, msg45, node64, explain11, unpack1(lines17, 1, lines17["n"])) + end),["range/get-source"]=getSource1,["visit-node"]=visitNode1,["visit-nodes"]=visitBlock1,["traverse-nodes"]=traverseNode1,["traverse-nodes"]=traverseList1,["symbol->var"]=(function(x60) + local var37 = x60["var"] + if string_3f_1(var37) then + return variables1[var37] else - return var35 + return var37 end end),["var->symbol"]=makeSymbol1,["builtin?"]=builtin_3f_1,["constant?"]=constant_3f_1,["node->val"]=urn_2d3e_val1,["val->node"]=val_2d3e_urn1,["add-pass!"]=(function(pass3) - local r_12621 = type1(pass3) - if (r_12621 ~= "table") then - error1(format1("bad argument %s (expected %s, got %s)", "pass", "table", r_12621), 2) + local r_12781 = type1(pass3) + if (r_12781 ~= "table") then + error1(format1("bad argument %s (expected %s, got %s)", "pass", "table", r_12781), 2) end if string_3f_1(pass3["name"]) then else @@ -6365,9 +6445,9 @@ createPluginState1 = (function(compiler13) return scp2["variables"] end end),["var-lookup"]=(function(symb1, scope10) - local r_12631 = type1(symb1) - if (r_12631 ~= "symbol") then - error1(format1("bad argument %s (expected %s, got %s)", "symb", "symbol", r_12631), 2) + local r_12791 = type1(symb1) + if (r_12791 ~= "symbol") then + error1(format1("bad argument %s (expected %s, got %s)", "symb", "symbol", r_12791), 2) end if (compiler13["active-node"] == nil) then error1("Not currently resolving") @@ -6376,31 +6456,31 @@ createPluginState1 = (function(compiler13) else scope10 = compiler13["active-scope"] end - return Scope3["getAlways"](scope10, symbol_2d3e_string1(symb1), compiler13["active-node"]) - end),["var-definition"]=(function(var36) + return Scope4["getAlways"](scope10, symbol_2d3e_string1(symb1), compiler13["active-node"]) + end),["var-definition"]=(function(var38) if (compiler13["active-node"] == nil) then error1("Not currently resolving") end - local state40 = states3[var36] - if state40 then - if (state40["stage"] == "parsed") then - yield1({["tag"]="build",["state"]=state40}) + local state42 = states3[var38] + if state42 then + if (state42["stage"] == "parsed") then + yield1(({["tag"]="build",["state"]=state42})) end - return state40["node"] + return state42["node"] else end - end),["var-value"]=(function(var37) + end),["var-value"]=(function(var39) if (compiler13["active-node"] == nil) then error1("Not currently resolving") end - local state41 = states3[var37] - if state41 then - return self1(state41, "get") + local state43 = states3[var39] + if state43 then + return self1(state43, "get") else end - end),["var-docstring"]=(function(var38) - return var38["doc"] - end)} + end),["var-docstring"]=(function(var40) + return var40["doc"] + end)}) end) rootScope2 = require1("tacky.analysis.resolve")["rootScope"] scope_2f_child3 = require1("tacky.analysis.scope")["child"] @@ -6408,43 +6488,44 @@ scope_2f_import_21_1 = require1("tacky.analysis.scope")["import"] local spec15 = create1() local directory1 local dir1 = arg1[0] +dir1 = gsub1(dir1, "\\", "/") dir1 = gsub1(dir1, "urn/cli%.lisp$", "") dir1 = gsub1(dir1, "urn/cli$", "") dir1 = gsub1(dir1, "tacky/cli%.lua$", "") if ((dir1 ~= "") and (sub1(dir1, -1, -1) ~= "/")) then dir1 = _2e2e_2(dir1, "/") end -local r_13231 = nil -r_13231 = (function() +local r_13391 = nil +r_13391 = (function() if (sub1(dir1, 1, 2) == "./") then dir1 = sub1(dir1, 3) - return r_13231() + return r_13391() else end end) -r_13231() +r_13391() directory1 = dir1 local paths3 = list1("?", "?/init", _2e2e_2(directory1, "lib/?"), _2e2e_2(directory1, "lib/?/init")) local tasks1 = list1(warning1, optimise2, emitLisp1, emitLua1, task1, task4, task3, execTask1, replTask1) addHelp_21_1(spec15) addArgument_21_1(spec15, ({tag = "list", n = 2, "--explain", "-e"}), "help", "Explain error messages in more detail.") -addArgument_21_1(spec15, ({tag = "list", n = 2, "--time", "-t"}), "help", "Time how long each task takes to execute. Multiple usages will show more detailed timings.", "many", true, "default", 0, "action", (function(arg26, data8) - data8[arg26["name"]] = ((data8[arg26["name"]] or 0) + 1) +addArgument_21_1(spec15, ({tag = "list", n = 2, "--time", "-t"}), "help", "Time how long each task takes to execute. Multiple usages will show more detailed timings.", "many", true, "default", 0, "action", (function(arg25, data8) + data8[arg25["name"]] = ((data8[arg25["name"]] or 0) + 1) return nil end)) -addArgument_21_1(spec15, ({tag = "list", n = 2, "--verbose", "-v"}), "help", "Make the output more verbose. Can be used multiple times", "many", true, "default", 0, "action", (function(arg27, data9) - data9[arg27["name"]] = ((data9[arg27["name"]] or 0) + 1) +addArgument_21_1(spec15, ({tag = "list", n = 2, "--verbose", "-v"}), "help", "Make the output more verbose. Can be used multiple times", "many", true, "default", 0, "action", (function(arg26, data9) + data9[arg26["name"]] = ((data9[arg26["name"]] or 0) + 1) return nil end)) addArgument_21_1(spec15, ({tag = "list", n = 2, "--include", "-i"}), "help", "Add an additional argument to the include path.", "many", true, "narg", 1, "default", ({tag = "list", n = 0}), "action", addAction1) addArgument_21_1(spec15, ({tag = "list", n = 2, "--prelude", "-p"}), "help", "A custom prelude path to use.", "narg", 1, "default", _2e2e_2(directory1, "lib/prelude")) addArgument_21_1(spec15, ({tag = "list", n = 3, "--output", "--out", "-o"}), "help", "The destination to output to.", "narg", 1, "default", "out") -addArgument_21_1(spec15, ({tag = "list", n = 2, "--wrapper", "-w"}), "help", "A wrapper script to launch Urn with", "narg", 1, "action", (function(a6, b6, value11) +addArgument_21_1(spec15, ({tag = "list", n = 2, "--wrapper", "-w"}), "help", "A wrapper script to launch Urn with", "narg", 1, "action", (function(a5, b5, value11) local args31 = map1(id1, arg1) local i13 = 1 local len15 = args31["n"] - local r_12661 = nil - r_12661 = (function() + local r_12821 = nil + r_12821 = (function() if (i13 <= len15) then local item2 = args31[i13] if ((item2 == "--wrapper") or (item2 == "-w")) then @@ -6459,45 +6540,45 @@ addArgument_21_1(spec15, ({tag = "list", n = 2, "--wrapper", "-w"}), "help", "A removeNth_21_1(args31, (i13 + 1)) i13 = (len15 + 1) end - return r_12661() + return r_12821() else end end) - r_12661() + r_12821() local command2 = list1(value11) local interp1 = arg1[-1] if interp1 then pushCdr_21_1(command2, interp1) end pushCdr_21_1(command2, arg1[0]) - local r_12681 = list1(execute1(concat1(append1(command2, args31), " "))) - if ((type1(r_12681) == "list") and ((r_12681["n"] >= 3) and ((r_12681["n"] <= 3) and true))) then - return exit1((r_12681[3])) + local r_12841 = list1(execute1(concat1(append1(command2, args31), " "))) + if ((type1(r_12841) == "list") and ((r_12841["n"] >= 3) and ((r_12841["n"] <= 3) and true))) then + return exit1((r_12841[3])) else - return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_12681), ", but none matched.\n", " Tried: `(_ _ ?code)`")) + return error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_12841), ", but none matched.\n", " Tried: `(_ _ ?code)`")) end end)) addArgument_21_1(spec15, ({tag = "list", n = 1, "--plugin"}), "help", "Specify a compiler plugin to load.", "var", "FILE", "default", ({tag = "list", n = 0}), "narg", 1, "many", true, "action", addAction1) addArgument_21_1(spec15, ({tag = "list", n = 1, "input"}), "help", "The file(s) to load.", "var", "FILE", "narg", "*") -local r_12791 = tasks1["n"] -local r_12771 = nil -r_12771 = (function(r_12781) - if (r_12781 <= r_12791) then - local task5 = tasks1[r_12781] +local r_12951 = tasks1["n"] +local r_12931 = nil +r_12931 = (function(r_12941) + if (r_12941 <= r_12951) then + local task5 = tasks1[r_12941] task5["setup"](spec15) - return r_12771((r_12781 + 1)) + return r_12931((r_12941 + 1)) else end end) -r_12771(1) +r_12931(1) local args32 = parse_21_1(spec15) -local logger26 = create4(args32["verbose"], args32["explain"], args32["time"]) -local r_12821 = args32["include"] -local r_12851 = r_12821["n"] -local r_12831 = nil -r_12831 = (function(r_12841) - if (r_12841 <= r_12851) then - local path6 = r_12821[r_12841] +local logger27 = create4(args32["verbose"], args32["explain"], args32["time"]) +local r_12981 = args32["include"] +local r_13011 = r_12981["n"] +local r_12991 = nil +r_12991 = (function(r_13001) + if (r_13001 <= r_13011) then + local path6 = r_12981[r_13001] path6 = gsub1(path6, "\\", "/") path6 = gsub1(path6, "^%./", "") if find1(path6, "%?") then @@ -6512,77 +6593,77 @@ r_12831 = (function(r_12841) ) end pushCdr_21_1(paths3, path6) - return r_12831((r_12841 + 1)) + return r_12991((r_13001 + 1)) else end end) -r_12831(1) -self1(logger26, "put-verbose!", (_2e2e_2("Using path: ", pretty1(paths3)))) -if nil_3f_1(args32["input"]) then +r_12991(1) +self1(logger27, "put-verbose!", (_2e2e_2("Using path: ", pretty1(paths3)))) +if empty_3f_1(args32["input"]) then args32["repl"] = true else args32["emit-lua"] = true end -local compiler14 = struct1("log", logger26, "timer", {["callback"]=(function(r_13191, r_13201, r_13211) - return self1(logger26, "put-time!", r_13191, r_13201, r_13211) -end),["timers"]={}}, "paths", paths3, "libEnv", {}, "libMeta", {}, "libs", ({tag = "list", n = 0}), "libCache", {}, "libNames", {}, "warning", {["normal"]=({tag = "list", n = 0}),["usage"]=list1(checkArity1)}, "optimise", default1(), "rootScope", rootScope2, "variables", {}, "states", {}, "out", ({tag = "list", n = 0})) +local compiler14 = ({["log"]=logger27,["timer"]=({["callback"]=(function(r_13351, r_13361, r_13371) + return self1(logger27, "put-time!", r_13351, r_13361, r_13371) +end),["timers"]=({})}),["paths"]=paths3,["libEnv"]=({}),["libMeta"]=({}),["libs"]=({tag = "list", n = 0}),["libCache"]=({}),["libNames"]=({}),["warning"]=({["normal"]=list1(documentation1),["usage"]=list1(checkArity1, deprecated1)}),["optimise"]=default1(),["rootScope"]=rootScope2,["variables"]=({}),["states"]=({}),["out"]=({tag = "list", n = 0})}) compiler14["compileState"] = createState1(compiler14["libMeta"]) compiler14["loader"] = (function(name40) return loader1(compiler14, name40, true) end) -compiler14["global"] = setmetatable1(struct1("_libs", compiler14["libEnv"], "_compiler", createPluginState1(compiler14)), struct1("__index", _5f_G1)) -iterPairs1(compiler14["rootScope"]["variables"], (function(_5f_3, var39) - compiler14["variables"][tostring1(var39)] = var39 +compiler14["global"] = setmetatable1(({["_libs"]=compiler14["libEnv"],["_compiler"]=createPluginState1(compiler14)}), ({["__index"]=_5f_G1})) +iterPairs1(compiler14["rootScope"]["variables"], (function(_5f_3, var41) + compiler14["variables"][tostring1(var41)] = var41 return nil end)) startTimer_21_1(compiler14["timer"], "loading") -local r_12871 = loader1(compiler14, args32["prelude"], false) -if ((type1(r_12871) == "list") and ((r_12871["n"] >= 2) and ((r_12871["n"] <= 2) and (eq_3f_1(r_12871[1], nil) and true)))) then - local errorMessage1 = r_12871[2] - self1(logger26, "put-error!", errorMessage1) +local r_13031 = loader1(compiler14, args32["prelude"], false) +if ((type1(r_13031) == "list") and ((r_13031["n"] >= 2) and ((r_13031["n"] <= 2) and (eq_3f_1(r_13031[1], nil) and true)))) then + local errorMessage1 = r_13031[2] + self1(logger27, "put-error!", errorMessage1) exit_21_1(1) -elseif ((type1(r_12871) == "list") and ((r_12871["n"] >= 1) and ((r_12871["n"] <= 1) and true))) then - local lib7 = r_12871[1] +elseif ((type1(r_13031) == "list") and ((r_13031["n"] >= 1) and ((r_13031["n"] <= 1) and true))) then + local lib7 = r_13031[1] compiler14["rootScope"] = scope_2f_child3(compiler14["rootScope"]) - iterPairs1(lib7["scope"]["exported"], (function(name41, var40) - return scope_2f_import_21_1(compiler14["rootScope"], name41, var40) + iterPairs1(lib7["scope"]["exported"], (function(name41, var42) + return scope_2f_import_21_1(compiler14["rootScope"], name41, var42) end)) - local r_12981 = append1(args32["plugin"], args32["input"]) - local r_13011 = r_12981["n"] - local r_12991 = nil - r_12991 = (function(r_13001) - if (r_13001 <= r_13011) then - local input1 = r_12981[r_13001] - local r_13031 = loader1(compiler14, input1, false) - if ((type1(r_13031) == "list") and ((r_13031["n"] >= 2) and ((r_13031["n"] <= 2) and (eq_3f_1(r_13031[1], nil) and true)))) then - local errorMessage2 = r_13031[2] - self1(logger26, "put-error!", errorMessage2) + local r_13141 = append1(args32["plugin"], args32["input"]) + local r_13171 = r_13141["n"] + local r_13151 = nil + r_13151 = (function(r_13161) + if (r_13161 <= r_13171) then + local input1 = r_13141[r_13161] + local r_13191 = loader1(compiler14, input1, false) + if ((type1(r_13191) == "list") and ((r_13191["n"] >= 2) and ((r_13191["n"] <= 2) and (eq_3f_1(r_13191[1], nil) and true)))) then + local errorMessage2 = r_13191[2] + self1(logger27, "put-error!", errorMessage2) exit_21_1(1) - elseif ((type1(r_13031) == "list") and ((r_13031["n"] >= 1) and ((r_13031["n"] <= 1) and true))) then + elseif ((type1(r_13191) == "list") and ((r_13191["n"] >= 1) and ((r_13191["n"] <= 1) and true))) then else - error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_13031), ", but none matched.\n", " Tried: `(nil ?error-message)`\n Tried: `(_)`")) + error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_13191), ", but none matched.\n", " Tried: `(nil ?error-message)`\n Tried: `(_)`")) end - return r_12991((r_13001 + 1)) + return r_13151((r_13161 + 1)) else end end) - r_12991(1) + r_13151(1) else - error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_12871), ", but none matched.\n", " Tried: `(nil ?error-message)`\n Tried: `(?lib)`")) + error1(_2e2e_2("Pattern matching failure!\nTried to match the following patterns against ", pretty1(r_13031), ", but none matched.\n", " Tried: `(nil ?error-message)`\n Tried: `(?lib)`")) end stopTimer_21_1(compiler14["timer"], "loading") -local r_13171 = tasks1["n"] -local r_13151 = nil -r_13151 = (function(r_13161) - if (r_13161 <= r_13171) then - local task6 = tasks1[r_13161] +local r_13331 = tasks1["n"] +local r_13311 = nil +r_13311 = (function(r_13321) + if (r_13321 <= r_13331) then + local task6 = tasks1[r_13321] if task6["pred"](args32) then startTimer_21_1(compiler14["timer"], task6["name"], 1) task6["run"](compiler14, args32) stopTimer_21_1(compiler14["timer"], task6["name"]) end - return r_13151((r_13161 + 1)) + return r_13311((r_13321 + 1)) else end end) -return r_13151(1) +return r_13311(1) diff --git a/tacky/logger/init.lua b/tacky/logger/init.lua index 30ce013..1b5d121 100644 --- a/tacky/logger/init.lua +++ b/tacky/logger/init.lua @@ -13,72 +13,33 @@ local _temp = (function() } end)() for k, v in pairs(_temp) do _libs["lua/basic-0/".. k] = v end -local _3d_1, _2f3d_1, _3c3d_1, _2b_1, _2d_1, _25_1, error1, getIdx1, setIdx_21_1, type_23_1, find1, match1, sub1, concat1, unpack1, type1, _2e2e_1, clock1, getenv1, struct1, self1, startTimer_21_1, pauseTimer_21_1, stopTimer_21_1, config1, coloredAnsi1, colored_3f_1, colored1, putError_21_1, putWarning_21_1, putVerbose_21_1, putDebug_21_1, putNodeError_21_1, putNodeWarning_21_1, doNodeError_21_1 -_3d_1 = function(v1, v2) return (v1 == v2) end +local _2f3d_1, _2b_1, _2d_1, error1, getIdx1, setIdx_21_1, find1, match1, sub1, concat1, unpack1, _2e2e_1, clock1, getenv1, self1, startTimer_21_1, pauseTimer_21_1, stopTimer_21_1, config1, coloredAnsi1, colored_3f_1, colored1, putError_21_1, putWarning_21_1, putVerbose_21_1, putDebug_21_1, putNodeError_21_1, putNodeWarning_21_1, doNodeError_21_1 _2f3d_1 = function(v1, v2) return (v1 ~= v2) end -_3c3d_1 = function(v1, v2) return (v1 <= v2) end _2b_1 = function(v1, v2) return (v1 + v2) end _2d_1 = function(v1, v2) return (v1 - v2) end -_25_1 = function(v1, v2) return (v1 % v2) end error1 = error getIdx1 = function(v1, v2) return v1[v2] end setIdx_21_1 = function(v1, v2, v3) v1[v2] = v3 end -type_23_1 = type find1 = string.find match1 = string.match sub1 = string.sub concat1 = table.concat unpack1 = table.unpack -type1 = (function(val1) - local ty1 = type_23_1(val1) - if (ty1 == "table") then - return (val1["tag"] or "table") - else - return ty1 - end -end) _2e2e_1 = (function(...) local args1 = _pack(...) args1.tag = "list" return concat1(args1) end) clock1 = os.clock getenv1 = os.getenv -struct1 = (function(...) - local entries1 = _pack(...) entries1.tag = "list" - if ((entries1["n"] % 2) == 1) then - error1("Expected an even number of arguments to struct", 2) - end - local out1 = {} - local r_1071 = entries1["n"] - local r_1051 = nil - r_1051 = (function(r_1061) - if (r_1061 <= r_1071) then - local key1 = entries1[r_1061] - local val2 = entries1[(1 + r_1061)] - out1[(function() - if (type1(key1) == "key") then - return key1["contents"] - else - return key1 - end - end)() - ] = val2 - return r_1051((r_1061 + 2)) - else - end - end) - r_1051(1) - return out1 -end) -self1 = (function(x1, key2, ...) +self1 = (function(x1, key1, ...) local args2 = _pack(...) args2.tag = "list" - return x1[key2](x1, unpack1(args2, 1, args2["n"])) + return x1[key1](x1, unpack1(args2, 1, args2["n"])) end) startTimer_21_1 = (function(timer1, name1, level1) local instance1 = timer1["timers"][name1] if instance1 then else - instance1 = {["name"]=name1,["level"]=(level1 or 1),["running"]=false,["total"]=0} + instance1 = ({["name"]=name1,["level"]=(level1 or 1),["running"]=false,["total"]=0}) timer1["timers"][name1] = instance1 end if instance1["running"] then @@ -174,4 +135,4 @@ doNodeError_21_1 = (function(logger7, msg9, node3, explain3, ...) self1(logger7, "put-node-error!", msg9, node3, explain3, lines3) return error1((match1(msg9, "^([^\n]+)\n") or msg9), 0) end) -return struct1("startTimer", startTimer_21_1, "pauseTimer", pauseTimer_21_1, "stopTimer", stopTimer_21_1, "putError", putError_21_1, "putWarning", putWarning_21_1, "putVerbose", putVerbose_21_1, "putDebug", putDebug_21_1, "putNodeError", putNodeError_21_1, "putNodeWarning", putNodeWarning_21_1, "doNodeError", doNodeError_21_1, "colored", colored1) +return ({["startTimer"]=startTimer_21_1,["pauseTimer"]=pauseTimer_21_1,["stopTimer"]=stopTimer_21_1,["putError"]=putError_21_1,["putWarning"]=putWarning_21_1,["putVerbose"]=putVerbose_21_1,["putDebug"]=putDebug_21_1,["putNodeError"]=putNodeError_21_1,["putNodeWarning"]=putNodeWarning_21_1,["doNodeError"]=doNodeError_21_1,["colored"]=colored1}) diff --git a/tacky/range.lua b/tacky/range.lua index 4abec3b..c6afefd 100644 --- a/tacky/range.lua +++ b/tacky/range.lua @@ -13,56 +13,14 @@ local _temp = (function() } end)() for k, v in pairs(_temp) do _libs["lua/basic-0/".. k] = v end -local _3d_1, _3c3d_1, _2b_1, _25_1, error1, getIdx1, setIdx_21_1, type_23_1, format1, concat1, type1, _2e2e_1, struct1, formatPosition1, formatRange1, formatNode1, getSource1 -_3d_1 = function(v1, v2) return (v1 == v2) end -_3c3d_1 = function(v1, v2) return (v1 <= v2) end -_2b_1 = function(v1, v2) return (v1 + v2) end -_25_1 = function(v1, v2) return (v1 % v2) end -error1 = error +local getIdx1, format1, concat1, _2e2e_1, formatPosition1, formatRange1, formatNode1, getSource1 getIdx1 = function(v1, v2) return v1[v2] end -setIdx_21_1 = function(v1, v2, v3) v1[v2] = v3 end -type_23_1 = type format1 = string.format concat1 = table.concat -type1 = (function(val1) - local ty1 = type_23_1(val1) - if (ty1 == "table") then - return (val1["tag"] or "table") - else - return ty1 - end -end) _2e2e_1 = (function(...) local args1 = _pack(...) args1.tag = "list" return concat1(args1) end) -struct1 = (function(...) - local entries1 = _pack(...) entries1.tag = "list" - if ((entries1["n"] % 2) == 1) then - error1("Expected an even number of arguments to struct", 2) - end - local out1 = {} - local r_1071 = entries1["n"] - local r_1051 = nil - r_1051 = (function(r_1061) - if (r_1061 <= r_1071) then - local key1 = entries1[r_1061] - local val2 = entries1[(1 + r_1061)] - out1[(function() - if (type1(key1) == "key") then - return key1["contents"] - else - return key1 - end - end)() - ] = val2 - return r_1051((r_1061 + 2)) - else - end - end) - r_1051(1) - return out1 -end) formatPosition1 = (function(pos1) return _2e2e_1(pos1["line"], ":", pos1["column"]) end) @@ -99,16 +57,16 @@ formatNode1 = (function(node1) end) getSource1 = (function(node2) local result1 = nil - local r_2131 = nil - r_2131 = (function() + local r_2171 = nil + r_2171 = (function() if (node2 and not result1) then result1 = node2["range"] node2 = node2["parent"] - return r_2131() + return r_2171() else end end) - r_2131() + r_2171() return result1 end) -return struct1("formatPosition", formatPosition1, "formatRange", formatRange1, "formatNode", formatNode1, "getSource", getSource1) +return ({["formatPosition"]=formatPosition1,["formatRange"]=formatRange1,["formatNode"]=formatNode1,["getSource"]=getSource1}) diff --git a/tacky/traceback.lua b/tacky/traceback.lua index addc576..8e8ef41 100644 --- a/tacky/traceback.lua +++ b/tacky/traceback.lua @@ -13,14 +13,13 @@ local _temp = (function() } end)() for k, v in pairs(_temp) do _libs["lua/basic-0/".. k] = v end -local _3d_1, _2f3d_1, _3c_1, _3c3d_1, _3e3d_1, _2b_1, _25_1, error1, getIdx1, setIdx_21_1, tonumber1, type_23_1, char1, find1, format1, gsub1, len1, lower1, match1, sub1, concat1, list1, between_3f_1, type1, pushCdr_21_1, _2e2e_1, struct1, unmangleIdent1, remapError1, remapMessage1, remapTraceback1 +local _3d_1, _2f3d_1, _3c_1, _3c3d_1, _3e3d_1, _2b_1, error1, getIdx1, setIdx_21_1, tonumber1, type_23_1, char1, find1, format1, gsub1, len1, lower1, match1, sub1, concat1, list1, between_3f_1, type1, pushCdr_21_1, _2e2e_1, unmangleIdent1, remapError1, remapMessage1, remapTraceback1 _3d_1 = function(v1, v2) return (v1 == v2) end _2f3d_1 = function(v1, v2) return (v1 ~= v2) end _3c_1 = function(v1, v2) return (v1 < v2) end _3c3d_1 = function(v1, v2) return (v1 <= v2) end _3e3d_1 = function(v1, v2) return (v1 >= v2) end _2b_1 = function(v1, v2) return (v1 + v2) end -_25_1 = function(v1, v2) return (v1 % v2) end error1 = error getIdx1 = function(v1, v2) return v1[v2] end setIdx_21_1 = function(v1, v2, v3) v1[v2] = v3 end @@ -51,9 +50,9 @@ type1 = (function(val2) end end) pushCdr_21_1 = (function(xs2, val3) - local r_841 = type1(xs2) - if (r_841 ~= "list") then - error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_841), 2) + local r_791 = type1(xs2) + if (r_791 ~= "list") then + error1(format1("bad argument %s (expected %s, got %s)", "xs", "list", r_791), 2) end local len2 = (xs2["n"] + 1) xs2["n"] = len2 @@ -64,33 +63,6 @@ _2e2e_1 = (function(...) local args1 = _pack(...) args1.tag = "list" return concat1(args1) end) -struct1 = (function(...) - local entries1 = _pack(...) entries1.tag = "list" - if ((entries1["n"] % 2) == 1) then - error1("Expected an even number of arguments to struct", 2) - end - local out1 = {} - local r_1071 = entries1["n"] - local r_1051 = nil - r_1051 = (function(r_1061) - if (r_1061 <= r_1071) then - local key1 = entries1[r_1061] - local val4 = entries1[(1 + r_1061)] - out1[(function() - if (type1(key1) == "key") then - return key1["contents"] - else - return key1 - end - end)() - ] = val4 - return r_1051((r_1061 + 2)) - else - end - end) - r_1051(1) - return out1 -end) unmangleIdent1 = (function(ident1) local esc1 = match1(ident1, "^(.-)%d+$") if (esc1 == nil) then @@ -101,28 +73,28 @@ unmangleIdent1 = (function(ident1) local buffer1 = ({tag = "list", n = 0}) local pos1 = 0 local len3 = len1(esc1) - local r_2111 = nil - r_2111 = (function() + local r_2151 = nil + r_2151 = (function() if (pos1 <= len3) then local char2 local x1 = pos1 char2 = sub1(esc1, x1, x1) if (char2 == "_") then - local r_2161 = list1(find1(esc1, "^_[%da-z]+_", pos1)) - if ((type1(r_2161) == "list") and ((r_2161["n"] >= 2) and ((r_2161["n"] <= 2) and true))) then - local start1 = r_2161[1] - local _eend1 = r_2161[2] + local r_2201 = list1(find1(esc1, "^_[%da-z]+_", pos1)) + if ((type1(r_2201) == "list") and ((r_2201["n"] >= 2) and ((r_2201["n"] <= 2) and true))) then + local start1 = r_2201[1] + local _eend1 = r_2201[2] pos1 = (pos1 + 1) - local r_2411 = nil - r_2411 = (function() + local r_2451 = nil + r_2451 = (function() if (pos1 < _eend1) then pushCdr_21_1(buffer1, char1(tonumber1(sub1(esc1, pos1, (pos1 + 1)), 16))) pos1 = (pos1 + 2) - return r_2411() + return r_2451() else end end) - r_2411() + r_2451() else pushCdr_21_1(buffer1, "_") end @@ -133,11 +105,11 @@ unmangleIdent1 = (function(ident1) pushCdr_21_1(buffer1, char2) end pos1 = (pos1 + 1) - return r_2111() + return r_2151() else end end) - r_2111() + r_2151() return concat1(buffer1) end end) @@ -153,11 +125,11 @@ remapError1 = (function(msg1) end))) end) remapMessage1 = (function(mappings1, msg2) - local r_2261 = list1(match1(msg2, "^(.-):(%d+)(.*)$")) - if ((type1(r_2261) == "list") and ((r_2261["n"] >= 3) and ((r_2261["n"] <= 3) and true))) then - local file1 = r_2261[1] - local line1 = r_2261[2] - local extra1 = r_2261[3] + local r_2301 = list1(match1(msg2, "^(.-):(%d+)(.*)$")) + if ((type1(r_2301) == "list") and ((r_2301["n"] >= 3) and ((r_2301["n"] <= 3) and true))) then + local file1 = r_2301[1] + local line1 = r_2301[2] + local extra1 = r_2301[3] local mapping1 = mappings1[file1] if mapping1 then local range1 = mapping1[tonumber1(line1)] @@ -174,8 +146,8 @@ remapMessage1 = (function(mappings1, msg2) end end) remapTraceback1 = (function(mappings2, msg3) - return gsub1(gsub1(gsub1(gsub1(gsub1(gsub1(gsub1(msg3, "^([^\n:]-:%d+:[^\n]*)", (function(r_2401) - return remapMessage1(mappings2, r_2401) + return gsub1(gsub1(gsub1(gsub1(gsub1(gsub1(gsub1(msg3, "^([^\n:]-:%d+:[^\n]*)", (function(r_2441) + return remapMessage1(mappings2, r_2441) end)), "\9([^\n:]-:%d+:)", (function(msg4) return _2e2e_1("\9", remapMessage1(mappings2, msg4)) end)), "<([^\n:]-:%d+)>\n", (function(msg5) @@ -190,4 +162,4 @@ remapTraceback1 = (function(mappings2, msg3) return _2e2e_1("in function '", unmangleIdent1(x9), "'\n") end)) end) -return struct1("remapTraceback", remapTraceback1) +return ({["remapTraceback"]=remapTraceback1})