Coder Social home page Coder Social logo

pepe's Introduction

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
  • XML
  • JavaScript
  • CSS
  • IDL
  • TeX
  • Fortran
  • PHP
  • Java
  • Shell scripts (Bash, CSH, etc.)
  • C#

History

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 code.py

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():
    pass
# #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
#if EXPRESSION
#elif EXPRESSION
#else
#endif
#error ERROR_STRING
#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.

pepe's People

Contributors

gorakhargosh avatar

Stargazers

Chris Drexler avatar

Watchers

Chris Drexler avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.