General Information
Tutorials
Reference Manuals
Libraries
Translation Tasks
Tools
Administration
|
|
Pattern-based Text Generator
PTG generates a C module consisting of an interface file ptg_gen.h
and an implementation file ptg_gen.c .
The interface file exports definitions for the following identifiers:
PTGNode
- the pointer type for internal representations of pattern applications;
PTGNULL
- a pointer of type
PTGNode representing no text;
Note: There are many ways to represent no text;
comparing a PTGNode to PTGNULL is only a pointer
comparison;
PTGNull()
- a macro without parameters that yields
PTGNULL , to be used
where a function notation is needed, as in
WITH clauses
of LIDO's CONSTITUENTS construct;
void PTGFree (void)
- a call of this function deallocates all data generated by
pattern applications; to be used for reduction of dynamic
memory usage in cases where output is produced in several phases.
The following functions can be used to process the contents of a PTGNode
and it's insertions recursively into an output file. These functions are only
available, under certain preconditions, See Influencing PTG Output.
PTGNode PTGOut (PTGNode root)
- a function that outputs the text represented by the parameter
root
to standard output
PTGNode PTGOutFile (char *filename, PTGNode root)
- a function that opens a file with the name given by
the parameter
filename ,
outputs the text represented by the parameter root ,
and closes the file
PTGNode PTGOutFPtr (FILE *output, PTGNode root)
- a function that expects the parameter
output to be a file
which is open for writing,
outputs the text represented by the parameter root to the file,
and leaves the file open
PTGNode PTGProcess (PTG_OUTPUT_FILE file, PTGNode root)
- a function that expects the parameter
file to be of a
type that is provided by the user, See Influencing PTG Output.
If the default definition of PTG_OUTPUT_FILE is overriding,
only PTGProcess can be used as output function;
the other three output functions are not available in that case.
The user should ensure that these predefined identifiers do not clash
with other definitions in the application importing the interface file.
In particular, the pattern names should be chosen such that prefixing
them with PTG does not yield a predefined name, e.g. a pattern
name Free would be a bad choice.
The implementation file contains external references to any user defined
function mentioned in the particular specification.
|