Science Score: 36.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
3 of 90 committers (3.3%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (16.7%) to scientific vocabulary
Keywords from Contributors
Repository
:snake: Complete C99 parser in pure Python
Basic Info
Statistics
- Stars: 3,424
- Watchers: 92
- Forks: 632
- Open Issues: 43
- Releases: 1
Metadata Files
README.rst
===============
pycparser v2.22
===============
.. image:: https://github.com/eliben/pycparser/workflows/pycparser-tests/badge.svg
:align: center
:target: https://github.com/eliben/pycparser/actions
----
.. contents::
:backlinks: none
.. sectnum::
Introduction
============
What is pycparser?
------------------
**pycparser** is a parser for the C language, written in pure Python. It is a
module designed to be easily integrated into applications that need to parse
C source code.
What is it good for?
--------------------
Anything that needs C code to be parsed. The following are some uses for
**pycparser**, taken from real user reports:
* C code obfuscator
* Front-end for various specialized C compilers
* Static code checker
* Automatic unit-test discovery
* Adding specialized extensions to the C language
One of the most popular uses of **pycparser** is in the `cffi
`_ library, which uses it to parse the
declarations of C functions and types in order to auto-generate FFIs.
**pycparser** is unique in the sense that it's written in pure Python - a very
high level language that's easy to experiment with and tweak. To people familiar
with Lex and Yacc, **pycparser**'s code will be simple to understand. It also
has no external dependencies (except for a Python interpreter), making it very
simple to install and deploy.
Which version of C does pycparser support?
------------------------------------------
**pycparser** aims to support the full C99 language (according to the standard
ISO/IEC 9899). Some features from C11 are also supported, and patches to support
more are welcome.
**pycparser** supports very few GCC extensions, but it's fairly easy to set
things up so that it parses code with a lot of GCC-isms successfully. See the
`FAQ `_ for more details.
What grammar does pycparser follow?
-----------------------------------
**pycparser** very closely follows the C grammar provided in Annex A of the C99
standard (ISO/IEC 9899).
How is pycparser licensed?
--------------------------
`BSD license `_.
Contact details
---------------
For reporting problems with **pycparser** or submitting feature requests, please
open an `issue `_, or submit a
pull request.
Installing
==========
Prerequisites
-------------
* **pycparser** was tested with Python 3.8+ on Linux, macOS and Windows.
* **pycparser** has no external dependencies. The only non-stdlib library it
uses is PLY, which is bundled in ``pycparser/ply``. The current PLY version is
3.10, retrieved from ` `_
Note that **pycparser** (and PLY) uses docstrings for grammar specifications.
Python installations that strip docstrings (such as when using the Python
``-OO`` option) will fail to instantiate and use **pycparser**. You can try to
work around this problem by making sure the PLY parsing tables are pre-generated
in normal mode; this isn't an officially supported/tested mode of operation,
though.
Installation process
--------------------
The recommended way to install **pycparser** is with ``pip``::
> pip install pycparser
Using
=====
Interaction with the C preprocessor
-----------------------------------
In order to be compilable, C code must be preprocessed by the C preprocessor -
``cpp``. A compatible ``cpp`` handles preprocessing directives like ``#include`` and
``#define``, removes comments, and performs other minor tasks that prepare the C
code for compilation.
For all but the most trivial snippets of C code **pycparser**, like a C
compiler, must receive preprocessed C code in order to function correctly. If
you import the top-level ``parse_file`` function from the **pycparser** package,
it will interact with ``cpp`` for you, as long as it's in your PATH, or you
provide a path to it.
Note also that you can use ``gcc -E`` or ``clang -E`` instead of ``cpp``. See
the ``using_gcc_E_libc.py`` example for more details. Windows users can download
and install a binary build of Clang for Windows `from this website
`_.
What about the standard C library headers?
------------------------------------------
C code almost always ``#include``\s various header files from the standard C
library, like ``stdio.h``. While (with some effort) **pycparser** can be made to
parse the standard headers from any C compiler, it's much simpler to use the
provided "fake" standard includes for C11 in ``utils/fake_libc_include``. These
are standard C header files that contain only the bare necessities to allow
valid parsing of the files that use them. As a bonus, since they're minimal, it
can significantly improve the performance of parsing large C files.
The key point to understand here is that **pycparser** doesn't really care about
the semantics of types. It only needs to know whether some token encountered in
the source is a previously defined type. This is essential in order to be able
to parse C correctly.
See `this blog post
`_
for more details.
Note that the fake headers are not included in the ``pip`` package nor installed
via ``setup.py`` (`#224 `_).
Basic usage
-----------
Take a look at the |examples|_ directory of the distribution for a few examples
of using **pycparser**. These should be enough to get you started. Please note
that most realistic C code samples would require running the C preprocessor
before passing the code to **pycparser**; see the previous sections for more
details.
.. |examples| replace:: ``examples``
.. _examples: examples
Advanced usage
--------------
The public interface of **pycparser** is well documented with comments in
``pycparser/c_parser.py``. For a detailed overview of the various AST nodes
created by the parser, see ``pycparser/_c_ast.cfg``.
There's also a `FAQ available here `_.
In any case, you can always drop me an `email `_ for help.
Modifying
=========
There are a few points to keep in mind when modifying **pycparser**:
* The code for **pycparser**'s AST nodes is automatically generated from a
configuration file - ``_c_ast.cfg``, by ``_ast_gen.py``. If you modify the AST
configuration, make sure to re-generate the code. This can be done by running
the ``_build_tables.py`` script from the ``pycparser`` directory.
* Make sure you understand the optimized mode of **pycparser** - for that you
must read the docstring in the constructor of the ``CParser`` class. For
development you should create the parser without optimizations, so that it
will regenerate the Yacc and Lex tables when you change the grammar.
Package contents
================
Once you unzip the ``pycparser`` package, you'll see the following files and
directories:
README.rst:
This README file.
LICENSE:
The pycparser license
setup.py:
Installation script
examples/:
A directory with some examples of using **pycparser**
pycparser/:
The **pycparser** module source code.
tests/:
Unit tests.
utils/fake_libc_include:
Minimal standard C library include files that should allow to parse any C code.
Note that these headers now include C11 code, so they may not work when the
preprocessor is configured to an earlier C standard (like ``-std=c99``).
utils/internal/:
Internal utilities for my own use. You probably don't need them.
Contributors
============
Some people have contributed to **pycparser** by opening issues on bugs they've
found and/or submitting patches. The list of contributors is in the CONTRIBUTORS
file in the source distribution. After **pycparser** moved to Github I stopped
updating this list because Github does a much better job at tracking
contributions.
Owner
- Name: Eli Bendersky
- Login: eliben
- Kind: user
- Location: California
- Company: @google
- Website: https://eli.thegreenplace.net
- Repositories: 71
- Profile: https://github.com/eliben
GitHub Events
Total
- Issues event: 21
- Watch event: 189
- Issue comment event: 50
- Push event: 8
- Pull request review event: 21
- Pull request review comment event: 12
- Pull request event: 19
- Fork event: 21
Last Year
- Issues event: 21
- Watch event: 189
- Issue comment event: 50
- Push event: 8
- Pull request review event: 21
- Pull request review comment event: 12
- Pull request event: 19
- Fork event: 21
Committers
Last synced: 11 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Eli Bendersky | e****n@g****m | 291 |
| eli.bendersky | d****l@l****t | 80 |
| Jon Dufresne | j****e@g****m | 11 |
| ldore | l****e@g****m | 6 |
| Akira Hayakawa | r****k@g****m | 6 |
| Julian Hammer | j****r@f****e | 5 |
| Vitaly Cheptsov | 4****6 | 5 |
| Hugo van Kemenade | h****k | 4 |
| Ben | B****n@b****e | 4 |
| Sye van der Veen | s****n@b****m | 4 |
| Hart Chu | c****y@y****t | 3 |
| Seth Poulsen | p****h@y****m | 2 |
| Thom Wiggers | t****s | 2 |
| Zecong Hu | h****g@g****m | 2 |
| Jason Pepas | j****s@g****m | 2 |
| Jean-Sébastien B | r****x@g****m | 2 |
| Saullo Carvalho Castelo Branco | s****o@g****m | 2 |
| Manuel Jacob | me@m****e | 2 |
| Jordy Ruiz | 5****r | 2 |
| zawan-ila | 8****a | 2 |
| Ignacio Tiraboschi | i****o@g****m | 2 |
| Florian Rathgeber | f****r@g****m | 2 |
| Even | e****h@g****m | 2 |
| Eisuke Kawashima | e****m | 2 |
| Dubslow | b****w@g****m | 2 |
| Amir Gonnen | a****n@g****m | 2 |
| Joyce | j****m@g****m | 2 |
| Tyson Andre | t****e@u****a | 2 |
| Stefano Rivera | g****b@r****t | 2 |
| Robin Martinjak | r****b@r****e | 2 |
| and 60 more... | ||
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 125
- Total pull requests: 67
- Average time to close issues: 3 months
- Average time to close pull requests: 28 days
- Total issue authors: 105
- Total pull request authors: 33
- Average comments per issue: 2.49
- Average comments per pull request: 1.57
- Merged pull requests: 39
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 15
- Pull requests: 20
- Average time to close issues: 1 day
- Average time to close pull requests: 6 days
- Issue authors: 15
- Pull request authors: 8
- Average comments per issue: 0.73
- Average comments per pull request: 1.35
- Merged pull requests: 12
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- vit9696 (4)
- joycebrum (4)
- nxmaintainer (3)
- corradods (2)
- kunzeng-ch (2)
- mingodad (2)
- eliben (2)
- kdschlosser (2)
- brmmm3 (2)
- retif (2)
- akash-isu (2)
- ldore-ks (2)
- MaggieCwj (2)
- tassosblackg (2)
- geajack (2)
Pull Request Authors
- vit9696 (7)
- hugovk (4)
- cellularmitosis (4)
- joycebrum (3)
- zawan-ila (3)
- bbb23exposed (3)
- ignatirabo (3)
- gudnimg (2)
- jackrosenthal (2)
- jordr (2)
- ldore (2)
- aerah8 (2)
- cclauss (2)
- dj-wednesday (2)
- e-kwsm (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 50
-
Total downloads:
- homebrew 9,693 last-month
- pypi 380,732,913 last-month
- Total docker downloads: 13,706,166,195
-
Total dependent packages: 857
(may contain duplicates) -
Total dependent repositories: 167,077
(may contain duplicates) - Total versions: 94
- Total maintainers: 7
pypi.org: pycparser
C parser in Python
- Homepage: https://github.com/eliben/pycparser
- Documentation: https://pycparser.readthedocs.io/
- License: BSD-3-Clause
-
Latest release: 2.22
published about 2 years ago
Rankings
Maintainers (1)
pkg.adelielinux.org: py3-cparser
C99 parser in pure Python
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.20-r0
published over 3 years ago
Rankings
Maintainers (1)
alpine-v3.18: py3-cparser-pyc
Precompiled Python bytecode for py3-cparser
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.21-r2
published about 3 years ago
Rankings
alpine-v3.18: py3-cparser
C parser written in Python3
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.21-r2
published about 3 years ago
Rankings
alpine-v3.16: py3-cparser
C parser written in Python3
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.20-r2
published over 4 years ago
Rankings
alpine-v3.15: py3-cparser
C parser written in Python3
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.20-r1
published about 5 years ago
Rankings
alpine-v3.13: py3-cparser
C parser written in Python3
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.20-r0
published over 6 years ago
Rankings
alpine-v3.12: py3-cparser
C parser written in Python3
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.20-r0
published over 6 years ago
Rankings
alpine-v3.8: py3-cparser
A C parser written in Python 3
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.18-r0
published about 8 years ago
Rankings
Maintainers (1)
alpine-v3.17: py3-cparser
C parser written in Python3
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.21-r0
published almost 4 years ago
Rankings
alpine-v3.11: py3-cparser
C parser written in Python3
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.19-r4
published over 6 years ago
Rankings
alpine-v3.3: py-cparser
a C parser written in Python
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.10-r0
published over 10 years ago
Rankings
Maintainers (1)
alpine-v3.10: py3-cparser
A C parser written in Python 3
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.19-r2
published about 7 years ago
Rankings
alpine-edge: py3-cparser
C parser written in Python3
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.22-r1
published about 2 years ago
Rankings
Maintainers (1)
alpine-v3.6: py2-cparser
A C parser written in Python 2
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.17-r1
published about 9 years ago
Rankings
Maintainers (1)
alpine-v3.14: py3-cparser
C parser written in Python3
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.20-r1
published about 5 years ago
Rankings
alpine-v3.7: py3-cparser
A C parser written in Python 3
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.18-r0
published over 8 years ago
Rankings
Maintainers (1)
alpine-v3.7: py2-cparser
A C parser written in Python 2
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.18-r0
published over 8 years ago
Rankings
Maintainers (1)
alpine-v3.9: py2-cparser
A C parser written in Python 2
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.19-r0
published over 7 years ago
Rankings
Maintainers (1)
alpine-v3.10: py2-cparser
A C parser written in Python 2
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.19-r2
published about 7 years ago
Rankings
conda-forge.org: pycparser
pycparser is a complete parser of the C language, written in pure Python using the PLY parsing library. It parses C code into an AST and can serve as a front-end for C compilers or analysis tools.
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.18
published over 3 years ago
Rankings
alpine-edge: py3-cparser-pyc
Precompiled Python bytecode for py3-cparser
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.22-r1
published about 2 years ago
Rankings
Maintainers (1)
alpine-v3.5: py2-cparser
A C parser written in Python 2
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.14-r2
published over 9 years ago
Rankings
Maintainers (1)
alpine-v3.5: py-cparser
A C parser written in Python
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.14-r2
published over 9 years ago
Rankings
Maintainers (1)
alpine-v3.5: py3-cparser
A C parser written in Python 3
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.14-r2
published over 9 years ago
Rankings
Maintainers (1)
alpine-v3.7: py-cparser
A C parser written in Python
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.18-r0
published over 8 years ago
Rankings
Maintainers (1)
alpine-v3.4: py-cparser
a C parser written in Python
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.10-r0
published about 10 years ago
Rankings
Maintainers (1)
alpine-v3.9: py3-cparser
A C parser written in Python 3
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.19-r0
published over 7 years ago
Rankings
Maintainers (1)
alpine-v3.9: py-cparser
A C parser written in Python
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.19-r0
published over 7 years ago
Rankings
Maintainers (1)
formulae.brew.sh: pycparser
C parser in Python
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.22
published about 2 years ago
Rankings
alpine-v3.6: py-cparser
A C parser written in Python
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.17-r1
published about 9 years ago
Rankings
Maintainers (1)
alpine-v3.6: py3-cparser
A C parser written in Python 3
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.17-r1
published about 9 years ago
Rankings
Maintainers (1)
alpine-v3.8: py-cparser
A C parser written in Python
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.18-r0
published about 8 years ago
Rankings
Maintainers (1)
alpine-v3.8: py2-cparser
A C parser written in Python 2
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.18-r0
published about 8 years ago
Rankings
Maintainers (1)
alpine-v3.10: py-cparser
A C parser written in Python
- Homepage: https://github.com/eliben/pycparser
- License: BSD
-
Latest release: 2.19-r2
published about 7 years ago
Rankings
spack.io: py-pycparser
A complete parser of the C language, written in pure python.
- Homepage: https://github.com/eliben/pycparser
- License: []
-
Latest release: 2.21
published over 3 years ago
Rankings
Maintainers (1)
pypi.org: pycparaser
C parser in Python
- Homepage: https://github.com/eliben/pycparser
- Documentation: https://pycparaser.readthedocs.io/
- License: BSD
-
Latest release: 2.21
published over 3 years ago
Rankings
Maintainers (1)
pypi.org: pycparserr
C parser in Python
- Homepage: https://github.com/eliben/pycparser
- Documentation: https://pycparserr.readthedocs.io/
- License: BSD
-
Latest release: 2.21
published over 3 years ago
Rankings
Maintainers (1)
pypi.org: pycparserrr
C parser in Python
- Homepage: https://github.com/eliben/pycparser
- Documentation: https://pycparserrr.readthedocs.io/
- License: BSD
-
Latest release: 2.21
published over 3 years ago
Rankings
pypi.org: pycparsre
C parser in Python
- Homepage: https://github.com/eliben/pycparser
- Documentation: https://pycparsre.readthedocs.io/
- License: BSD
-
Latest release: 2.21
published over 3 years ago
Rankings
pypi.org: pycparser-plz-ignore
C parser in Python
- Homepage: https://github.com/eliben/pycparser
- Documentation: https://pycparser-plz-ignore.readthedocs.io/
- License: BSD
-
Latest release: 2.14
published over 10 years ago
Rankings
Maintainers (1)
anaconda.org: pycparser
pycparser is a complete parser of the C language, written in pure Python using the PLY parsing library. It parses C code into an AST and can serve as a front-end for C compilers or analysis tools.
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-clause
-
Latest release: 2.21
published over 4 years ago
Rankings
alpine-v3.19: py3-cparser
C parser written in Python3
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.21-r4
published over 2 years ago
Rankings
Maintainers (1)
alpine-v3.20: py3-cparser
C parser written in Python3
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.22-r1
published about 2 years ago
Rankings
Maintainers (1)
alpine-v3.21: py3-cparser
C parser written in Python3
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.22-r1
published about 2 years ago
Rankings
Maintainers (1)
alpine-v3.22: py3-cparser-pyc
Precompiled Python bytecode for py3-cparser
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.22-r1
published over 1 year ago
Rankings
Maintainers (1)
alpine-v3.20: py3-cparser-pyc
Precompiled Python bytecode for py3-cparser
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.22-r1
published about 2 years ago
Rankings
Maintainers (1)
alpine-v3.19: py3-cparser-pyc
Precompiled Python bytecode for py3-cparser
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.21-r4
published over 2 years ago
Rankings
Maintainers (1)
alpine-v3.21: py3-cparser-pyc
Precompiled Python bytecode for py3-cparser
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.22-r1
published about 2 years ago
Rankings
Maintainers (1)
alpine-v3.22: py3-cparser
C parser written in Python3
- Homepage: https://github.com/eliben/pycparser
- License: BSD-3-Clause
-
Latest release: 2.22-r1
published over 1 year ago
Rankings
Maintainers (1)
Dependencies
- actions/checkout v2 composite
- actions/setup-python v2 composite