pycparser v1.0 is out!

November 15th, 2008 at 5:47 pm

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.

Related posts:

  1. pycparser v1.06 released
  2. pycparser now supports C99
  3. Faking standard C header files for pycparser
  4. ASTs for analyzing C
  5. Implementing cdecl with pycparser

4 Responses to “pycparser v1.0 is out!”

  1. Andrew MontalentiNo Gravatar Says:

    This is really cool. I’m going to check it out. Python is becoming quite the platform for parsing both natural language and programming languages, what with NLTK, PLY, and projects like yours. Keep up the good work.

  2. MartinNo Gravatar Says:

    Congratulations! I took a quick look at the code and it looks very clear and readable.

  3. eddieNo Gravatar Says:

    If you are going to write a C compiler in python, that is actually very cool.

    That would mean people can compile extensions without dependencies external to python and/or can bootstrap a python installation directly from python without requiring a native C compiler. It would also mean people can write their own specialized compiler based on your code.

  4. Kim P. GostelowNo Gravatar Says:

    I found pycparser very useful for writing a Domain-Specific Language as an extension to C. Thanks for the tool.