TABLE.mk revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/*
* table ... :TABLE: [class=name] [format={lower,upper}]
* [ignore=pattern] [map[=map]] [name=name]
* [novariables] [options] [state]
*
* if map==1 then do $(.TABLE.MAP. $(table) [name=name]) otherwise
* define variables in table name of the form [(class|table)_]name=1[value]
* format=upper[lower] converts var names to upper[lower] case
* ignore=pattern to ignore matching .TABLE.SET. generated variables
* set TABLE.list=1 or TABLE.list.name=1 to list the table variables
* if state==1 then define state variables rather than normal variables
* if noassign then variables not defined
*/
local I
for I $(<)
if "$(@$(I):V)"
if name
if map == "1"
else
list = 1
if class == "1"
class := $(table)_
else if class
class := $(class)_
if format
if options
if novariables
state = -
else if state
state = ==
else
state = =
if map
else if name
if map
/*
* :TABLE: inner loop
*/
if class
name := $(class)_
for I $($(row))
if I == "*=*"
V := $(I:/[^=]*=//)
I := $(I:/=.*)
else
V = 1
if I == "-"
continue
if N != "$(ignore)"
if map && ( M = "$($(map).$(N))" )
M := $(M:/,/ /G)
if assign != "-"
for J $(M|N)
if J != "-"
$(J) $(assign) $(V)
if list
/*
* $(.TABLE.INIT. table [name=name] [options])
*
* name {
* [no|NO]op1[=value]
* [no|NO]op2[=value] {
* ...
* }
* }
*
* convert the table in action to name[name]=value
* if options then op names matching no* are placed in noname[name]=value
* if options then op names matching NO* are placed in NOname[name]=value
* TABLE.all=1 or TABLE.all.name=1 enables all no* entries
* table data name returned
*/
if ( T = "$(.TABLE.$(table))" )
return $(T)
if "$(@$(table):V)"
all = 1
for I $(@$(table))
if I == "{"
if options
if P == "no*"
P := $(P:/..//)
if ! all
$(no)$(T) += $(P)
else if P == "NO*"
P := $(P:/..//)
$(no)$(T) += $(P)
T := $(T).$(P:/=.*//)
P :=
else if I == "}"
if T == "*."
$(P:N=options=*)
T := $(T:/\.\([^.]*\)\.$/.$(no)\1./)
no :=
else if no
$(T) :=
K := 0
else
if options
if P == "-|no*"
P := $(P:/..//)
no$(T) += $(P)
if ! all && P != "-"
P :=
else if P == "NO*"
P := $(P:/..//)
NO$(T) += $(P)
P :=
$(T) += $(P)
K := 1
P := $(T)
T := $(T:/\.[^.]*$//)
if K
$(T) += $(P:/.*\.//)
P :=
else
if options
if P == "-|no*"
P := $(P:/..//)
no$(T) += $(P)
if ! all && P != "-"
P :=
else if P == "NO*"
P := $(P:/..//)
NO$(T) += $(P)
P :=
$(T) += $(P)
P := $(I)
if options
if P == "no*"
P := $(P:/..//)
no$(T) += $(P)
if ! all
P :=
else if P == "NO*"
P := $(P:/..//)
NO$(T) += $(P)
P :=
$(T) += $(P)
return $(T)
/*
* $(.TABLE.MAP. map [name=name])
*
* name {
* old new[,new...]|-
* ...
* }
*
* convert the map in name's action to name[name].old=new
* map data name returned
*/
if ( T = "$(.TABLE.MAP.$(map))" )
return $(T)
if "$(@$(map):V)"
local I P
for I $(@$(map))
if P
$(T).$(P) := $(I)
P =
else
P := $(I)
return $(T)