cmonster (Python wrapper for clang's preprocessor)

Hi folks,

I’ve been working on a hobby project for a little while now, a Python-driven C preprocessor. I’m using clang’s Lex and Frontend libraries (and friends). As well as the usual stuff, it adds the ability to:

  • define macros in Python (i.e. the macro is a Python function), inline in the C/C++ source or in the driving Python program.
  • intercept and resolve missing files in #include directives using a Python callback.

So anyway, I do actually have a question: does anyone think this could be useful? I embarked on this quest initially as part of a larger project, a Python-based C++ source-to-source translator. I haven’t done much on that front yet, as I ended up having too much fun bending clang to my will. If you can think of anything that it could be useful for, please let me know. As much fun as I’ve had, I’d like even more for it to be useful to someone.

If you’re interested in reading more (only slightly more), I’ve written up a post on my blog. It also has instructions on installing, if you’re keen to play.

Andrew Wilkins

P.S. I’m loving Clang: very clean code, pretty easy it understand (what I’ve read), and very efficient!