diff options
author | Hans Hagen <pragma@wxs.nl> | 2019-02-22 20:29:46 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2019-02-22 20:29:46 +0100 |
commit | 7b271baae19db1528fbe6621bdf50af89a5a336b (patch) | |
tree | 4fc24a8f2be20aa90e90f6e1bcb62d69f4946235 /tex/context/base/mkiv/toks-scn.lua | |
parent | 67b9965fe473d18f13ed4c40f1e4e008eb870322 (diff) | |
download | context-7b271baae19db1528fbe6621bdf50af89a5a336b.tar.gz |
2019-02-22 19:43:00
Diffstat (limited to 'tex/context/base/mkiv/toks-scn.lua')
-rw-r--r-- | tex/context/base/mkiv/toks-scn.lua | 70 |
1 files changed, 37 insertions, 33 deletions
diff --git a/tex/context/base/mkiv/toks-scn.lua b/tex/context/base/mkiv/toks-scn.lua index fe32a1de4..f73ecc86c 100644 --- a/tex/context/base/mkiv/toks-scn.lua +++ b/tex/context/base/mkiv/toks-scn.lua @@ -106,7 +106,40 @@ local function scanconditional() return nil end +local function scantable(t,data) + if not data then + data = { } + end + local wrapped = scanopen() + while true do + local key = scanword() + if key then + local get = t[key] + if get then + data[key] = get() + else + -- catch all we can get + end + else + break + end + end + if wrapped then + scanclose() + end + return data +end + +function tokens.constant(s) + if type(s) == "string" then + return "'" .. s .. "'" + else + return s + end +end + scanners.list = scanlist +scanners.table = scantable scanners.conditional = scanconditional local shortcuts = { @@ -118,6 +151,7 @@ local shortcuts = { scanstring = scanstring, scaninteger = scaninteger, scannumber = scannumber, + scantable = scantable, scankeyword = scankeyword, scankeywordcs = scankeywordcs, scanword = scanword, @@ -254,6 +288,8 @@ local presets = { ["8 strings"] = { "string", "string", "string", "string", "string", "string", "string", "string" }, } +tokens.presets = presets + function tokens.compile(specification) local f = { } local n = 0 @@ -319,7 +355,7 @@ function tokens.compile(specification) return c end end - local p = t and presets[t] + local p = t and presets[t] -- already done in implement if p then t = p end @@ -460,35 +496,3 @@ end -- } -- -- os.exit() - -function tokens.scantable(t,data) - if not data then - data = { } - end - local wrapped = scanopen() - while true do - local key = scanword() - if key then - local get = t[key] - if get then - data[key] = get() - else - -- catch all we can get - end - else - break - end - end - if wrapped then - scanclose() - end - return data -end - -function tokens.constant(s) - if type(s) == "string" then - return "'" .. s .. "'" - else - return s - end -end |