General Purpose Macro Processor

From Wikipedia, the free encyclopedia

A general purpose macro processor is a macro processor that is not tied to, or integrated with, a particular language or piece of software.

In its simplest form, a macro processor is a program that copies a stream of text from one place to another, making some kind of systematic set of replacements as it does so. Macro processors are often embedded in other programs (for example, many assembler programs incorporate a macro processor, and the C language mandates the presence of a preprocessor which incorporates some crude macro processing facilities).

However, macro processors may also be stand alone programs, which means that it is easy to use them for processing any kind of text at all.

General purpose macro processors can be used for many tasks; they have been used for language expansion (defining new language constructs that can be expressed in terms of existing language components), for systematic textual replacements that require some kind of decision making (where a global edit would be insufficient), and for textual reformatting (e.g. conditional extraction of material from an HTML file).

[edit] Examples of general purpose macro processors

One of the earliest macro processors was GPM (the General Purpose Macroprocessor). This was developed at the University of Cambridge, UK, in the mid 1960s.

One particularly important general purpose macro processor was (and still is) ML/I (Macro Language One). This was developed as part of PhD research by a Cambridge postgraduate, Peter Brown. Decades later, it is still in use; see http://www.ml1.org.uk . ML/I operates on a character stream, and requires no special format for its input, nor any special flag characters to introduce macros.

A contemporary of ML/I was STAGE2, part of William Waite's Mobile Programming System. This too is a general purpose macro processor, but it processes input a line at a time, matching each line against specified patterns.

gema is a contextual macro processor, which is based on pattern matching. It replaces/enhances the concept of regular expressions by contexts. Contexts roughly corresponds to named sets of patterns. As a consequence, macros in gema closely resemble an EBNF description.

XPOP was another attempt at a general macro processing language by Mark Halpern at IBM in the 60's.

[edit] See also