From d65c11e8d9b7a400dd62635c30da3bac4b968d36 Mon Sep 17 00:00:00 2001 From: Reuh Date: Mon, 17 May 2021 14:29:08 +0200 Subject: [PATCH] Fix Candran loader --- candran.can | 4 ++-- candran.lua | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/candran.can b/candran.can index e5fbefa..3b433ac 100644 --- a/candran.can +++ b/candran.can @@ -316,10 +316,10 @@ function candran.searcher(modpath) return "\n\tno candran file in package.path" end end - return () + return (modpath) -- 2nd argument is not passed in Lua 5.1, so a closure is required local r, s = candran.loadfile(filepath) if r then - return r() + return r(modpath, filepath) else error("error loading candran module '%s' from file '%s':\n\t%s":format(modpath, filepath, s), 0) end diff --git a/candran.lua b/candran.lua index 14357bd..514e2d8 100644 --- a/candran.lua +++ b/candran.lua @@ -6347,10 +6347,10 @@ end + P("--") * (P(1) - P("\ ["ShortStr"] = P("\"") * Cs((V("EscSeq") + (P(1) - S("\"\ "))) ^ 0) * expect(P("\""), "Quote") + P("'") * Cs((V("EscSeq") + (P(1) - S("'\ "))) ^ 0) * expect(P("'"), "Quote"), -- ./candran/can-parser/parser.lua:693 -["EscSeq"] = P("\\") / "" * (P("a") / "\7" + P("b") / "\8" + P("f") / "\12" + P("n") / "\ -" + P("r") / "\13" + P("t") / "\9" + P("v") / "\11" + P("\ +["EscSeq"] = P("\\") / "" * (P("a") / "" + P("b") / "" + P("f") / " " + P("n") / "\ +" + P("r") / "\r" + P("t") / " " + P("v") / " " + P("\ ") / "\ -" + P("\13") / "\ +" + P("\r") / "\ " + P("\\") / "\\" + P("\"") / "\"" + P("'") / "'" + P("z") * space ^ 0 / "" + digit * digit ^ - 2 / tonumber / string["char"] + P("x") * expect(C(xdigit * xdigit), "HexEsc") * Cc(16) / tonumber / string["char"] + P("u") * expect("{", "OBraceUEsc") * expect(C(xdigit ^ 1), "DigitUEsc") * Cc(16) * expect("}", "CBraceUEsc") / tonumber / (utf8 and utf8["char"] or string["char"]) + throw("EscSeq")), -- ./candran/can-parser/parser.lua:723 ["LongStr"] = V("Open") * C((P(1) - V("CloseEq")) ^ 0) * expect(V("Close"), "CloseLStr") / function(s, eqs) -- ./candran/can-parser/parser.lua:726 return s -- ./candran/can-parser/parser.lua:726 @@ -6495,7 +6495,7 @@ env["write"](f:read("*a")) -- candran.can:128 f:close() -- candran.can:129 end -- candran.can:129 env["write"] = function(...) -- candran.can:133 -env["output"] = env["output"] .. (table["concat"]({ ... }, "\9") .. "\ +env["output"] = env["output"] .. (table["concat"]({ ... }, " ") .. "\ ") -- candran.can:134 end -- candran.can:134 env["placeholder"] = function(name) -- candran.can:138 @@ -6642,16 +6642,16 @@ if _VERSION == "Lua 5.4" then -- candran.can:313 return "no candran file in package.path" -- candran.can:314 else -- candran.can:314 return "\ -\9no candran file in package.path" -- candran.can:316 + no candran file in package.path" -- candran.can:316 end -- candran.can:316 end -- candran.can:316 -return function() -- candran.can:319 +return function(modpath) -- candran.can:319 local r, s = candran["loadfile"](filepath) -- candran.can:320 if r then -- candran.can:321 -return r() -- candran.can:322 +return r(modpath, filepath) -- candran.can:322 else -- candran.can:322 error(("error loading candran module '%s' from file '%s':\ -\9%s"):format(modpath, filepath, s), 0) -- candran.can:324 + %s"):format(modpath, filepath, s), 0) -- candran.can:324 end -- candran.can:324 end, filepath -- candran.can:326 end -- candran.can:326 @@ -6668,7 +6668,7 @@ if s == candran["searcher"] then -- candran.can:338 return candran -- candran.can:339 end -- candran.can:339 end -- candran.can:339 -table["insert"](searchers, 2, candran["searcher"]) -- candran.can:343 +table["insert"](searchers, 1, candran["searcher"]) -- candran.can:343 return candran -- candran.can:344 end -- candran.can:344 return candran -- candran.can:347