I’m happy to announce that I’ve finally released version 1.0 of pycparser – a complete ANSI C parser written in Python. It generates a complete AST from C code, and thus can serve as a front-end for a C compiler, or as a platform for static code analysis of C.
pycparser uses PLY to construct the lexer and the parser for the C language. At the moment it supports ANSI C89 (the language described in K&R2).
A lot of work went into
pycparser (2,500 LOC for the module + 2,000 more for examples and tests), and I’m very happy it’s finally out. My own plan for it is to use it as a front-end for a complete C compiler, but I’m sure people can employ it for various useful tasks. After all, it is written in Python, which means the code should be easy to understand, modify and extend.