@willbooster/tree-sitter-ruby 2.0.3 → 2.0.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 +42 -1
- package/package.json +12 -13
- package/src/node-types.json +48 -0
- package/tree-sitter-ruby.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
[](https://github.com/WillBooster/tree-sitter-ruby/actions/workflows/test.yml)
|
|
6
6
|
[](https://github.com/WillBooster/tree-sitter-ruby/actions/workflows/test-rust.yml)
|
|
7
7
|
[](https://github.com/semantic-release/semantic-release)
|
|
8
|
-
[](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
|
|
9
9
|
[](https://crates.io/crates/willbooster-tree-sitter-ruby)
|
|
10
10
|
|
|
11
11
|
Ruby grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
|
|
12
12
|
[tree-sitter/tree-sitter-ruby](https://github.com/tree-sitter/tree-sitter-ruby). We are grateful
|
|
13
13
|
to its authors and contributors. This is not an official release of that project.
|
|
14
14
|
|
|
15
|
-
This fork
|
|
15
|
+
This fork extends the upstream grammar to parse anonymous block forwarding, spaced block arguments, and command calls in endless methods, 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
18
|
runtime; upstream's tree-sitter runtime rejects it. Use runtime 2.0.18 or later so contiguous included ranges do not terminate comments.
|
package/grammar.js
CHANGED
|
@@ -69,6 +69,7 @@ module.exports = grammar({
|
|
|
69
69
|
$._unary_minus_num,
|
|
70
70
|
$._binary_minus,
|
|
71
71
|
$._binary_star,
|
|
72
|
+
$._bitwise_and,
|
|
72
73
|
$._singleton_class_left_angle_left_langle,
|
|
73
74
|
$.hash_key_symbol,
|
|
74
75
|
$._identifier_suffix,
|
|
@@ -167,6 +168,44 @@ module.exports = grammar({
|
|
|
167
168
|
|
|
168
169
|
_body_expr: ($) => seq('=', field('body', choice($._arg, alias($.rescue_modifier_arg, $.rescue_modifier)))),
|
|
169
170
|
|
|
171
|
+
_command_method: ($) => seq('def', $._command_method_rest),
|
|
172
|
+
|
|
173
|
+
_command_singleton_method: ($) =>
|
|
174
|
+
seq(
|
|
175
|
+
'def',
|
|
176
|
+
seq(choice(field('object', $._variable), seq('(', field('object', $._arg), ')')), choice('.', '::')),
|
|
177
|
+
$._command_method_rest
|
|
178
|
+
),
|
|
179
|
+
|
|
180
|
+
_command_method_rest: ($) =>
|
|
181
|
+
seq(
|
|
182
|
+
field('name', $._method_name),
|
|
183
|
+
optional(field('parameters', alias($.parameters, $.method_parameters))),
|
|
184
|
+
'=',
|
|
185
|
+
field('body', $._endless_command)
|
|
186
|
+
),
|
|
187
|
+
|
|
188
|
+
// Ruby 4.0's default parser (Prism) lets an endless body hold at most one `rescue`, applied outside any `not`; a
|
|
189
|
+
// further `rescue` applies to the whole definition.
|
|
190
|
+
_endless_command: ($) => choice($._endless_command_operand, alias($._endless_command_rescue, $.rescue_modifier)),
|
|
191
|
+
|
|
192
|
+
_endless_command_operand: ($) =>
|
|
193
|
+
choice(
|
|
194
|
+
alias($.command_call, $.call),
|
|
195
|
+
alias($.command_call_with_block, $.call),
|
|
196
|
+
prec.left(alias($._chained_command_call, $.call)),
|
|
197
|
+
alias($.return_command, $.return),
|
|
198
|
+
alias($.yield_command, $.yield),
|
|
199
|
+
alias($._endless_command_not, $.unary),
|
|
200
|
+
alias($._command_method, $.method),
|
|
201
|
+
alias($._command_singleton_method, $.singleton_method)
|
|
202
|
+
),
|
|
203
|
+
|
|
204
|
+
_endless_command_not: ($) => prec.right(PREC.NOT, seq(field('operator', 'not'), field('operand', $._expression))),
|
|
205
|
+
|
|
206
|
+
_endless_command_rescue: ($) =>
|
|
207
|
+
prec(PREC.RESCUE, seq(field('body', $._endless_command_operand), 'rescue', field('handler', $._arg))),
|
|
208
|
+
|
|
170
209
|
parameters: ($) => seq('(', commaSep($._formal_parameter), ')'),
|
|
171
210
|
|
|
172
211
|
bare_parameters: ($) => seq($._simple_formal_parameter, repeat(seq(',', $._formal_parameter))),
|
|
@@ -536,6 +575,8 @@ module.exports = grammar({
|
|
|
536
575
|
// This naming convention is based on Ruby's standard grammar.
|
|
537
576
|
_expression: ($) =>
|
|
538
577
|
choice(
|
|
578
|
+
alias($._command_method, $.method),
|
|
579
|
+
alias($._command_singleton_method, $.singleton_method),
|
|
539
580
|
alias($.command_binary, $.binary),
|
|
540
581
|
alias($.command_unary, $.unary),
|
|
541
582
|
alias($.command_assignment, $.assignment),
|
|
@@ -792,7 +833,7 @@ module.exports = grammar({
|
|
|
792
833
|
[prec.left, PREC.BOOLEAN_AND, '&&'],
|
|
793
834
|
[prec.left, PREC.SHIFT, choice('<<', '>>')],
|
|
794
835
|
[prec.left, PREC.COMPARISON, choice('<', '<=', '>', '>=')],
|
|
795
|
-
[prec.left, PREC.BITWISE_AND, '&'],
|
|
836
|
+
[prec.left, PREC.BITWISE_AND, alias($._bitwise_and, '&')],
|
|
796
837
|
[prec.left, PREC.BITWISE_OR, choice('^', '|')],
|
|
797
838
|
[prec.left, PREC.ADDITIVE, choice('+', alias($._binary_minus, '-'))],
|
|
798
839
|
[prec.left, PREC.MULTIPLICATIVE, choice('/', '%', alias($._binary_star, '*'))],
|
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.5",
|
|
4
4
|
"description": "Ruby grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -46,21 +46,20 @@
|
|
|
46
46
|
"@vitest/browser-playwright": "5.0.3",
|
|
47
47
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
48
48
|
"@willbooster/oxlint-config": "1.4.8",
|
|
49
|
-
"@willbooster/wb": "22.
|
|
50
|
-
"@willbooster/web-tree-sitter": "2.0.
|
|
51
|
-
"conventional-changelog-conventionalcommits": "10.4.
|
|
52
|
-
"lefthook": "2.1
|
|
53
|
-
"oxfmt": "0.
|
|
54
|
-
"oxlint": "1.
|
|
55
|
-
"oxlint-tsgolint": "7.0.
|
|
56
|
-
"playwright": "1.
|
|
49
|
+
"@willbooster/wb": "22.26.1",
|
|
50
|
+
"@willbooster/web-tree-sitter": "2.0.27",
|
|
51
|
+
"conventional-changelog-conventionalcommits": "10.4.1",
|
|
52
|
+
"lefthook": "2.2.1",
|
|
53
|
+
"oxfmt": "0.72.0",
|
|
54
|
+
"oxlint": "1.87.0",
|
|
55
|
+
"oxlint-tsgolint": "7.0.2004",
|
|
56
|
+
"playwright": "1.64.0",
|
|
57
57
|
"semantic-release": "25.0.9",
|
|
58
58
|
"sort-package-json": "4.0.0",
|
|
59
|
-
"tree-sitter-cli": "0.27.
|
|
60
|
-
"
|
|
61
|
-
"vite": "8.3.2",
|
|
59
|
+
"tree-sitter-cli": "0.27.1",
|
|
60
|
+
"vite": "8.3.4",
|
|
62
61
|
"vitest": "5.0.3",
|
|
63
|
-
"wrangler": "4.
|
|
62
|
+
"wrangler": "4.149.0"
|
|
64
63
|
},
|
|
65
64
|
"peerDependencies": {
|
|
66
65
|
"@willbooster/web-tree-sitter": "^2.0.18"
|
package/src/node-types.json
CHANGED
|
@@ -61,6 +61,10 @@
|
|
|
61
61
|
"type": "match_pattern",
|
|
62
62
|
"named": true
|
|
63
63
|
},
|
|
64
|
+
{
|
|
65
|
+
"type": "method",
|
|
66
|
+
"named": true
|
|
67
|
+
},
|
|
64
68
|
{
|
|
65
69
|
"type": "next",
|
|
66
70
|
"named": true
|
|
@@ -73,6 +77,10 @@
|
|
|
73
77
|
"type": "return",
|
|
74
78
|
"named": true
|
|
75
79
|
},
|
|
80
|
+
{
|
|
81
|
+
"type": "singleton_method",
|
|
82
|
+
"named": true
|
|
83
|
+
},
|
|
76
84
|
{
|
|
77
85
|
"type": "test_pattern",
|
|
78
86
|
"named": true
|
|
@@ -2399,9 +2407,29 @@
|
|
|
2399
2407
|
"type": "body_statement",
|
|
2400
2408
|
"named": true
|
|
2401
2409
|
},
|
|
2410
|
+
{
|
|
2411
|
+
"type": "call",
|
|
2412
|
+
"named": true
|
|
2413
|
+
},
|
|
2414
|
+
{
|
|
2415
|
+
"type": "method",
|
|
2416
|
+
"named": true
|
|
2417
|
+
},
|
|
2402
2418
|
{
|
|
2403
2419
|
"type": "rescue_modifier",
|
|
2404
2420
|
"named": true
|
|
2421
|
+
},
|
|
2422
|
+
{
|
|
2423
|
+
"type": "return",
|
|
2424
|
+
"named": true
|
|
2425
|
+
},
|
|
2426
|
+
{
|
|
2427
|
+
"type": "singleton_method",
|
|
2428
|
+
"named": true
|
|
2429
|
+
},
|
|
2430
|
+
{
|
|
2431
|
+
"type": "yield",
|
|
2432
|
+
"named": true
|
|
2405
2433
|
}
|
|
2406
2434
|
]
|
|
2407
2435
|
},
|
|
@@ -3073,9 +3101,29 @@
|
|
|
3073
3101
|
"type": "body_statement",
|
|
3074
3102
|
"named": true
|
|
3075
3103
|
},
|
|
3104
|
+
{
|
|
3105
|
+
"type": "call",
|
|
3106
|
+
"named": true
|
|
3107
|
+
},
|
|
3108
|
+
{
|
|
3109
|
+
"type": "method",
|
|
3110
|
+
"named": true
|
|
3111
|
+
},
|
|
3076
3112
|
{
|
|
3077
3113
|
"type": "rescue_modifier",
|
|
3078
3114
|
"named": true
|
|
3115
|
+
},
|
|
3116
|
+
{
|
|
3117
|
+
"type": "return",
|
|
3118
|
+
"named": true
|
|
3119
|
+
},
|
|
3120
|
+
{
|
|
3121
|
+
"type": "singleton_method",
|
|
3122
|
+
"named": true
|
|
3123
|
+
},
|
|
3124
|
+
{
|
|
3125
|
+
"type": "yield",
|
|
3126
|
+
"named": true
|
|
3079
3127
|
}
|
|
3080
3128
|
]
|
|
3081
3129
|
},
|
package/tree-sitter-ruby.wasm
CHANGED
|
Binary file
|