|
|
|
|
|
|
Somusar/Tefigel[tm]
Reference Guide Francesco Aliverti-Piuri Copyright © 2003-2007 Somusar Updated on: January 31, 2005 |
|
|
|
|
|
|
|
|
|
Unix is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Limited.
Linux is a registered trademark of Linus Torvalds in the United States and other countries.
Sun, Sun Microsystems, the Sun logo, Solaris, Java, and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.
Symbian and all Symbian-based marks and logos are trademarks of Symbian Software Limited.
Apple and Mac OS are registered trademarks of Apple Computer, Inc. in the United States and other countries.
Intel is a registered trademark of Intel Corporation in the United States and other countries.
PowerPC and CICS are registered trademarks of International Business Machines Corporation in the United States and other countries.
Microsoft, Windows, Visual Basic are either trademarks or registered trademarks of Microsoft Corp. in the United States and/or other countries.
Oracle is a registered trademark, and PL/SQL is a trademark of Oracle Corporation.
SAP and ABAP/4 are registered trademarks of SAP AG in Germany and several other countries.
PostScript is a registered trademark of Adobe Systems Incorporated in the United States and/or other countries.
So.mus.ar, the Somusar logo, Somusar/Software Production Technique, Somusar/Software Production Machine, Somusar/Sisendel, Somusar/Tefigel, Somusar/SoProTech, Somusar/SoProMach, Somusar/Software Entity, Somusar/Software Mold, Somusar/Software Mold Kit, Somusar/Software Mold Building, Somusar/Code Generator Building, Somusar/Generator Building, and Somusar/File Generation Scheme are trademarks of so.mus.ar. s.a.s. in Italy, in the European Union, in the United States of America and other countries.
Other trademarks or service marks referenced herein are property of their respective owners.
This document defines and describes the syntax and semantics of the Somusar/Tefigel[tm] language. Each chapter defines purpose and usage of a set of Somusar/Tefigel[tm] constructs, and describes them concisely.
In the syntax convention used in this document literal words and characters are indicated by text in bold fixed-font type, as in process. Non-terminal symbols are indicated by text between < and > in italic type, as in <this-is-a-symbol> (when defined) or as in <this-is-a-symbol> (when referred to).
An input file for Tefigel may contain one or more <file-section>'s of three types: text, Tefigel code, and comment blocks. File sections allow to improve readability of Tefigel files and can be freely defined within each Tefigel file in no particular order. By default the content of a Tefigel file whose name ends in ".tfg" is assumed to start with a <tefigel-section>. The content of a Tefigel file whose name does not end in ".tfg" is assumed to start with a <text-section>.
Define a <text-section>:
text
<text-section>
endtext
Define a <tefigel-section>:
tefigel
<tefigel-section>
endtefigel
Define a <comment-section>:
<comment-marker>\
<comment-section>
<comment-marker>/
A <file-section> consists of zero or more <logical-line>'s.
The content of a <text-section> is subject to textual
substitution of <variable>'s and in-line function calls via
<subprogram-reference>'s.
Lines starting with the current
<command-marker> are treated as <command>'s.
Lines starting with the current
<comment-marker> are treated as <comment-line>'s.
The content of a <tefigel-section> is processed as
a sequence of <command>'s or subroutine and function calls via
<subprogram-reference>'s.
Lines starting with any current
<instruction-marker>, possibly preceded by blanks and/or tabs,
are processed as the corresponding <instruction>.
In particular, lines starting with the current
<comment-marker>, possibly preceded by blanks and/or tabs,
are treated as <comment-line>'s.
The content of a <comment-section>, including its opening and
closing delimiters, is treated as a sequence of <comment-line>'s.
Both <text-section>'s and <tefigel-section>'s may contain
any number of <comment-section>'s.
An input file for Tefigel consists of a sequence of <logical-line>'s. Commands and instructions steer the file generation process performed by Tefigel on its input(s) to generate its output(s).
<command-marker> <instruction> <instruction-parameters>
<command-marker> <subprogram-reference>
<command-marker> <subprogram-reference>(<parameter-list>)
<instruction-marker> <instruction-parameters>
A <logical-line> consists of one or more physical lines of text; if the
last character of a physical line matches the current
linebreak <special-function> then
the logical line continues on the next physical line.
A Tefigel <command> is a logical text line beginning
with one of the following:
The <instruction-marker> and <command-marker>, collectively
referred to as <marker>'s,
are characters associated respectively with one specific
instruction or with all instructions, and appearing as the first
character in an input line. White spaces (blank or tab)
appearing on a command line between the <command-marker>
and the instruction are ignored.
Within <tefigel-section>'s the
<command-marker> may be omitted and leading white spaces (blank or tab)
are ignored.
Depending on the <instruction>, a list of <instruction-parameters>
may follow the Tefigel keyword.
A Tefigel <instruction> is a Tefigel keyword in lower case (default)
or upper case,
depending on the current value of <control-variable> CMD_CASE.
Define a first-column marker for Tefigel commands or instructions.
Define a new command or instruction marker:
Restore the previous command or instruction marker (if any):
mark CMD <new-marker>
mark <instruction> <new-marker>
mark CMD
mark <instruction>
The initial value for the CMD (command) marker is
the at-sign @.
The initial value for the call (subroutine call) marker is
the dollar-sign $.
The initial value for the rem (remark) marker is
the sharp-sign #.
The <instruction>'s that can be specified as
parameters for mark are the following:
rem
call
set
globset
unset
link
unlink
trap
untrap
add
sub
mul
div
trunc
neg
eval
and
or
not
A <marker> is the most recent <new-marker> defined for the
corresponding instruction.
The <new-marker> can be any non-blank character.
If no <new-marker>
is specified, the previous corresponding marker (if any) is
automatically restored.
Add textual descriptions to Tefigel scripts.
rem comment text
<comment-marker> comment text
The <comment-marker> is the most recent <new-marker>
specified for instruction rem. Its initial value is the
sharp-sign #.
All <comment-line>'s in input are ignored by Tefigel.
Associate a special text-processing function with a single character.
Define a new special character for a given special function:
Restore the previous special character (if any)
for a given special function:
<special-function> <new-special-character>
<special-function>
The <special-function> can be one of the following:
The <new-special-character> can be any non-blank character.
If no <new-special-character>
is specified, the previous corresponding special character (if any) is
automatically restored.
Separator of parameters for Tefigel subroutine or function call's.
In-line function call marker: on output, the in-line function call is replaced by the string (if any) returned by the called function.
String concatenation operator, also used to create name-value associations, which can be used for traditional data structures such as records and arrays.
Escape character within lists of parameters in function or subroutine calls.
Logical line concatenation operator, used to split long input logical lines into two or more input physical lines.
Define placeholders for character strings that can also be used as traditional program variables.
Set a variable in the global name space:
globset <variable>=<value>
globset <associative-variable>=<value>
Set a new variable in the current name space, or change value to a
previously set variable:
set <variable>=<value>
set <associative-variable>=<value>
Unset a variable:
unset <variable>
unset <associative-variable>
Access contents of a variable within an input line (both text and command line):
text text text text text text text text
text text text <variable> text text text
text text text text text text text text
A <variable> is defined as an identifier represented by a sequence of
letters, digits and underscore ('_'). The first character of the
identifier must be either a letter or an underscore.
Tefigel is case-sensitive with respect to variable identifiers.
A <value> can be any string and requires no delimiters: every character
after the assignment operator = up to the end of the logical
command line is considered part of the <value> to be stored in the
<variable>, including blanks and tabs, which are treated exactly as
all other characters. A <value> may contain other variables as well as
in-line function calls, so that <variable> is assigned the string
of characters resulting from replacing the other variables with their contents,
and the in-line function calls with their return values.
An <associative-variable> is defined as the concatenation of
two or more identifiers by means of the current dash
special character. The identifiers may refer to previously set variables -
in which case their current value is used to construct the corresponding
part of the identifier of the <associative-variable> - or not refer
to any variable - in which case they will literally be
used to construct the corresponding part of the identifier of the
<associative-variable>.
Depending on its current value, a variable may be used for arithmetic
or boolean computation, as explained later in this guide.
Perform basic arithmetic operations.
Add, subtract, multiply, divide two numbers:
<arithmetic-instruction> <numerical-variable> <numerical-value>
Compute the negative value of a numerical variable:
neg <numerical-variable>
Truncate value of a numerical variable to the nearest integer value
between that value and 0:
trunc <numerical-variable>
The <arithmetic-instruction> must be one of the following:
A <numerical-value> can be either a <numerical-variable>, or
a string representing a decimal integer or floating-point
number. The value resulting from the arithmetic computation
is stored into <numerical-variable>.
Arithmetic computation is always performed by Tefigel in floating-point
in decimal base representation.
add
sub
mul
div
A <numerical-variable> must be the identifier of a variable whose
current value is a string representing a decimal integer or floating-point
number.
Perform simple boolean (logical) computation.
Evaluate a plain boolean comparison storing the result into a variable:
eval <target-variable> <boolean-comparison>
Compute boolean and or or operation:
<boolean-instruction> <target-variable> <boolean-comparison>
Compute boolean not operation:
not <boolean-variable>
The <boolean-instruction> must be either and or or.
A <target-variable> is defined as the identifier of a <variable> whose
value will be set to 1 or 0 depending on the boolean result -
true or false, respectively - yielded by the boolean
comparison or operation.
A <boolean-variable> is defined as the identifier of a <variable>
whose current value is a string representing a number, the boolean value
of which will be considered false if the number equals 0, true
if the number equals 1, or invalid otherwise.
A <boolean-comparison> is defined as follows:
A <comparison-value> can be either a <variable>, or
a string of characters, possibly empty.
The <comparison-operator> must be one of the following characters:
A <boolean-comparison> with no <comparison-operator>
and no <comparison-value> is assumed to be as follows:
<comparison-variable><comparison-operator><comparison-value>
<comparison-variable>
A <comparison-variable> is the identifier of either a <variable>
or an <associative-variable>, possibly not set yet.
With the exception of comparison operator ~, that always
implies a pattern-matching comparison between one string value and
a regular expression,
the type of comparison performed by Tefigel depends on the value of
<comparison-variable> and
<comparison-value>: if both values are numerical, then a numerical
comparison takes place, otherwise a lexicographical comparison
is performed.
"equal": yields true if the value of <comparison-variable> equals <comparison-value>;
"not equal": yields true if the value of <comparison-variable> does not equal <comparison-value>;
"greater than": yields true if the value of <comparison-variable> is greater than <comparison-value>;
"less than": yields true if the value of <comparison-variable> is less than <comparison-value>;
"greater or equal": yields true if the value of <comparison-variable> is greater than, or equal to, <comparison-value>;
"less or equal": yields true if the value of <comparison-variable> is less than, or equal to, <comparison-value>;
"like": yields true if the value of <comparison-variable> is matched by the regular expression represented by <comparison-value>.
<comparison-variable>#0
Specify the order in which the processing of input lines must be performed by Tefigel.
Terminate processing:
exit <exit-code>
Perform a conditional statement:
if <boolean-comparison>
<input-block>
else
<alternative-input-block>
endif
Perform a multiblock conditional statement:
case <case-variable>
when <case-evaluator>
<input-block>
when <case-evaluator>
<input-block>
otherwise
<alternative-input-block>
endcase
Perform a while loop:
while <boolean-comparison>
<input-block>
endwhile
Perform a for each loop, with automatic
<counter-variable>'s and automatic <total-loops-variable>'s:
for <loop-variable>=<for-each-list>
<input-block>
endfor
Perform a numeric loop:
loop <loop-variable>=<range-definition>
<input-block>
endloop
Perform an unconditional transfer of control:
jump <target-label>
<input-block>
label <target-label>
Perform a conditional transfer of control:
jumpcond <target-label> <boolean-comparison>
<input-block>
label <target-label>
An <exit-code> is an integer number to be returned to
the operating system process that started Tefigel.
An <input-block>, or an <alternative-input-block>,
is a sequence of logical input lines, that
may contain none, one, or more Tefigel command lines.
A <case-evaluator> is defined as follows:
A <for-each-list> is a list of strings separated by the current
argdelim <special-function>.
A <counter-variable> is a numeric variable that gets
automatically initialized to 0 or 1 and incremented at each iteration
of the for loop. There are four such variables: the
name of these variables are the same
as the corresponding <loop-variable> with the following suffixes:
A <total-loops-variable> is a numeric variable that gets
automatically initialized with the for loop.
There are two such variables: the name of these variables are the same
as the corresponding <loop-variable> with suffixes
_loops and _LOOPS respectively.
All <counter-variable>'s and <total-loops-variable>'s get
automatically unset after the corresponding endfor
instruction.
A <range-definition> is a list of two or three numbers
separated by the current argdelim <special-function>.
The first number specifies the initialization value for the
<loop-variable>; the second number specifies the loop
termination value; the third optional number specifies the
loop increment or decrement step, which defaults to 1 if not
otherwise specified.
A <loop-variable> is a <variable> that gets automatically
initialized and updated by Tefigel while performing the corresponding
loop.
A <target-label> is a sequence of non-blank characters, that is
a sequence of letters, digits and underscore ('_').
When performing a conditional statement,
the <input-block> is processed if
the value of <boolean-comparison> is true,
whereas the <alternative-input-block> is processed if
the value of <boolean-comparison> is false.
The else instruction and
the <alternative-input-block> may be omitted.
When performing a multiblock conditional statement,
each <input-block> is processed if
the value of the related <case-evaluator> applied to the
<case-variable> yields true,
whereas the <alternative-input-block>, if present, is processed
only if all <case-evaluator>'s evaluate to false.
When performing a loop, depending on the type of loop,
the <input-block> is repeatedly processed as long as:
When performing a conditional transfer of control,
on processing the jumpcond instruction, if the
<boolean-comparison> yields true, file generation
control is transferred to the input line immediately following
the label instruction, so that the <input-block>
is not processed. Both forward and backward conditional transfer of control
are allowed.
<comparison-operator><comparison-value>
A <case-variable> is a <variable> that gets automatically
initialized and evaluated by Tefigel while performing the corresponding
multiblock conditional statement.
When performing an unconditional transfer of control,
on processing the jump instruction file generation
control is transferred to the input line immediately following
the label instruction, so that the <input-block>
is not processed. Both forward and backward transfer of control
are allowed.
Divide a complex file generation process in a set of simpler functional modules that insulate repetitive or specific tasks and are easier to write, test, and manage.
Transfer control to a subroutine (a file) in the same variable name space:
process <file-reference>
Transfer control to a subroutine (a file) in the same variable name space,
ignoring non-existent subroutine files:
process_if_readable <file-reference>
Transfer control to a subroutine (a file) in a new variable name space:
[call] <subprogram-reference>
[call] <subprogram-reference>(<parameter-list>)
Transfer control to a function (a file) in a new variable name space, using
its return value within a logical line:
<call-key><subprogram-reference>(<parameter-list>)
Assign values of a <parameter-list> to a corresponding set of
variables in the new variable name space of current function:
interface(<new-variable-list>)
Shift the <parameter-list>:
shift
Set return value of current function:
retvalue=<value>
Return from a function or subroutine:
quit
Declare a file to be a <code-file>:
codefile
|
Note:
Instruction codefile is obsolete and superseded by <file-section>'s. |
A <file-reference> can be either a valid file pathname - absolute
or relative -
or a <variable> containing a string corresponding to a valid
pathname.
Relative file pathnames of functions or subroutines are first
sought for with respect to the working directory of Tefigel, then
using the current <library-path-specifier>, described later in the
guide. Tefigel will first attempt to access the file with the given name;
in case of failure it will try to access the file adding the extension ".tfg".
In other words, extension ".tfg" is optional and may be omitted in
<file-reference>'s.
A <subprogram-reference> can be either a <file-reference>
or a <built-in-function>. The call instruction may be omitted.
A <parameter-list> is a sequence of strings or <variable>'s,
separated by the character currently associated with <special-function>
argdelim.
The <call-key> is the character currently associated with
<special-function> callkey.
A <new-variable-list> is a sequence of <variable>'s,
separated by the character currently associated with <special-function>
argdelim.
The <parameter-list> may be omitted, in which case it is also
possible to omit the left and right parentheses.
Arguments supplied as parameters
to a function or subroutine are made available in the new name space
of the called function or subroutine as "register" variables identified
as
REG_0,
REG_1,
REG_2,
etc., according
to their sequential position in the <parameter-list>. Unspecified
registers are guaranteed to be initialized to the empty string.
The number of arguments is available in variable
REG_COUNT.
The complete list of arguments is also available in variable
REG_ALL.
Instruction shift transfers the contents of each
REG_n into
REG_n - 1, decrements REG_COUNT,
and updates REG_ALL accordingly.
Instruction interface automatically initializes each
variable in the <new-variable-list> to the value of the
register in the corresponding order position.
A <new-variable-list> in the form "..." specifies that
the function or subroutine has a variable number of parameters, hence
no automatic initialization is performed.
Beyond positional association, no restriction is imposed, and no check is
performed, by Tefigel on the function or subroutine signature,
so that it is possible to supply a variable number of arguments
to functions and subroutines.
Currently, Tefigel supports up to 32 parameters.
Functions may set their return value by means of instruction
retvalue.
Returning from a function or subroutine is automatically
performed when the end of the file containing the function or
subroutine is reached. Alternatively, instruction quit
can be used to explicitly return from the function or subroutine.
A <code-file> is a file where each line is interpreted as
a <command>.
|
Note:
This feature is obsolete and superseded by <tefigel-section>'s. |
Perform frequently needed routine tasks.
Built-in functions are used in the same way as user-defined
functions are used:
[call] <built-in-function>(<parameter-list>)
<call-key><built-in-function>(<parameter-list>)
A <built-in-function> is one of the subroutines and functions
listed below.
Built-in functions have a higher precedence in comparison with
file functions or subroutines, so that it is not possible to
override a built-in function with a file function or subroutine
carrying the same name.
By default built-in functions carry the lower-case names listed below,
unless <control-variable> CMD_CASE is switched to
upper-case mode, in which case their names are also switched to upper-case.
Return name of current input file.
Return name of Tefigel input file at nesting level n. Nesting level starts at 0, thus CUR_INPUT(0) is equivalent to cur_input.
Return current line number of current input file.
Return current line number of Tefigel input file at nesting level n. Nesting level starts at 0, thus CUR_INPUT_LINE(0) is equivalent to cur_input_line.
Return name of current output file.
Return current line number of current output file.
Return 1 if filename can be opened for reading, 0 otherwise.
Process tag file filename (typically, an XML or HTML file) applying corresponding user-defined Tefigel scripts from directory subroutine dir. The optional case sensitive flag, which defaults to 1, can be set to 0 for case-insensitive tag identifiers, such as HTML tags. Additional information on this subject is provided in a later chapter.
Process comma-separated value (CSV) file filename through subroutine using character separator as value delimiter. Additional information on this subject is provided in a later chapter.
Format to_format, which can be a string or a file name, producing output lines of width characters, using filler as "background" character, according to the following scheme:
A heading line, as specified by h_line
hdr Text line #1, width characters long trl
hdr Text line #2, width characters long trl
hdr ................................... trl
A trailing line, as specified by t_line
Return edited copy of input string, replacing tabs with blanks aligned to the positions specified by numerical parameters t1, t2, t3, etc. Default alignment values for t1, t2, t3, etc., are 8, 16, 24, etc.
Return string value of variable formatted as per double floating-point printf_fmt. Refer to the technical literature for valid printf_fmt strings.
Return string value of variable formatted as per long integer printf_fmt. Refer to the technical literature for valid printf_fmt strings.
Return string value of variable formatted as per character string printf_fmt. Refer to the technical literature for valid printf_fmt strings.
Return the character (ASCII or ISO 8859-1) corresponding to the given number, which can be specified as a decimal, octal or hexadecimal number.
Return length of string.
Return an identifier built by applying the <id-pattern> to the given <base-identifier>, as explained in further detail below.
Return a string with all occurrences of old string replaced with corresponding occurrences of new string.
Return substring of n characters starting from position offset (zero-based) of the given string.
Return STRING converted to lower case as in string.
Return string converted to upper case as in STRING.
Return string with the first letter converted to upper case as in String.
Return final value of string, which can be an arbitrarily complex sequence of dash-concatenated variables. This function is used to expand complex name-value associations, also referred to as <associative-variable>'s, such as plain or multi-dimensional arrays, or nested records.
Return a data group (a dynamic record) with the specified data fields separated by the specified single-character separator.
Assigns the data fields from the specified data group to the specified variables using the specified single-character separator.
Create a new empty list identified by list id.
Create a new list identified by list id containing the specified items.
Delete the list identified by list id.
Add item at the end of the list identified by list id.
Return number of items contained in the list identified by list id.
Return a string containing the items of the list separated by separator. If separator is omitted, it defaults to comma.
The optional prefix and suffix allow to specify a leading and a trailing string for each item of the list.
Apply processor (a user-defined Tefigel script) to each item contained in the list identified by list id. The processor is called with three arguments:
1. the position (zero-based) of the current item in the list;
2. the total number of items in the list;
3. the current item.
Return n-th word (zero-based) from string, using separator list as the set of separator characters. The separator list may be omitted, in which case its content defaults to blank and tab.
Return number of words from string, using separator list as the set of separator characters. The separator list may be omitted, in which case its content defaults to blank and tab.
Apply processor (a user-defined Tefigel script) to each word contained in string, using separator list as the set of separator characters. The separator list may be omitted, in which case its content defaults to blank and tab. The processor is called with three arguments:
1. the position (zero-based) of the current word in the string;
2. the total number of words in string;
3. the current word.
Return n-th field (zero-based) from string, using separator as the field separator.
Return number of fields from string, using separator as the field separator.
Return current system date, formatted as in "Tue Jan 14 2003".
Return current system time, formatted as in "23:17:51.255".
Return name of current execution platform, one of "Linux", "Mac_OS_X", or "Windows".
Return value of the specified environment variable.
Return name of <hook-subroutine> currently associated with the <hook-event> specified by which. Hook events are listed later in this guide.
Return current value of Tefigel internal switch specified by which. Internal switches are listed later in this guide.
A <base-identifier> is the identifier of a variable,
defined as a string of letters, decimal
digits and underscores ('_'), as in this_is_a_Valid_BASE_id.
An <id-pattern> is one of the strings listed below,
providing a mnemonic identifier pattern specifying the desired
format for the conversion of a given <base-identifier>. The following list
shows the identifier resulting by applying an
<id-pattern> to this_is_a_Valid_BASE_id.
Manage input files, that provide text and commands for Tefigel, and output files, where the result of Tefigel's processing is stored.
Change the source of input text and commands:
the same instructions used to divide a complex file generation
task into a set of more manageable, smaller tasks - namely
process, process_if_readable, and call,
described in the previous
chapter - can also be used to perform this function,
as Tefigel allows text and commands to be freely intermixed
in any text file.
Attach, without any processing, the contents of a file to the current
output file:
attach <file-reference>
Write output to a file, creating it if it does not exist,
or overwriting it if it already exists:
output <file-reference>
Write output to a file, creating it if it does not exist,
or extending it from its current end if it already exists:
append <file-reference>
Write a line of text to the current output file:
echo text
Write a line of text to the current diagnostic file (standard error):
msg text
The distinction between file processing and subroutine or function calling in Tefigel is purely theoretical; in practice, calling a subroutine or a function implies the processing of the file that implements the called subroutine or function.
Divide logically related subroutines and functions into packages, hierarchically grouped in collections called libraries.
Define a logical root, called library path,
for a set of function and subroutine packages,
to be used as the starting point within the file-system
when searching for files, functions, or subroutines, to be
processed or called.
library <library-path-specifier>
Discard current definition of library path:
library
A <library-path-specifier> can be either a valid directory
pathname - absolute or relative -
or a <variable> containing a string corresponding to a valid
directory pathname.
File pathnames supplied as parameters to call and
process instructions are first used literally by Tefigel
to attempt completion of the relevant instruction; should this
attempt fail, then the current library path - if previously defined
by means of a library instruction - is
used as a prefix to attempt the requested calling or
processing of the supplied file pathname.
Tefigel allows to define only one library path at a time,
to ensure that called or
processed files can be uniquely identified.
Associate Tefigel processors (subroutines) with tag file contents and process a tag file (typically, XML or HTML files).
Process a tag file
applying corresponding user-defined Tefigel scripts from
a given directory:
[call] tag_file_process(<tag-file>,<subroutine-dir>,<case-sensitive>)
The built-in subroutine tag_file_process parses the specified
<tag-file> and processes its contents through user-defined
Tefigel scripts contained in directory <subroutine-dir>.
Both <tag-file>
and <subroutine-dir> are specified as <file-reference>'s.
The optional <case-sensitive> flag, which
defaults to 1, can be set to 0 for case-insensitive tag identifiers,
such as HTML tags.
When processing <tag-file>, Tefigel calls subroutines from
<subroutine-dir> according to the scheme described below. Only available
subroutines are called: it is not required to supply all subroutines
described below. Missing subroutines will result in Tefigel silently
ignoring them.
Calls to subroutines 2-4 above are issued only if the current tag
matches the tag path search criteria specified by means of variable
TARGET_TAG_PATH, which should be set to a regular expression
according to the tag nodes of interest.
The following variables are automatically set by Tefigel when executing
a tag_file_process request:
Variables 2-6 in the above list change dynamically with each tag node
being processed. All punctuation marks in tag identifiers are converted
to underscore _.
Process a comma-separated value (CSV) file (typically, a file containing row-column data or metadata) through a Tefigel processor (subroutine).
Process a CSV file through a user-defined CSV subroutine (a
Tefigel script):
[call] csv_file_process(<CSV-file>,<CSV-subroutine>,<value-separator>)
The built-in subroutine csv_file_process reads the
<CSV-file> and processes each line of its contents through the
user-defined Tefigel script <CSV-subroutine>.
Both <CSV-file>
and <CSV-subroutine> are specified as <file-reference>'s.
Parameter <value-separator> specifies the character separating
each value in each line of <CSV-file>.
When processing <CSV-file>, Tefigel calls for each input line
the specified <CSV-subroutine> passing the input line as
a <parameter-list>, so that each value from the
input line appears as a distinct input argument to the <CSV-subroutine>.
Tefigel automatically sets the <special-function> argdelim
to <value-separator>.
Associate Tefigel processors (subroutines) with text lines matching regular expressions.
Activate a filter for a given regular expression:
filter <file-reference> <regular-expression>
Deactivate filter previously associated with a regular expression:
filter <file-reference>
When an input line processed by Tefigel matches the <regular-expression> associated with a filter, a call to the subroutine specified by means of <file-reference> is automatically issued by Tefigel, providing as argument the whole text line via REG_0.
Associate Tefigel processors (subroutines) with input character strings resembling identifiers.
Associate a parametrical function call with a character string:
link <link>=<subprogram-reference>
Associate a non-parametrical function call with a character string:
trap <trap>=<subprogram-reference>
Disassociate function call from character string:
unlink <link>
untrap <trap>
Activate implicit call to a parametrical function from
an input line (both text and command line):
text text text text text text text text
text text text <link> text text text
text text text text text text text text
text text text <link>(par1, par2, ...) text text text
text text text text text text text text
Activate implicit call to a non-parametrical function from
an input line (both text and command line):
text text text text text text text text
text text <trap> text text text
text text text text text text text text
<trap>
text text text text text text text text
A <link> is a <variable> associated with a <file-reference>.
On encountering a <link> in its input, Tefigel calls the associated
<file-reference> providing the given arguments, if any, and replaces in
output the <link> call with the string returned by the called
function, if any.
A <trap> is a <variable> associated with a <file-reference>.
On encountering a <trap> in its input, Tefigel calls the associated
<file-reference> without arguments, and replaces in
output the <link> call with the string returned by the called
function, if any.
Create nested scopes of variables, to enable saving and restoring of values stored in variables.
Save contents of all non-global variables:
push
Restore contents of all non-global variables:
pop
All variables defined using a set instruction are
kept in name spaces which are saved and restored
either explicitly on issuing of push and pop
instructions, or implicitly on call's to function and
subroutines.
All variables defined using a globset are kept in
a global name space which is unaffected by instructions
push, pop and call.
Instruction process does not affect name spaces.
Perform miscellaneous instructions to control Tefigel operating mode and state or to access the underlying operating system.
Execute an operating system shell command:
system <command-string>
Print Tefigel version string:
version
Reset Tefigel internal state to initial state:
reset
Dump Tefigel internal state:
dump
Tune behavior of Tefigel:
switch <control-variable>=<control-value>
"Hook" a user-defined Tefigel subroutine to a given processing event:
hook <hook-event>=<hook-subroutine>
Remove association between a <hook-event> and a user-defined
<hook-subroutine>:
hook <hook-event>=
A <command-string> can be any command for the command interpreter
(shell) of the underlying operating system.
Instruction reset resets all Tefigel variables and filters,
and sets special characters, markers, control switches and event hooks
to their default start-up state.
Instruction dump prints all available information
about Tefigel status, including variables and name spaces,
special characters, markers, filters, control switches, event hooks,
and library path.
Switch <control-variable>'s may be set to the <control-value>'s
described in the following list:
A <hook-subroutine> is a Tefigel script that can be associated
with one of the <hook-event>'s described in the following list:
0: do not automatically print a CR-LF sequence after each output line;
1: [default] print a CR-LF sequence after each output line.
0: Tefigel <instruction>'s are in upper case;
1: [default] Tefigel <instruction>'s are in lower case.
0: silently ignore attempts to process or call non-existent files;
1: print a warning message when attempting to process or call non-existent files;
2: [default] print a fatal error message and terminate processing on attempts to process or call non-existent files.
0: consider input lines starting with an instruction as command lines, even if a command marker has been defined;
1: [default] when a command marker is set, treat all input lines not starting with the current command marker as text lines.
0: [default] do not print tracing messages about Tefigel processing;
1: trace begin and end of file processing instruction execution;
2: same as 1, moreover trace execution of all instructions;
3: same as 2, moreover trace processing of all input lines, including text lines.
The <hook-subroutine> (if any) associated with this event will be called when processing of a new input file begins. The file name of the new input file will be passed as a parameter to the <hook-subroutine>.
The <hook-subroutine> (if any) associated with this event will be called when processing of the current input file ends. The file name of the input file will be passed as a parameter to the <hook-subroutine>.
Additional information on the different aspects of the
Somusar/Software Production Technique[tm] can be found in the other volumes of
the Somusar/SoProTech[tm] Booklet Series, listed below.
Vol. I -
somusar/SoProTech: An Introduction
Vol. II -
somusar/SoProTech: A Sample Project
Vol. III -
somusar/Sisendel: A Tutorial Introduction
Vol. IV -
somusar/Tefigel: A Tutorial Introduction
Vol. V -
somusar/Sisendel: Reference Guide
Vol. VII -
somusar/SoProMach: User's Guide
Vol. VIII -
somusar/tjpp: User's Guide
Vol. IX -
Code Generation Somusar Style
An introduction to the Somusar/Software Production Technique[tm], a new, fast, and efficient
technology to make high-quality multifacet software.
Description of a sample project, serving as a proof-of-concept
for the Somusar/Software Production Technique[tm], and the Somusar/Sisendel[tm] and Somusar/Tefigel[tm] languages.
A few code examples are provided and
demonstrate the practical applicability of the technique.
A tutorial introduction to Somusar/Sisendel[tm], describing all
features of the simple software entity design language. Several code examples
practically demonstrate the conciseness and flexibility
of the language.
An introduction to the syntax, semantics, and usage of Somusar/Tefigel[tm],
including a vast set of code examples, illustrating the powerful
features of the text file generation language.
Sisendel reference guide: official definition of syntax and semantics
of the Somusar/Sisendel[tm] language.
The Somusar/Software Production Machine[tm] User's Guide. How to install and operate
SoProMach.
The Somusar/tjpp[tm] User's Guide. How to install and operate
the Java[tm] preprocessor.
Proof-of-concept samples of what you can generate with Somusar/SoProMach[tm].