1if not modules then modules = { } end modules ['catc-ini'] = {
2 version = 1.001,
3 comment = "companion to catc-ini.mkiv",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files"
7}
8
9catcodes = catcodes or { }
10catcodes.numbers = catcodes.numbers or { }
11catcodes.names = catcodes.names or { }
12
13storage.register("catcodes/numbers", catcodes.numbers, "catcodes.numbers")
14storage.register("catcodes/names", catcodes.names, "catcodes.names")
15
16local numbers = catcodes.numbers
17local names = catcodes.names
18
19
20
21
22
23
24function catcodes.register(name,number)
25 numbers[name] = number
26 local cnn = names[number]
27 if cnn then
28 cnn[#cnn+1] = name
29 else
30 names[number] = { name }
31 end
32 tex[name] = number
33end
34
35
36
37for name, number in next, numbers do
38 tex[name] = number
39end
40
41
42
43table.setmetatableindex(numbers,function(t,k) if type(k) == "number" then t[k] = k return k end end)
44table.setmetatableindex(names, function(t,k) if type(k) == "string" then t[k] = k return k end end)
45 |