Skip to content

Commit 1c4d687

Browse files
committed
Update rust grammar
1 parent 94985c1 commit 1c4d687

File tree

7 files changed

+70122
-60820
lines changed

7 files changed

+70122
-60820
lines changed

tree-sitter-rust/corpus/patterns.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ match x {
108108
a @ A(_) | b @ B(..) => a,
109109
a @ 1 ... 5 => a,
110110
Some(1 ... 5) => a,
111+
a @ b...c => a,
111112
}
112113

113114
---
@@ -126,4 +127,7 @@ match x {
126127
(match_arm
127128
(match_pattern
128129
(tuple_struct_pattern (identifier) (range_pattern (integer_literal) (integer_literal))))
130+
(identifier))
131+
(match_arm
132+
(match_pattern (captured_pattern (identifier) (range_pattern (identifier) (identifier))))
129133
(identifier)))))

tree-sitter-rust/grammar.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,9 +1202,15 @@ module.exports = grammar({
12021202
)),
12031203

12041204
range_pattern: $ => seq(
1205-
$._literal_pattern,
1205+
choice(
1206+
$._literal_pattern,
1207+
$._path,
1208+
),
12061209
'...',
1207-
$._literal_pattern
1210+
choice(
1211+
$._literal_pattern,
1212+
$._path,
1213+
),
12081214
),
12091215

12101216
ref_pattern: $ => seq(

tree-sitter-rust/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"nan": "^2.8.0"
1414
},
1515
"devDependencies": {
16-
"tree-sitter-cli": "^0.15.3"
16+
"tree-sitter-cli": "^0.15.6"
1717
},
1818
"scripts": {
1919
"test": "tree-sitter test && script/parse-examples",

tree-sitter-rust/src/grammar.json

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6596,16 +6596,34 @@
65966596
"type": "SEQ",
65976597
"members": [
65986598
{
6599-
"type": "SYMBOL",
6600-
"name": "_literal_pattern"
6599+
"type": "CHOICE",
6600+
"members": [
6601+
{
6602+
"type": "SYMBOL",
6603+
"name": "_literal_pattern"
6604+
},
6605+
{
6606+
"type": "SYMBOL",
6607+
"name": "_path"
6608+
}
6609+
]
66016610
},
66026611
{
66036612
"type": "STRING",
66046613
"value": "..."
66056614
},
66066615
{
6607-
"type": "SYMBOL",
6608-
"name": "_literal_pattern"
6616+
"type": "CHOICE",
6617+
"members": [
6618+
{
6619+
"type": "SYMBOL",
6620+
"name": "_literal_pattern"
6621+
},
6622+
{
6623+
"type": "SYMBOL",
6624+
"name": "_path"
6625+
}
6626+
]
66096627
}
66106628
]
66116629
},

0 commit comments

Comments
 (0)