module documentation

takes templated file .xxx.src and produces .xxx file where .xxx is .i or .c or .h, using the following template rules

/**begin repeat -- on a line by itself marks the start of a repeated code
segment

/end repeat/ -- on a line by itself marks it's end

After the /**begin repeat and before the */, all the named templates are placed these should all have the same number of replacements

Repeat blocks can be nested, with each nested block labeled with its depth, i.e. /**begin repeat1

*.... */

/end repeat1/

When using nested loops, you can optionally exclude particular combinations of the variables using (inside the comment portion of the inner loop):

This will exclude the pattern where var1 is value1 and var2 is value2 when the result is being generated.

In the main body each replace will use one entry from the list of named replacements

Note that all #..# forms in a block must have the same number of
comma-separated entries.

Example:

An input file containing

/**begin repeat
  • #a = 1,2,3#
  • #b = 1,2,3#

*/

/**begin repeat1
  • #c = ted, jim#

*/

@a@, @b@, @c@ /end repeat1/

/end repeat/

produces

line 1 "template.c.src"

/*
** This file was autogenerated from a template DO NOT EDIT!!** ** Changes should be made to the original source (.src) file ** ***************************************************************** */

#line 9 1, 1, ted

#line 9 1, 1, jim

#line 9 2, 2, ted

#line 9 2, 2, jim

#line 9 3, 3, ted

#line 9 3, 3, jim

Unknown Field: exclude
var1=value1, var2=value2, ...
Function main Undocumented
Function paren_repl Undocumented
Function parse_loop_header Find all named replacements in the header
Function parse_string Undocumented
Function parse_structure The returned line number is from the beginning of the string, starting at zero. Returns an empty list if no loops found.
Function parse_values Undocumented
Function process_file Undocumented
Function process_str Undocumented
Function resolve_includes Undocumented
Function unique_key Undocumented
Variable exclude_re Undocumented
Variable exclude_vars_re Undocumented
Variable global_names Undocumented
Variable header Undocumented
Variable include_src_re Undocumented
Variable named_re Undocumented
Variable parenrep Undocumented
Variable plainrep Undocumented
Variable replace_re Undocumented
Variable stripast Undocumented
def main(): (source)

Undocumented

def paren_repl(obj): (source)

Undocumented

def parse_loop_header(loophead): (source)

Find all named replacements in the header

Returns a list of dictionaries, one for each loop iteration, where each key is a name to be substituted and the corresponding value is the replacement string.

Also return a list of exclusions. The exclusions are dictionaries
of key value pairs. There can be more than one exclusion. [{'var1':'value1', 'var2', 'value2'[,...]}, ...]
def parse_string(astr, env, level, line): (source)

Undocumented

def parse_structure(astr, level): (source)

The returned line number is from the beginning of the string, starting at zero. Returns an empty list if no loops found.

def parse_values(astr): (source)

Undocumented

def process_file(source): (source)

Undocumented

def process_str(astr): (source)

Undocumented

def resolve_includes(source): (source)

Undocumented

def unique_key(adict): (source)

Undocumented

exclude_re = (source)

Undocumented

exclude_vars_re = (source)

Undocumented

global_names: dict = (source)

Undocumented

Undocumented

include_src_re = (source)

Undocumented

named_re = (source)

Undocumented

parenrep = (source)

Undocumented

plainrep = (source)

Undocumented

replace_re = (source)

Undocumented

stripast = (source)

Undocumented