General Information
Tutorials
Reference Manuals
Libraries
Translation Tasks
Tools
Administration
|
Tasks related to generating outputIntroducing Separators in PTG OutputThe `Separator' module supplies functions to insert separator characters into the generated output in a context dependent fashion.
It provides the function
loop: "while" [Separator] $1 [Separator] $2 [Separator]
The insertions of
The decision whether a separator is needed must be made by
the user-supplied function
Sep_Print(PtgFilePtr file, const char *last, const char *next) /* On entry- * file points to the output file * last points to the last string printed * next points to the string about to be printed * On exit- * An appropriate separator has been added to the output file ***/
Based on the textual context
The `Separator' module provides the following output functions which must be used instead of the corresponding PTG functions (see Output Functions of PTG: Pattern-based Text Generator):
PTGNode Sep_Out(PTGNode root); PTGNode Sep_OutFile(char *filename, PTGNode root); PTGNode Sep_OutFPtr(FILE *fptr, PTGNode root);
The `Separator' module is used in conjunction with the Unparser Generator
`Idem' (see Abstract Syntax Tree Unparsing of Abstract Syntax Tree Unparsing)
to simplify
pretty-printing of the output. Idem inserts calls to
UsageTo include this module into your specification simply add the following line to one of your `.specs'-files:
$/Output/Separator.fw
An example of a `C_Separator.fw' can be included in your specifications by putting
$/Output/C_Separator.fw into a `.specs'-file.
`C_Separator.fw' is also useful as an example how to
develop your own
-> $elipkg/Output/C_Separator.fw > My_Separator.fw -> My_Separator.fw !chmod +w -> My_Separator.fw < In order to change the decision about what (if any) separator is to be inserted in a given context, you need to change `Sep_Print' function, as described above.
RestrictionsSince the `Separator' module uses its own PTG output functions
Sep_Out Sep_OutFile Sep_OutFPtr as explained above, it cannot be combined with specifications that influence PTG output by redefining the PTG output macros (see Influencing PTG Output of PTG: Pattern-based Text Generation). The memory for storing the last string printed for the `Sep_Print' function is restricted to 1024 characters. If the last string printed exceeds 1024 characters, only its last 1024 characters are stored and passed to `Sep_Print'.
|