B.3 Macro Processors

In this section, we have a brief look at some real-life macro processors. The first one is a general-purpose macro handling facility, while the second one is for a specific language use.

B.3.1 Real-world: M4 Macro Processor

This macro processor is a general-purpose macro processor, used extensively on Unix and Unix-like systems, including Linux. An extended version is available as a GNU package.

M4 is a macro processor, in the sense that it copies its input to the output, expanding macros as it goes. Macros are either built-in or user-defined, and can take any number of arguments. Besides just doing macro expansion, M4 has built-in functions for including named files, running shell commands, doing integer arithmetic, manipulating ...

Get Compilers: Principles and Practice now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.