@willbooster/tree-sitter-ruby 2.0.4 → 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 CHANGED
@@ -5,14 +5,14 @@
5
5
  [![Test](https://github.com/WillBooster/tree-sitter-ruby/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-ruby/actions/workflows/test.yml)
6
6
  [![Test rust](https://github.com/WillBooster/tree-sitter-ruby/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-ruby/actions/workflows/test-rust.yml)
7
7
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
8
- [![wbfy](https://img.shields.io/badge/wbfy-20.36.11-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-20.41.8-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
9
9
  [![crates.io](https://img.shields.io/crates/v/willbooster-tree-sitter-ruby.svg)](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 extends the upstream grammar to parse anonymous block forwarding and spaced block arguments, with a parser generated by
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
@@ -168,6 +168,44 @@ module.exports = grammar({
168
168
 
169
169
  _body_expr: ($) => seq('=', field('body', choice($._arg, alias($.rescue_modifier_arg, $.rescue_modifier)))),
170
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
+
171
209
  parameters: ($) => seq('(', commaSep($._formal_parameter), ')'),
172
210
 
173
211
  bare_parameters: ($) => seq($._simple_formal_parameter, repeat(seq(',', $._formal_parameter))),
@@ -537,6 +575,8 @@ module.exports = grammar({
537
575
  // This naming convention is based on Ruby's standard grammar.
538
576
  _expression: ($) =>
539
577
  choice(
578
+ alias($._command_method, $.method),
579
+ alias($._command_singleton_method, $.singleton_method),
540
580
  alias($.command_binary, $.binary),
541
581
  alias($.command_unary, $.unary),
542
582
  alias($.command_assignment, $.assignment),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-ruby",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
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.26.1",
50
- "@willbooster/web-tree-sitter": "2.0.24",
50
+ "@willbooster/web-tree-sitter": "2.0.27",
51
51
  "conventional-changelog-conventionalcommits": "10.4.1",
52
52
  "lefthook": "2.2.1",
53
53
  "oxfmt": "0.72.0",
@@ -57,7 +57,6 @@
57
57
  "semantic-release": "25.0.9",
58
58
  "sort-package-json": "4.0.0",
59
59
  "tree-sitter-cli": "0.27.1",
60
- "typescript": "7.0.2",
61
60
  "vite": "8.3.4",
62
61
  "vitest": "5.0.3",
63
62
  "wrangler": "4.149.0"
@@ -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
  },
Binary file
package/tree-sitter.json CHANGED
@@ -19,7 +19,7 @@
19
19
  }
20
20
  ],
21
21
  "metadata": {
22
- "version": "2.0.4",
22
+ "version": "2.0.5",
23
23
  "license": "MIT",
24
24
  "description": "Ruby grammar for tree-sitter",
25
25
  "authors": [