Xonsh grammar for tree-sitter
Project description
Xonsh grammar for TreeSitter
A tree-sitter grammar for xonsh, the Python-powered shell.
Overview
Xonsh extends Python 3 with shell-like syntax for subprocess execution. This grammar extends tree-sitter-python with xonsh-specific constructs.
[!IMPORTANT]
- This should be treated as experimental beta-stage software. The output tree layout would change.
- Some limitations are forced by the fact that tree-sitter is context-free while some xonsh constructs are resolvable only at runtime.
Installation
Building from source
git clone https://github.com/FoamScience/tree-sitter-xonsh
cd tree-sitter-xonsh
npm install
tree-sitter generate
tree-sitter parse <your_file>.xsh
Known Limitations
- Unknown commands parsed as Python instead of a bare subprocess command.
- Workaround: Use explicit subprocess syntax:
$[mycommand]instead of justmycommand - This is an effect of scanner-based approaches, for context-bound xonsh subprocesses.
- Workaround: Use explicit subprocess syntax:
Architecture
This grammar extends tree-sitter-python. Key components:
- grammar.js: Defines xonsh-specific rules and overrides Python rules where needed
- scanner.c: External scanner for:
- Bare subprocess detection (heuristic-based)
@symbol usage disambiguation (decorator vs@(...)vs@.attrvs@modifier)- Subprocess modifier handling (
@json,@unthread, etc.) &&/||vs&disambiguation- Brace expansion vs literal detection
- Python's indent/dedent handling (inherited)
- String delimiter handling (inherited)
- queries/highlights.scm provides syntax highlighting queries for Neovim.
- The TreeSitter CLI can read those, but will render the highlighting differently.
Currently the scanner may look-ahead a whole line, which can affect performance.
License
MIT
Project details
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_xonsh-0.2.0.tar.gz.
File metadata
- Download URL: tree_sitter_xonsh-0.2.0.tar.gz
- Upload date:
- Size: 345.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a833ac315a15e8a7f549d75a5375a1ed9b71d80a27a7cf890a73a1c0220468c0
|
|
| MD5 |
f80edf053d18392e25d1639e0dfac664
|
|
| BLAKE2b-256 |
844997af23fa99c22ed6d2d405edfae26a5c3586810be513f339127a76a9c89c
|
Provenance
The following attestation bundles were made for tree_sitter_xonsh-0.2.0.tar.gz:
Publisher:
release.yml on FoamScience/tree-sitter-xonsh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_xonsh-0.2.0.tar.gz -
Subject digest:
a833ac315a15e8a7f549d75a5375a1ed9b71d80a27a7cf890a73a1c0220468c0 - Sigstore transparency entry: 955668194
- Sigstore integration time:
-
Permalink:
FoamScience/tree-sitter-xonsh@b46f3a07a7fa12060e6daa21d828f32dd0a0ff61 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/FoamScience
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b46f3a07a7fa12060e6daa21d828f32dd0a0ff61 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_xonsh-0.2.0-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: tree_sitter_xonsh-0.2.0-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 135.3 kB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3eff7325434c12d46ae4b61dbcb3b381cbdabd258032215de728289cdb6e03b
|
|
| MD5 |
d2a9539ff5efb38d9cdf2ef502d46f18
|
|
| BLAKE2b-256 |
af5a1bfff3fe63ec543ba4bd39705994015fd44408380594a1f3b97abcf1137d
|
Provenance
The following attestation bundles were made for tree_sitter_xonsh-0.2.0-cp38-abi3-win_amd64.whl:
Publisher:
release.yml on FoamScience/tree-sitter-xonsh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_xonsh-0.2.0-cp38-abi3-win_amd64.whl -
Subject digest:
b3eff7325434c12d46ae4b61dbcb3b381cbdabd258032215de728289cdb6e03b - Sigstore transparency entry: 955668242
- Sigstore integration time:
-
Permalink:
FoamScience/tree-sitter-xonsh@b46f3a07a7fa12060e6daa21d828f32dd0a0ff61 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/FoamScience
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b46f3a07a7fa12060e6daa21d828f32dd0a0ff61 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_xonsh-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: tree_sitter_xonsh-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 184.3 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff7abbfa8e48490817afcd7126c166a3fab57f54da1c46bb1236f8b7fa228e47
|
|
| MD5 |
76bb061360f90a93d45f25da6e328529
|
|
| BLAKE2b-256 |
4acb30359ba88cdc2f9dc5da898e72c44c7f1e83a3fbee95d63c8726b6bf98ae
|
Provenance
The following attestation bundles were made for tree_sitter_xonsh-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on FoamScience/tree-sitter-xonsh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_xonsh-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
ff7abbfa8e48490817afcd7126c166a3fab57f54da1c46bb1236f8b7fa228e47 - Sigstore transparency entry: 955668255
- Sigstore integration time:
-
Permalink:
FoamScience/tree-sitter-xonsh@b46f3a07a7fa12060e6daa21d828f32dd0a0ff61 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/FoamScience
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b46f3a07a7fa12060e6daa21d828f32dd0a0ff61 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_xonsh-0.2.0-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: tree_sitter_xonsh-0.2.0-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 173.3 kB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
458ba10cc090bb86c65a0dacce935c24deae4e32e3713356d87ac5e4805e4e7f
|
|
| MD5 |
c63d686dbaa2b35648c6186c4c8d978e
|
|
| BLAKE2b-256 |
eeed5c5a6c49a668bcf93c8937c84a55b7f41bb3906f4268aaf551c65d29592b
|
Provenance
The following attestation bundles were made for tree_sitter_xonsh-0.2.0-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on FoamScience/tree-sitter-xonsh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_xonsh-0.2.0-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
458ba10cc090bb86c65a0dacce935c24deae4e32e3713356d87ac5e4805e4e7f - Sigstore transparency entry: 955668230
- Sigstore integration time:
-
Permalink:
FoamScience/tree-sitter-xonsh@b46f3a07a7fa12060e6daa21d828f32dd0a0ff61 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/FoamScience
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b46f3a07a7fa12060e6daa21d828f32dd0a0ff61 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_xonsh-0.2.0-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: tree_sitter_xonsh-0.2.0-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 142.7 kB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e2ad92fec25bce338d5f3a986f1ad9b29a4a96a8dfb76b583e68ee63d99ad48
|
|
| MD5 |
9f3d8ae4084e83c02b02795265e76642
|
|
| BLAKE2b-256 |
8fba527a7e22d6263ffe74f1b4ae93cde5a5dd65ae833c9d6a45d270d8dcb45c
|
Provenance
The following attestation bundles were made for tree_sitter_xonsh-0.2.0-cp38-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on FoamScience/tree-sitter-xonsh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_xonsh-0.2.0-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
7e2ad92fec25bce338d5f3a986f1ad9b29a4a96a8dfb76b583e68ee63d99ad48 - Sigstore transparency entry: 955668213
- Sigstore integration time:
-
Permalink:
FoamScience/tree-sitter-xonsh@b46f3a07a7fa12060e6daa21d828f32dd0a0ff61 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/FoamScience
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b46f3a07a7fa12060e6daa21d828f32dd0a0ff61 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tree_sitter_xonsh-0.2.0-cp38-abi3-macosx_10_9_x86_64.whl.
File metadata
- Download URL: tree_sitter_xonsh-0.2.0-cp38-abi3-macosx_10_9_x86_64.whl
- Upload date:
- Size: 131.7 kB
- Tags: CPython 3.8+, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1aed49e7eec3f191cede7f99071ccdce0c22d74c4f4de325799f883667c4e23b
|
|
| MD5 |
08b5a493677b89e7a87ae6c3faf055bf
|
|
| BLAKE2b-256 |
30c8539b42bffe1b244d054232e24d6cc76a6db274dd82d12b57da0bd3885f7c
|
Provenance
The following attestation bundles were made for tree_sitter_xonsh-0.2.0-cp38-abi3-macosx_10_9_x86_64.whl:
Publisher:
release.yml on FoamScience/tree-sitter-xonsh
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tree_sitter_xonsh-0.2.0-cp38-abi3-macosx_10_9_x86_64.whl -
Subject digest:
1aed49e7eec3f191cede7f99071ccdce0c22d74c4f4de325799f883667c4e23b - Sigstore transparency entry: 955668273
- Sigstore integration time:
-
Permalink:
FoamScience/tree-sitter-xonsh@b46f3a07a7fa12060e6daa21d828f32dd0a0ff61 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/FoamScience
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b46f3a07a7fa12060e6daa21d828f32dd0a0ff61 -
Trigger Event:
push
-
Statement type: