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.1.tar.gz (344.8 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.1-cp38-abi3-win_amd64.whl (135.1 kB view details)

Uploaded CPython 3.8+Windows x86-64

tree_sitter_xonsh-0.2.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (184.0 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ ARM64

tree_sitter_xonsh-0.2.1-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (172.1 kB view details)

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

tree_sitter_xonsh-0.2.1-cp38-abi3-macosx_11_0_arm64.whl (142.8 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

tree_sitter_xonsh-0.2.1-cp38-abi3-macosx_10_9_x86_64.whl (131.8 kB view details)

Uploaded CPython 3.8+macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: tree_sitter_xonsh-0.2.1.tar.gz
  • Upload date:
  • Size: 344.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tree_sitter_xonsh-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c79b9ad608acb8614218280bba17d6f4351ac0319830abfa673aa9ed7047363e
MD5 92280c1bb3057a14bafbb318c5f291fa
BLAKE2b-256 0caaae3886c8c9674c581660f05be389c0974e0d62be9db9c55181ab4ac3c6c6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for tree_sitter_xonsh-0.2.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 689e8c32d1ca618318fc4f86c220c9935e5c502a085685d2bec334685a43afbb
MD5 150225ff4198877a8e35a020361cfe3e
BLAKE2b-256 25809be8a4283c9ffed50298d15bc678a131c5fa6b8a4b2635cf600d5ab18100

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_xonsh-0.2.1-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.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tree_sitter_xonsh-0.2.1-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4144b004395097ab74337eb2538da06ed70e28b70371ec82b766e4fe5e45b809
MD5 a42a4db14ac2d7b5efae4dffa409a66e
BLAKE2b-256 f31a8907e2c3a0bbfae4b4e6e9a1e40d458ee7b94747720dd87a24f02634a2af

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_xonsh-0.2.1-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.1-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.1-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 80a71b4da8acf25768e72fb727f89cddb37e19eb580a35cffcb97b8f8cdc0693
MD5 f5e86684b36d708325b72b2187474ed7
BLAKE2b-256 6ce18d97951026d1277e84a17c7b580f51ab22cc80300e14d67b8069ec31b19b

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_xonsh-0.2.1-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.1-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tree_sitter_xonsh-0.2.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3404e27602107049e3170529dc8e91d1022fccdff5d472fea9405fb8f73455b7
MD5 cd16d95536e682ec9477f0e8a4f97c5d
BLAKE2b-256 cb0471d353273045fbe6cebe498d99a968fe56962e9621e7284e12f684b82788

See more details on using hashes here.

Provenance

The following attestation bundles were made for tree_sitter_xonsh-0.2.1-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.1-cp38-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tree_sitter_xonsh-0.2.1-cp38-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 403a53b8943cc8e4af14a9fd83f972a6590440e740dbd8ee3d96574fcd1dc28a
MD5 ce9b80e41e49d929d834c95cb74832c5
BLAKE2b-256 1c1cefdf6ecfb3982230a3988b9936ea96fcf42d583461a377beafb5669261da

See more details on using hashes here.

Provenance

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