Using GPP the General Purpose Preprocessor

GPP (gpp) is a general purpose preprocessor. Wikipedia has an entry called General-purpose macro processor that describes the idea:

A general-purpose macro processor or general purpose preprocessor is a macro processor that is not tied to or integrated with a particular language or piece of software.

A macro processor is a program that copies a stream of text from one place to another, making a systematic set of replacements as it does so. Macro processors are often embedded in other programs, such as assemblers and compilers. Sometimes they are standalone programs that can be used to process any kind of text.

Macro processors have been used for language expansion (defining new language constructs that can be expressed in terms of existing language components), for systematic text replacements that require decision making, and for text reformatting (e.g. conditional extraction of material from an HTML file).

On my Lubuntu laptop I searched for gpp but refining it to this gives the specific output:

apt search 'general-purpose preprocessor with customizable syntax'

I installed with the usual sudo apt install gpp. This installs a manual page (man gpp) and presumably the detailed HTML documentation. I don't know where the HTML manual is on my system but it is online.

Examples

The syntax is customizable but there are some built-in "modes." This trivial example uses a TeX-like mode.

\define{gpp}{General Purpose preprocessor}
GPP stands for \gpp.

And the processed version:

gpp -T +n gpp-example.txt

Notice in the input file the line with the macro definition is retained so the output file starts with blank line.

Author: Stephen Weigand

Created: 2023-08-28 Mon 09:02

Validate