diff options
author | Aleksey Kladov <[email protected]> | 2018-08-07 12:41:03 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-07 12:41:03 +0100 |
commit | ba21da52741bf207db5081811e00eacf45796429 (patch) | |
tree | 0c79ba590bf704142dd9edca39217b6c0d5aca3e /src/grammar | |
parent | a6ba736a507f428c12617ca82d918080248d7b96 (diff) |
tuple patterns
Diffstat (limited to 'src/grammar')
-rw-r--r-- | src/grammar/patterns.rs | 14 |
1 files changed, 13 insertions, 1 deletions
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 | // } | ||
124 | fn 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 = (); |