From 03a9bbacf2a82faaecc269c1d97dea392f4f9874 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 23 Dec 2020 01:49:43 +0100 Subject: Parse ConstBlockPat --- crates/parser/src/grammar/patterns.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'crates/parser/src/grammar/patterns.rs') diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs index 7e7f73dee..44400c9f8 100644 --- a/crates/parser/src/grammar/patterns.rs +++ b/crates/parser/src/grammar/patterns.rs @@ -1,5 +1,7 @@ //! FIXME: write short doc here +use expressions::block_expr; + use super::*; pub(super) const PATTERN_FIRST: TokenSet = @@ -89,6 +91,7 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option { let m = match p.nth(0) { T![box] => box_pat(p), T![ref] | T![mut] => ident_pat(p, true), + T![const] => const_block_pat(p), IDENT => match p.nth(1) { // Checks the token after an IDENT to see if a pattern is a path (Struct { .. }) or macro // (T![x]). @@ -386,3 +389,16 @@ fn box_pat(p: &mut Parser) -> CompletedMarker { pattern_single(p); m.complete(p, BOX_PAT) } + +// test const_block_pat +// fn main() { +// let const { 15 } = (); +// let const { foo(); bar() } = (); +// } +fn const_block_pat(p: &mut Parser) -> CompletedMarker { + assert!(p.at(T![const])); + let m = p.start(); + p.bump(T![const]); + block_expr(p); + m.complete(p, CONST_BLOCK_PAT) +} -- cgit v1.2.3 From bdd8c0b68f097c7d1a65a5b85b94f0a79affa506 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 23 Dec 2020 11:22:36 +0100 Subject: Remove local ungrammar dependency --- crates/parser/src/grammar/patterns.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'crates/parser/src/grammar/patterns.rs') diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs index 44400c9f8..b53d5749f 100644 --- a/crates/parser/src/grammar/patterns.rs +++ b/crates/parser/src/grammar/patterns.rs @@ -1,7 +1,5 @@ //! FIXME: write short doc here -use expressions::block_expr; - use super::*; pub(super) const PATTERN_FIRST: TokenSet = @@ -399,6 +397,6 @@ fn const_block_pat(p: &mut Parser) -> CompletedMarker { assert!(p.at(T![const])); let m = p.start(); p.bump(T![const]); - block_expr(p); + expressions::block_expr(p); m.complete(p, CONST_BLOCK_PAT) } -- cgit v1.2.3