Is there a known implementation of the C pre-processor tool implemented either in Python or JavaScript? I am looking for a way to robustly pre-process C (and C like) source code and want to be able to process, for example, conditional compilation and macros without invoking an external CPP tool or native code library. Another potential use case is pre-processing within a web application, within the web browser.
So far, I have found implementations in Java, Perl, and of course, C and C again. It may be plausible to use one of the C to JavaScript compilers now becoming available.
The PLY (Python Lex and Yacc) tools include a cpp implemented in Python.
Check out PLY, an implementation of Lex and Yacc on Python which contains a cpp tool implemented in python using the PLY lexer. There is also pycparser, a parser built on top of PLY for the C language.