diff options
author | Hans Hagen <pragma@wxs.nl> | 2020-11-27 20:36:33 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2020-11-27 20:36:33 +0100 |
commit | f066d60455a53a472fac24abfb210cd6361ffb08 (patch) | |
tree | ebb1980d42a4804cc0a19b5f35f9189ab3f6afcd /tex/context/base/mkxl/catc-ini.lmt | |
parent | b27d13bebb952ac46eb5ee1305f4ad8a7183132c (diff) | |
download | context-f066d60455a53a472fac24abfb210cd6361ffb08.tar.gz |
2020-11-27 20:10:00
Diffstat (limited to 'tex/context/base/mkxl/catc-ini.lmt')
-rw-r--r-- | tex/context/base/mkxl/catc-ini.lmt | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tex/context/base/mkxl/catc-ini.lmt b/tex/context/base/mkxl/catc-ini.lmt new file mode 100644 index 000000000..ede8216a6 --- /dev/null +++ b/tex/context/base/mkxl/catc-ini.lmt @@ -0,0 +1,44 @@ +if not modules then modules = { } end modules ['catc-ini'] = { + version = 1.001, + comment = "companion to catc-ini.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +catcodes = catcodes or { } +catcodes.numbers = catcodes.numbers or { } +catcodes.names = catcodes.names or { } + +storage.register("catcodes/numbers", catcodes.numbers, "catcodes.numbers") +storage.register("catcodes/names", catcodes.names, "catcodes.names") + +local numbers = catcodes.numbers +local names = catcodes.names + +-- We register the catcode tables in the \type {tex} namespace as we have been doing +-- right from the start (when there wasn't much in that namespace). Normally +-- registration of a table only happens when we're in so called ini mode. Also, the +-- number of tables is rather small. + +function catcodes.register(name,number) + numbers[name] = number + local cnn = names[number] + if cnn then + cnn[#cnn+1] = name + else + names[number] = { name } + end + tex[name] = number -- downward compatible +end + +-- At runtime we need to populate the \type {tex} namespace again. + +for name, number in next, numbers do + tex[name] = number -- downward compatible +end + +-- We catch wrong usage. + +table.setmetatableindex(numbers,function(t,k) if type(k) == "number" then t[k] = k return k end end) +table.setmetatableindex(names, function(t,k) if type(k) == "string" then t[k] = k return k end end) |