summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/toks-scn.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/toks-scn.lua')
-rw-r--r--tex/context/base/mkiv/toks-scn.lua43
1 files changed, 35 insertions, 8 deletions
diff --git a/tex/context/base/mkiv/toks-scn.lua b/tex/context/base/mkiv/toks-scn.lua
index 5c8dee8f3..3c41eedd8 100644
--- a/tex/context/base/mkiv/toks-scn.lua
+++ b/tex/context/base/mkiv/toks-scn.lua
@@ -153,8 +153,25 @@ tokens.converters = {
toglue = "todimen",
}
+-- We could just pickup a keyword but then we really need to make sure
+-- that no number follows it when that is the assignment and adding
+-- an optional = defeats the gain in speed. Currently we have sources
+-- with no spaces (\startcontextdefinitioncode ...) so it fails there.
+--
+-- Another drawback is that we then need to use { } instead of ending
+-- with \relax (as we can do now) but that is no big deal. It's just
+-- that I then need to check the TeX end. More pain than gain and a bit
+-- risky too.
+
local f_if = formatters[ " if scankeyword('%s') then data['%s'] = scan%s()"]
local f_elseif = formatters[" elseif scankeyword('%s') then data['%s'] = scan%s()"]
+
+----- f_if = formatters[" local key = scanword() if key == '' then break elseif key == '%s' then data['%s'] = scan%s()"]
+----- f_elseif = formatters[" elseif key == '%s' then data['%s'] = scan%s()"]
+
+----- f_if_x = formatters[ " if not data['%s'] and scankeyword('%s') then data['%s'] = scan%s()"]
+----- f_elseif_x = formatters[" elseif not data['%s'] and scankeyword('%s') then data['%s'] = scan%s()"]
+
local f_local = formatters["local scan%s = scanners.%s"]
local f_scan = formatters["scan%s()"]
local f_shortcut = formatters["local %s = scanners.converters.%s"]
@@ -163,6 +180,11 @@ local f_if_c = formatters[ " if scankeyword('%s') then data['%s'] = %s(s
local f_elseif_c = formatters[" elseif scankeyword('%s') then data['%s'] = %s(scan%s())"]
local f_scan_c = formatters["%s(scan%s())"]
+-- see above
+--
+----- f_if_c = formatters[" local key = scanword() if key == '' then break elseif key == '%s' then data['%s'] = %s(scan%s())"]
+----- f_elseif_c = formatters[" elseif k == '%s' then data['%s'] = %s(scan%s())"]
+
local f_any = formatters[" else local key = scanword() if key then data[key] = scan%s() else break end end"]
local f_any_c = formatters[" else local key = scanword() if key then data[key] = %s(scan%s()) else break end end"]
local s_done = " else break end"
@@ -269,6 +291,7 @@ function tokens.compile(specification)
else
m = m + 1
r[m] = (m > 1 and f_elseif or f_if )(t1,t1,t2)
+ -- r[m] = (m > 1 and f_elseif_x or f_if_x)(t1,t1,t1,t2)
end
end
end
@@ -291,8 +314,9 @@ function tokens.compile(specification)
end
tokens._action = a
for i=1,#a do
- code = f_action_f(i,code)
- f[#f+1] = f_action_s(i,i)
+ code = f_action_f(i,code)
+ n = n + 1
+ f[n] = f_action_s(i,i)
end
code = f_simple(f,code)
else
@@ -308,8 +332,9 @@ function tokens.compile(specification)
if a then
tokens._action = a
for i=1,#a do
- code = f_action_f(i,code)
- f[#f+1] = f_action_s(i,i)
+ code = f_action_f(i,code)
+ n = n + 1
+ f[n] = f_action_s(i,i)
end
end
code = f_table(f,ti,code)
@@ -317,8 +342,9 @@ function tokens.compile(specification)
code = f_scan(ti)
tokens._action = a
for i=1,#a do
- code = f_action_f(i,code)
- f[#f+1] = f_action_s(i,i)
+ code = f_action_f(i,code)
+ n = n + 1
+ f[n] = f_action_s(i,i)
end
code = f_simple(f,code)
else
@@ -364,8 +390,9 @@ function tokens.compile(specification)
if a then
tokens._action = a
for i=1,#a do
- code = f_action_f(i,code)
- f[#f+1] = f_action_s(i,i)
+ code = f_action_f(i,code)
+ n = n + 1
+ f[n] = f_action_s(i,i)
end
end
code = f_sequence(c,f,p,code)