{"repo":"tree-sitter/py-tree-sitter","free":true,"listed":false,"github":"https://github.com/tree-sitter/py-tree-sitter","clone":"git clone https://github.com/tree-sitter/py-tree-sitter.git","description":"Python bindings to the Tree-sitter parsing library","language":"C","stars":1488,"topics":["tree-sitter","python","binding"],"license":"MIT","category":"dev-tools","readme_excerpt":"Python Tree-sitter [![CI][ci]](https://github.com/tree-sitter/py-tree-sitter/actions/workflows/ci.yml) [![pypi][pypi]](https://pypi.org/project/tree-sitter/) [![docs][docs]](https://tree-sitter.github.io/py-tree-sitter/) This module provides Python bindings to the [tree-sitter] parsing library. Installation The package has no library dependencies and provides pre-compiled wheels for all major platforms. [!NOTE] If your platform is not currently supported, please submit an [issue] on GitHub. Usage Setup Install languages Tree-sitter language implementations also provide pre-compiled binary wheels. Let's take [Python][tree-sitter-python] as an example. Then, you can load it as a Language object: Basic parsing Create a Parser and configure it to use a language: Parse some source code: If you have your source code in some data structure other than a bytes object, you can pass a \"read\" callable to the parse function. The read callable can use either the byte offset or point tuple to read from buffer and return source code as bytes object. An empty bytes object or None terminates parsing for that line. The bytes must be encoded as UTF-8 or UTF-16. For example, to use the byte offset with UTF-8 encoding: And to use the point: Inspect the resulting Tree : Or, to use the byte offset with UTF-16 encoding: Walking syntax trees If you need to traverse a large number of nodes efficiently, you can use a TreeCursor : [!IMPORTANT] Keep in mind that the cursor can only walk into children of t","default_branch":null,"files":null,"tree":[],"storefront":"/r/tree-sitter","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/tree-sitter/py-tree-sitter/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}