summaryrefslogtreecommitdiff
path: root/tex/context/base/l-lpeg.lua
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2010-05-12 18:43:00 +0200
committerHans Hagen <pragma@wxs.nl>2010-05-12 18:43:00 +0200
commit8c0bb98e13632d6caf24fd08261ff4bca4fdd4eb (patch)
tree79c561dbc438a8e8089e289aa89710ee4783cee1 /tex/context/base/l-lpeg.lua
parent8ad1a9bed2cf3271f1922759060c2ba1c8e3ced1 (diff)
downloadcontext-8c0bb98e13632d6caf24fd08261ff4bca4fdd4eb.tar.gz
beta 2010.05.12 18:43
Diffstat (limited to 'tex/context/base/l-lpeg.lua')
-rw-r--r--tex/context/base/l-lpeg.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua
index f060f3b36..c936d0010 100644
--- a/tex/context/base/l-lpeg.lua
+++ b/tex/context/base/l-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
@@ -109,6 +118,17 @@ end
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