@willbooster/tree-sitter-rust 1.2.1 → 1.4.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/grammar.js CHANGED
@@ -273,6 +273,7 @@ module.exports = grammar({
273
273
  'as',
274
274
  'async',
275
275
  'await',
276
+ 'become',
276
277
  'break',
277
278
  'const',
278
279
  'continue',
@@ -815,6 +816,7 @@ module.exports = grammar({
815
816
  $.type_cast_expression,
816
817
  $.call_expression,
817
818
  $.return_expression,
819
+ $.become_expression,
818
820
  $.yield_expression,
819
821
  $._literal,
820
822
  prec.left($.identifier),
@@ -978,6 +980,8 @@ module.exports = grammar({
978
980
 
979
981
  return_expression: ($) => choice(prec.left(seq('return', $._expression)), prec(-1, 'return')),
980
982
 
983
+ become_expression: ($) => prec.left(seq('become', $._expression)),
984
+
981
985
  yield_expression: ($) => choice(prec.left(seq('yield', $._expression)), prec(-1, 'yield')),
982
986
 
983
987
  call_expression: ($) =>
@@ -1204,15 +1208,26 @@ module.exports = grammar({
1204
1208
 
1205
1209
  struct_pattern: ($) =>
1206
1210
  seq(
1207
- field('type', choice($._type_identifier, $.scoped_type_identifier)),
1211
+ field(
1212
+ 'type',
1213
+ choice($._type_identifier, $.scoped_type_identifier, alias($._generic_struct_pattern_type, $.generic_type))
1214
+ ),
1208
1215
  '{',
1209
1216
  sepBy(',', choice($.field_pattern, $.remaining_field_pattern)),
1210
1217
  optional(','),
1211
1218
  '}'
1212
1219
  ),
1213
1220
 
1221
+ _generic_struct_pattern_type: ($) =>
1222
+ seq(
1223
+ field('type', choice($._type_identifier, $.scoped_type_identifier)),
1224
+ '::',
1225
+ field('type_arguments', $.type_arguments)
1226
+ ),
1227
+
1214
1228
  field_pattern: ($) =>
1215
1229
  seq(
1230
+ repeat($.attribute_item),
1216
1231
  optional('ref'),
1217
1232
  optional($.mutable_specifier),
1218
1233
  choice(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-rust",
3
- "version": "1.2.1",
3
+ "version": "1.4.0",
4
4
  "description": "Rust grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -1,20 +1,14 @@
1
- ; Identifiers
2
-
3
1
  (type_identifier) @type
4
2
  (primitive_type) @type.builtin
5
3
  (field_identifier) @property
6
4
 
7
- ; Identifier conventions
8
5
 
9
- ; Assume all-caps names are constants
10
6
  ((identifier) @constant
11
7
  (#match? @constant "^[A-Z][A-Z\\d_]+$'"))
12
8
 
13
- ; Assume uppercase names are enum constructors
14
9
  ((identifier) @constructor
15
10
  (#match? @constructor "^[A-Z]"))
16
11
 
17
- ; Assume that uppercase names in paths are types
18
12
  ((scoped_identifier
19
13
  path: (identifier) @type)
20
14
  (#match? @type "^[A-Z]"))
@@ -36,8 +30,11 @@
36
30
  (struct_pattern
37
31
  type: (scoped_type_identifier
38
32
  name: (type_identifier) @constructor))
33
+ (struct_pattern
34
+ type: (generic_type
35
+ type: (scoped_type_identifier
36
+ name: (type_identifier) @constructor)))
39
37
 
40
- ; Function calls
41
38
 
42
39
  (call_expression
43
40
  function: (identifier) @function)
@@ -64,7 +61,6 @@
64
61
 
65
62
  (decl_macro name: (identifier) @function.macro)
66
63
 
67
- ; Function definitions
68
64
 
69
65
  (function_item (identifier) @function)
70
66
  (function_signature_item (identifier) @function)
@@ -102,6 +98,7 @@
102
98
  "as" @keyword
103
99
  "async" @keyword
104
100
  "await" @keyword
101
+ "become" @keyword
105
102
  "break" @keyword
106
103
  "const" @keyword
107
104
  "continue" @keyword
@@ -121,6 +121,10 @@
121
121
  "type": "await_expression",
122
122
  "named": true
123
123
  },
124
+ {
125
+ "type": "become_expression",
126
+ "named": true
127
+ },
124
128
  {
125
129
  "type": "binary_expression",
126
130
  "named": true
@@ -792,6 +796,21 @@
792
796
  ]
793
797
  }
794
798
  },
799
+ {
800
+ "type": "become_expression",
801
+ "named": true,
802
+ "fields": {},
803
+ "children": {
804
+ "multiple": false,
805
+ "required": true,
806
+ "types": [
807
+ {
808
+ "type": "_expression",
809
+ "named": true
810
+ }
811
+ ]
812
+ }
813
+ },
795
814
  {
796
815
  "type": "binary_expression",
797
816
  "named": true,
@@ -1064,6 +1083,10 @@
1064
1083
  "type": "await_expression",
1065
1084
  "named": true
1066
1085
  },
1086
+ {
1087
+ "type": "become_expression",
1088
+ "named": true
1089
+ },
1067
1090
  {
1068
1091
  "type": "binary_expression",
1069
1092
  "named": true
@@ -1963,9 +1986,13 @@
1963
1986
  }
1964
1987
  },
1965
1988
  "children": {
1966
- "multiple": false,
1989
+ "multiple": true,
1967
1990
  "required": false,
1968
1991
  "types": [
1992
+ {
1993
+ "type": "attribute_item",
1994
+ "named": true
1995
+ },
1969
1996
  {
1970
1997
  "type": "mutable_specifier",
1971
1998
  "named": true
@@ -3918,6 +3945,10 @@
3918
3945
  "multiple": false,
3919
3946
  "required": true,
3920
3947
  "types": [
3948
+ {
3949
+ "type": "generic_type",
3950
+ "named": true
3951
+ },
3921
3952
  {
3922
3953
  "type": "scoped_type_identifier",
3923
3954
  "named": true
@@ -5385,6 +5416,10 @@
5385
5416
  "type": "await",
5386
5417
  "named": false
5387
5418
  },
5419
+ {
5420
+ "type": "become",
5421
+ "named": false
5422
+ },
5388
5423
  {
5389
5424
  "type": "block",
5390
5425
  "named": false
Binary file
package/tree-sitter.json CHANGED
@@ -22,7 +22,7 @@
22
22
  }
23
23
  ],
24
24
  "metadata": {
25
- "version": "1.2.1",
25
+ "version": "1.4.0",
26
26
  "license": "MIT",
27
27
  "description": "Rust grammar for tree-sitter",
28
28
  "authors": [