@willbooster/tree-sitter-bash 1.1.0 → 1.1.2
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 -0
- package/grammar.js +13 -11
- package/package.json +3 -3
- package/prebuilds/darwin-arm64/tree-sitter-bash.node +0 -0
- package/prebuilds/darwin-x64/tree-sitter-bash.node +0 -0
- package/prebuilds/linux-arm64/tree-sitter-bash.node +0 -0
- package/prebuilds/linux-x64/tree-sitter-bash.node +0 -0
- package/src/grammar.json +13 -13
- package/src/parser.c +7624 -7775
- package/src/scanner.c +131 -74
- package/tree-sitter-bash.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,8 @@ original grammar's.
|
|
|
18
18
|
consist of assignments and redirections only.
|
|
19
19
|
- `$((…))` is always an arithmetic expansion, including inside heredoc bodies; escaped `\$` and `` \` `` are literal.
|
|
20
20
|
- A newline is a statement terminator only where one may end a statement; elsewhere it is whitespace.
|
|
21
|
+
- Like bash, only a space, a tab, and a newline separate words. Any other whitespace is part of a word, including
|
|
22
|
+
the CR of a CRLF line ending, so a CRLF script parses as bash runs it (`echo a` + CRLF passes `a` + CR).
|
|
21
23
|
|
|
22
24
|
## Usage
|
|
23
25
|
|
package/grammar.js
CHANGED
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
// @ts-check
|
|
8
8
|
|
|
9
9
|
// Characters that end an unquoted word part: metacharacters, quotes, and characters that begin an
|
|
10
|
-
// expansion. `#` only starts a comment at the beginning of a word, so it is handled separately.
|
|
11
|
-
|
|
10
|
+
// expansion. `#` only starts a comment at the beginning of a word, so it is handled separately. Like
|
|
11
|
+
// bash, only a space, a tab, and a newline separate words; any other whitespace (CR, a no-break space)
|
|
12
|
+
// is part of a word.
|
|
13
|
+
const WORD_BREAKS = [' ', '\\t', '\\n', '|', '&', ';', '(', ')', '<', '>', '"', '\'', '`', '$', '\\\\'];
|
|
12
14
|
|
|
13
15
|
// Extglob groups nest (`@(a|+([0-9]))`); a regular expression expresses a fixed depth, and three levels
|
|
14
16
|
// cover every nested pattern in the example corpora.
|
|
@@ -81,8 +83,8 @@ module.exports = grammar({
|
|
|
81
83
|
extras: $ => [
|
|
82
84
|
$.comment,
|
|
83
85
|
$.heredoc_body,
|
|
84
|
-
|
|
85
|
-
/\\\
|
|
86
|
+
/[ \t\n]/,
|
|
87
|
+
/\\\n/,
|
|
86
88
|
$._line_continuation,
|
|
87
89
|
],
|
|
88
90
|
|
|
@@ -474,7 +476,7 @@ module.exports = grammar({
|
|
|
474
476
|
|
|
475
477
|
_negated_extglob_word: _ => token(prec(1, seq(
|
|
476
478
|
EXTGLOB_NEGATION,
|
|
477
|
-
repeat(choice(noneOf(...WORD_BREAKS), /\\[^\
|
|
479
|
+
repeat(choice(noneOf(...WORD_BREAKS), /\\[^\n]/, EXTGLOB_GROUP, EXTGLOB_NEGATION)),
|
|
478
480
|
))),
|
|
479
481
|
|
|
480
482
|
concatenation: $ => prec.right(seq(
|
|
@@ -506,8 +508,8 @@ module.exports = grammar({
|
|
|
506
508
|
// An extglob group (`@(a|b)`) is part of the word; `!(` only inside a word, since a leading `!`
|
|
507
509
|
// before `(` negates a subshell.
|
|
508
510
|
word: _ => token(seq(
|
|
509
|
-
choice(noneOf('#', ...WORD_BREAKS), /\\[^\
|
|
510
|
-
repeat(choice(noneOf(...WORD_BREAKS), /\\[^\
|
|
511
|
+
choice(noneOf('#', ...WORD_BREAKS), /\\[^\n]/, EXTGLOB_GROUP),
|
|
512
|
+
repeat(choice(noneOf(...WORD_BREAKS), /\\[^\n]/, EXTGLOB_GROUP, EXTGLOB_NEGATION)),
|
|
511
513
|
)),
|
|
512
514
|
|
|
513
515
|
// A `#` inside a word (`a$b#c`) is literal; only a `#` that begins a word starts a comment.
|
|
@@ -533,7 +535,7 @@ module.exports = grammar({
|
|
|
533
535
|
|
|
534
536
|
_hash_word: _ => token(prec(1, seq(
|
|
535
537
|
'#',
|
|
536
|
-
repeat(choice(noneOf(...WORD_BREAKS), /\\[^\
|
|
538
|
+
repeat(choice(noneOf(...WORD_BREAKS), /\\[^\n]/, EXTGLOB_GROUP, EXTGLOB_NEGATION)),
|
|
537
539
|
))),
|
|
538
540
|
|
|
539
541
|
string: $ => seq(
|
|
@@ -550,7 +552,7 @@ module.exports = grammar({
|
|
|
550
552
|
|
|
551
553
|
raw_string: _ => /'[^']*'/,
|
|
552
554
|
|
|
553
|
-
ansi_c_string: _ => /\$'([^'\\]|\\(.|\
|
|
555
|
+
ansi_c_string: _ => /\$'([^'\\]|\\(.|\n))*'/,
|
|
554
556
|
|
|
555
557
|
translated_string: $ => seq('$"', repeat(choice(
|
|
556
558
|
$.string_content,
|
|
@@ -633,7 +635,7 @@ module.exports = grammar({
|
|
|
633
635
|
))),
|
|
634
636
|
),
|
|
635
637
|
|
|
636
|
-
_expansion_text: _ => token(prec(-1, /([^}$`"'\\<>]|[<>]+[^(}$`"'\\<>]|\\(.|\
|
|
638
|
+
_expansion_text: _ => token(prec(-1, /([^}$`"'\\<>]|[<>]+[^(}$`"'\\<>]|\\(.|\n))+/)),
|
|
637
639
|
|
|
638
640
|
// A `<` or `>` that the text above cannot end with, e.g. before `}`. A single character, so that a
|
|
639
641
|
// run before `(` leaves its last `<`/`>` to open a process substitution (`${x:-a<<(b)}`).
|
|
@@ -645,7 +647,7 @@ module.exports = grammar({
|
|
|
645
647
|
seq('$(', $._substitution_start, optional($._statements), $._substitution_end, ')'),
|
|
646
648
|
// bash 5.3 runs `${ list; }` and `${| list; }` in the current shell.
|
|
647
649
|
seq(
|
|
648
|
-
alias(token(/\$\{[\
|
|
650
|
+
alias(token(/\$\{[ \t\n|]/), '${'),
|
|
649
651
|
$._brace_substitution_start,
|
|
650
652
|
optional($._terminated_statements),
|
|
651
653
|
$._brace_substitution_end,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-bash",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Bash grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@semantic-release/exec": "7.1.0",
|
|
54
|
-
"@willbooster/wb": "22.
|
|
55
|
-
"conventional-changelog-conventionalcommits": "
|
|
54
|
+
"@willbooster/wb": "22.8.0",
|
|
55
|
+
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
56
56
|
"lefthook": "2.1.14",
|
|
57
57
|
"node-gyp": "13.0.2",
|
|
58
58
|
"prebuildify": "^6.0.1",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/grammar.json
CHANGED
|
@@ -2467,11 +2467,11 @@
|
|
|
2467
2467
|
"members": [
|
|
2468
2468
|
{
|
|
2469
2469
|
"type": "PATTERN",
|
|
2470
|
-
"value": "[
|
|
2470
|
+
"value": "[^ \\t\\n|&;()<>\"'`$\\\\]"
|
|
2471
2471
|
},
|
|
2472
2472
|
{
|
|
2473
2473
|
"type": "PATTERN",
|
|
2474
|
-
"value": "\\\\[^\\
|
|
2474
|
+
"value": "\\\\[^\\n]"
|
|
2475
2475
|
},
|
|
2476
2476
|
{
|
|
2477
2477
|
"type": "PATTERN",
|
|
@@ -2617,11 +2617,11 @@
|
|
|
2617
2617
|
"members": [
|
|
2618
2618
|
{
|
|
2619
2619
|
"type": "PATTERN",
|
|
2620
|
-
"value": "[
|
|
2620
|
+
"value": "[^# \\t\\n|&;()<>\"'`$\\\\]"
|
|
2621
2621
|
},
|
|
2622
2622
|
{
|
|
2623
2623
|
"type": "PATTERN",
|
|
2624
|
-
"value": "\\\\[^\\
|
|
2624
|
+
"value": "\\\\[^\\n]"
|
|
2625
2625
|
},
|
|
2626
2626
|
{
|
|
2627
2627
|
"type": "PATTERN",
|
|
@@ -2636,11 +2636,11 @@
|
|
|
2636
2636
|
"members": [
|
|
2637
2637
|
{
|
|
2638
2638
|
"type": "PATTERN",
|
|
2639
|
-
"value": "[
|
|
2639
|
+
"value": "[^ \\t\\n|&;()<>\"'`$\\\\]"
|
|
2640
2640
|
},
|
|
2641
2641
|
{
|
|
2642
2642
|
"type": "PATTERN",
|
|
2643
|
-
"value": "\\\\[^\\
|
|
2643
|
+
"value": "\\\\[^\\n]"
|
|
2644
2644
|
},
|
|
2645
2645
|
{
|
|
2646
2646
|
"type": "PATTERN",
|
|
@@ -2818,11 +2818,11 @@
|
|
|
2818
2818
|
"members": [
|
|
2819
2819
|
{
|
|
2820
2820
|
"type": "PATTERN",
|
|
2821
|
-
"value": "[
|
|
2821
|
+
"value": "[^ \\t\\n|&;()<>\"'`$\\\\]"
|
|
2822
2822
|
},
|
|
2823
2823
|
{
|
|
2824
2824
|
"type": "PATTERN",
|
|
2825
|
-
"value": "\\\\[^\\
|
|
2825
|
+
"value": "\\\\[^\\n]"
|
|
2826
2826
|
},
|
|
2827
2827
|
{
|
|
2828
2828
|
"type": "PATTERN",
|
|
@@ -2886,7 +2886,7 @@
|
|
|
2886
2886
|
},
|
|
2887
2887
|
"ansi_c_string": {
|
|
2888
2888
|
"type": "PATTERN",
|
|
2889
|
-
"value": "\\$'([^'\\\\]|\\\\(.|\\
|
|
2889
|
+
"value": "\\$'([^'\\\\]|\\\\(.|\\n))*'"
|
|
2890
2890
|
},
|
|
2891
2891
|
"translated_string": {
|
|
2892
2892
|
"type": "SEQ",
|
|
@@ -3471,7 +3471,7 @@
|
|
|
3471
3471
|
"value": -1,
|
|
3472
3472
|
"content": {
|
|
3473
3473
|
"type": "PATTERN",
|
|
3474
|
-
"value": "([^}$`\"'\\\\<>]|[<>]+[^(}$`\"'\\\\<>]|\\\\(.|\\
|
|
3474
|
+
"value": "([^}$`\"'\\\\<>]|[<>]+[^(}$`\"'\\\\<>]|\\\\(.|\\n))+"
|
|
3475
3475
|
}
|
|
3476
3476
|
}
|
|
3477
3477
|
},
|
|
@@ -3531,7 +3531,7 @@
|
|
|
3531
3531
|
"type": "TOKEN",
|
|
3532
3532
|
"content": {
|
|
3533
3533
|
"type": "PATTERN",
|
|
3534
|
-
"value": "\\$\\{[\\
|
|
3534
|
+
"value": "\\$\\{[ \\t\\n|]"
|
|
3535
3535
|
}
|
|
3536
3536
|
},
|
|
3537
3537
|
"named": false,
|
|
@@ -4601,11 +4601,11 @@
|
|
|
4601
4601
|
},
|
|
4602
4602
|
{
|
|
4603
4603
|
"type": "PATTERN",
|
|
4604
|
-
"value": "\\
|
|
4604
|
+
"value": "[ \\t\\n]"
|
|
4605
4605
|
},
|
|
4606
4606
|
{
|
|
4607
4607
|
"type": "PATTERN",
|
|
4608
|
-
"value": "\\\\\\
|
|
4608
|
+
"value": "\\\\\\n"
|
|
4609
4609
|
},
|
|
4610
4610
|
{
|
|
4611
4611
|
"type": "SYMBOL",
|