# eliben/pycparser

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/eliben-pycparser).**

3,473 stars · 639 forks · Python · other

## Links

- GitHub: https://github.com/eliben/pycparser
- awesome-repositories: https://awesome-repositories.com/repository/eliben-pycparser.md

## Description

pycparser is a C99 parser library that converts C source code into an abstract syntax tree consisting of Python objects. It functions as an abstract syntax tree generator, transforming preprocessed C code into a structured hierarchy for programmatic analysis and transformation.

The library integrates with a C preprocessor to handle directives before parsing. It also features a stub header parser, which uses minimal mock headers to allow the parsing of C code without requiring a full system C library installation.

The project provides tools for static code analysis, C program analysis, and source-to-source transformation. Its parsing engine is generated from a formal C99 grammar using Python Lex-Yacc.

## Tags

### Programming Languages & Runtimes

- [Abstract Syntax Tree Parsers](https://awesome-repositories.com/f/programming-languages-runtimes/abstract-syntax-tree-parsers.md) — Provides a C99-compliant parser that transforms source code into a structured abstract syntax tree for programmatic analysis.
- [C Source Parsing](https://awesome-repositories.com/f/programming-languages-runtimes/c-source-parsing.md) — Transforms C source code into an abstract syntax tree to facilitate program analysis and structural transformation. ([source](https://github.com/eliben/pycparser#readme))
- [C Source Generators](https://awesome-repositories.com/f/programming-languages-runtimes/c-source-generators.md) — Parses C code into a tree structure to programmatically rewrite or modify source logic.
- [Stub Headers](https://awesome-repositories.com/f/programming-languages-runtimes/header-file-inclusions/stub-headers.md) — Implements stub-based header substitution to allow parsing C code without a full system library installation.
- [Header Mocking](https://awesome-repositories.com/f/programming-languages-runtimes/language-interoperability/native-c-interoperability/c-function-bindings/native-header-generators/c-header-binding-generators/header-mocking.md) — Provides minimal stub headers to enable parsing of C source code without a full system library installation.
- [Mock Header Parsers](https://awesome-repositories.com/f/programming-languages-runtimes/mock-header-parsers.md) — Uses minimal stub headers to enable parsing of C code without requiring a full system C library installation.
- [Preprocessing Directives](https://awesome-repositories.com/f/programming-languages-runtimes/preprocessing-directives.md) — Processes C preprocessing directives and definitions before generating the syntax tree. ([source](https://github.com/eliben/pycparser#readme))
- [Preprocessors](https://awesome-repositories.com/f/programming-languages-runtimes/programming-language-varieties/programming-languages/systems-languages/c/preprocessors.md) — Integrates with C preprocessors to handle macro expansion and conditional compilation before parsing.

### Development Tools & Productivity

- [AST Node Generation](https://awesome-repositories.com/f/development-tools-productivity/ast-transformation-tools/ast-node-generation.md) — Generates a typed hierarchy of Python objects representing C constructs for structured traversal.
- [Abstract Syntax Tree Generators](https://awesome-repositories.com/f/development-tools-productivity/project-scaffolding-config-code-generation/code-generation/abstract-syntax-tree-generators.md) — Transforms preprocessed C code into a structured tree of Python objects for programmatic analysis.

### Software Engineering & Architecture

- [LALR Parsers](https://awesome-repositories.com/f/software-engineering-architecture/trees/syntax-tree-construction/formal-grammar-parser-generators/lalr-parsers.md) — Implements a C99 parsing engine generated from a formal grammar using the Python Lex-Yacc (PLY) framework.
- [Typed AST Nodes](https://awesome-repositories.com/f/software-engineering-architecture/typed-ast-nodes.md) — Represents C language constructs as a tree of specialized Python objects to maintain semantic structure.
- [AST Visitor Patterns](https://awesome-repositories.com/f/software-engineering-architecture/ast-visitor-patterns.md) — Provides an AST visitor pattern to enable custom analysis and transformation of C code structures.
- [Formal Grammar Parser Generators](https://awesome-repositories.com/f/software-engineering-architecture/trees/syntax-tree-construction/formal-grammar-parser-generators.md) — Uses Python Lex-Yacc as a formal grammar parser generator to implement the C99 specification.
- [Grammar-Based Parsers](https://awesome-repositories.com/f/software-engineering-architecture/trees/syntax-tree-construction/grammar-based-parsers.md) — Implements the C99 language syntax using a formal grammar-based parser.

### Testing & Quality Assurance

- [Static Code Analysis](https://awesome-repositories.com/f/testing-quality-assurance/static-code-analysis.md) — Enables the analysis of C source files without execution to identify vulnerabilities and enforce standards.
- [Structural Code Analysis](https://awesome-repositories.com/f/testing-quality-assurance/static-code-analysis/ast-extraction/static-analysis-ast-parsing/structural-code-analysis.md) — Converts C source into ASTs for structural program analysis and bug detection.

### Data & Databases

- [Stub Libraries](https://awesome-repositories.com/f/data-databases/data-processing-pipelines/data-serialization/json-libraries/c/header-only-libraries/stub-libraries.md) — Replaces standard library includes with minimal stub headers for environment-independent parsing.
