summaryrefslogtreecommitdiff
path: root/lualibs-lpeg.lua
diff options
context:
space:
mode:
authorKhaled Hosny <khaledhosny@eglug.org>2010-05-21 06:22:29 +0300
committerKhaled Hosny <khaledhosny@eglug.org>2010-05-21 06:22:29 +0300
commit5f2ef13d20837eb9c0fe84a378e70c5066e6d021 (patch)
tree8da8eb76198b5015119d88aeb0480dedefa27e1d /lualibs-lpeg.lua
parent2ede45796e70760267e4928dfff04d3546a8f159 (diff)
downloadlualibs-5f2ef13d20837eb9c0fe84a378e70c5066e6d021.tar.gz
Sync with ConTeXt beta (beta 2010.05.20)
Needed to sync luaotfload.
Diffstat (limited to 'lualibs-lpeg.lua')
-rw-r--r--lualibs-lpeg.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/lualibs-lpeg.lua b/lualibs-lpeg.lua
index f060f3b..b107a8e 100644
--- a/lualibs-lpeg.lua
+++ b/lualibs-lpeg.lua
@@ -98,6 +98,15 @@ lpeg.splitat = splitat
local cache = { }
+function lpeg.split(separator,str)
+ local c = cache[separator]
+ if not c then
+ c = Ct(splitat(separator))
+ cache[separator] = c
+ end
+ return match(c,str)
+end
+
function string:split(separator)
local c = cache[separator]
if not c then
@@ -107,8 +116,21 @@ function string:split(separator)
return match(c,self)
end
+lpeg.splitters = cache
+
local cache = { }
+function lpeg.checkedsplit(separator,str)
+ local c = cache[separator]
+ if not c then
+ separator = P(separator)
+ local other = C((1 - separator)^0)
+ c = Ct(separator^0 * other * (separator^1 * other)^0)
+ cache[separator] = c
+ end
+ return match(c,str)
+end
+
function string:checkedsplit(separator)
local c = cache[separator]
if not c then