diff options
author | Marius <mariausol@gmail.com> | 2010-07-04 15:32:09 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2010-07-04 15:32:09 +0300 |
commit | 85b7bc695629926641c7cb752fd478adfdf374f3 (patch) | |
tree | 80293f5aaa7b95a500a78392c39688d8ee7a32fc /tex/context/base/mult-chk.lua | |
download | context-85b7bc695629926641c7cb752fd478adfdf374f3.tar.gz |
stable 2010-05-24 13:10
Diffstat (limited to 'tex/context/base/mult-chk.lua')
-rw-r--r-- | tex/context/base/mult-chk.lua | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tex/context/base/mult-chk.lua b/tex/context/base/mult-chk.lua new file mode 100644 index 000000000..bdbd1dd22 --- /dev/null +++ b/tex/context/base/mult-chk.lua @@ -0,0 +1,66 @@ +if not modules then modules = { } end modules ['mult-chk'] = { + version = 1.001, + comment = "companion to mult-chk.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local format = string.format +local lpegmatch = lpeg.match +local type = type +local texsprint, ctxcatcodes = tex.sprint, tex.ctxcatcodes + +interfaces = interfaces or { } + +interfaces.syntax = { + test = { keys = table.tohash { "a","b","c","d","e","f","g" } } +} + +function interfaces.invalidkey(kind,key) + commands.writestatus("syntax","invalid key '%s' for '%s' in line %s",key,kind,tex.inputlineno) +end + +function interfaces.setvalidkeys(kind,list) + local s = interfaces.syntax[kind] + if not s then + interfaces.syntax[kind] = { + keys = aux.settings_to_set(list) + } + else + s.keys = aux.settings_to_set(list) + end +end + +function interfaces.addvalidkeys(kind,list) + local s = interfaces.syntax[kind] + if not s then + interfaces.syntax[kind] = { + keys = aux.settings_to_set(list) + } + else + aux.settings_to_set(list,s.keys) + end +end + +local prefix, kind, keys + +local function set(key,value) + if keys and not keys[key] then + interfaces.invalidkey(kind,key) + else + texsprint(ctxcatcodes,format("\\setsomevalue{%s}{%s}{%s}",prefix,key,value)) + end +end + +local pattern = aux.make_settings_to_hash_pattern(set,"tolerant") + +function commands.getcheckedparameters(k,p,s) + if s and s ~= "" then + prefix, kind = p, k + keys = k and k ~= "" and interfaces.syntax[k].keys + lpegmatch(pattern,s) + end +end + +_gcp_ = commands.getcheckedparameters |