@willbooster/tree-sitter-rust 1.1.12 → 1.1.14

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
@@ -30,6 +30,10 @@ const PREC = {
30
30
  closure: -1,
31
31
  };
32
32
 
33
+ const numericSuffixWithoutExponent = new RegExp(String.raw`[\p{XID_Start}--[eE]][_\p{XID_Continue}]*`, 'v');
34
+ const zeroNumericSuffix = new RegExp(String.raw`[\p{XID_Start}--[eEbox]][_\p{XID_Continue}]*`, 'v');
35
+ const hexadecimalSuffix = new RegExp(String.raw`[\p{XID_Start}--[a-fA-F]][_\p{XID_Continue}]*`, 'v');
36
+
33
37
  const numericTypes = [
34
38
  'u8',
35
39
  'i8',
@@ -110,7 +114,7 @@ module.exports = grammar({
110
114
  $._raw_string_literal_start,
111
115
  $.raw_string_literal_content,
112
116
  $._raw_string_literal_end,
113
- $.float_literal,
117
+ $._trailing_dot_float_literal,
114
118
  $._outer_block_doc_comment_marker,
115
119
  $._inner_block_doc_comment_marker,
116
120
  $._block_comment_content,
@@ -614,7 +618,7 @@ module.exports = grammar({
614
618
  '(',
615
619
  sepBy(
616
620
  ',',
617
- seq(optional($.attribute_item), choice($.parameter, $.self_parameter, $.variadic_parameter, '_', $._type))
621
+ seq(repeat($.attribute_item), choice($.parameter, $.self_parameter, $.variadic_parameter, '_', $._type))
618
622
  ),
619
623
  optional(','),
620
624
  ')'
@@ -1014,7 +1018,7 @@ module.exports = grammar({
1014
1018
  field_initializer: ($) =>
1015
1019
  seq(
1016
1020
  repeat($.attribute_item),
1017
- field('field', choice($._field_identifier, $.integer_literal)),
1021
+ field('field', choice($._field_identifier, alias(/[0-9][0-9_]*/, $.integer_literal))),
1018
1022
  ':',
1019
1023
  field('value', $._expression)
1020
1024
  ),
@@ -1123,7 +1127,11 @@ module.exports = grammar({
1123
1127
  field_expression: ($) =>
1124
1128
  prec(
1125
1129
  PREC.field,
1126
- seq(field('value', $._expression), '.', field('field', choice($._field_identifier, $.integer_literal)))
1130
+ seq(
1131
+ field('value', $._expression),
1132
+ '.',
1133
+ field('field', choice($._field_identifier, alias(/[0-9][0-9_]*/, $.integer_literal)))
1134
+ )
1127
1135
  ),
1128
1136
 
1129
1137
  unsafe_block: ($) => seq('unsafe', $.block),
@@ -1244,7 +1252,37 @@ module.exports = grammar({
1244
1252
  negative_literal: ($) => seq('-', choice($.integer_literal, $.float_literal)),
1245
1253
 
1246
1254
  integer_literal: () =>
1247
- token(seq(choice(/[0-9][0-9_]*/, /0x[0-9a-fA-F_]+/, /0b[01_]+/, /0o[0-7_]+/), optional(choice(...numericTypes)))),
1255
+ token(
1256
+ choice(
1257
+ seq(
1258
+ choice(/[1-9][0-9_]*/, /0[0-9_]+/, /0b_*[01][01_]*/, /0o_*[0-7][0-7_]*/),
1259
+ optional(numericSuffixWithoutExponent)
1260
+ ),
1261
+ /0[box]_+/,
1262
+ seq('0', optional(zeroNumericSuffix)),
1263
+ seq(/0x_*[0-9a-fA-F][0-9a-fA-F_]*/, optional(hexadecimalSuffix))
1264
+ )
1265
+ ),
1266
+
1267
+ float_literal: ($) =>
1268
+ choice(
1269
+ $._trailing_dot_float_literal,
1270
+ token(
1271
+ prec(
1272
+ 1,
1273
+ choice(
1274
+ seq(
1275
+ /[0-9][0-9_]*/,
1276
+ optional(seq('.', /[0-9][0-9_]*/)),
1277
+ /[eE][+-]?_*[0-9][0-9_]*/,
1278
+ optional(/\p{XID_Start}[_\p{XID_Continue}]*/u)
1279
+ ),
1280
+ seq(/[0-9][0-9_]*/, optional(seq('.', /[0-9][0-9_]*/)), /[eE][+-]?_+/),
1281
+ seq(/[0-9][0-9_]*/, '.', /[0-9][0-9_]*/, optional(numericSuffixWithoutExponent))
1282
+ )
1283
+ )
1284
+ )
1285
+ ),
1248
1286
 
1249
1287
  string_literal: ($) =>
1250
1288
  seq(alias(/[bc]?"/, '"'), repeat(choice($.escape_sequence, $.string_content)), alias($.string_close, '"')),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-rust",
3
- "version": "1.1.12",
3
+ "version": "1.1.14",
4
4
  "description": "Rust grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -1985,6 +1985,11 @@
1985
1985
  ]
1986
1986
  }
1987
1987
  },
1988
+ {
1989
+ "type": "float_literal",
1990
+ "named": true,
1991
+ "fields": {}
1992
+ },
1988
1993
  {
1989
1994
  "type": "for_expression",
1990
1995
  "named": true,
@@ -5467,10 +5472,6 @@
5467
5472
  "type": "field_identifier",
5468
5473
  "named": true
5469
5474
  },
5470
- {
5471
- "type": "float_literal",
5472
- "named": true
5473
- },
5474
5475
  {
5475
5476
  "type": "fn",
5476
5477
  "named": false
Binary file
package/tree-sitter.json CHANGED
@@ -22,7 +22,7 @@
22
22
  }
23
23
  ],
24
24
  "metadata": {
25
- "version": "1.1.12",
25
+ "version": "1.1.14",
26
26
  "license": "MIT",
27
27
  "description": "Rust grammar for tree-sitter",
28
28
  "authors": [