pycparser is a parser for the C language written in pure Python.
pycparser solves the problem of parsing C source code within Python applications. It implements a complete C99 parser that closely follows the grammar specified in the C99 standard, with some support for C11 features and limited GCC extensions. The parser is written entirely in Python with no external dependencies beyond a Python interpreter, making it straightforward to install and integrate into projects that need to analyze or manipulate C code.
The tool suits projects that need to work with C code programmatically, such as code obfuscators, specialized compiler front-ends, static analysis tools, or automatic test discovery systems. It is particularly well-suited for applications where ease of experimentation and modification matter more than raw parsing speed, since the pure Python implementation prioritizes readability and accessibility over performance. The tool is widely used in the cffi library for parsing C function and type declarations to auto-generate foreign function interfaces. Anyone adopting pycparser should be aware that it requires preprocessed C code as input, meaning the C preprocessor must be run first to handle directives like #include and #define; the tool provides a parse_file function that handles this automatically if cpp is available in the system PATH.
The project maintains active continuous integration testing across Linux, macOS, and Windows with modern Python versions. Development activity shows responsiveness to user-reported issues and feature requests through the issue tracker and pull request process.