aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorDJMcNab <[email protected]>2018-12-20 12:28:59 +0000
committerDJMcNab <[email protected]>2018-12-20 12:28:59 +0000
commit27e814e182b97f8097121aceea8b42a4d4ea31b7 (patch)
treed50c1b1dbaabcef9dd39e8a4de582eb883c4b3fa /crates/ra_syntax/src
parent5205c016e9f704796aa7893f89ef108248bda2e2 (diff)
Simplify NO_BLOCK testing
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/grammar/expressions.rs5
-rw-r--r--crates/ra_syntax/src/grammar/expressions/atom.rs9
2 files changed, 3 insertions, 11 deletions
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};
5use super::*; 5use super::*;
6 6
7const EXPR_FIRST: TokenSet = LHS_FIRST; 7const EXPR_FIRST: TokenSet = LHS_FIRST;
8const EXPR_FIRST_NO_BLOCK: TokenSet = LHS_FIRST_NO_BLOCK;
9 8
10pub(super) fn expr(p: &mut Parser) -> BlockLike { 9pub(super) fn expr(p: &mut Parser) -> BlockLike {
11 let r = Restrictions { 10 let r = Restrictions {
@@ -210,10 +209,6 @@ const LHS_FIRST: TokenSet = token_set_union![
210 token_set![AMP, STAR, EXCL, DOTDOT, MINUS], 209 token_set![AMP, STAR, EXCL, DOTDOT, MINUS],
211 atom::ATOM_EXPR_FIRST, 210 atom::ATOM_EXPR_FIRST,
212]; 211];
213const LHS_FIRST_NO_BLOCK: TokenSet = token_set_union![
214 token_set![AMP, STAR, EXCL, DOTDOT, MINUS],
215 atom::ATOM_EXPR_FIRST_NO_BLOCK,
216];
217 212
218fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> { 213fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
219 let m; 214 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<CompletedMarker> {
36} 36}
37 37
38// E.g. for after the break in `if break {}`, this should not match 38// E.g. for after the break in `if break {}`, this should not match
39pub(super) const ATOM_EXPR_FIRST_NO_BLOCK: TokenSet = token_set_union![ 39pub(super) const ATOM_EXPR_FIRST: TokenSet = token_set_union![
40 LITERAL_FIRST, 40 LITERAL_FIRST,
41 token_set![ 41 token_set![
42 L_PAREN, 42 L_PAREN,
43 L_CURLY,
43 L_BRACK, 44 L_BRACK,
44 PIPE, 45 PIPE,
45 MOVE_KW, 46 MOVE_KW,
@@ -59,9 +60,6 @@ pub(super) const ATOM_EXPR_FIRST_NO_BLOCK: TokenSet = token_set_union![
59 ], 60 ],
60]; 61];
61 62
62pub(super) const ATOM_EXPR_FIRST: TokenSet =
63 token_set_union![ATOM_EXPR_FIRST_NO_BLOCK, token_set![L_CURLY],];
64
65const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; 63const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW];
66 64
67pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> { 65pub(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 {
442 // for i in break {} 440 // for i in break {}
443 // match break {} 441 // match break {}
444 // } 442 // }
445 if r.forbid_structs && p.at_ts(EXPR_FIRST_NO_BLOCK) || !r.forbid_structs && p.at_ts(EXPR_FIRST) 443 if p.at_ts(EXPR_FIRST) && !(r.forbid_structs && p.at(L_CURLY)) {
446 {
447 expr(p); 444 expr(p);
448 } 445 }
449 m.complete(p, BREAK_EXPR) 446 m.complete(p, BREAK_EXPR)