pycparser is a complete, standards-compliant C99 parser written in pure Python, producing an Abstract Syntax Tree (AST) that can be traversed, modified, and re-emitted as C code. Current version is 3.0, released January 2026, which replaced the bundled PLY (Lex/Yacc) backend with a hand-written lexer and recursive-descent parser—eliminating all external dependencies and improving parse speed by ~30%. Release cadence is irregular; major versions are rare (2.x spanned 2012–2025).
pip install pycparserVerified import paths — ran on the pinned version, not inferred.
Parse a tiny C snippet directly with CParser (no preprocessor needed for self-contained code), then walk the AST with a visitor.
Remove all PLY-related kwargs from CParser() calls. The public AST API is unchanged; only internal constructor arguments differ.
Upgrade to Python 3.10+. Pin pycparser<3 if you must support Python 3.8 or 3.9.
Use parse_file(..., use_cpp=True) which calls cpp/gcc-E automatically, or manually preprocess with subprocess before calling parser.parse().
Install the companion package `pip install pycparser-fake-libc` and use `import pycparser_fake_libc; cpp_args='-I' + pycparser_fake_libc.directory`, or vendor the headers from the GitHub source tree.
Omit -std=c99 from cpp_args when using fake_libc_include, or use a preprocessor invocation that defaults to C11 or later.
Pass cpp_args=['-D__attribute__(x)=', '-D__extension__=', ...] to strip extensions before parsing, as shown in the project FAQ.
Check for updated hooks in your freezer tool. As a workaround, pin pycparser<3 until the packager adds support.
Install the package using pip: `pip install pycparser`
Update your code to remove any direct imports of `pycparser.plyparser`. If a dependency requires it, ensure that dependency is compatible with `pycparser` 3.0 or downgrade `pycparser` to a 2.x version if necessary.
Ensure the C code is fully preprocessed (e.g., using `gcc -E` or `clang -E`) before parsing with `pycparser`. If using standard library headers, provide `pycparser` with its bundled `fake_libc_include` directory (e.g., `parse_file('file.c', parse_headers=True, cpp_args=['-Iutils/fake_libc_include'])`). Simplify or remove non-standard C constructs if `pycparser` doesn't support them.Downgrade `pycparser` to a version prior to 3.0 (e.g., `pip install pycparser<3`). Alternatively, check for updates to `pycparser` or the freezing tool that address this specific compatibility problem.
No dependency data recorded yet.