1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
if not modules then modules = { } end modules ['util-tab'] = {
version = 1.001,
comment = "companion to luat-lib.mkiv",
author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
copyright = "PRAGMA ADE / ConTeXt Development Team",
license = "see context related readme files"
}
utilities = utilities or {}
utilities.tables = utilities.tables or { }
local tables = utilities.tables
local concat, format, gmatch = table.concat, string.format, string.gmatch
function tables.definetable(target) -- defines undefined tables
local composed, t = nil, { }
for name in gmatch(target,"([^%.]+)") do
if composed then
composed = composed .. "." .. name
else
composed = name
end
t[#t+1] = format("%s = %s or { }",composed,composed)
end
return concat(t,"\n")
end
function tables.accesstable(target)
local t = _G
for name in gmatch(target,"([^%.]+)") do
t = t[name]
end
return t
end
|