diff options
author | DJMcNab <[email protected]> | 2018-12-20 12:28:59 +0000 |
---|---|---|
committer | DJMcNab <[email protected]> | 2018-12-20 12:28:59 +0000 |
commit | 27e814e182b97f8097121aceea8b42a4d4ea31b7 (patch) | |
tree | d50c1b1dbaabcef9dd39e8a4de582eb883c4b3fa /crates/ra_syntax/src/grammar | |
parent | 5205c016e9f704796aa7893f89ef108248bda2e2 (diff) |
Simplify NO_BLOCK testing
Diffstat (limited to 'crates/ra_syntax/src/grammar')
-rw-r--r-- | crates/ra_syntax/src/grammar/expressions.rs | 5 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar/expressions/atom.rs | 9 |
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}; | |||
5 | use super::*; | 5 | use super::*; |
6 | 6 | ||
7 | const EXPR_FIRST: TokenSet = LHS_FIRST; | 7 | const EXPR_FIRST: TokenSet = LHS_FIRST; |
8 | const EXPR_FIRST_NO_BLOCK: TokenSet = LHS_FIRST_NO_BLOCK; | ||
9 | 8 | ||
10 | pub(super) fn expr(p: &mut Parser) -> BlockLike { | 9 | pub(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 | ]; |
213 | const 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 | ||
218 | fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> { | 213 | fn 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 |
39 | pub(super) const ATOM_EXPR_FIRST_NO_BLOCK: TokenSet = token_set_union![ | 39 | pub(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 | ||
62 | pub(super) const ATOM_EXPR_FIRST: TokenSet = | ||
63 | token_set_union![ATOM_EXPR_FIRST_NO_BLOCK, token_set![L_CURLY],]; | ||
64 | |||
65 | const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; | 63 | const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; |
66 | 64 | ||
67 | pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> { | 65 | 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 { | |||
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) |