@willbooster/tree-sitter-ruby 2.0.2 → 2.0.4

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
@@ -12,10 +12,11 @@ Ruby grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), fork
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 ships upstream's grammar with a parser generated by
15
+ This fork extends the upstream grammar to parse anonymous block forwarding and spaced block arguments, 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, version 2.0.0 or later; upstream's tree-sitter runtime rejects it. The scanner preserves long heredoc identifiers
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.0 or later.
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.0 or later:
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.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
@@ -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,
@@ -77,6 +78,8 @@ module.exports = grammar({
77
78
  $._binary_star_star,
78
79
  $._element_reference_bracket,
79
80
  $._short_interpolation,
81
+ $._line_comment,
82
+ $._uninterpreted,
80
83
  ],
81
84
 
82
85
  extras: ($) => [$.comment, $.heredoc_body, /\s/, /\\\r?\n/],
@@ -103,7 +106,8 @@ module.exports = grammar({
103
106
  rules: {
104
107
  program: ($) => seq(optional($._statements), optional(choice(seq(/__END__/, $.uninterpreted)))),
105
108
 
106
- uninterpreted: () => /(.|\s)*/,
109
+ // External extras must yield to the internal lexer after __END__.
110
+ uninterpreted: ($) => choice(/(.|\s)*/, $._uninterpreted),
107
111
 
108
112
  block_body: ($) => $._statements,
109
113
 
@@ -789,7 +793,7 @@ module.exports = grammar({
789
793
  [prec.left, PREC.BOOLEAN_AND, '&&'],
790
794
  [prec.left, PREC.SHIFT, choice('<<', '>>')],
791
795
  [prec.left, PREC.COMPARISON, choice('<', '<=', '>', '>=')],
792
- [prec.left, PREC.BITWISE_AND, '&'],
796
+ [prec.left, PREC.BITWISE_AND, alias($._bitwise_and, '&')],
793
797
  [prec.left, PREC.BITWISE_OR, choice('^', '|')],
794
798
  [prec.left, PREC.ADDITIVE, choice('+', alias($._binary_minus, '-'))],
795
799
  [prec.left, PREC.MULTIPLICATIVE, choice('/', '%', alias($._binary_star, '*'))],
@@ -930,13 +934,16 @@ module.exports = grammar({
930
934
  undef: ($) => seq('undef', commaSep1($._method_name)),
931
935
  alias: ($) => seq('alias', field('name', $._method_name), field('alias', $._method_name)),
932
936
 
933
- comment: () =>
934
- token(
935
- prec(
936
- PREC.COMMENT,
937
- choice(
938
- seq('#', /.*/),
939
- seq(/=begin.*\r?\n/, repeat(choice(/[^=]/, /=[^e]/, /=e[^n]/, /=en[^d]/)), /[\s*]*=end.*/)
937
+ comment: ($) =>
938
+ choice(
939
+ $._line_comment,
940
+ token(
941
+ prec(
942
+ PREC.COMMENT,
943
+ choice(
944
+ seq('#', /.*/),
945
+ seq(/=begin.*\r?\n/, repeat(choice(/[^=]/, /=[^e]/, /=e[^n]/, /=en[^d]/)), /[\s*]*=end.*/)
946
+ )
940
947
  )
941
948
  )
942
949
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-ruby",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Ruby grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -46,24 +46,24 @@
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.24.0",
50
- "@willbooster/web-tree-sitter": "2.0.1",
51
- "conventional-changelog-conventionalcommits": "10.4.0",
52
- "lefthook": "2.1.16",
53
- "oxfmt": "0.71.0",
54
- "oxlint": "1.86.0",
55
- "oxlint-tsgolint": "7.0.2003",
56
- "playwright": "1.63.0",
49
+ "@willbooster/wb": "22.26.1",
50
+ "@willbooster/web-tree-sitter": "2.0.24",
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.0",
59
+ "tree-sitter-cli": "0.27.1",
60
60
  "typescript": "7.0.2",
61
- "vite": "8.3.2",
61
+ "vite": "8.3.4",
62
62
  "vitest": "5.0.3",
63
- "wrangler": "4.147.0"
63
+ "wrangler": "4.149.0"
64
64
  },
65
65
  "peerDependencies": {
66
- "@willbooster/web-tree-sitter": "^2.0.0"
66
+ "@willbooster/web-tree-sitter": "^2.0.18"
67
67
  },
68
68
  "peerDependenciesMeta": {
69
69
  "@willbooster/web-tree-sitter": {
@@ -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
Binary file
package/tree-sitter.json CHANGED
@@ -19,7 +19,7 @@
19
19
  }
20
20
  ],
21
21
  "metadata": {
22
- "version": "2.0.2",
22
+ "version": "2.0.4",
23
23
  "license": "MIT",
24
24
  "description": "Ruby grammar for tree-sitter",
25
25
  "authors": [