Run Tree Sitter queries from the command line
Project description
TSQuery
Run Tree Sitter queries from the command line.
Installation
pip install tsquery
Usage
Parsers (.so
files) should be installed somewhere in $XDG_DATA_HOME
or
$XDG_DATA_DIRS
. Use the
official Tree Sitter CLI tool
to compile a grammar to parser source.
For example, this command prints the names of functions defined in a toy Python program:
# Write a toy Python program
cat > example.py <<EOF
def baz():
return 1
def foo(bar):
if bar:
baz()
EOF
# Run a query against it
tsquery '(function_definition name: (identifier) @func.name)' example.py
See also example.sh
in this repository.
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
tsquery-0.1.1.tar.gz
(5.9 kB
view details)
Built Distribution
tsquery-0.1.1-py3-none-any.whl
(19.9 kB
view details)
File details
Details for the file tsquery-0.1.1.tar.gz
.
File metadata
- Download URL: tsquery-0.1.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9e8fda8744d12be39475ebd2138201e4c6428dc586624e70cd726ec7d9d2bfe |
|
MD5 | 8f4f4da686725cde3ec37fa3fb8d6ec6 |
|
BLAKE2b-256 | 3bc001b831ac80d4ca3c408a3fc86c8d614db3f4d661a057d84272e8363fe966 |
File details
Details for the file tsquery-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: tsquery-0.1.1-py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 009cad8516357551df89e283b43a26625cf5ad718a56eb2fdb8fe565074afeb8 |
|
MD5 | 29bbb9cfad8a5e026425706a9c4c61d5 |
|
BLAKE2b-256 | 61348c7c233301295fa1ff2f8a64f0ed1b2528afca10da9aa767112bc7eb35e5 |