github georgeharker/tree-sitter-zsh v0.64.0-dev.1
v0.64.0-dev.1 (prerelease)

pre-release21 minutes ago

Prerelease for testing. Not published to npm, crates.io or PyPI.

A large round of parsing improvements. Measured on 2,793 real-world zsh files (zsh's own functions, ohmyzsh, prezto, zsh-completions, zinit, powerlevel10k and others), compared with v0.63.5:

v0.63.5 0.64.0-dev.1
files that parse without errors 2,129 2,683
ERROR / MISSING nodes 25,067 7,813
files that ran out of memory 17 0

Highlights

  • zsh's short if form: if [[ … ]] { … } elif (( … )) { … } else { … }, and while/until with a { } body.
  • Modifiers outside braces now parse as modifiers ($x:h, $x:t:r, $f:s/a/b/, $w:gs/a/A/:gs/b/B/), plus :f, :F:n: and :s with any delimiter (${n:r:fs#/#::#}).
  • A $ that starts no expansion is literal ("%B$%b", echo $;, ${b//$}).
  • Function names with colons (zinit::setup(), :helper()); anonymous function { … }.
  • Several assignments on one line no longer swallow the next line; PATH=/sbin:$PATH and similar values.
  • Case patterns starting with a string, quotes between pattern pieces, glob groups with empty alternatives, glob flags before expansions, balanced {…} inside words (find … {} + in a brace group), ${x//a/b/c} replacements containing /, and more.
  • The scanner's state is now consistent: incremental re-parses give the same tree as a fresh parse (now checked in CI), and the context stack no longer leaks.
  • The parse table is ~30% smaller (parser.c 50 MB → ~44 MB) despite the additions.

Tree changes that may affect queries

  • expansion_modifier holds whole tokens (:h, :s/) and, for :s, search / replace fields.
  • A literal $ is a word (or string_content in strings).
  • The short if's elif_clause / else_clause sit inside the preceding block's compound_statement.
  • _statement, _statement_or_comment and _primary_expression are no longer listed as supertypes (they are inlined; tree-sitter 0.27 ignores them).

Don't miss a new tree-sitter-zsh release

NewReleases is sending notifications on new releases.