next up previous contents
Next: Changing the Output File Up: 6.1 Universal Function Generator Previous: 6.1.1 Definition of a

6.1.2 UNFUG Control Statements

Control statements of UNFUG are used for conditional output and for looping over tuples. The use of a tuple is encapsulated by
block2632
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.

 figure2648
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.
 listing2669
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
block2687
and uses the `output_if' with the UNFUG tuple variable `ObjectType' from the tuple. Additional loaded functions are used as simple UNFUG expressions.

  table2697
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.

  table2718
Tabelle 6.2: Predefined tokens in UNFUG


next up previous contents
Next: Changing the Output File Up: 6.1 Universal Function Generator Previous: 6.1.1 Definition of a

IUE WWW server
Fri Jan 3 17:00:13 MET 1997