Skip to main content

Portable multi-language file preprocessor

Project description

pepe—a portable multi-language file preprocessor

There are tons of template systems. This is just a basic preprocessor.

Pepe is usable both as a command line app and as a Python module.
Pepe syntax is hidden within comments (whatever the syntax for comments
in the target file type), so that the file can still have valid syntax.
Pepe syntax mimics that of the C preprocessor, but its behavior differs.

Who is it for?
Pepe is targeted at **build systems** that deal with many types of files.
Languages for which it works include:

* C++
* Python,
* Perl
* Tcl
* JavaScript
* TeX
* Fortran
* Java
* Shell scripts (Bash, CSH, etc.)
* C#

Pepe began as a fork of Trent Mick's preprocess_ which has been used for
build-time code differentiation in the Komodo_ build system, which
includes source code in Python, JavaScript, XML, CSS, Perl, and C/C++.

How it works
All preprocessor statements are on their own line. A preprocessor statement
is a comment (as appropriate for the language of the file being preprocessed).
This way the preprocessor statements do not make an unpreprocessed file
syntactically incorrect.

For example::

pepe -D FEATURES=macros,scc

will yield this transformation::

... ...
# #if "macros" in FEATURES
def do_work_with_macros(): def do_work_with_macros():
pass pass
# #else
def do_work_without_macros():
# #endif
... ...

or, with a JavaScript file::

... ...
// #if "macros" in FEATURES
function do_work_with_macros() { function do_work_with_macros() {
} }
// #else
function do_work_without_macros() {
// #endif
... ...

The ``#if`` expression (``"macros" in FEATURES`` in the example) is Python
code, so it has Python's full comparison richness. A number of
preprocessor statements are implemented::

#define VAR [VALUE]
#undef VAR
#ifdef VAR
#ifndef VAR
#include "FILE"

As well, pepe will do inline substitution of defined variables.
Although, this is currently turned off by default because substitution occurs
in program strings, which is not ideal. When a future version of
pepe can lex languages being preprocessed it will NOT substitute
into program strings and substitution will be turned ON by default.

Install Notes
Installing Pepe is easy::

$ pip install pepe

Getting Started

Using as a shell command::

$ pepe --help

Pepe can also be used as a module. Please see the documentation_
for more information.

.. _preprocess:
.. _Komodo:
.. _documentation:

Project details

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page