diff options
author | Marius <mariausol@gmail.com> | 2012-10-20 04:00:13 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2012-10-20 04:00:13 +0300 |
commit | 1fbec75954e7911bd1546a04af666fc1a3827a54 (patch) | |
tree | 16f39836f5e13bd1220a2ffc55e11912dde5bd82 /tex/context/base/l-lpeg.lua | |
parent | c36e19abdfd15bf6cae6fa379c6ce51f3ef5332d (diff) | |
download | context-1fbec75954e7911bd1546a04af666fc1a3827a54.tar.gz |
beta 2012.10.20 02:07
Diffstat (limited to 'tex/context/base/l-lpeg.lua')
-rw-r--r-- | tex/context/base/l-lpeg.lua | 48 |
1 files changed, 11 insertions, 37 deletions
diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua index d92b722ed..38ac3c0dd 100644 --- a/tex/context/base/l-lpeg.lua +++ b/tex/context/base/l-lpeg.lua @@ -431,15 +431,10 @@ end function lpeg.replacer(one,two) if type(one) == "table" then local no = #one - local p + local p = P(false) if no == 0 then for k, v in next, one do - local pp = P(k) / v - if p then - p = p + pp - else - p = pp - end + p = p + P(k) / v end return Cs((p + 1)^0) elseif no == 1 then @@ -449,12 +444,7 @@ function lpeg.replacer(one,two) else for i=1,no do local o = one[i] - local pp = P(o[1]) / o[2] - if p then - p = p + pp - else - p = pp - end + p = p + P(o[1]) / o[2] end return Cs((p + 1)^0) end @@ -585,13 +575,9 @@ lpeg.UP = lpeg.P if utfcharacters then function lpeg.US(str) - local p + local p = P(false) for uc in utfcharacters(str) do - if p then - p = p + P(uc) - else - p = P(uc) - end + p = p + P(uc) end return p end @@ -600,13 +586,9 @@ if utfcharacters then elseif utfgmatch then function lpeg.US(str) - local p + local p = P(false) for uc in utfgmatch(str,".") do - if p then - p = p + P(uc) - else - p = P(uc) - end + p = p + P(uc) end return p end @@ -614,13 +596,9 @@ elseif utfgmatch then else function lpeg.US(str) - local p + local p = P(false) local f = function(uc) - if p then - p = p + P(uc) - else - p = P(uc) - end + p = p + P(uc) end lpegmatch((utf8char/f)^0,str) return p @@ -646,13 +624,9 @@ function lpeg.UR(str,more) if first == last then return P(str) elseif utfchar and last - first < 8 then -- a somewhat arbitrary criterium - local p + local p = P(false) for i=first,last do - if p then - p = p + P(utfchar(i)) - else - p = P(utfchar(i)) - end + p = p + P(utfchar(i)) end return p -- nil when invalid range else |