- General purpose macro processor
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).Examples of general purpose macro processors
One of the earliest macro processors was GPM (the "General Purpose Macrogenerator") [cite journal | last = Strachey| first = Christopher | title = A General Purpose Macrogenerator| journal = Computer Journal| volume = 8 | issue = 3 | pages = 225–241| date = October 1965 | doi = 10.1093/comjnl/8.3.225 ] . 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.
[http://gema.sourceforge.net gema] is a contextual macro processor 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 anEBNF description.[http://en.nothingisreal.com/wiki/GPP gpp] is another general macro processor written by Denis Auroux. It resembles a C preprocessor, but has more general semantics and allows for customized syntax (for instance,
TeX ,XHTML , andProlog -like scripts are definable).XPOP was another attempt at a general macro processing language by Mark Halpern at IBM in the 60's.
m4 was designed for
Unix byBrian Kernighan andDennis 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.ELENASoftware: Practice and Experience, Vol. 14, pp. 519-531, Jun. 1984Macro 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 labelmacro time instruction (.SET, .IF .JUMP, .E)macro time variables or labels (.)
External links
* [http://www.ml1.org.uk ML/I web site]
* [http://gema.sourceforge.net Gema homepage]
* [http://en.nothingisreal.com/wiki/GPP GPP's homepage]References
Wikimedia Foundation. 2010.