tree-sitter-python
repository·master·Indexed 20 days ago
https://github.com/tree-sitter/tree-sitter-pythonA tree-sitter grammar implementation for the Python programming language that enables high-performance, incremental syntax tree generation. It provides a concrete grammar for parsing Python source code, compatible with core tree-sitter library bindings in Python, C++, JavaScript, and Rust.
What's inside tree-sitter-python
- tree-sitter-python provides a concrete grammar for parsing Python code using the tree-sitter incremental parsing framework. It allows developers to generate syntax trees for Python source code, which can be used for syntax highlighting, code analysis, refactoring tools, and more. The grammar is compatible with the core tree-sitter library across multiple language bindings including Python, C++, JavaScript, and Rust.
Use the Node.js bindings for tree-sitter-python
masterThe
tree-sitter-pythonNode.js package provides the compiled bindings for the Python grammar. It is designed to work with standard Node.js environments vianode-gyp-buildand also provides support for Bun's static analysis duringbun build --compileto ensure the.nodebinary is correctly located.To use this in a project, require the module as usual. The exported object contains the grammar implementation and, if available,
nodeTypeInfowhich maps node types to their definitions fromsrc/node-types.json.const parser = require('tree-sitter-python'); // The exported object contains the grammar bindings. // It may also contain nodeTypeInfo for inspecting node types. if (parser.nodeTypeInfo) { console.log('Node type information is available'); }