aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/grammar.ron1
-rw-r--r--src/grammar/patterns.rs14
-rw-r--r--src/syntax_kinds/generated.rs2
-rw-r--r--tests/data/parser/inline/0071_tuple_pat_fields.txt8
-rw-r--r--tests/data/parser/inline/0072_path_part.txt2
-rw-r--r--tests/data/parser/inline/0076_cond.txt2
-rw-r--r--tests/data/parser/inline/0077_while_expr.txt2
-rw-r--r--tests/data/parser/inline/0086_tuple_pat.rs3
-rw-r--r--tests/data/parser/inline/0086_tuple_pat.txt40
9 files changed, 66 insertions, 8 deletions
diff --git a/src/grammar.ron b/src/grammar.ron
index 0620a8b8c..5181e296e 100644
--- a/src/grammar.ron
+++ b/src/grammar.ron
@@ -140,6 +140,7 @@ Grammar(
140 "PLACEHOLDER_PAT", 140 "PLACEHOLDER_PAT",
141 "PATH_PAT", 141 "PATH_PAT",
142 "STRUCT_PAT", 142 "STRUCT_PAT",
143 "TUPLE_STRUCT_PAT",
143 "TUPLE_PAT", 144 "TUPLE_PAT",
144 145
145 // atoms 146 // atoms
diff --git a/src/grammar/patterns.rs b/src/grammar/patterns.rs
index d67f180fa..f1d48b5fa 100644
--- a/src/grammar/patterns.rs
+++ b/src/grammar/patterns.rs
@@ -16,6 +16,7 @@ pub(super) fn pattern(p: &mut Parser) {
16 match la0 { 16 match la0 {
17 UNDERSCORE => placeholder_pat(p), 17 UNDERSCORE => placeholder_pat(p),
18 AMP => ref_pat(p), 18 AMP => ref_pat(p),
19 L_PAREN => tuple_pat(p),
19 _ => p.err_and_bump("expected pattern"), 20 _ => p.err_and_bump("expected pattern"),
20 } 21 }
21} 22}
@@ -33,7 +34,7 @@ fn path_pat(p: &mut Parser) {
33 let kind = match p.current() { 34 let kind = match p.current() {
34 L_PAREN => { 35 L_PAREN => {
35 tuple_pat_fields(p); 36 tuple_pat_fields(p);
36 TUPLE_PAT 37 TUPLE_STRUCT_PAT
37 } 38 }
38 L_CURLY => { 39 L_CURLY => {
39 struct_pat_fields(p); 40 struct_pat_fields(p);
@@ -116,6 +117,17 @@ fn ref_pat(p: &mut Parser) {
116 m.complete(p, REF_PAT); 117 m.complete(p, REF_PAT);
117} 118}
118 119
120// test tuple_pat
121// fn main() {
122// let (a, b, ..) = ();
123// }
124fn tuple_pat(p: &mut Parser) {
125 assert!(p.at(L_PAREN));
126 let m = p.start();
127 tuple_pat_fields(p);
128 m.complete(p, TUPLE_PAT);
129}
130
119// test bind_pat 131// test bind_pat
120// fn main() { 132// fn main() {
121// let a = (); 133// let a = ();
diff --git a/src/syntax_kinds/generated.rs b/src/syntax_kinds/generated.rs
index db8c20004..c8ddf333c 100644
--- a/src/syntax_kinds/generated.rs
+++ b/src/syntax_kinds/generated.rs
@@ -132,6 +132,7 @@ pub enum SyntaxKind {
132 PLACEHOLDER_PAT, 132 PLACEHOLDER_PAT,
133 PATH_PAT, 133 PATH_PAT,
134 STRUCT_PAT, 134 STRUCT_PAT,
135 TUPLE_STRUCT_PAT,
135 TUPLE_PAT, 136 TUPLE_PAT,
136 TUPLE_EXPR, 137 TUPLE_EXPR,
137 ARRAY_EXPR, 138 ARRAY_EXPR,
@@ -371,6 +372,7 @@ impl SyntaxKind {
371 PLACEHOLDER_PAT => &SyntaxInfo { name: "PLACEHOLDER_PAT" }, 372 PLACEHOLDER_PAT => &SyntaxInfo { name: "PLACEHOLDER_PAT" },
372 PATH_PAT => &SyntaxInfo { name: "PATH_PAT" }, 373 PATH_PAT => &SyntaxInfo { name: "PATH_PAT" },
373 STRUCT_PAT => &SyntaxInfo { name: "STRUCT_PAT" }, 374 STRUCT_PAT => &SyntaxInfo { name: "STRUCT_PAT" },
375 TUPLE_STRUCT_PAT => &SyntaxInfo { name: "TUPLE_STRUCT_PAT" },
374 TUPLE_PAT => &SyntaxInfo { name: "TUPLE_PAT" }, 376 TUPLE_PAT => &SyntaxInfo { name: "TUPLE_PAT" },
375 TUPLE_EXPR => &SyntaxInfo { name: "TUPLE_EXPR" }, 377 TUPLE_EXPR => &SyntaxInfo { name: "TUPLE_EXPR" },
376 ARRAY_EXPR => &SyntaxInfo { name: "ARRAY_EXPR" }, 378 ARRAY_EXPR => &SyntaxInfo { name: "ARRAY_EXPR" },
diff --git a/tests/data/parser/inline/0071_tuple_pat_fields.txt b/tests/data/parser/inline/0071_tuple_pat_fields.txt
index a6bfd3256..1eca6d370 100644
--- a/tests/data/parser/inline/0071_tuple_pat_fields.txt
+++ b/tests/data/parser/inline/0071_tuple_pat_fields.txt
@@ -14,7 +14,7 @@ FILE@[0; 97)
14 LET_STMT@[15; 28) 14 LET_STMT@[15; 28)
15 LET_KW@[15; 18) 15 LET_KW@[15; 18)
16 WHITESPACE@[18; 19) 16 WHITESPACE@[18; 19)
17 TUPLE_PAT@[19; 22) 17 TUPLE_STRUCT_PAT@[19; 22)
18 PATH@[19; 20) 18 PATH@[19; 20)
19 PATH_SEGMENT@[19; 20) 19 PATH_SEGMENT@[19; 20)
20 NAME_REF@[19; 20) 20 NAME_REF@[19; 20)
@@ -32,7 +32,7 @@ FILE@[0; 97)
32 LET_STMT@[33; 47) 32 LET_STMT@[33; 47)
33 LET_KW@[33; 36) 33 LET_KW@[33; 36)
34 WHITESPACE@[36; 37) 34 WHITESPACE@[36; 37)
35 TUPLE_PAT@[37; 41) 35 TUPLE_STRUCT_PAT@[37; 41)
36 PATH@[37; 38) 36 PATH@[37; 38)
37 PATH_SEGMENT@[37; 38) 37 PATH_SEGMENT@[37; 38)
38 NAME_REF@[37; 38) 38 NAME_REF@[37; 38)
@@ -52,7 +52,7 @@ FILE@[0; 97)
52 LET_STMT@[52; 67) 52 LET_STMT@[52; 67)
53 LET_KW@[52; 55) 53 LET_KW@[52; 55)
54 WHITESPACE@[55; 56) 54 WHITESPACE@[55; 56)
55 TUPLE_PAT@[56; 61) 55 TUPLE_STRUCT_PAT@[56; 61)
56 PATH@[56; 57) 56 PATH@[56; 57)
57 PATH_SEGMENT@[56; 57) 57 PATH_SEGMENT@[56; 57)
58 NAME_REF@[56; 57) 58 NAME_REF@[56; 57)
@@ -73,7 +73,7 @@ FILE@[0; 97)
73 LET_STMT@[72; 94) 73 LET_STMT@[72; 94)
74 LET_KW@[72; 75) 74 LET_KW@[72; 75)
75 WHITESPACE@[75; 76) 75 WHITESPACE@[75; 76)
76 TUPLE_PAT@[76; 88) 76 TUPLE_STRUCT_PAT@[76; 88)
77 PATH@[76; 77) 77 PATH@[76; 77)
78 PATH_SEGMENT@[76; 77) 78 PATH_SEGMENT@[76; 77)
79 NAME_REF@[76; 77) 79 NAME_REF@[76; 77)
diff --git a/tests/data/parser/inline/0072_path_part.txt b/tests/data/parser/inline/0072_path_part.txt
index 696de200e..0c7865998 100644
--- a/tests/data/parser/inline/0072_path_part.txt
+++ b/tests/data/parser/inline/0072_path_part.txt
@@ -74,7 +74,7 @@ FILE@[0; 103)
74 LET_STMT@[83; 100) 74 LET_STMT@[83; 100)
75 LET_KW@[83; 86) 75 LET_KW@[83; 86)
76 WHITESPACE@[86; 87) 76 WHITESPACE@[86; 87)
77 TUPLE_PAT@[87; 94) 77 TUPLE_STRUCT_PAT@[87; 94)
78 PATH@[87; 90) 78 PATH@[87; 90)
79 PATH_SEGMENT@[87; 90) 79 PATH_SEGMENT@[87; 90)
80 NAME_REF@[87; 90) 80 NAME_REF@[87; 90)
diff --git a/tests/data/parser/inline/0076_cond.txt b/tests/data/parser/inline/0076_cond.txt
index c4924574f..e8cf677cf 100644
--- a/tests/data/parser/inline/0076_cond.txt
+++ b/tests/data/parser/inline/0076_cond.txt
@@ -16,7 +16,7 @@ FILE@[0; 38)
16 WHITESPACE@[13; 14) 16 WHITESPACE@[13; 14)
17 LET_KW@[14; 17) 17 LET_KW@[14; 17)
18 WHITESPACE@[17; 18) 18 WHITESPACE@[17; 18)
19 TUPLE_PAT@[18; 25) 19 TUPLE_STRUCT_PAT@[18; 25)
20 PATH@[18; 22) 20 PATH@[18; 22)
21 PATH_SEGMENT@[18; 22) 21 PATH_SEGMENT@[18; 22)
22 NAME_REF@[18; 22) 22 NAME_REF@[18; 22)
diff --git a/tests/data/parser/inline/0077_while_expr.txt b/tests/data/parser/inline/0077_while_expr.txt
index fffbb37de..5c936a607 100644
--- a/tests/data/parser/inline/0077_while_expr.txt
+++ b/tests/data/parser/inline/0077_while_expr.txt
@@ -29,7 +29,7 @@ FILE@[0; 70)
29 WHITESPACE@[39; 40) 29 WHITESPACE@[39; 40)
30 LET_KW@[40; 43) 30 LET_KW@[40; 43)
31 WHITESPACE@[43; 44) 31 WHITESPACE@[43; 44)
32 TUPLE_PAT@[44; 51) 32 TUPLE_STRUCT_PAT@[44; 51)
33 PATH@[44; 48) 33 PATH@[44; 48)
34 PATH_SEGMENT@[44; 48) 34 PATH_SEGMENT@[44; 48)
35 NAME_REF@[44; 48) 35 NAME_REF@[44; 48)
diff --git a/tests/data/parser/inline/0086_tuple_pat.rs b/tests/data/parser/inline/0086_tuple_pat.rs
new file mode 100644
index 000000000..f785acd36
--- /dev/null
+++ b/tests/data/parser/inline/0086_tuple_pat.rs
@@ -0,0 +1,3 @@
1fn main() {
2 let (a, b, ..) = ();
3}
diff --git a/tests/data/parser/inline/0086_tuple_pat.txt b/tests/data/parser/inline/0086_tuple_pat.txt
new file mode 100644
index 000000000..6c2f25d36
--- /dev/null
+++ b/tests/data/parser/inline/0086_tuple_pat.txt
@@ -0,0 +1,40 @@
1FILE@[0; 39)
2 FN_ITEM@[0; 38)
3 FN_KW@[0; 2)
4 WHITESPACE@[2; 3)
5 NAME@[3; 7)
6 IDENT@[3; 7) "main"
7 PARAM_LIST@[7; 9)
8 L_PAREN@[7; 8)
9 R_PAREN@[8; 9)
10 WHITESPACE@[9; 10)
11 BLOCK_EXPR@[10; 38)
12 L_CURLY@[10; 11)
13 WHITESPACE@[11; 16)
14 LET_STMT@[16; 36)
15 LET_KW@[16; 19)
16 WHITESPACE@[19; 20)
17 TUPLE_PAT@[20; 30)
18 L_PAREN@[20; 21)
19 BIND_PAT@[21; 22)
20 NAME@[21; 22)
21 IDENT@[21; 22) "a"
22 COMMA@[22; 23)
23 WHITESPACE@[23; 24)
24 BIND_PAT@[24; 25)
25 NAME@[24; 25)
26 IDENT@[24; 25) "b"
27 COMMA@[25; 26)
28 WHITESPACE@[26; 27)
29 DOTDOT@[27; 29)
30 R_PAREN@[29; 30)
31 WHITESPACE@[30; 31)
32 EQ@[31; 32)
33 WHITESPACE@[32; 33)
34 TUPLE_EXPR@[33; 35)
35 L_PAREN@[33; 34)
36 R_PAREN@[34; 35)
37 SEMI@[35; 36)
38 WHITESPACE@[36; 37)
39 R_CURLY@[37; 38)
40 WHITESPACE@[38; 39)