Eli   Documents

General Information

 o Eli: Translator Construction Made Easy
 o Global Index
 o Frequently Asked Questions
 o Typical Eli Usage Errors

Tutorials

 o Quick Reference Card
 o Guide For new Eli Users
 o Release Notes of Eli
 o Tutorial on Name Analysis
 o Tutorial on Scope Graphs
 o Tutorial on Type Analysis
 o Typical Eli Usage Errors

Reference Manuals

 o User Interface
 o Eli products and parameters
 o LIDO Reference Manual
 o Typical Eli Usage Errors

Libraries

 o Eli library routines
 o Specification Module Library

Translation Tasks

 o Lexical analysis specification
 o Syntactic Analysis Manual
 o Computation in Trees

Tools

 o LIGA Control Language
 o Debugging Information for LIDO
 o Graphical ORder TOol

 o FunnelWeb User's Manual

 o Pattern-based Text Generator
 o Property Definition Language
 o Operator Identification Language
 o Tree Grammar Specification Language
 o Command Line Processing
 o COLA Options Reference Manual

 o Generating Unparsing Code

 o Monitoring a Processor's Execution

Administration

 o System Administration Guide

Mail Home

Tasks related to generating output

Previous Chapter Next Chapter Table of Contents


Typesetting for Block Structured Output

The module `BlockPrint' supplies C functions that can be inserted in PTG patterns for block formatting. It is the aim of this module to print all the text between the block marks into one line. If that does not succeed, all embedded line breaks of the block are converted into newlines. Additionally, blocks can be nested and blocking can be combined with indentation.

There are functions to mark line breaks and the beginning and end of a block. These functions can be included into PTG Pattern definitions.

BP_BreakLine
Specifies, that a LineBreak can be inserted at this point. A line will only be broken at these points.

BP_BeginBlock
BP_EndBlock
Marks the beginning and end of a Block. If the text until the call to BP_BlockEnd has room in the current line, all line breaks will be discarded. Else, all embedded line breaks will be converted into newlines.

BP_BeginBlockI
BP_EndBlockI
Same as the above. The block created by this pair of functions will additionally be indented by one indentation step.

BP_Newline
Forces a linefeed thereby inserting the newline sequence. Note that with the presence of this pattern function, the enclosing block is automatically tagged as 'too long' and all the remaining Line breaks in the current block are also converted to newlines. The next line will be indented properly. The newline character `"\n"' in a PTG pattern is a shortcut for a call to this output function.

Examples

The following PTG patterns can be used to print nested C scopes with intermediate function calls. The statements in one block will be indented properly and always be separated by newlines. The arguments of a function call will be set into one line, if there is enough room. If not, newlines will be inserted between the arguments.

   FCall:          "\n" $ string "(" [BP_BeginBlockI] $ [BP_EndBlockI] ");"
   Arg:            $ { "," [BP_BreakLine] } $
   Block:          "\n{" [BP_BeginBlockI]
                       $ [BP_EndBlockI]
                   "\n}"

Additional functions

BP_SetLineWidth(int width)
Sets the linewidth to the specified value. The default is 80.
BP_SetSoftBreakShortcut(char)
Assings a character that should behave like a call to BP_LineBreak. A good choice for this would be the tab character. The default is set to the null character what disables substitution.
BP_SetIndentationWidth(int width)
Sets the amount to indent in one indentation level. Indentation is normally done by spaces. If a negative value is used, a tab character will be used for one indentation step (counting as 8 character positions).
BP_SetEndline(char *endline)
Assigns the given string to be used as end-of-line sequence. Default for this is "\n". Another good choice would be "\r\n".

All these functions need to be called prior to start output with one of the following functions. They replace the PTG generated ones, if block printing is used.

BP_OutFPtr(FILE *f, PTGNode n)
Output the given `PTGNode' to the given file that must have been opened for output.

BP_OutFile(char *filename, PTGNode n)
Output the given PTGNode to the named file.

BP_Out(PTGNode n)
Output the given PTGNode to the standard output.

Usage of Module

To use the block printing module, simply include it's name in one of the .specs files:

   $/Output/BlockPrint.fw

Restrictions

In two cases it is possible that an output line exceeds the given maximal length:

  • A sequence of characters longer than the specified linewidth is output without intermediate call to BP_BreakLine.
  • A PTG Pattern contains tab characters that will be counted to have a width of 1 which of course is not always true.

Additional information about this module and it's implementation can be obtained by the derivation

   $elipkg/Output/BlockPrint.fw :fwTexinfo :display


Previous Chapter Next Chapter Table of Contents