Eli   Documents Get Eli: Translator Construction Made Easy at SourceForge.net.
    Fast, secure and Free Open Source software downloads

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

Pattern-based Text Generator

Previous Chapter Next Chapter Table of Contents


Output Functions

PTG separates the composition of a target text from outputting it: A target text is composed by calls of pattern functions. They yield results of type PTGNode representing the target text or fragments thereof.

There are three predefined PTG functions that can be applied to PTGNode values in order to output the text. They have the following signatures:

   PTGNode PTGOut(PTGNode r)
   PTGNode PTGOutFile(char *f, PTGNode r)
   PTGNode PTGOutFPtr(FILE *f, PTGNode r)

A call PTGOut (x) writes the text represented by x to stdout.

The function PTGOutFile takes the name of the output file as an additional parameter. A call PTGOutFile (n, x) opens the file named n for writing, writes the text represented by x to it, and closes the file before returning.

The function PTGOutFPtr takes the file pointer to an already open file as additional parameter. A call PTGOutFPtr (f, x) writes the text represented by x to f, and leaves The function PTGOutFPtr takes open upon exit.

Each of the functions yields its PTGNode argument as result. Hence, nested calls of output functions may produce parts of the complete target text on separate files, e.g.

   PTGOutFile ("f1",
      PTGModule (
         PTGOutFile ("f2", PTGInterface ( ...... )),
         PTGBody ( .... )))
In the above example a Module is composed by two text fragments Interface and Body. The whole text is written to the file f1. The Interface fragment is also written to the file f2.

Of course nested calls like the above can be decomposed by storing intermediate PTGNode values. Nested calls of PTGOutFile to the same file would destroy the results of the former calls. Nested calls of PTGOutFPtr to the same file would append the results of each call to the end of the file.

Note: Be aware that the output functions do not add a newline character to the end of an output text. It has to be explicitly specified by a pattern. This behavior has been changed compared to previous versions of PTG. Adding a newline character to a text is simply specified by a pattern like

     NewLine:    $ "\n"


Previous Chapter Next Chapter Table of Contents