@willbooster/tree-sitter-bash 3.0.7 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  [![license](https://img.shields.io/npm/l/@willbooster/tree-sitter-bash.svg)](https://www.npmjs.com/package/@willbooster/tree-sitter-bash)
5
5
  [![Test](https://github.com/WillBooster/tree-sitter-bash/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-bash/actions/workflows/test.yml)
6
6
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
7
- [![wbfy](https://img.shields.io/badge/wbfy-20.28.8-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
7
+ [![wbfy](https://img.shields.io/badge/wbfy-20.36.11-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
8
 
9
9
  Bash grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
10
10
  [tree-sitter/tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash). We are grateful to its authors and
@@ -17,7 +17,9 @@ As a result, its syntax trees differ from the original grammar's; review your qu
17
17
  ## Usage
18
18
 
19
19
  The npm package ships `tree-sitter-bash.wasm` for
20
- [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) 1.4.2 or later, a peer dependency:
20
+ [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) 2.0.0 or later, a peer dependency.
21
+ The parser carries the ABI number of WillBooster/tree-sitter (`0x57420001`), so only that runtime loads it; the
22
+ original tree-sitter runtime rejects it, and so does `@willbooster/web-tree-sitter` 1.x:
21
23
 
22
24
  ```sh
23
25
  npm install @willbooster/tree-sitter-bash @willbooster/web-tree-sitter
@@ -64,9 +66,19 @@ parser.setLanguage(await Language.load(bash));
64
66
 
65
67
  The package also ships the queries in `queries/` and the node types in `src/node-types.json`.
66
68
 
67
- The ABI 16 major release can change recovery trees for malformed scripts. Valid syntax and completed constructs
68
- remain supported, and incremental parses must match fresh parses. Review consumers that depend on the exact shape
69
- of `ERROR` nodes when upgrading.
69
+ When upgrading from 3.x, upgrade `@willbooster/web-tree-sitter` to 2.x in the same change: each major of this package
70
+ loads only with the runtime major it was generated for. Scripts that parse without errors get the same syntax trees as
71
+ with 3.x, except where backslashes inside backquotes precede `$` (or `"` when the backquotes are inside double quotes):
72
+ like bash, the parser removes one level of those backslashes before it parses the text, so `` `echo \$x` `` holds an
73
+ expansion and `` `echo \\$x` `` a literal `$x`. Recovery trees for malformed scripts can differ from every earlier
74
+ major, so review consumers that depend on the exact shape of `ERROR` nodes.
75
+
76
+ Inside backquotes, the text of a node is the source text: consumers that read the value of a word or a string there
77
+ remove a backslash before `$`, a backquote, or a backslash (and before `"` when the backquotes are inside double quotes)
78
+ before they remove quotes and escapes as usual. The parser normalizes runs before `$`, and before `"` when the
79
+ backquotes opened inside double quotes, only in ordinary word and double-quoted string scanning. Runs before other
80
+ characters (including whitespace and metacharacters), heredoc bodies, parameter-expansion text, regexes, nested
81
+ backquotes, and PID expansions split by a removed escape retain their existing parsing limitations.
70
82
 
71
83
  ## Development
72
84
 
@@ -85,7 +97,7 @@ and the runtime of upstream's CLI are not the ones this package ships with. Its
85
97
  runtime's GitHub Release, or builds it with `cargo` (whose build runs the CMake that `mise.toml` pins) when the download fails or the release has no
86
98
  binary that runs here. Run other CLI commands through it as well (e.g. `script/tree-sitter parse script.sh`).
87
99
 
88
- `bun run generate` records a fresh ABI 16 generation profile from the applicable `test/corpus` cases and Git-tracked
100
+ `bun run generate` records a fresh generation profile from the applicable `test/corpus` cases and Git-tracked
89
101
  files in `examples/`, then generates compact parser tables. The parser also embeds metadata from `tree-sitter.json`. After changing a grammar,
90
102
  `tree-sitter.json`, a corpus case, or a tracked example,
91
103
  regenerate and commit `src/`. Stage added or removed examples with `git add -A examples` before generation so the profile uses the intended file list.
package/grammar.js CHANGED
@@ -149,9 +149,21 @@ module.exports = grammar({
149
149
  $._timing_keyword,
150
150
  $._timing_option,
151
151
  $._timing_terminator,
152
+ $._backquote_escape,
152
153
  ],
153
154
 
154
- extras: ($) => [$.comment, $.heredoc_body, /[ \t\n]/, /\\\n/, $._line_continuation, $._arithmetic_cache_reset],
155
+ // Bash removes the backslash before `$` (and before `"` where the backquotes are inside double quotes)
156
+ // when it reads the text of backquotes, so the scanner returns that backslash on its own and what
157
+ // follows it is parsed as an expansion or a quote.
158
+ extras: ($) => [
159
+ $.comment,
160
+ $.heredoc_body,
161
+ /[ \t\n]/,
162
+ /\\\n/,
163
+ $._line_continuation,
164
+ $._arithmetic_cache_reset,
165
+ $._backquote_escape,
166
+ ],
155
167
 
156
168
  supertypes: ($) => [$._statement, $._arithmetic_expression],
157
169
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-bash",
3
- "version": "3.0.7",
3
+ "version": "4.0.1",
4
4
  "description": "Bash grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -45,8 +45,8 @@
45
45
  "@vitest/browser-playwright": "5.0.3",
46
46
  "@willbooster/oxfmt-config": "1.2.2",
47
47
  "@willbooster/oxlint-config": "1.4.8",
48
- "@willbooster/wb": "22.23.1",
49
- "@willbooster/web-tree-sitter": "1.4.8",
48
+ "@willbooster/wb": "22.24.0",
49
+ "@willbooster/web-tree-sitter": "2.0.1",
50
50
  "conventional-changelog-conventionalcommits": "10.4.0",
51
51
  "lefthook": "2.1.16",
52
52
  "oxfmt": "0.71.0",
@@ -62,7 +62,7 @@
62
62
  "wrangler": "4.147.0"
63
63
  },
64
64
  "peerDependencies": {
65
- "@willbooster/web-tree-sitter": "^1.4.2"
65
+ "@willbooster/web-tree-sitter": "^2.0.0"
66
66
  },
67
67
  "peerDependenciesMeta": {
68
68
  "@willbooster/web-tree-sitter": {
Binary file
package/tree-sitter.json CHANGED
@@ -18,7 +18,7 @@
18
18
  }
19
19
  ],
20
20
  "metadata": {
21
- "version": "3.0.7",
21
+ "version": "4.0.1",
22
22
  "license": "MIT",
23
23
  "description": "Bash grammar for tree-sitter",
24
24
  "authors": [