Solutions Application Development Metro/C

METRO is a powerful macro preprocessor which allows to capture the generic structure present in many kind of files used in software development and document processing and to generate all possible specific file instances obeying to this generic structure.


Recognizing that some files always reveal the same structure and contain similar fragments, it becomes easy to replace these parts by macro calls and to associate the substituted file fragment as the body of a macro definition. Macro arguments can be defined to introduce variable parts as data or as control variables for introducing some genericity between similar but not identical fragments. This substitution may occur in the original file or in already defined macros.
At the end of this process, the file contain macro calls and text fragments; these remaining text fragments can also be replaced by specific macro calls (called place-holders) whose definitions are kept into a new specific library. This new version of the file only contains macro calls and represent the generic structure of all these files which can also be encapsulated into a macro (this structure is also called a template or a skeleton or a model).
Metro provides a sophisticated macro formalism to define what is also often called "cliches".

Expressive power

Macros are defined and logically grouped in special files called macro libraries. A macro definition contains a header and a body; the header identifies the macro and its typeless arguments with a possible default value; the body contains macro-calls and textlines. The concept of macro is similar to the one of control abstraction (procedure) in programming languages and the concept of library is similar to the one of module.
Macro-calls and textlines may refer to typeless variables. All variables have a list structure. Macro arguments are actualized as well by value as by reference. Variables are macro arguments or locally declared and their validity follows the macro call hierarchy. Variables may also be globally declared. Macro call recursivity is possible.
Predefined macro identifiers are used for controlling the production flow, accessing files, activating processes and defining variables; their possible arguments may be actualized by expressions of constants and/or variables and/or predefined functions. The embedded translation directives (ifdef,...) obey to the same syntactically conventions.

The interpretation process

METRO interprets a template with the help of libraries.
All METRO libraries are translated into a binary representation to speed up the interpretation process and check their validity.
The interpreter first substitutes the variables by their value, then executes the predefined macros or expands the macro calls and sends the relevant textlines to the RESULT file. Empty variables may be prompted for a value.
The symbolic debugger is useful during the creation phase.

The utilities

A cross-reference utility reports which macro is used, where it is called and which macro it is calling.
A second utility allow to relocate text fragments from a document to anchor points within the same document. This is usefull in a development environment where macro definition may refer to variables to be declared somewhere else. These declaration may then be locally attached. The tool also takes care of avoiding double relocation of the same fragment.
Another utility produces a tag file to speed up the editing process. Tag files allow to retrieve a macro definition associated to a macro call reference.
METRO is also the backend engine of XGL, the DECADE open application generator.

Available platforms

  • MS/DOS
  • MPE/XL, MPE/iX
  • any UNIX


Reusability, one of the major issue of the Object Oriented paradigm, enforces :

  • productivity by:
    • reusing reliable parts instead of developing them again (creation)
    • modifying once and reusing everywhere (maintenance)
    • enforcing standards (both)
  • efficiency by:
    • using one preprocessor instead of many
    • replacing run-time parameters by preprocessor time parameters

But METRO extends the scope of reusability :

  • As with Object Oriented environment, METRO allows to define standard components which have to be seen as black boxes by their users.
  • METRO also allows to define standard program model (also called template) which have to be seen as white boxes by their users ("fill in the blanks" approach).
  • METRO is also used outside the programming world where files are produced.

Example of applications

  • encapsulation of printer commands in text file to produce software manuals while providing printer command language independency
  • definition of manual outlines
  • production of documents such as invoices from a variable document template representing its layout and containing the statements to merge a data file
  • production of general C function definitions such as "print_recordid" from a data file containing the record definitions (Interface Definition Language)
The limits of METRO are the limits of your creativity.
Subscribe here for our free WEBISO and STARJET