summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2013-04-14 23:03:58 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2013-04-14 23:03:58 +0200
commit7b2ac38cf888ed3269b5e3ef72a80fa4ae12841f (patch)
tree1a012fd7c9e996348091f4b7f6dad35f02df2490
parent9d3e292ead8e354c836d0c4dcd25e0b4aa03486c (diff)
downloadlualibs-7b2ac38cf888ed3269b5e3ef72a80fa4ae12841f.tar.gz
import changes from Context 2013.04.14 16:51
-rw-r--r--lualibs-lpeg.lua2
-rw-r--r--lualibs-lua.lua13
-rw-r--r--lualibs-util-mrg.lua67
3 files changed, 50 insertions, 32 deletions
diff --git a/lualibs-lpeg.lua b/lualibs-lpeg.lua
index 681ef09..323c73b 100644
--- a/lualibs-lpeg.lua
+++ b/lualibs-lpeg.lua
@@ -300,7 +300,7 @@ function string.splitlines(str)
return lpegmatch(linesplitter,str)
end
---~ lpeg.splitters = cache -- no longer public
+-- lpeg.splitters = cache -- no longer public
local cache = { }
diff --git a/lualibs-lua.lua b/lualibs-lua.lua
index 538c65d..5181640 100644
--- a/lualibs-lua.lua
+++ b/lualibs-lua.lua
@@ -356,7 +356,7 @@ end
local function notloaded(name)
if helpers.trace then
- helpers.report("? unable to locate library '%s'",name)
+ helpers.report("unable to locate library '%s'",name)
end
end
@@ -391,3 +391,14 @@ function helpers.loaded(name)
end
return notloaded(name)
end
+
+function helpers.unload(name)
+ if helpers.trace then
+ if package.loaded[name] then
+ helpers.report("unloading library '%s', %s",name,"done")
+ else
+ helpers.report("unloading library '%s', %s",name,"not loaded")
+ end
+ end
+ package.loaded[name] = nil
+end
diff --git a/lualibs-util-mrg.lua b/lualibs-util-mrg.lua
index 78b23dc..690188e 100644
--- a/lualibs-util-mrg.lua
+++ b/lualibs-util-mrg.lua
@@ -77,36 +77,43 @@ end
-- -- saves some 20K .. ldx comments
-- data = gsub(data,"%-%-%[%[ldx%-%-.-%-%-ldx%]%]%-%-","")
-local space = patterns.space
-local eol = patterns.newline
-local equals = P("=")^0
-local open = P("[") * Cg(equals,"init") * P("[") * P("\n")^-1
-local close = P("]") * C(equals) * P("]")
-local closeeq = Cmt(close * Cb("init"), function(s,i,a,b) return a == b end)
-local longstring = open * (1 - closeeq)^0 * close
-
-local quoted = patterns.quoted
-local emptyline = space^0 * eol
-local operator1 = P("<=") + P(">=") + P("~=") + P("..") + S("/^<>=*+%%")
-local operator2 = S("*+/")
-local operator3 = S("-")
-local separator = S(",;")
-
-local ignore = (P("]") * space^1 * P("=") * space^1 * P("]")) / "]=[" +
- (P("=") * space^1 * P("{")) / "={" +
- (P("(") * space^1) / "(" +
- (P("{") * (space+eol)^1 * P("}")) / "{}"
-local strings = quoted -- / function (s) print("<<"..s..">>") return s end
-local longcmt = (emptyline^0 * P("--") * longstring * emptyline^0) / ""
-local longstr = longstring
-local comment = emptyline^0 * P("--") * P("-")^0 * (1-eol)^0 * emptyline^1 / "\n"
-local pack = ((eol+space)^0 / "") * operator1 * ((eol+space)^0 / "") +
- ((eol+space)^0 / "") * operator2 * ((space)^0 / "") +
- ((eol+space)^1 / "") * operator3 * ((space)^1 / "") +
- ((space)^0 / "") * separator * ((space)^0 / "")
-local lines = emptyline^2 / "\n"
-local spaces = (space * space) / " "
------ spaces = ((space+eol)^1 ) / " "
+local space = patterns.space
+local eol = patterns.newline
+local equals = P("=")^0
+local open = P("[") * Cg(equals,"init") * P("[") * P("\n")^-1
+local close = P("]") * C(equals) * P("]")
+local closeeq = Cmt(close * Cb("init"), function(s,i,a,b) return a == b end)
+local longstring = open * (1 - closeeq)^0 * close
+
+local quoted = patterns.quoted
+local digit = patterns.digit
+local emptyline = space^0 * eol
+local operator1 = P("<=") + P(">=") + P("~=") + P("..") + S("/^<>=*+%%")
+local operator2 = S("*+/")
+local operator3 = S("-")
+local operator4 = P("..")
+local separator = S(",;")
+
+local ignore = (P("]") * space^1 * P("=") * space^1 * P("]")) / "]=[" +
+ (P("=") * space^1 * P("{")) / "={" +
+ (P("(") * space^1) / "(" +
+ (P("{") * (space+eol)^1 * P("}")) / "{}"
+local strings = quoted -- / function (s) print("<<"..s..">>") return s end
+local longcmt = (emptyline^0 * P("--") * longstring * emptyline^0) / ""
+local longstr = longstring
+local comment = emptyline^0 * P("--") * P("-")^0 * (1-eol)^0 * emptyline^1 / "\n"
+local optionalspaces = space^0 / ""
+local mandatespaces = space^1 / ""
+local optionalspacing = (eol+space)^0 / ""
+local mandatespacing = (eol+space)^1 / ""
+local pack = digit * space^1 * operator4 * optionalspacing +
+ optionalspacing * operator1 * optionalspacing +
+ optionalspacing * operator2 * optionalspaces +
+ mandatespacing * operator3 * mandatespaces +
+ optionalspaces * separator * optionalspaces
+local lines = emptyline^2 / "\n"
+local spaces = (space * space) / " "
+----- spaces = ((space+eol)^1 ) / " "
local compact = Cs ( (
ignore +