diff options
author | Hans Hagen <pragma@wxs.nl> | 2018-04-19 17:37:21 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2018-04-19 17:37:21 +0200 |
commit | d817aef76ab8b606c02bd0636661b634b43a68a6 (patch) | |
tree | b222d7a356ebe7f1f2267f6aa4f4e424a4d6d88c /tex/context/base/mkiv/toks-scn.lua | |
parent | d57683f5f67d6651f7b3353ff347ae57a409e0d4 (diff) | |
download | context-d817aef76ab8b606c02bd0636661b634b43a68a6.tar.gz |
2018-04-19 16:02: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 |