Control statements of UNFUG are used for conditional output and for
looping over tuples. The use of a tuple is encapsulated by
The code between the `UseTuple' and `EndTuple' is repeated for
every value list in the definition of the tuple with the name
name. For empty tuples no output is created between
`UseTuple' and `EndTuple'.
In Fig. 6.4 the tuple `MyTuple' is used for C code replication. This very simple example shows already the power of UNFUG.
Abbildung 6.4: Example code replication with UNFUG
In real world applications UNFUG produces some thousands lines of code
by replication of template files. UNFUG supports nested use of
`UseTuple'/`EndTuple' and the use of a tuple holding tuple
names as values, which allows matrix code generation. This replication
facility is the big difference to the standard preprocessor Cpp used by
C and C++ which supports conditional output similar to
UNFUG but no looping control. A complex template is shown in
Listing 6.1 which is used in combination with the tuple shown in
Figure 6.3.
This example also uses the LISP extension of UNFUG by loading
functions which can be used as simple and complex expressions. The token
`IfNotSymbol' is an extension to the predefined
conditional tokens known by UNFUG shown in Table 6.1. Its definition is
and uses the `output_if' with the UNFUG tuple variable
`ObjectType' from the tuple. Additional loaded functions are used as
simple UNFUG expressions.
Tabelle 6.1: Conditional control statements
Usually conditionals occur between `UseTuple'/`EndTuple' and the condition depends on some of the variables defined in the tuple. Multiple conditional outputs can be nested at any level.
Some additional general tokens shown in Table 6.2 are available in UNFUG.
Tabelle 6.2: Predefined tokens in UNFUG