From 27e814e182b97f8097121aceea8b42a4d4ea31b7 Mon Sep 17 00:00:00 2001 From: DJMcNab <36049421+DJMcNab@users.noreply.github.com> Date: Thu, 20 Dec 2018 12:28:59 +0000 Subject: Simplify NO_BLOCK testing --- crates/ra_syntax/src/grammar/expressions.rs | 5 ----- crates/ra_syntax/src/grammar/expressions/atom.rs | 9 +++------ 2 files changed, 3 insertions(+), 11 deletions(-) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/grammar/expressions.rs b/crates/ra_syntax/src/grammar/expressions.rs index 79de0add0..4f8c46ab3 100644 --- a/crates/ra_syntax/src/grammar/expressions.rs +++ b/crates/ra_syntax/src/grammar/expressions.rs @@ -5,7 +5,6 @@ pub(super) use self::atom::{literal, LITERAL_FIRST}; use super::*; const EXPR_FIRST: TokenSet = LHS_FIRST; -const EXPR_FIRST_NO_BLOCK: TokenSet = LHS_FIRST_NO_BLOCK; pub(super) fn expr(p: &mut Parser) -> BlockLike { let r = Restrictions { @@ -210,10 +209,6 @@ const LHS_FIRST: TokenSet = token_set_union![ token_set![AMP, STAR, EXCL, DOTDOT, MINUS], atom::ATOM_EXPR_FIRST, ]; -const LHS_FIRST_NO_BLOCK: TokenSet = token_set_union![ - token_set![AMP, STAR, EXCL, DOTDOT, MINUS], - atom::ATOM_EXPR_FIRST_NO_BLOCK, -]; fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> { let m; diff --git a/crates/ra_syntax/src/grammar/expressions/atom.rs b/crates/ra_syntax/src/grammar/expressions/atom.rs index fcc0a4490..3b5749318 100644 --- a/crates/ra_syntax/src/grammar/expressions/atom.rs +++ b/crates/ra_syntax/src/grammar/expressions/atom.rs @@ -36,10 +36,11 @@ pub(crate) fn literal(p: &mut Parser) -> Option { } // E.g. for after the break in `if break {}`, this should not match -pub(super) const ATOM_EXPR_FIRST_NO_BLOCK: TokenSet = token_set_union![ +pub(super) const ATOM_EXPR_FIRST: TokenSet = token_set_union![ LITERAL_FIRST, token_set![ L_PAREN, + L_CURLY, L_BRACK, PIPE, MOVE_KW, @@ -59,9 +60,6 @@ pub(super) const ATOM_EXPR_FIRST_NO_BLOCK: TokenSet = token_set_union![ ], ]; -pub(super) const ATOM_EXPR_FIRST: TokenSet = - token_set_union![ATOM_EXPR_FIRST_NO_BLOCK, token_set![L_CURLY],]; - const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> { @@ -442,8 +440,7 @@ fn break_expr(p: &mut Parser, r: Restrictions) -> CompletedMarker { // for i in break {} // match break {} // } - if r.forbid_structs && p.at_ts(EXPR_FIRST_NO_BLOCK) || !r.forbid_structs && p.at_ts(EXPR_FIRST) - { + if p.at_ts(EXPR_FIRST) && !(r.forbid_structs && p.at(L_CURLY)) { expr(p); } m.complete(p, BREAK_EXPR) -- cgit v1.2.3