Skip to main content

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

  1. Unknown commands parsed as Python instead of a bare subprocess command.
    • Workaround: Use explicit subprocess syntax: $[mycommand] instead of just mycommand
    • This is an effect of scanner-based approaches, for context-bound xonsh subprocesses.

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 @.attr vs @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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tree_sitter_xonsh-0.2.2.tar.gz (370.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tree_sitter_xonsh-0.2.2-cp38-abi3-win_amd64.whl (141.4 kB view details)

Uploaded CPython 3.8+Windows x86-64

tree_sitter_xonsh-0.2.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (191.2 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

tree_sitter_xonsh-0.2.2-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (179.7 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

tree_sitter_xonsh-0.2.2-cp38-abi3-macosx_11_0_arm64.whl (150.5 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

tree_sitter_xonsh-0.2.2-cp38-abi3-macosx_10_9_x86_64.whl (138.1 kB view details)

Uploaded CPython 3.8+macOS 10.9+ x86-64

File details

Details for the file tree_sitter_xonsh-0.2.2.tar.gz.

File metadata

  • Download URL: tree_sitter_xonsh-0.2.2.tar.gz
  • Upload date:
  • Size: 370.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for tree_sitter_xonsh-0.2.2.tar.gz
Algorithm Hash digest
SHA256 8278b2ef34f2c0ff02ca6b7574319f5dc0e989a3026ba0b9e81ee7a6402e4a05
MD5 6b81d54b530cd1c67cce946c19c8a881
BLAKE2b-256 f8e9f6e89a10ab3fbf6fac3d5f8413dbaefe7d5c60a2d1dbd24889a12fc4d7bf

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_xonsh-0.2.2.tar.gz:

Publisher: release.yml on FoamScience/tree-sitter-xonsh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_xonsh-0.2.2-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_xonsh-0.2.2-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 8fb918a16a4c293d984a669e2ab9659c01671f6608b60f25243a037474f58d65
MD5 8957ebb5b64724dfa3300b02a7860906
BLAKE2b-256 fabc93ecb6ce36cb90fb8662ef6d9ade2965bcfe9811b1f87cfa270f4421f4fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_xonsh-0.2.2-cp38-abi3-win_amd64.whl:

Publisher: release.yml on FoamScience/tree-sitter-xonsh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_xonsh-0.2.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_xonsh-0.2.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f6cf6071438a8a89f84daf9338f4727a6fe4aeed8b069e6c985a367d17328547
MD5 bd710395dd1c905cec4b15fe82c168ee
BLAKE2b-256 ebbca047107d47e5cd120f7f9ab0951911fdb56eb4fccd9c4dc86c92b4652fe0

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_xonsh-0.2.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on FoamScience/tree-sitter-xonsh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_xonsh-0.2.2-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_xonsh-0.2.2-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9bfb343e0e1c8fffebba25e5ac8a134b31269d03ff4910fcd6f7c587975711ca
MD5 16c5a63d5ab4cad79a57a2f3a7e9561f
BLAKE2b-256 3219c7e1bd4f9db4234677e4d61bda065021dc036e472eee7b3ac91937680aab

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_xonsh-0.2.2-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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_xonsh-0.2.2-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_xonsh-0.2.2-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b986ae3b65f666041f6f3a2828712a358b516c873953cf128743302efe625619
MD5 b4234aeda7b3be48f20c0272311d79f2
BLAKE2b-256 026fa22bc6acc741ca20e0a02b5eddecd0eaf6afc7a2915b4e1e21e317b2cd83

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_xonsh-0.2.2-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on FoamScience/tree-sitter-xonsh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tree_sitter_xonsh-0.2.2-cp38-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_xonsh-0.2.2-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 546a3a39428007e2a0958f752c2df52e7d453b8099b9a0809291758cb559ba55
MD5 e976edb07a75ef36a26e74048432f70c
BLAKE2b-256 09770094797cd36f0eac704bbbbedd45761c35a390aa3a309c5c3182930b29da

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_xonsh-0.2.2-cp38-abi3-macosx_10_9_x86_64.whl:

Publisher: release.yml on FoamScience/tree-sitter-xonsh

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.2 This release

6 files

0.2.1

6 files

0.2.0

6 files

0.1.7

6 files

0.1.6

6 files

0.1.5

6 files

0.1.4

6 files

0.1.3

6 files

0.1.2

6 files

0.1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page