@willbooster/tree-sitter-bash 2.1.4 → 2.1.5
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 +2 -2
- package/grammar.js +37 -20
- package/package.json +8 -7
- package/tree-sitter-bash.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@willbooster/tree-sitter-bash)
|
|
5
5
|
[](https://github.com/WillBooster/tree-sitter-bash/actions/workflows/test.yml)
|
|
6
6
|
[](https://github.com/semantic-release/semantic-release)
|
|
7
|
-
[](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
|
|
@@ -78,7 +78,7 @@ script/parse-examples
|
|
|
78
78
|
The scripts and tests generate, build, test, and parse with `script/tree-sitter`, the tree-sitter CLI of the
|
|
79
79
|
WillBooster/tree-sitter runtime version that `package.json` pins as `@willbooster/web-tree-sitter`, since the generator
|
|
80
80
|
and the runtime of upstream's CLI are not the ones this package ships with. Its first run downloads that CLI from the
|
|
81
|
-
runtime's GitHub Release, or builds it with `cargo` (
|
|
81
|
+
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
|
|
82
82
|
binary that runs here. Run other CLI commands through it as well (e.g. `script/tree-sitter parse script.sh`).
|
|
83
83
|
|
|
84
84
|
`bun run test` runs:
|
package/grammar.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* @license MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
/// <reference types="tree-sitter-cli/dsl" />
|
|
7
|
+
// @ts-check
|
|
8
|
+
|
|
6
9
|
// Characters that end an unquoted word part: metacharacters, quotes, and characters that begin an
|
|
7
10
|
// expansion. `#` only starts a comment at the beginning of a word, so it is handled separately. Like
|
|
8
11
|
// bash, only a space, a tab, and a newline separate words; any other whitespace (CR, a no-break space)
|
|
@@ -137,6 +140,8 @@ module.exports = grammar({
|
|
|
137
140
|
$._closer_line_raw_string_content,
|
|
138
141
|
$._closer_line_ansi_c_string_content,
|
|
139
142
|
$._joined_comment,
|
|
143
|
+
$._backtick_comment,
|
|
144
|
+
$._backtick_comment_boundary,
|
|
140
145
|
$.__error_recovery,
|
|
141
146
|
],
|
|
142
147
|
|
|
@@ -154,8 +159,6 @@ module.exports = grammar({
|
|
|
154
159
|
rules: {
|
|
155
160
|
program: ($) => optional($._statements),
|
|
156
161
|
|
|
157
|
-
// Statements
|
|
158
|
-
|
|
159
162
|
_statements: ($) => seq(repeat(seq($._statement, $._terminator)), $._statement, optional($._terminator)),
|
|
160
163
|
|
|
161
164
|
_terminated_statements: ($) => repeat1(seq($._statement, $._terminator)),
|
|
@@ -221,15 +224,18 @@ module.exports = grammar({
|
|
|
221
224
|
seq(field('body', choice($._compound_command, $.function_definition)), repeat1(field('redirect', $._redirect)))
|
|
222
225
|
),
|
|
223
226
|
|
|
224
|
-
// Simple commands
|
|
225
|
-
|
|
226
227
|
command: ($) =>
|
|
227
228
|
prec.left(
|
|
228
229
|
choice(
|
|
229
230
|
seq(
|
|
230
231
|
repeat($._command_prefix),
|
|
231
232
|
field('name', $.command_name),
|
|
232
|
-
repeat(
|
|
233
|
+
repeat(
|
|
234
|
+
seq(
|
|
235
|
+
optional($._backtick_comment_boundary),
|
|
236
|
+
choice(field('argument', $._argument), field('redirect', $._redirect))
|
|
237
|
+
)
|
|
238
|
+
)
|
|
233
239
|
),
|
|
234
240
|
repeat1($._command_prefix)
|
|
235
241
|
)
|
|
@@ -237,14 +243,19 @@ module.exports = grammar({
|
|
|
237
243
|
|
|
238
244
|
_command_prefix: ($) => choice(field('assignment', $.variable_assignment), field('redirect', $._redirect)),
|
|
239
245
|
|
|
240
|
-
command_name: ($) => $._word,
|
|
246
|
+
command_name: ($) => seq(optional($._backtick_comment_boundary), $._word),
|
|
241
247
|
|
|
242
248
|
declaration_command: ($) =>
|
|
243
249
|
prec.left(
|
|
244
250
|
seq(
|
|
245
251
|
repeat($._command_prefix),
|
|
246
252
|
field('name', alias(choice('declare', 'typeset', 'export', 'readonly', 'local'), $.command_name)),
|
|
247
|
-
repeat(
|
|
253
|
+
repeat(
|
|
254
|
+
seq(
|
|
255
|
+
optional($._backtick_comment_boundary),
|
|
256
|
+
choice(field('argument', choice($.variable_assignment, $._argument)), field('redirect', $._redirect))
|
|
257
|
+
)
|
|
258
|
+
)
|
|
248
259
|
)
|
|
249
260
|
),
|
|
250
261
|
|
|
@@ -306,8 +317,6 @@ module.exports = grammar({
|
|
|
306
317
|
|
|
307
318
|
array: ($) => seq(token.immediate('('), repeat($._argument), ')'),
|
|
308
319
|
|
|
309
|
-
// Redirections
|
|
310
|
-
|
|
311
320
|
_redirect: ($) => choice($.file_redirect, $.heredoc_redirect, $.herestring_redirect),
|
|
312
321
|
|
|
313
322
|
file_redirect: ($) =>
|
|
@@ -343,8 +352,6 @@ module.exports = grammar({
|
|
|
343
352
|
$.heredoc_end
|
|
344
353
|
),
|
|
345
354
|
|
|
346
|
-
// Compound commands
|
|
347
|
-
|
|
348
355
|
compound_statement: ($) => seq('{', optional($._terminated_statements), '}'),
|
|
349
356
|
|
|
350
357
|
subshell: ($) => seq('(', optional($._statements), ')'),
|
|
@@ -437,7 +444,7 @@ module.exports = grammar({
|
|
|
437
444
|
field('body', $.do_group)
|
|
438
445
|
),
|
|
439
446
|
|
|
440
|
-
do_group: ($) => seq('do', optional($._terminated_statements), 'done'),
|
|
447
|
+
do_group: ($) => seq(optional($._backtick_comment_boundary), 'do', optional($._terminated_statements), 'done'),
|
|
441
448
|
|
|
442
449
|
for_statement: ($) =>
|
|
443
450
|
seq(
|
|
@@ -445,7 +452,14 @@ module.exports = grammar({
|
|
|
445
452
|
field('variable', alias($.word, $.variable_name)),
|
|
446
453
|
// Without a word list the separator is optional (`for i do …`); a newline may precede `in`.
|
|
447
454
|
choice(
|
|
448
|
-
seq(
|
|
455
|
+
seq(
|
|
456
|
+
optional($._newline),
|
|
457
|
+
optional($._backtick_comment_boundary),
|
|
458
|
+
'in',
|
|
459
|
+
repeat(seq(optional($._backtick_comment_boundary), field('value', $._argument))),
|
|
460
|
+
optional($._backtick_comment_boundary),
|
|
461
|
+
$._terminator
|
|
462
|
+
),
|
|
449
463
|
optional($._terminator)
|
|
450
464
|
),
|
|
451
465
|
field('body', choice($.do_group, $.compound_statement))
|
|
@@ -471,6 +485,7 @@ module.exports = grammar({
|
|
|
471
485
|
seq(
|
|
472
486
|
'case',
|
|
473
487
|
field('value', $._argument),
|
|
488
|
+
optional($._backtick_comment_boundary),
|
|
474
489
|
'in',
|
|
475
490
|
repeat($.case_item),
|
|
476
491
|
optional(alias($._last_case_item, $.case_item)),
|
|
@@ -484,16 +499,21 @@ module.exports = grammar({
|
|
|
484
499
|
_last_case_item: ($) => seq($._case_patterns, optional($._terminated_statements)),
|
|
485
500
|
|
|
486
501
|
_case_patterns: ($) =>
|
|
487
|
-
seq(
|
|
502
|
+
seq(
|
|
503
|
+
optional($._backtick_comment_boundary),
|
|
504
|
+
optional('('),
|
|
505
|
+
field('pattern', $._argument),
|
|
506
|
+
repeat(seq('|', field('pattern', $._argument))),
|
|
507
|
+
')'
|
|
508
|
+
),
|
|
488
509
|
|
|
489
510
|
function_definition: ($) =>
|
|
490
511
|
seq(
|
|
491
512
|
choice(seq('function', field('name', $.word), optional(seq('(', ')'))), seq(field('name', $.word), '(', ')')),
|
|
513
|
+
optional($._backtick_comment_boundary),
|
|
492
514
|
field('body', $._compound_command)
|
|
493
515
|
),
|
|
494
516
|
|
|
495
|
-
// Words
|
|
496
|
-
|
|
497
517
|
_word: ($) => choice($._word_part, $.concatenation),
|
|
498
518
|
|
|
499
519
|
// Outside command position a leading `!(` is a negated extglob group rather than `!` negating a
|
|
@@ -803,8 +823,6 @@ module.exports = grammar({
|
|
|
803
823
|
seq('$[', $._bracket_substitution_start, optional($._arithmetic_expression), $._bracket_substitution_end, ']')
|
|
804
824
|
),
|
|
805
825
|
|
|
806
|
-
// Arithmetic
|
|
807
|
-
|
|
808
826
|
_arithmetic_expression: ($) =>
|
|
809
827
|
choice(
|
|
810
828
|
$.number,
|
|
@@ -892,8 +910,7 @@ module.exports = grammar({
|
|
|
892
910
|
|
|
893
911
|
_arithmetic_parenthesized: ($) => seq('(', $._arithmetic_expression, ')'),
|
|
894
912
|
|
|
895
|
-
|
|
896
|
-
comment: ($) => choice(token(prec(-10, /#.*/)), $._joined_comment),
|
|
913
|
+
comment: ($) => choice(token(prec(-10, /#.*/)), $._joined_comment, $._backtick_comment),
|
|
897
914
|
},
|
|
898
915
|
});
|
|
899
916
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-bash",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"description": "Bash grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@tsconfig/bun": "1.0.11",
|
|
43
43
|
"@types/bun": "1.4.2",
|
|
44
|
-
"@vitest/browser-playwright": "5.0.
|
|
44
|
+
"@vitest/browser-playwright": "5.0.2",
|
|
45
45
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
46
46
|
"@willbooster/oxlint-config": "1.4.8",
|
|
47
|
-
"@willbooster/wb": "22.
|
|
48
|
-
"@willbooster/web-tree-sitter": "1.0.
|
|
47
|
+
"@willbooster/wb": "22.18.0",
|
|
48
|
+
"@willbooster/web-tree-sitter": "1.0.17",
|
|
49
49
|
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
50
50
|
"lefthook": "2.1.14",
|
|
51
51
|
"oxfmt": "0.70.0",
|
|
@@ -54,10 +54,11 @@
|
|
|
54
54
|
"playwright": "1.63.0",
|
|
55
55
|
"semantic-release": "25.0.9",
|
|
56
56
|
"sort-package-json": "4.0.0",
|
|
57
|
+
"tree-sitter-cli": "0.27.0",
|
|
57
58
|
"typescript": "7.0.2",
|
|
58
|
-
"vite": "8.3.
|
|
59
|
-
"vitest": "5.0.
|
|
60
|
-
"wrangler": "4.
|
|
59
|
+
"vite": "8.3.1",
|
|
60
|
+
"vitest": "5.0.2",
|
|
61
|
+
"wrangler": "4.141.0"
|
|
61
62
|
},
|
|
62
63
|
"peerDependencies": {
|
|
63
64
|
"@willbooster/web-tree-sitter": "^1.0.0"
|
package/tree-sitter-bash.wasm
CHANGED
|
Binary file
|