cparser


Namecparser JSON
Version 0.4.1 PyPI version JSON
download
home_pagehttps://github.com/typhoon-hil/cparser
SummaryC Parser writen in pure Python
upload_time2023-11-24 09:15:49
maintainer
docs_urlNone
authorTyphoon HIL, Inc
requires_python
licenseMIT
keywords parser c glr
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": "https://github.com/typhoon-hil/cparser",
    "name": "cparser",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "parser C GLR",
    "author": "Typhoon HIL, Inc",
    "author_email": "",
    "download_url": "",
    "platform": null,
    "description": "\r\nA C parser based on `parglare <https://github.com/igordejanovic/parglare/>`_ - a pure Python scannerless LR/GLR parser.\r\n\r\nQuick intro\r\n-----------\r\n\r\n**cparser** is a parser for C language. This example shows how to\r\ncollect all IDs from a simple C code.\r\n\r\n.. code:: python\r\n\r\n    from cparser import CParser\r\n    from cparser.visitor import ASTVisitor\r\n\r\n    code = \"\"\"\r\n    typedef struct {\r\n        int element;\r\n        int weight;\r\n    } Atom;\r\n\r\n    Atom helium;\r\n    \"\"\"\r\n\r\n    class IDVisitor(ASTVisitor):\r\n        \"\"\"Visitor that collects all identifiers in the code.\"\"\"\r\n\r\n        def visit_id(self, node):\r\n            print(node.value)\r\n            return node\r\n\r\n    parser = CParser()\r\n    ast = parser.parse(code)\r\n\r\n    visitor = IDVisitor()\r\n    visitor.visit(ast)\r\n\r\n    # Output should look like this:\r\n    # element\r\n    # weight\r\n    # Atom\r\n    # Atom\r\n    # helium\r\n\r\n\r\nInstallation\r\n------------\r\n\r\n- Stable version:\r\n\r\n.. code:: shell\r\n\r\n    $ pip install cparser\r\n\r\n\r\n- Development version:\r\n\r\n.. code:: shell\r\n\r\n    $ git clone https://github.com/typhoon-hil/cparser.git\r\n    $ pip install -e cparser\r\n\r\nLicence\r\n-------\r\n\r\nMIT\r\n\r\nPython versions\r\n---------------\r\n\r\nTested with 3.6-3.9\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "C Parser writen in pure Python",
    "version": "0.4.1",
    "project_urls": {
        "Homepage": "https://github.com/typhoon-hil/cparser"
    },
    "split_keywords": [
        "parser",
        "c",
        "glr"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a0e0ded4d7a34e1ad17ef1abc94c4d6aa2058cbb11412ff23f5afcad58fbe579",
                "md5": "885c5e80f5315728b7bdf9e1f074cd79",
                "sha256": "ad71c70a9d263942c4306b7c8a71979049ded99263aff5c87c4af5de76cd65a1"
            },
            "downloads": -1,
            "filename": "cparser-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "885c5e80f5315728b7bdf9e1f074cd79",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 17518,
            "upload_time": "2023-11-24T09:15:49",
            "upload_time_iso_8601": "2023-11-24T09:15:49.667042Z",
            "url": "https://files.pythonhosted.org/packages/a0/e0/ded4d7a34e1ad17ef1abc94c4d6aa2058cbb11412ff23f5afcad58fbe579/cparser-0.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-24 09:15:49",
    "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.14121s