General Information
Tutorials
Reference Manuals
Libraries
Translation Tasks
Tools
Administration
|
Tasks related to generating outputPretty PrintingThe module `PrettyPrint' supplies C functions that can be inserted in PTG patterns to handle line breaks properly. The functions try to break the current line at the last possible position that precedes the maximum line width. Furthermore, regions of text can be indented. Functions exist to mark line breaks and the begin and end of an indentation region. These functions can be included into PTG pattern definitions.
Examples
The following PTG patterns can be used to yield different styles of
indenting for blocks.
Here
Block: "\n{" [PP_Indent] "\n" $ [PP_Exdent] "\n}" Stmt: [PP_BreakLine] $ The next example also specifies an indented region. Here, the opening brace is set as last token outside the block, separated with whitespace instead of a newline:
Block: " " [PP_BreakLine] "{" [PP_Indent] "\n" $ [PP_Exdent] "\n}" The third example uses the indentation style commonly known as the GNU indentation style. Here, the braces are set on a new line, indented two positions. The indented region then follows indented four positions. To use this, set the indentation width to two by one of the function calls discussed later. Then use the following pattern:
Block: [PP_Indent] "\n{" [PP_Indent] "\n" $ [PP_Exdent] "\n}" [PP_Exdent]
Additional functionsAdditional functions exist to influence the behavior of the module.
All these functions need to be called prior to the start of the output with one of the following functions. They replace the PTG generated ones, if PrettyPrinting should be used.
Usage of Module
To use the pretty printing module, simply include it's name in one of the
$/Output/PrettyPrint.fw
RestrictionsIn two cases it is possible that an output line exceeds the given maximal length:
Additional information about this module and it's implementation can be obtained by the derivation $elipkg/Output/PrettyPrint.fw :fwTexinfo :display |