@willbooster/tree-sitter-bash 1.1.1 → 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 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
- const WORD_BREAKS = ['\\s', '|', '&', ';', '(', ')', '<', '>', '"', '\'', '`', '$', '\\\\'];
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,7 +83,7 @@ module.exports = grammar({
81
83
  extras: $ => [
82
84
  $.comment,
83
85
  $.heredoc_body,
84
- /\s/,
86
+ /[ \t\n]/,
85
87
  /\\\n/,
86
88
  $._line_continuation,
87
89
  ],
@@ -550,7 +552,7 @@ module.exports = grammar({
550
552
 
551
553
  raw_string: _ => /'[^']*'/,
552
554
 
553
- ansi_c_string: _ => /\$'([^'\\]|\\(.|\r?\n))*'/,
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, /([^}$`"'\\<>]|[<>]+[^(}$`"'\\<>]|\\(.|\r?\n))+/)),
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(/\$\{[\s|]/), '${'),
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.1",
3
+ "version": "1.1.2",
4
4
  "description": "Bash grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -52,7 +52,7 @@
52
52
  "devDependencies": {
53
53
  "@semantic-release/exec": "7.1.0",
54
54
  "@willbooster/wb": "22.8.0",
55
- "conventional-changelog-conventionalcommits": "9.3.1",
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",
package/src/grammar.json CHANGED
@@ -2467,7 +2467,7 @@
2467
2467
  "members": [
2468
2468
  {
2469
2469
  "type": "PATTERN",
2470
- "value": "[^\\s|&;()<>\"'`$\\\\]"
2470
+ "value": "[^ \\t\\n|&;()<>\"'`$\\\\]"
2471
2471
  },
2472
2472
  {
2473
2473
  "type": "PATTERN",
@@ -2617,7 +2617,7 @@
2617
2617
  "members": [
2618
2618
  {
2619
2619
  "type": "PATTERN",
2620
- "value": "[^#\\s|&;()<>\"'`$\\\\]"
2620
+ "value": "[^# \\t\\n|&;()<>\"'`$\\\\]"
2621
2621
  },
2622
2622
  {
2623
2623
  "type": "PATTERN",
@@ -2636,7 +2636,7 @@
2636
2636
  "members": [
2637
2637
  {
2638
2638
  "type": "PATTERN",
2639
- "value": "[^\\s|&;()<>\"'`$\\\\]"
2639
+ "value": "[^ \\t\\n|&;()<>\"'`$\\\\]"
2640
2640
  },
2641
2641
  {
2642
2642
  "type": "PATTERN",
@@ -2818,7 +2818,7 @@
2818
2818
  "members": [
2819
2819
  {
2820
2820
  "type": "PATTERN",
2821
- "value": "[^\\s|&;()<>\"'`$\\\\]"
2821
+ "value": "[^ \\t\\n|&;()<>\"'`$\\\\]"
2822
2822
  },
2823
2823
  {
2824
2824
  "type": "PATTERN",
@@ -2886,7 +2886,7 @@
2886
2886
  },
2887
2887
  "ansi_c_string": {
2888
2888
  "type": "PATTERN",
2889
- "value": "\\$'([^'\\\\]|\\\\(.|\\r?\\n))*'"
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": "([^}$`\"'\\\\<>]|[<>]+[^(}$`\"'\\\\<>]|\\\\(.|\\r?\\n))+"
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": "\\$\\{[\\s|]"
3534
+ "value": "\\$\\{[ \\t\\n|]"
3535
3535
  }
3536
3536
  },
3537
3537
  "named": false,
@@ -4601,7 +4601,7 @@
4601
4601
  },
4602
4602
  {
4603
4603
  "type": "PATTERN",
4604
- "value": "\\s"
4604
+ "value": "[ \\t\\n]"
4605
4605
  },
4606
4606
  {
4607
4607
  "type": "PATTERN",