Text-substitution macros




Languages such as C and some assembly languages have rudimentary macro systems, implemented as preprocessors to the compiler or assembler. C preprocessor macros work by simple textual substitution at the token, rather than the character level. However, the macro facilities of more sophisticated assemblers, e.g., IBM High Level Assembler (HLASM) can't be implemented with a preprocessor; the code for assembling instructions and data is interspersed with the code for assembling macro invocations.

A classic use of macros is in the computer typesetting system TeX and its derivatives, where most of the functionality is based on macros.

MacroML is an experimental system that seeks to reconcile static typing and macro systems. Nemerle has typed syntax macros, and one productive way to think of these syntax macros is as a multi-stage computation.

Other examples:

  • m4 is a sophisticated stand-alone macro processor.
  • TRAC
  • Macro Extension TAL, accompanying Template Attribute Language
  • SMX: for web pages
  • ML/1 (Macro Language One)
  • The General Purpose Macroprocessor is a contextual pattern matching macro processor, which could be described as a combination of regular expressions, EBNF and AWKcitation needed
  • SAM76
  • troff and nroff: for typesetting and formatting Unix manpages.
  • CMS EXEC: for command-line macros and application macros
  • EXEC 2 in Conversational Monitor System (CMS): for command-line macros and application macros
  • CLIST in IBM's Time Sharing Option (TSO): for command-line macros and application macros
  • REXX: for command-line macros and application macros in, e.g., AmigaOS, CMS, OS/2, TSO
  • SCRIPT: for formatting documents
  • Various shells for, e.g., Linux

Some major applications have been written as text macro invoked by other applications, e.g., by XEDIT in CMS.

Embeddable languagesedit

Some languages, such as PHP, can be embedded in free-format text, or the source code of other languages. The mechanism by which the code fragments are recognised (for instance, being bracketed by <?php and ?>) is similar to a textual macro language, but they are much more powerful, fully featured languages.

Comments

Popular posts from this blog

46)The Republic of Inhospitality

Macro (computer science)

Text-substitution macros