@willbooster/tree-sitter-rust 7.0.0 → 9.0.0

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
@@ -74,7 +74,7 @@ fuzzed with. The parser requires version 7.0.5 or later within major version 7 o
74
74
  ```toml
75
75
  [dependencies]
76
76
  tree-sitter = { package = "willbooster-tree-sitter", version = "7.0.5" }
77
- tree-sitter-rust = { package = "willbooster-tree-sitter-rust", version = "7" }
77
+ tree-sitter-rust = { package = "willbooster-tree-sitter-rust", version = "9" }
78
78
  ```
79
79
 
80
80
  ```rust
@@ -82,6 +82,17 @@ let mut parser = tree_sitter::Parser::new();
82
82
  parser.set_language(&tree_sitter_rust::LANGUAGE.into())?;
83
83
  ```
84
84
 
85
+ ## Macros
86
+
87
+ A macro definition's anonymous `macro_rules!` node covers the `macro_rules` keyword. The `!` is a separate
88
+ anonymous child. A macro invocation's `macro` field contains its name, including when that name is `macro_rules`.
89
+
90
+ ## Reference nodes
91
+
92
+ A joint `&&` token produces one `reference_pattern` or `reference_type` node with an anonymous `&&` child.
93
+ Consecutive `&` tokens separated by whitespace or comments produce nested reference nodes.
94
+ For a joint token, an optional lifetime and mutability describe the inner reference.
95
+
85
96
  ## Attributes
86
97
 
87
98
  An attribute in an expression position can produce an `attributed_expression` node with a `value` field.
package/grammar.js CHANGED
@@ -266,7 +266,8 @@ module.exports = grammar({
266
266
  const rules = seq(repeat(seq($.macro_rule, ';')), optional($.macro_rule));
267
267
 
268
268
  return seq(
269
- choice('macro_rules!', seq(alias('macro_rules', 'macro_rules!'), '!')),
269
+ alias('macro_rules', 'macro_rules!'),
270
+ '!',
270
271
  field('name', choice($.identifier, $._reserved_identifier)),
271
272
  choice(seq('(', rules, ')', ';'), seq('[', rules, ']', ';'), seq('{', rules, '}'))
272
273
  );
@@ -992,7 +993,8 @@ module.exports = grammar({
992
993
  field('type', $._type)
993
994
  ),
994
995
 
995
- reference_type: ($) => seq('&', optional($.lifetime), optional($.mutable_specifier), field('type', $._type)),
996
+ reference_type: ($) =>
997
+ seq(choice('&', '&&'), optional($.lifetime), optional($.mutable_specifier), field('type', $._type)),
996
998
 
997
999
  pointer_type: ($) => seq('*', choice('const', $.mutable_specifier), field('type', $._type)),
998
1000
 
@@ -1582,7 +1584,7 @@ module.exports = grammar({
1582
1584
  $._pattern
1583
1585
  ),
1584
1586
 
1585
- reference_pattern: ($) => seq('&', optional($.mutable_specifier), $._pattern),
1587
+ reference_pattern: ($) => seq(choice('&', '&&'), optional($.mutable_specifier), $._pattern),
1586
1588
 
1587
1589
  or_pattern: ($) => prec.left(-2, choice(seq($._pattern, '|', $._pattern), seq('|', $._pattern))),
1588
1590
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-rust",
3
- "version": "7.0.0",
3
+ "version": "9.0.0",
4
4
  "description": "Rust grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -118,6 +118,7 @@
118
118
  "let" @keyword
119
119
  "loop" @keyword
120
120
  "macro_rules!" @keyword
121
+ (macro_definition "!" @keyword)
121
122
  "macro" @keyword
122
123
  "match" @keyword
123
124
  "mod" @keyword
@@ -161,4 +162,6 @@
161
162
 
162
163
  "*" @operator
163
164
  "&" @operator
165
+ (reference_type "&&" @operator)
166
+ (reference_pattern "&&" @operator)
164
167
  "'" @operator
Binary file
package/tree-sitter.json CHANGED
@@ -25,7 +25,7 @@
25
25
  }
26
26
  ],
27
27
  "metadata": {
28
- "version": "7.0.0",
28
+ "version": "9.0.0",
29
29
  "license": "MIT",
30
30
  "description": "Rust grammar for tree-sitter",
31
31
  "authors": [