diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/luat-mac.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/luat-mac.lua | 131 |
1 files changed, 111 insertions, 20 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/luat-mac.lua b/Master/texmf-dist/tex/context/base/mkiv/luat-mac.lua index e6789a2338a..3c50a41f89c 100644 --- a/Master/texmf-dist/tex/context/base/mkiv/luat-mac.lua +++ b/Master/texmf-dist/tex/context/base/mkiv/luat-mac.lua @@ -30,36 +30,125 @@ local report_macros = logs.reporter("interface","macros") local stack, top, n, hashes = { }, nil, 0, { } -local function set(s) - if top then - n = n + 1 - if n > 9 then - report_macros("number of arguments > 9, ignoring %s",s) - else +-- local function set(s) +-- if top then +-- n = n + 1 +-- if n > 9 then +-- report_macros("number of arguments > 9, ignoring %s",s) +-- else +-- local ns = #stack +-- local h = hashes[ns] +-- if not h then +-- h = rep("#",2^(ns-1)) +-- hashes[ns] = h +-- end +-- if s == "ignore" then +-- top[s] = "" +-- return h .. "0" +-- else +-- local m = h .. n +-- top[s] = m +-- return m +-- end +-- end +-- end +-- end + +-- local function get(s) +-- if s == "ignore" then +-- return "" +-- else +-- if not top then +-- report_macros("keeping #%s, no stack",s) +-- return "#" .. s -- can be lua +-- end +-- local m = top[s] +-- if m then +-- return m +-- else +-- report_macros("keeping #%s, not on stack",s) +-- return "#" .. s -- quite likely an error +-- end +-- end +-- end + +local set = CONTEXTLMTXMODE > 0 and + function(s) + if top then local ns = #stack local h = hashes[ns] if not h then h = rep("#",2^(ns-1)) hashes[ns] = h end - local m = h .. n - top[s] = m - return m + if s == "ignore" then + return h .. "-" + elseif s == "spacer" then + return h .. "*" + elseif s == "pickup" then + return h .. ":" + else + n = n + 1 + if n > 9 then + report_macros("number of arguments > 9, ignoring %s",s) + elseif s == "discard" then + top[s] = "" + return h .. "0" + elseif s == "keepbraces" then + top[s] = "" + return h .. "+" + elseif s == "mandate" then + top[s] = "" + return h .. "=" + elseif s == "keepmandate" then + top[s] = "" + return h .. "_" + elseif s == "prunespacing" then + top[s] = "" + return h .. "/" + else + local m = h .. n + top[s] = m + return m + end + end + end + end +or + function(s) + if top then + local ns = #stack + local h = hashes[ns] + if not h then + h = rep("#",2^(ns-1)) + hashes[ns] = h + end + n = n + 1 + if n > 9 then + report_macros("number of arguments > 9, ignoring %s",s) + else + local m = h .. n + top[s] = m + return m + end end end -end local function get(s) - if not top then - report_macros("keeping #%s, no stack",s) - return "#" .. s -- can be lua - end - local m = top[s] - if m then - return m + if s == "ignore" or s == "discard" then + return "" else - report_macros("keeping #%s, not on stack",s) - return "#" .. s -- quite likely an error + if not top then + report_macros("keeping #%s, no stack",s) + return "#" .. s -- can be lua + end + local m = top[s] + if m then + return m + else + report_macros("keeping #%s, not on stack",s) + return "#" .. s -- quite likely an error + end end end @@ -209,7 +298,7 @@ end function macros.convertfile(oldname,newname) -- beware, no testing on oldname == newname local data = loadtexfile(oldname) - data = interfaces.preprocessed(data) or "" -- interfaces not yet defined + data = macros.preprocessed(data) or "" -- interfaces not yet defined savedata(newname,data) end @@ -336,6 +425,8 @@ end -- ]])) -- print(macros.preprocessed([[\checked \def \bla #bla{bla#{bla}}]])) +-- print(macros.preprocessed([[\checked \def \bla #bla#discard#foo{bla#{bla}+#ignore+bla#foo}]])) +-- print(macros.preprocessed([[\checked \def \bla #bla#ignore#foo{bla#{bla}+#ignore+bla#foo}]])) -- print(macros.preprocessed([[\def\bla#bla{#{bla}bla}]])) -- print(macros.preprocessed([[\def\blä#{blá}{blà:#{blá}}]])) -- print(macros.preprocessed([[\def\blä#bla{blà:#bla}]])) |