cparser


Namecparser JSON
Version 0.5.2 PyPI version JSON
download
home_pageNone
SummaryC Parser written in pure Python
upload_time2024-12-27 10:08:35
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords parser glr c
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
A C parser based on `parglare <https://github.com/igordejanovic/parglare/>`_ - a pure Python scannerless LR/GLR parser.

Quick intro
-----------

**cparser** is a parser for C language. This example shows how to
collect all IDs from a simple C code.

.. code:: python

    from cparser import CParser
    from cparser.visitor import ASTVisitor

    code = """
    typedef struct {
        int element;
        int weight;
    } Atom;

    Atom helium;
    """

    class IDVisitor(ASTVisitor):
        """Visitor that collects all identifiers in the code."""

        def visit_id(self, node):
            print(node.value)
            return node

    parser = CParser()
    ast = parser.parse(code)

    visitor = IDVisitor()
    visitor.visit(ast)

    # Output should look like this:
    # element
    # weight
    # Atom
    # Atom
    # helium


Installation
------------

- Stable version:

.. code:: shell

    $ pip install cparser


- Development version:

.. code:: shell

    $ git clone https://github.com/typhoon-hil/cparser.git
    $ pip install -e cparser

Licence
-------

MIT

Python versions
---------------

Tested with 3.6-3.9


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cparser",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "\"Typhoon HIL, Inc\" <office@typhoon-hil.com>",
    "keywords": "parser, GLR, C",
    "author": null,
    "author_email": "\"Typhoon HIL, Inc\" <office@typhoon-hil.com>",
    "download_url": null,
    "platform": null,
    "description": "\nA C parser based on `parglare <https://github.com/igordejanovic/parglare/>`_ - a pure Python scannerless LR/GLR parser.\n\nQuick intro\n-----------\n\n**cparser** is a parser for C language. This example shows how to\ncollect all IDs from a simple C code.\n\n.. code:: python\n\n    from cparser import CParser\n    from cparser.visitor import ASTVisitor\n\n    code = \"\"\"\n    typedef struct {\n        int element;\n        int weight;\n    } Atom;\n\n    Atom helium;\n    \"\"\"\n\n    class IDVisitor(ASTVisitor):\n        \"\"\"Visitor that collects all identifiers in the code.\"\"\"\n\n        def visit_id(self, node):\n            print(node.value)\n            return node\n\n    parser = CParser()\n    ast = parser.parse(code)\n\n    visitor = IDVisitor()\n    visitor.visit(ast)\n\n    # Output should look like this:\n    # element\n    # weight\n    # Atom\n    # Atom\n    # helium\n\n\nInstallation\n------------\n\n- Stable version:\n\n.. code:: shell\n\n    $ pip install cparser\n\n\n- Development version:\n\n.. code:: shell\n\n    $ git clone https://github.com/typhoon-hil/cparser.git\n    $ pip install -e cparser\n\nLicence\n-------\n\nMIT\n\nPython versions\n---------------\n\nTested with 3.6-3.9\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "C Parser written in pure Python",
    "version": "0.5.2",
    "project_urls": {
        "Changelog": "https://github.com/typhoon-hil/cparser/blob/master/CHANGELOG.md",
        "Homepage": "https://github.com/typhoon-hil/cparser",
        "Repository": "https://github.com/typhoon-hil/cparser"
    },
    "split_keywords": [
        "parser",
        " glr",
        " c"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff66dd275035c2cf5f860885e70451978eb49362c94821cad931fc8caaa1eddc",
                "md5": "b50600b127139f487dde4d8692bc472e",
                "sha256": "e9c969846ecd03a06e3f914c9937267db79a42513ba1572041d58645a12c69cb"
            },
            "downloads": -1,
            "filename": "cparser-0.5.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b50600b127139f487dde4d8692bc472e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 11258,
            "upload_time": "2024-12-27T10:08:35",
            "upload_time_iso_8601": "2024-12-27T10:08:35.263855Z",
            "url": "https://files.pythonhosted.org/packages/ff/66/dd275035c2cf5f860885e70451978eb49362c94821cad931fc8caaa1eddc/cparser-0.5.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-27 10:08:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "typhoon-hil",
    "github_project": "cparser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "cparser"
}
        
Elapsed time: 0.93242s