@willbooster/tree-sitter-bash 1.0.1 → 1.0.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 +17 -4
- package/grammar.js +8 -2
- 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 +7 -2
- package/src/parser.c +109530 -134537
- package/src/scanner.c +121 -16
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -35,14 +35,27 @@ const tree = parser.parse('cat <<EOF; echo done\n$(date)\nEOF\n');
|
|
|
35
35
|
```sh
|
|
36
36
|
mise install
|
|
37
37
|
bun install --frozen-lockfile
|
|
38
|
-
bun run
|
|
38
|
+
bun run build/ci
|
|
39
39
|
bun run test
|
|
40
40
|
script/parse-examples
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
`
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
`bun run test` runs:
|
|
44
|
+
|
|
45
|
+
- the corpus in `test/corpus`;
|
|
46
|
+
- the Node.js binding test;
|
|
47
|
+
- a check that real-world scripts cloned into `examples/` fail to parse exactly as listed in
|
|
48
|
+
`script/known-failures.txt`. The first run clones them, which takes a few minutes. The example repositories are
|
|
49
|
+
pinned to commits in `script/parse-examples`. After a grammar change or a moved pin alters that list,
|
|
50
|
+
`script/parse-examples` rewrites it; review its diff before committing;
|
|
51
|
+
- a differential test (`test/unit/differential.test.ts`, with helpers in `test/helpers/differential`) that generates
|
|
52
|
+
scripts and runs them with the bash that `mise.toml` pins. It checks that the syntax tree shows exactly the commands
|
|
53
|
+
bash runs, with as many words and the same value for each word without expansions, and that the tree has no
|
|
54
|
+
`ERROR` or `MISSING` node for a script bash accepts. A failure prints the seed; `DIFFERENTIAL_SEED` and
|
|
55
|
+
`DIFFERENTIAL_CASES` run other or more scripts. It loads the Node.js addon, which `bun run build/ci` rebuilds after
|
|
56
|
+
regenerating the parser;
|
|
57
|
+
- a performance check (`test/unit/performance.test.ts`) that a 240 KB line parses in linear time, since consumers
|
|
58
|
+
parse untrusted scripts.
|
|
46
59
|
|
|
47
60
|
### References
|
|
48
61
|
|
package/grammar.js
CHANGED
|
@@ -96,6 +96,11 @@ module.exports = grammar({
|
|
|
96
96
|
$._command_statement,
|
|
97
97
|
],
|
|
98
98
|
|
|
99
|
+
// Until `;;` or `esac`, a case item's statements may belong to a middle item or to the last one.
|
|
100
|
+
conflicts: $ => [
|
|
101
|
+
[$._statements, $._last_case_item],
|
|
102
|
+
],
|
|
103
|
+
|
|
99
104
|
word: $ => $.word,
|
|
100
105
|
|
|
101
106
|
rules: {
|
|
@@ -425,8 +430,9 @@ module.exports = grammar({
|
|
|
425
430
|
field('terminator', choice(';;', ';&', ';;&')),
|
|
426
431
|
),
|
|
427
432
|
|
|
428
|
-
// Only the last item may omit its terminator
|
|
429
|
-
|
|
433
|
+
// Only the last item may omit its terminator, but its statements still end before `esac`, which is
|
|
434
|
+
// otherwise an argument (`a) echo esac`).
|
|
435
|
+
_last_case_item: $ => seq($._case_patterns, optional($._terminated_statements)),
|
|
430
436
|
|
|
431
437
|
_case_patterns: $ => seq(
|
|
432
438
|
optional('('),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-bash",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Bash grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build-prebuilds": "prebuildify --napi --strip --name tree-sitter-bash",
|
|
31
|
-
"build/ci": "tree-sitter generate",
|
|
31
|
+
"build/ci": "tree-sitter generate && node-gyp rebuild",
|
|
32
32
|
"cleanup": "bun wb lint --fix --format",
|
|
33
33
|
"format": "bun wb lint --format",
|
|
34
34
|
"install": "node-gyp-build",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"release-test": "node node_modules/semantic-release/bin/semantic-release.js --dry-run --plugins @semantic-release/commit-analyzer @semantic-release/release-notes-generator",
|
|
40
40
|
"prestart": "tree-sitter build --wasm",
|
|
41
41
|
"start": "tree-sitter playground",
|
|
42
|
-
"test": "
|
|
42
|
+
"test": "bun wb test",
|
|
43
43
|
"test/ci": "bun wb test-on-ci",
|
|
44
44
|
"verify": "bun wb verify",
|
|
45
45
|
"verify-full": "bun wb verify --full"
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/grammar.json
CHANGED
|
@@ -2193,7 +2193,7 @@
|
|
|
2193
2193
|
"members": [
|
|
2194
2194
|
{
|
|
2195
2195
|
"type": "SYMBOL",
|
|
2196
|
-
"name": "
|
|
2196
|
+
"name": "_terminated_statements"
|
|
2197
2197
|
},
|
|
2198
2198
|
{
|
|
2199
2199
|
"type": "BLANK"
|
|
@@ -4612,7 +4612,12 @@
|
|
|
4612
4612
|
"name": "_line_continuation"
|
|
4613
4613
|
}
|
|
4614
4614
|
],
|
|
4615
|
-
"conflicts": [
|
|
4615
|
+
"conflicts": [
|
|
4616
|
+
[
|
|
4617
|
+
"_statements",
|
|
4618
|
+
"_last_case_item"
|
|
4619
|
+
]
|
|
4620
|
+
],
|
|
4616
4621
|
"precedences": [],
|
|
4617
4622
|
"externals": [
|
|
4618
4623
|
{
|