Skip to main content

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

  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

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

tree_sitter_xonsh-0.2.0.tar.gz (345.0 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.0-cp38-abi3-win_amd64.whl (135.3 kB view details)

Uploaded CPython 3.8+Windows x86-64

tree_sitter_xonsh-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (184.3 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

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 (173.3 kB view details)

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

tree_sitter_xonsh-0.2.0-cp38-abi3-macosx_11_0_arm64.whl (142.7 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

tree_sitter_xonsh-0.2.0-cp38-abi3-macosx_10_9_x86_64.whl (131.7 kB view details)

Uploaded CPython 3.8+macOS 10.9+ x86-64

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

Hashes for tree_sitter_xonsh-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a833ac315a15e8a7f549d75a5375a1ed9b71d80a27a7cf890a73a1c0220468c0
MD5 f80edf053d18392e25d1639e0dfac664
BLAKE2b-256 844997af23fa99c22ed6d2d405edfae26a5c3586810be513f339127a76a9c89c

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_xonsh-0.2.0.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.0-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for tree_sitter_xonsh-0.2.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b3eff7325434c12d46ae4b61dbcb3b381cbdabd258032215de728289cdb6e03b
MD5 d2a9539ff5efb38d9cdf2ef502d46f18
BLAKE2b-256 af5a1bfff3fe63ec543ba4bd39705994015fd44408380594a1f3b97abcf1137d

See more details on using hashes here.

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

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.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_xonsh-0.2.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ff7abbfa8e48490817afcd7126c166a3fab57f54da1c46bb1236f8b7fa228e47
MD5 76bb061360f90a93d45f25da6e328529
BLAKE2b-256 4acb30359ba88cdc2f9dc5da898e72c44c7f1e83a3fbee95d63c8726b6bf98ae

See more details on using hashes here.

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

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.0-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.0-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 458ba10cc090bb86c65a0dacce935c24deae4e32e3713356d87ac5e4805e4e7f
MD5 c63d686dbaa2b35648c6186c4c8d978e
BLAKE2b-256 eeed5c5a6c49a668bcf93c8937c84a55b7f41bb3906f4268aaf551c65d29592b

See more details on using hashes here.

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

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.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_xonsh-0.2.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7e2ad92fec25bce338d5f3a986f1ad9b29a4a96a8dfb76b583e68ee63d99ad48
MD5 9f3d8ae4084e83c02b02795265e76642
BLAKE2b-256 8fba527a7e22d6263ffe74f1b4ae93cde5a5dd65ae833c9d6a45d270d8dcb45c

See more details on using hashes here.

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

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.0-cp38-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_xonsh-0.2.0-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1aed49e7eec3f191cede7f99071ccdce0c22d74c4f4de325799f883667c4e23b
MD5 08b5a493677b89e7a87ae6c3faf055bf
BLAKE2b-256 30c8539b42bffe1b244d054232e24d6cc76a6db274dd82d12b57da0bd3885f7c

See more details on using hashes here.

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

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page