@willbooster/tree-sitter-ruby 2.0.2 → 2.0.3
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 +7 -4
- package/grammar.js +14 -8
- package/package.json +3 -3
- package/src/node-types.json +11 -9
- package/tree-sitter-ruby.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,8 @@ to its authors and contributors. This is not an official release of that project
|
|
|
15
15
|
This fork ships upstream's grammar with a parser generated by
|
|
16
16
|
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter), whose compact parse tables make the
|
|
17
17
|
parser smaller. The parser carries that fork's own ABI number (`0x57420001`), so it loads only with the WillBooster
|
|
18
|
-
runtime
|
|
18
|
+
runtime; upstream's tree-sitter runtime rejects it. Use runtime 2.0.18 or later so contiguous included ranges do not terminate comments.
|
|
19
|
+
The scanner preserves long heredoc identifiers
|
|
19
20
|
when their state fits the runtime's serialization buffer. If the open heredocs cannot fit, their bodies are parsed as
|
|
20
21
|
code instead of aborting the process.
|
|
21
22
|
|
|
@@ -23,7 +24,7 @@ code instead of aborting the process.
|
|
|
23
24
|
|
|
24
25
|
The npm package ships `tree-sitter-ruby.wasm` for
|
|
25
26
|
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter), which runs in Node.js, Bun,
|
|
26
|
-
browsers, and Cloudflare Workers. The parser requires runtime 2.0.
|
|
27
|
+
browsers, and Cloudflare Workers. The parser requires runtime 2.0.18 or later.
|
|
27
28
|
|
|
28
29
|
In Node.js and Bun, load the grammar from its path:
|
|
29
30
|
|
|
@@ -66,11 +67,11 @@ The package also ships the queries in `queries/` and the node types in `src/node
|
|
|
66
67
|
|
|
67
68
|
In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-ruby) and on
|
|
68
69
|
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
|
|
69
|
-
fuzzed with. The parser requires runtime 2.0.
|
|
70
|
+
fuzzed with. The parser requires runtime 2.0.18 or later:
|
|
70
71
|
|
|
71
72
|
```toml
|
|
72
73
|
[dependencies]
|
|
73
|
-
tree-sitter = { package = "willbooster-tree-sitter", version = "2.0.
|
|
74
|
+
tree-sitter = { package = "willbooster-tree-sitter", version = "2.0.18" }
|
|
74
75
|
tree-sitter-ruby = { package = "willbooster-tree-sitter-ruby", version = "2" }
|
|
75
76
|
```
|
|
76
77
|
|
|
@@ -109,6 +110,8 @@ Profiles in `.tmp/generation-profiles/` are temporary and must not be committed.
|
|
|
109
110
|
- an incremental-parsing check (`test/unit/incremental.test.ts`): `script/fuzz-corpus` runs `tree-sitter fuzz`, which
|
|
110
111
|
edits each corpus case at random, reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`,
|
|
111
112
|
`TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits;
|
|
113
|
+
- included-range comment and incremental-edit checks (`test/unit/includedRanges.test.ts`), which load the Wasm build
|
|
114
|
+
produced by `bun run build/ci`;
|
|
112
115
|
- a check that the real-world Ruby files of [ruby/spec](https://github.com/ruby/spec) cloned into `examples/` fail to
|
|
113
116
|
parse exactly as listed in `script/known-failures.txt`. The first run clones the repository, which is pinned to a
|
|
114
117
|
commit in `script/parse-examples`. After a grammar change or a moved pin alters that list, `script/parse-examples`
|
package/grammar.js
CHANGED
|
@@ -77,6 +77,8 @@ module.exports = grammar({
|
|
|
77
77
|
$._binary_star_star,
|
|
78
78
|
$._element_reference_bracket,
|
|
79
79
|
$._short_interpolation,
|
|
80
|
+
$._line_comment,
|
|
81
|
+
$._uninterpreted,
|
|
80
82
|
],
|
|
81
83
|
|
|
82
84
|
extras: ($) => [$.comment, $.heredoc_body, /\s/, /\\\r?\n/],
|
|
@@ -103,7 +105,8 @@ module.exports = grammar({
|
|
|
103
105
|
rules: {
|
|
104
106
|
program: ($) => seq(optional($._statements), optional(choice(seq(/__END__/, $.uninterpreted)))),
|
|
105
107
|
|
|
106
|
-
|
|
108
|
+
// External extras must yield to the internal lexer after __END__.
|
|
109
|
+
uninterpreted: ($) => choice(/(.|\s)*/, $._uninterpreted),
|
|
107
110
|
|
|
108
111
|
block_body: ($) => $._statements,
|
|
109
112
|
|
|
@@ -930,13 +933,16 @@ module.exports = grammar({
|
|
|
930
933
|
undef: ($) => seq('undef', commaSep1($._method_name)),
|
|
931
934
|
alias: ($) => seq('alias', field('name', $._method_name), field('alias', $._method_name)),
|
|
932
935
|
|
|
933
|
-
comment: () =>
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
936
|
+
comment: ($) =>
|
|
937
|
+
choice(
|
|
938
|
+
$._line_comment,
|
|
939
|
+
token(
|
|
940
|
+
prec(
|
|
941
|
+
PREC.COMMENT,
|
|
942
|
+
choice(
|
|
943
|
+
seq('#', /.*/),
|
|
944
|
+
seq(/=begin.*\r?\n/, repeat(choice(/[^=]/, /=[^e]/, /=e[^n]/, /=en[^d]/)), /[\s*]*=end.*/)
|
|
945
|
+
)
|
|
940
946
|
)
|
|
941
947
|
)
|
|
942
948
|
),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-ruby",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Ruby grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
48
48
|
"@willbooster/oxlint-config": "1.4.8",
|
|
49
49
|
"@willbooster/wb": "22.24.0",
|
|
50
|
-
"@willbooster/web-tree-sitter": "2.0.
|
|
50
|
+
"@willbooster/web-tree-sitter": "2.0.18",
|
|
51
51
|
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
52
52
|
"lefthook": "2.1.16",
|
|
53
53
|
"oxfmt": "0.71.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"wrangler": "4.147.0"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"@willbooster/web-tree-sitter": "^2.0.
|
|
66
|
+
"@willbooster/web-tree-sitter": "^2.0.18"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
69
69
|
"@willbooster/web-tree-sitter": {
|
package/src/node-types.json
CHANGED
|
@@ -1414,6 +1414,12 @@
|
|
|
1414
1414
|
}
|
|
1415
1415
|
}
|
|
1416
1416
|
},
|
|
1417
|
+
{
|
|
1418
|
+
"type": "comment",
|
|
1419
|
+
"named": true,
|
|
1420
|
+
"extra": true,
|
|
1421
|
+
"fields": {}
|
|
1422
|
+
},
|
|
1417
1423
|
{
|
|
1418
1424
|
"type": "complex",
|
|
1419
1425
|
"named": true,
|
|
@@ -3345,6 +3351,11 @@
|
|
|
3345
3351
|
]
|
|
3346
3352
|
}
|
|
3347
3353
|
},
|
|
3354
|
+
{
|
|
3355
|
+
"type": "uninterpreted",
|
|
3356
|
+
"named": true,
|
|
3357
|
+
"fields": {}
|
|
3358
|
+
},
|
|
3348
3359
|
{
|
|
3349
3360
|
"type": "unless",
|
|
3350
3361
|
"named": true,
|
|
@@ -3868,11 +3879,6 @@
|
|
|
3868
3879
|
"type": "class_variable",
|
|
3869
3880
|
"named": true
|
|
3870
3881
|
},
|
|
3871
|
-
{
|
|
3872
|
-
"type": "comment",
|
|
3873
|
-
"named": true,
|
|
3874
|
-
"extra": true
|
|
3875
|
-
},
|
|
3876
3882
|
{
|
|
3877
3883
|
"type": "def",
|
|
3878
3884
|
"named": false
|
|
@@ -4037,10 +4043,6 @@
|
|
|
4037
4043
|
"type": "undef",
|
|
4038
4044
|
"named": false
|
|
4039
4045
|
},
|
|
4040
|
-
{
|
|
4041
|
-
"type": "uninterpreted",
|
|
4042
|
-
"named": true
|
|
4043
|
-
},
|
|
4044
4046
|
{
|
|
4045
4047
|
"type": "unless",
|
|
4046
4048
|
"named": false
|
package/tree-sitter-ruby.wasm
CHANGED
|
Binary file
|