Home | Support | About Us

Python Preprocessor

I needed a preprocessor to expand some C code. I have a custom preprocessor which generates the following code, from ... well the following code.  Here’s an example of what it looks like...

(lots of C code here)
/* Python Preprocessor (begin)
--------------------------------
   out(“*/”)
   for name in [“test1”, “test2”]
:
--------------------------------
   function %(name)s() {
       (lots of C code here)
   }

--------------------------------
*/
   function test1() {
       (lots of C code here)
   }
   function test2() {
       (lots of C code here)
   }

/*
--------------------------------
   # (so that we know to dedent)
   out(“/*”)
--------------------------------
   Python Preprocessor (end) */
 

Features

You can use any delimiter.
 ------- is just an example

python code is in bold. (initial indentation is deduced)

Italics are the template code

expanded code are marked in red here.

 

Download

Without further ado, I present to you:
ppp.py (5kb)

Copyright Reserved (c) 2004-2006 Red Mountain Software. An Australian Company. Microsoft, Oracle, Plone and Zope are trademarks of their respective owners.