@willbooster/tree-sitter-ruby 6.0.0 → 6.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 CHANGED
@@ -117,10 +117,7 @@ Profiles in `.tmp/generation-profiles/` are temporary and must not be committed.
117
117
  parse exactly as listed in `script/known-failures.txt`. The first run clones the repository, which is pinned to a
118
118
  commit in `script/parse-examples`. After a grammar change or a moved pin alters that list, `script/parse-examples`
119
119
  rewrites it; review its diff before committing;
120
- - a performance check (`test/unit/performance.test.ts`) that recovering from an error on each line takes linear time
121
- (ten times the lines take about ten times the CPU time, under a ceiling), since consumers parse files while they are
122
- being edited. It loads the Wasm build through @willbooster/web-tree-sitter, which `bun run build/ci` rebuilds after
123
- regenerating the parser;
120
+ - bounded CPU-growth checks for error recovery and comment chains (`test/unit/performance.test.ts`);
124
121
  - a check that `package.json` and `Cargo.lock` test the same runtime version (`test/unit/runtimeVersion.test.ts`);
125
122
  - checks that the Wasm build parses in Chromium (`test/unit/browser/`) and in Cloudflare Workers with and without
126
123
  Node.js compatibility (`test/unit/workerd.test.ts`). Run `bun run test/ci-setup` once to install Chromium.
package/grammar.js CHANGED
@@ -45,7 +45,7 @@ const ALPHA_CHAR = /[^\x00-\x1F\s0-9:;`"'@$#.,|^&<=>+\-*/\\%?!~()\[\]{}]/;
45
45
  // oxlint-disable-next-line unicorn/prefer-module -- This package is CommonJS, so tree-sitter loads grammar.js as CommonJS.
46
46
  module.exports = grammar({
47
47
  name: 'ruby',
48
- inline: ($) => [$._arg_rhs, $._call_operator],
48
+ inline: ($) => [$._arg_rhs, $._call_operator, $._body_statement],
49
49
  externals: ($) => [
50
50
  $._line_break,
51
51
  $._no_line_break,
@@ -91,6 +91,8 @@ module.exports = grammar({
91
91
  $._not_parenthesized,
92
92
  $._lambda_brace,
93
93
  $._heredoc_resume,
94
+ $._body_comment,
95
+ $._body_line_break,
94
96
  ],
95
97
 
96
98
  extras: ($) => [$.comment, $.heredoc_body, $._heredoc_resume, /\s/, /\\\r?\n/],
@@ -349,7 +351,7 @@ module.exports = grammar({
349
351
  seq(
350
352
  'class',
351
353
  field('name', choice($.constant, $.scope_resolution)),
352
- choice(seq(field('superclass', $.superclass), $._terminator), optional($._terminator)),
354
+ choice(seq(field('superclass', $.superclass), $._body_separator), optional($._terminator)),
353
355
  optional(field('body', $.body_statement)),
354
356
  'end'
355
357
  ),
@@ -361,7 +363,7 @@ module.exports = grammar({
361
363
  'class',
362
364
  alias($._singleton_class_left_angle_left_langle, '<<'),
363
365
  field('value', $._arg),
364
- $._terminator,
366
+ $._body_separator,
365
367
  optional(field('body', $.body_statement)),
366
368
  'end'
367
369
  ),
@@ -650,7 +652,9 @@ module.exports = grammar({
650
652
 
651
653
  exception_variable: ($) => seq('=>', $._lhs),
652
654
 
653
- body_statement: ($) => $._body_statement,
655
+ body_statement: ($) => choice(seq($._body_comments, optional($._body_statement)), $._body_statement),
656
+
657
+ _body_comments: ($) => repeat1(alias($._body_comment, $.comment)),
654
658
 
655
659
  _body_statement: ($) =>
656
660
  choice(
@@ -1206,7 +1210,7 @@ module.exports = grammar({
1206
1210
  seq(
1207
1211
  'do',
1208
1212
  optional($._terminator),
1209
- optional(seq(field('parameters', $.block_parameters), optional($._terminator))),
1213
+ optional(seq(optional($._body_comments), field('parameters', $.block_parameters), optional($._terminator))),
1210
1214
  optional(field('body', $.body_statement)),
1211
1215
  'end'
1212
1216
  ),
@@ -1706,6 +1710,8 @@ module.exports = grammar({
1706
1710
 
1707
1711
  empty_statement: () => prec(-1, ';'),
1708
1712
 
1713
+ _body_separator: ($) => choice(prec.dynamic(1, $._body_line_break), ';'),
1714
+
1709
1715
  _terminator: ($) => choice(prec.dynamic(1, $._line_break), ';'),
1710
1716
  },
1711
1717
  });
@@ -2115,7 +2121,7 @@ function methodRest($, bodyExpression) {
2115
2121
  ),
2116
2122
  seq(
2117
2123
  optional(field('parameters', alias($.bare_parameters, $.method_parameters))),
2118
- $._terminator,
2124
+ $._body_separator,
2119
2125
  optional(field('body', $.body_statement)),
2120
2126
  'end'
2121
2127
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-ruby",
3
- "version": "6.0.0",
3
+ "version": "6.0.2",
4
4
  "description": "Ruby grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -1215,6 +1215,10 @@
1215
1215
  "type": "_statement",
1216
1216
  "named": true
1217
1217
  },
1218
+ {
1219
+ "type": "comment",
1220
+ "named": true
1221
+ },
1218
1222
  {
1219
1223
  "type": "else",
1220
1224
  "named": true
@@ -1668,6 +1672,16 @@
1668
1672
  }
1669
1673
  ]
1670
1674
  }
1675
+ },
1676
+ "children": {
1677
+ "multiple": true,
1678
+ "required": false,
1679
+ "types": [
1680
+ {
1681
+ "type": "comment",
1682
+ "named": true
1683
+ }
1684
+ ]
1671
1685
  }
1672
1686
  },
1673
1687
  {
Binary file
package/tree-sitter.json CHANGED
@@ -19,7 +19,7 @@
19
19
  }
20
20
  ],
21
21
  "metadata": {
22
- "version": "6.0.0",
22
+ "version": "6.0.2",
23
23
  "license": "MIT",
24
24
  "description": "Ruby grammar for tree-sitter",
25
25
  "authors": [