From ba21da52741bf207db5081811e00eacf45796429 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 7 Aug 2018 14:41:03 +0300 Subject: tuple patterns --- src/grammar.ron | 1 + src/grammar/patterns.rs | 14 +++++++++++++- src/syntax_kinds/generated.rs | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') 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( "PLACEHOLDER_PAT", "PATH_PAT", "STRUCT_PAT", + "TUPLE_STRUCT_PAT", "TUPLE_PAT", // 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) { match la0 { UNDERSCORE => placeholder_pat(p), AMP => ref_pat(p), + L_PAREN => tuple_pat(p), _ => p.err_and_bump("expected pattern"), } } @@ -33,7 +34,7 @@ fn path_pat(p: &mut Parser) { let kind = match p.current() { L_PAREN => { tuple_pat_fields(p); - TUPLE_PAT + TUPLE_STRUCT_PAT } L_CURLY => { struct_pat_fields(p); @@ -116,6 +117,17 @@ fn ref_pat(p: &mut Parser) { m.complete(p, REF_PAT); } +// test tuple_pat +// fn main() { +// let (a, b, ..) = (); +// } +fn tuple_pat(p: &mut Parser) { + assert!(p.at(L_PAREN)); + let m = p.start(); + tuple_pat_fields(p); + m.complete(p, TUPLE_PAT); +} + // test bind_pat // fn main() { // 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 { PLACEHOLDER_PAT, PATH_PAT, STRUCT_PAT, + TUPLE_STRUCT_PAT, TUPLE_PAT, TUPLE_EXPR, ARRAY_EXPR, @@ -371,6 +372,7 @@ impl SyntaxKind { PLACEHOLDER_PAT => &SyntaxInfo { name: "PLACEHOLDER_PAT" }, PATH_PAT => &SyntaxInfo { name: "PATH_PAT" }, STRUCT_PAT => &SyntaxInfo { name: "STRUCT_PAT" }, + TUPLE_STRUCT_PAT => &SyntaxInfo { name: "TUPLE_STRUCT_PAT" }, TUPLE_PAT => &SyntaxInfo { name: "TUPLE_PAT" }, TUPLE_EXPR => &SyntaxInfo { name: "TUPLE_EXPR" }, ARRAY_EXPR => &SyntaxInfo { name: "ARRAY_EXPR" }, -- cgit v1.2.3