| PREPROCESS(1) | General Commands Manual | PREPROCESS(1) |
preprocess - Preprocess a file.
preprocess [options...] infile
Preprocess is like a typical C preprocessor, but it extends to multiple languages. Languages for which it works include: C++, Python, Perl, Tcl, XML, JavaScript, CSS, IDL, TeX, Fortran, PHP, Java, Shell scripts (Bash, CSH, etc.) and C#. Preprocess is usable both as a command line app and as a Python module.
The <infile> can be marked up with special preprocessor statement lines of the form:
where the <comment-prefix/suffix> are the native comment delimiters for that file type.
HTML (*.htm, *.html) or XML (*.xml, *.kpf, *.xul) files:
Python (*.py), Perl (*.pl), Tcl (*.tcl), Ruby (*.rb), Bash (*.sh), or make ([Mm]akefile*) files:
C (*.c, *.h), C++ (*.cpp, *.cxx, *.cc, *.h, *.hpp, *.hxx, *.hh), Java (*.java), PHP (*.php) or C# (*.cs) files:
Fortran 77 (*.f) or 90/95 (*.f90) files:
Valid statements:
where <expr> is any valid Python expression.
The expression after #if/elif may be a Python statement. It is an error to refer to a variable that has not been defined by a -D option or by an in-content #define.
Special built-in methods for expressions:
A suggested file naming convention is to let input files to preprocess be of the form <basename>.p.<ext> and direct the output of preprocess to <basename>.<ext>, e.g.:
The advantage is that other tools (esp. editors) will still recognize the unpreprocessed file as the original language.
Trent Mick <trentm@gmail.com>
This manual page was written by Johannes Ring <johannr@simula.no> for the Debian GNU/Linux system (but may be used by others).