SPARQL grammar for tree-sitter
Project description
Tree-sitter SPARQL
Python bindings for the tree-sitter SPARQL grammar.
This is based on the original repo here: https://github.com/GordianDziwis/tree-sitter-sparql - but updated to work with more recent versions of tree-sitter.
Installation
Install from source:
git clone https://github.com/yourusername/tree_sitter_sparql
cd tree_sitter_sparql
pip install .
Usage (tree-sitter 0.21.0+)
If you're using tree-sitter version 0.21.0 or later:
import tree_sitter_sparql
from tree_sitter import Language, Parser
# Initialize the language
SPARQL_LANGUAGE = Language(tree_sitter_sparql.language())
# Create parser
parser = Parser(SPARQL_LANGUAGE)
# Parse SPARQL query
query = b"""
SELECT ?subject ?predicate ?object
WHERE {
?subject ?predicate ?object .
}
LIMIT 10
"""
tree = parser.parse(query)
# Walk the syntax tree
cursor = tree.walk()
def walk_tree(cursor, depth=0):
node = cursor.node
print(" " * depth + f"{node.type}: {node.text.decode('utf8')[:50]}")
if cursor.goto_first_child():
walk_tree(cursor, depth + 1)
cursor.goto_parent()
if cursor.goto_next_sibling():
walk_tree(cursor, depth)
walk_tree(cursor)
Requirements
- Python 3.8+
- tree-sitter
Development
To build from source:
# Install in development mode
pip install -e .
# Run tests (if available)
pytest
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tree_sitter_sparql-0.1.0.tar.gz.
File metadata
- Download URL: tree_sitter_sparql-0.1.0.tar.gz
- Upload date:
- Size: 103.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab96caa8b123661d81f53fe6491a1ba631b4a9b8e2171cb07d58bc3c72d44e91
|
|
| MD5 |
d127836ee1c6ac177e72e712cdf3c5ec
|
|
| BLAKE2b-256 |
6f9e9122d41adb037ea0d08c580264d608b16e26abd01bf94536c673b342d67c
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 97.0 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf55f69fb87d627db847d44d7e780282a3963fc859220f9df8e66206bca752b5
|
|
| MD5 |
ca79cb669c06fa352fe252a09fb00ef5
|
|
| BLAKE2b-256 |
8834d94508de6fd496de99a5abe37c80d358e6c4d99a541545f98017101bf2f1
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 92.5 kB
- Tags: CPython 3.12, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e3a5e1b0bf711a3a13620ca7eeb1d252813c40ef10decc1ffae4ce793b5e58c
|
|
| MD5 |
8241db44fa82cc308f6516021e1ca4ff
|
|
| BLAKE2b-256 |
57f9b30fdc35d20103ebff26ece0b365ca0809256396d1f97d857226604df499
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 49.5 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e2fc6530ca28330587e224ca3c535b09611be600257ab0426a10e8c28ec7d4a
|
|
| MD5 |
42b202f768b1efbfb7dd98280ef97919
|
|
| BLAKE2b-256 |
5fac2e8caa3b716433eed7d65dbe833af53da0527fae2b39be00f4ff3c0178a3
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp312-cp312-macosx_10_9_x86_64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp312-cp312-macosx_10_9_x86_64.whl
- Upload date:
- Size: 48.5 kB
- Tags: CPython 3.12, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9566a809d9073aec1cf734fd7b3481b7d18524cde21f64c1c491c8419c5d78d1
|
|
| MD5 |
6dc5b205a92de727b22c676d69a278e1
|
|
| BLAKE2b-256 |
6219b28f45eb1a10d5bbe093716e02bf341618ffa36dc3d3f19f0e4eddd7460c
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 98.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d8706c82667c5396f01edb01d5bfa7872b37f47d20f25ff2fb15a7d078ba877
|
|
| MD5 |
edd2d905435215fcb2742707e7e51ba1
|
|
| BLAKE2b-256 |
838e7c4819ef8ed0f629a4862b1533c4e6930a48207e31aef5fcb2db08e2c930
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 96.3 kB
- Tags: CPython 3.11, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cd4b89e566a4864c248e7cf77877009a16ead99c92f7acfa07fe8233679f2f24
|
|
| MD5 |
89c91bc641fbc05f2e8f22bdb597f92e
|
|
| BLAKE2b-256 |
07807be01317c592f48c829aa0d3b4bdf8d1aada1982f3f38dd570cdcd0e767d
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 49.5 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0383eb5e0f8c1cf880d15ecefe4a63cf6676560af70bfb626891f26acb222888
|
|
| MD5 |
c60cda1bed039c4ae3e8cc53d2d50376
|
|
| BLAKE2b-256 |
dc85a3fb09ec3fe7dbb83eac73cf3b5e9e7219d6403ba12cc8abaa69c135504c
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 48.5 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3da9b0a474908f3b226354cfe8f5e7aa385e65f55b0d8351f368bb0edaeced22
|
|
| MD5 |
94f983a39b078e7b2302ac669af4d704
|
|
| BLAKE2b-256 |
a5134c195bad25e6f79739b6586c215e8f694cbdae85faa3128259276ca212a1
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 98.5 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4744ad72a9382404582def7a30da8f598edf724a6f3ba1f23e4f3d2ed5b4a60a
|
|
| MD5 |
7ea020a6c1069e68bff8ee2a2fdb22ed
|
|
| BLAKE2b-256 |
0a610ebd666bb0139347e496eeaffd6661d0005d546c4089b2a45c90545a9e65
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 96.3 kB
- Tags: CPython 3.10, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
609f0eb45b2123c6c95cb96675711ab284d7a9931b6e06581c665dfa5aebdfee
|
|
| MD5 |
638f90899a9881e0a082092f88b9fbf4
|
|
| BLAKE2b-256 |
a8d039830bd171e32af477f6bb6629a04d1419dfefcbd4f7af0e17d073a6e437
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 49.5 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
237fec9e171ba0b690518df33e643a4da2c0c58a316b4007e98e251999bfb038
|
|
| MD5 |
bbb801c45f83cc465bdc389a00ccabc6
|
|
| BLAKE2b-256 |
03e8bb14752a7788d2bc37a7d5ac1d42d0432bc28eecec6a516bf943b7995d25
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 48.5 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae07fb07ec653e2b7412fef8ccc65b99543fd7396ddc9c8182d8cfab3e82f7e0
|
|
| MD5 |
397f7b7ea44fab8d6ee28358dca36d18
|
|
| BLAKE2b-256 |
b6c1df3c8c06a669ad028e8a4f5caaf51997ca550eeba691a1e86ef4fcf65df2
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
- Upload date:
- Size: 98.4 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ ARM64, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bcb3f0ab96e0557d76ac3c3c2bc8f04036405449847c30cc87aad78fe215f3c
|
|
| MD5 |
50ae83a8c0bf61d83c0743560933c278
|
|
| BLAKE2b-256 |
16131bbf6fa4dd27eedae0624177d1f66289c91cc7be8b0ce65f4272da51d1ed
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp39-cp39-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
- Upload date:
- Size: 96.1 kB
- Tags: CPython 3.9, manylinux: glibc 2.28+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86c22cf8ff2cd6c403e8898446043a592ab1da54e16978fc7cb8e14aa03829e1
|
|
| MD5 |
671aceecdfe184d5314bb347bce3b4aa
|
|
| BLAKE2b-256 |
da90c3cda56d4ce8600cb3ee5f3abb2f33586b42e1ceef99167f573e3b6f5223
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 49.5 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1173e0984291dbf5bae7842b7d316d18fa8dbe94f5be2d2bc390838e4c053fdd
|
|
| MD5 |
83387ed48f9238828eac86ffcff8b93d
|
|
| BLAKE2b-256 |
7ae1490fac5f7d8d8fad2411742a7de9d8f56fa74c0488aee8fc85c00412273b
|
File details
Details for the file tree_sitter_sparql-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl.
File metadata
- Download URL: tree_sitter_sparql-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 48.5 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6ff4b9ea246f1947a97497c6c00cc33e014f02fde68128e310cb29c368e4e12
|
|
| MD5 |
ccc0f5af136c0b46a8dc98f941f8118c
|
|
| BLAKE2b-256 |
55095e38581adb01d1a7b6c47f7b9bfc25f1aab1e95f725f439cb0997be99291
|