@willbooster/tree-sitter-bash 4.0.0 → 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
@@ -68,8 +68,17 @@ The package also ships the queries in `queries/` and the node types in `src/node
68
68
 
69
69
  When upgrading from 3.x, upgrade `@willbooster/web-tree-sitter` to 2.x in the same change: each major of this package
70
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. Recovery trees for malformed scripts can differ from every earlier major, so review consumers that depend on
72
- the exact shape of `ERROR` nodes.
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.
73
82
 
74
83
  ## Development
75
84
 
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": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Bash grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
package/tree-sitter.json CHANGED
@@ -18,7 +18,7 @@
18
18
  }
19
19
  ],
20
20
  "metadata": {
21
- "version": "4.0.0",
21
+ "version": "4.0.1",
22
22
  "license": "MIT",
23
23
  "description": "Bash grammar for tree-sitter",
24
24
  "authors": [