diff options
author | Hans Hagen <pragma@wxs.nl> | 2012-01-05 19:27:36 +0100 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2012-01-05 19:27:36 +0100 |
commit | 1b023b411cc3c2b9701ddca2f3caaba010e51730 (patch) | |
tree | 6632c508ca4f3095f0260ae074d53ba90227460d /tex/generic | |
parent | 6ef8659db06139f3e00aa60ac699434d1f4665d3 (diff) | |
download | context-1b023b411cc3c2b9701ddca2f3caaba010e51730.tar.gz |
beta 2011.11.29 18:47
Diffstat (limited to 'tex/generic')
-rw-r--r-- | tex/generic/context/luatex/luatex-fonts-merged.lua | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua index c09168701..907b4fd81 100644 --- a/tex/generic/context/luatex/luatex-fonts-merged.lua +++ b/tex/generic/context/luatex/luatex-fonts-merged.lua @@ -1,6 +1,6 @@ -- merged file : luatex-fonts-merged.lua -- parent file : luatex-fonts.lua --- merge date : 11/25/11 21:29:42 +-- merge date : 11/29/11 18:47:56 do -- begin closure to overcome local limits and interference @@ -1695,32 +1695,72 @@ function lpeg.is_lpeg(p) return p and lpegtype(p) == "pattern" end --- For the moment here, but it might move to utilities: +-- For the moment here, but it might move to utilities. Beware, we need to +-- have the longest keyword first, so 'aaa' comes beforte 'aa' which is why we +-- loop back from the end. -local sort, fastcopy, sortedpairs = table.sort, table.fastcopy, table.sortedpairs -- dependency! +local sort, fastcopy, sortedkeys = table.sort, table.fastcopy, table.sortedkeys -- dependency! -function lpeg.append(list,pp,delayed) +function lpeg.append(list,pp,delayed,checked) local p = pp if #list > 0 then - list = fastcopy(list) - sort(list) - for l=1,#list do + local keys = fastcopy(list) + sort(keys) + for i=#keys,1,-1 do + local k = keys[i] if p then - p = P(list[l]) + p + p = P(k) + p else - p = P(list[l]) + p = P(k) end end - elseif delayed then - for k, v in sortedpairs(list) do - if p then + elseif delayed then -- hm, it looks like the lpeg parser resolves anyway + local keys = sortedkeys(list) + if p then + for i=#keys,1,-1 do + local k = keys[i] + local v = list[k] p = P(k)/list + p + end + else + for i=#keys,1,-1 do + local k = keys[i] + local v = list[k] + if p then + p = P(k) + p + else + p = P(k) + end + end + if p then + p = p / list + end + end + elseif checked then + -- problem: substitution gives a capture + local keys = sortedkeys(list) + for i=#keys,1,-1 do + local k = keys[i] + local v = list[k] + if p then + if k == v then + p = P(k) + p + else + p = P(k)/v + p + end else - p = P(k)/list + if k == v then + p = P(k) + else + p = P(k)/v + end end end else - for k, v in sortedpairs(list) do + local keys = sortedkeys(list) + for i=#keys,1,-1 do + local k = keys[i] + local v = list[k] if p then p = P(k)/v + p else |