From 8c0bb98e13632d6caf24fd08261ff4bca4fdd4eb Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Wed, 12 May 2010 18:43:00 +0200 Subject: beta 2010.05.12 18:43 --- tex/context/base/l-lpeg.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tex/context/base/l-lpeg.lua') 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 -- cgit v1.2.3