Working with template files
A template file contains the definition of all rules needed by an application. A rule essentially
produces a character string from its parameters; most parameters are rules refer-ring
to other template rules.
The definition of a rule is made of a rule name, rule class, of a mandatory parameter
defining the rule, and of optional modifiers, without any specific order; the definition ends
with a semi-colon.
The template rules (rules belonging to the TEMPL class) are the most used rules. Every
template rule is associated to a template string. A template string contains sub-rules and
edition codes. Processing a template string consists in replacing the sub-rules and edition
codes by the strings they represent. Within a template string, sub-rules and edition
codes are preceded by a dollar sign and followed by a semi-colon, in order to distinguish
them from the surrounding text.
Valid characters for a rule name are: ASCII letters (A-Z and a-z), digits (0-9) and underscore;
the first character of a name cannot be a digit; the name must be made up of at
least two (2) characters and at most sixty-three (63). Case is significant; for example
objname and ObjName refer to two (2) different variables.
The various fields of the definition are separated by one or more spacing characters.
Spacing characters are: space, tab, return. These characters have no other purposes
than to act as token separators. A comma can be used as separator in the parameter list
of a definition.
Comments can appear anywhere between definition tokens or between definitions; they
begin with /* and end with */ , or they begin with // and end with a carriage return (at
the end of the current line).
Strings are enclosed in double quotes; a long string can be split into a number of strings
separated by spacing characters; when a closing quote is followed by spacing characters
and an opening quote, the two adjoining strings are considered part of a single
string.
There are two types of modifiers: values and flags. A value modifier is followed by an
equal sign and the value; the flag modifier is by itself. Most value modifiers take a rule as
value. This is expressed as a string enclosed in quotes.
Example
drop_table TEMPL "DROP TABLE $TableName;;";
This statement defines a drop_table sub-rule of TEMPL class. The parameter is a
template string referring to the TableName sub-rule which must be defined elsewhere in
the template file. For example, if the TableName rule returns "department" as a result;
then the result of the drop_table variable will be "DROP TABLE department;".
equal sign and the value; the flag modifier is by itself. Most value modifiers take a rule as
value. This is expressed as a string enclosed in quotes.
Rule classes and modifiers
must be specified
in uppercase.