aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-07 12:41:03 +0100
committerAleksey Kladov <[email protected]>2018-08-07 12:41:03 +0100
commitba21da52741bf207db5081811e00eacf45796429 (patch)
tree0c79ba590bf704142dd9edca39217b6c0d5aca3e /src
parenta6ba736a507f428c12617ca82d918080248d7b96 (diff)
tuple patterns
Diffstat (limited to 'src')
-rw-r--r--src/grammar.ron1
-rw-r--r--src/grammar/patterns.rs14
-rw-r--r--src/syntax_kinds/generated.rs2
3 files changed, 16 insertions, 1 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" },