diff options
author | Hans Hagen <pragma@wxs.nl> | 2018-12-17 18:19:48 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2018-12-17 18:19:48 +0100 |
commit | 15b67b20aa0d6c508578d0ca8cbdcd9cff9829a8 (patch) | |
tree | d656b4161487a8c54d954458084914c7d408aca7 /tex/context/base/mkiv/l-lpeg.lua | |
parent | 5bb786877a5617fb8fbe3fd0e7b54fbcea3ce002 (diff) | |
download | context-15b67b20aa0d6c508578d0ca8cbdcd9cff9829a8.tar.gz |
2018-12-17 16:49:00
Diffstat (limited to 'tex/context/base/mkiv/l-lpeg.lua')
-rw-r--r-- | tex/context/base/mkiv/l-lpeg.lua | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/tex/context/base/mkiv/l-lpeg.lua b/tex/context/base/mkiv/l-lpeg.lua index eb55a55a0..51bc1d3df 100644 --- a/tex/context/base/mkiv/l-lpeg.lua +++ b/tex/context/base/mkiv/l-lpeg.lua @@ -657,83 +657,6 @@ function lpeg.counter(pattern,action) end end --- utf extensies - --- utf = utf or (unicode and unicode.utf8) or { } -utf = utf or { } - -local utfcharacters = utf and utf.characters or string.utfcharacters -local utfgmatch = utf and utf.gmatch -local utfchar = utf and utf.char - -lpeg.UP = lpeg.P - -if utfcharacters then - - function lpeg.US(str) - local p = P(false) - for uc in utfcharacters(str) do - p = p + P(uc) - end - return p - end - - -elseif utfgmatch then - - function lpeg.US(str) - local p = P(false) - for uc in utfgmatch(str,".") do - p = p + P(uc) - end - return p - end - -else - - function lpeg.US(str) - local p = P(false) - local f = function(uc) - p = p + P(uc) - end - lpegmatch((utf8char/f)^0,str) - return p - end - -end - -local range = utf8byte * utf8byte + Cc(false) -- utf8byte is already a capture - -function lpeg.UR(str,more) - local first, last - if type(str) == "number" then - first = str - last = more or first - else - first, last = lpegmatch(range,str) - if not last then - return P(str) - end - end - if first == last then - return P(str) - elseif utfchar and (last - first < 8) then -- a somewhat arbitrary criterium - local p = P(false) - for i=first,last do - p = p + P(utfchar(i)) - end - return p -- nil when invalid range - else - local f = function(b) - return b >= first and b <= last - end - -- tricky, these nested captures - return utf8byte / f -- nil when invalid range - end -end - --- print(lpeg.match(lpeg.Cs((C(lpeg.UR("αω"))/{ ["χ"] = "OEPS" })^0),"αωχαω")) - -- lpeg.print(lpeg.R("ab","cd","gh")) -- lpeg.print(lpeg.P("a","b","c")) -- lpeg.print(lpeg.S("a","b","c")) @@ -1052,7 +975,6 @@ function lpeg.utfreplacer(list,insensitive) end end - -- local t = { "start", "stoep", "staart", "paard" } -- local p = lpeg.Cs((lpeg.utfchartabletopattern(t)/string.upper + 1)^1) |