Grammar-Based Definition of Metaprogramming Systems

Robert D. Cameron, Mabo Robert Ito. Grammar-Based Definition of Metaprogramming Systems. ACM Transactions on Programming Languages and Systems, 6(1):20-54, 1984. [doi]

Abstract

A metaprogramming system is a programming facility (subprogramming system or language) whose basic data objects include the programs and program fragments of some particular programming language, known as the target language of the system. Such systems are designed to facilitate the writing of metaprograms, that is, programs about programs. Metaprograms take as input programs and fragments in the target language, perform various operations on them, and possibly generate modified target-language programs as output.

A grammar-based approach to the specification of the syntactic-manipulation component of a metaprogramming system is described. The method derives the specifications for a set of programmanipulating subprograms from an augmented BNF grammar for the target language. The method is applicable to any programming language and is illustrated in its particular application to Pascal.