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 Macrogenerator)[1]. 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 J. Brown. 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.

m4 was designed for Unix by Brian Kernighan and Dennis Ritchie.

SNOBOL is a string processing language which is capable of doing most of the pre-processing which can be done by a macro processor.

ELENA Software: Practice and Experience, Vol. 14, pp. 519-531, Jun. 1984 Macro definition

header: a sequence of keywords and parameter markers (%) at least one of the first two tokens in a macro header must be a keyword, not a parameter marker

body: the character & identifies a local label macro time instruction (.SET, .IF .JUMP, .E) macro time variables or labels (.)

[edit] External links

[edit] References

  1. ^ Strachey, Christopher (October 1965). "A General Purpose Macrogenerator". Computer Journal 8 (3): 225–241. doi:10.1093/comjnl/8.3.225.