Skip to content

Language Specification (G) : Generics

Benjamin Kowarsch edited this page Aug 16, 2026 · 1 revision

Source Code Generation by Text Replacement

The Modula-2 Template Engine is a standalone utility for generating source files by placeholder substitution. It reads any text file as input, replaces placeholders found within the input file with their translations supplied as a key/value list via command line interface (CLI) and writes the result into an output file. An input file that contains placeholders is called a template.

Image

Placeholders

Placeholders will be replaced by their translations. They are identified by opening and closing delimiters <# and #>.

placeholder := '<#' identifier `#>';
identifier := Letter ( Letter | Digit )*;

Example

INTERFACE MODULE <#TypeIdent#>;

Template Comments

Template comments are not copied into the output file. They are identified by opening and closing delimiters /* and */.

templateComment := '/*' ( printableChar | Space | Tab | Newline )*  `*/';
printableChar := Letter | Digit | graphicAsciiChar;

Example

/* This template generates a stack library interface for arbitrary types. */

Any Other Input

Any other input will be copied into the output file verbatim.

Clone this wiki locally