diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2015-04-10 16:15:05 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2015-04-10 16:15:05 +0200 |
commit | cb778ed4a2252111bd0498f3d80ebe9ab03c8b41 (patch) | |
tree | bc48741edfe8843d64d5d0aed0df7b333fd4d62c /tex/context/base/l-lpeg.lua | |
parent | c8d9322c99e6fca7e972605f7a180a694d080e2c (diff) | |
download | context-cb778ed4a2252111bd0498f3d80ebe9ab03c8b41.tar.gz |
2015-04-10 15:21:00
Diffstat (limited to 'tex/context/base/l-lpeg.lua')
-rw-r--r-- | tex/context/base/l-lpeg.lua | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/tex/context/base/l-lpeg.lua b/tex/context/base/l-lpeg.lua index 9225b57b2..4aadadb72 100644 --- a/tex/context/base/l-lpeg.lua +++ b/tex/context/base/l-lpeg.lua @@ -841,7 +841,7 @@ local function make(t) local function making(t) local p = p_false local keys = sortedkeys(t) - local okay = t[""] +-- local okay = t[""] for i=1,#keys do local k = keys[i] if k ~= "" then @@ -850,13 +850,16 @@ local function make(t) p = p + P(k) * p_true elseif v == false then -- can't happen - elseif okay then - p = p + P(k) * (making(v) + p_true) +-- elseif okay then +-- p = p + P(k) * (making(v) + p_true) else p = p + P(k) * making(v) end end end + if t[""] then + p = p + p_true + end return p end local p = p_false @@ -869,8 +872,8 @@ local function make(t) p = p + P(k) * p_true elseif v == false then -- can't happen - elseif v[""] then - p = p + P(k) * (making(v) + p_true) +-- elseif v[""] then +-- p = p + P(k) * (making(v) + p_true) else p = p + P(k) * making(v) end @@ -956,10 +959,11 @@ function lpeg.utfchartabletopattern(list) -- goes to util-lpg return make(tree) end --- local t = { "a", "abc", "ac", "abe", "abxyz", "xy", "bef" } +-- local t = { "a", "abc", "ac", "abe", "abxyz", "xy", "bef","aa" } -- local p = lpeg.Cs((lpeg.utfchartabletopattern(t)/string.upper + 1)^1) --- + -- inspect(lpegmatch(p,"a")) +-- inspect(lpegmatch(p,"aa")) -- inspect(lpegmatch(p,"aaaa")) -- inspect(lpegmatch(p,"ac")) -- inspect(lpegmatch(p,"bc")) @@ -974,6 +978,14 @@ end -- inspect(lpegmatch(p,"abxyz")) -- inspect(lpegmatch(p,"foobarbefcrap")) +-- local t = { ["^"] = 1, ["^^"] = 2, ["^^^"] = 3, ["^^^^"] = 4 } +-- local p = lpeg.Cs((lpeg.utfchartabletopattern(t)/t + 1)^1) +-- inspect(lpegmatch(p," ^ ^^ ^^^ ^^^^ ^^^^^ ^^^^^^ ^^^^^^^ ")) + +-- local t = { ["^^"] = 2, ["^^^"] = 3, ["^^^^"] = 4 } +-- local p = lpeg.Cs((lpeg.utfchartabletopattern(t)/t + 1)^1) +-- inspect(lpegmatch(p," ^ ^^ ^^^ ^^^^ ^^^^^ ^^^^^^ ^^^^^^^ ")) + -- lpeg.utfchartabletopattern { -- utfchar(0x00A0), -- nbsp -- utfchar(0x2000), -- enquad |