diff options
author | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2010-05-29 09:25:56 +0000 |
---|---|---|
committer | Manuel Pégourié-Gonnard <mpg@elzevir.fr> | 2010-05-29 09:25:56 +0000 |
commit | e62580242146a93f7836af785779cfd1a79e0ce1 (patch) | |
tree | 4f9364e96e8ff73dfedf7c8135d1f6593fefcaaa /Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua | |
parent | cdcd956592bbd615b0540c0cac7d19a5fceed9b7 (diff) |
lualibs update (2010/05/28 v0.94)
git-svn-id: svn://tug.org/texlive/trunk@18577 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua')
-rw-r--r-- | Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua b/Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua index f060f3b366c..b107a8e6432 100644 --- a/Master/texmf-dist/tex/luatex/lualibs/lualibs-lpeg.lua +++ b/Master/texmf-dist/tex/luatex/lualibs/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 |