Simplify NO_BLOCK testing
This commit is contained in:
parent
5205c016e9
commit
27e814e182
@ -5,7 +5,6 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const EXPR_FIRST: TokenSet = LHS_FIRST;
|
const EXPR_FIRST: TokenSet = LHS_FIRST;
|
||||||
const EXPR_FIRST_NO_BLOCK: TokenSet = LHS_FIRST_NO_BLOCK;
|
|
||||||
|
|
||||||
pub(super) fn expr(p: &mut Parser) -> BlockLike {
|
pub(super) fn expr(p: &mut Parser) -> BlockLike {
|
||||||
let r = Restrictions {
|
let r = Restrictions {
|
||||||
@ -210,10 +209,6 @@ fn expr_bp(p: &mut Parser, r: Restrictions, bp: u8) -> BlockLike {
|
|||||||
token_set![AMP, STAR, EXCL, DOTDOT, MINUS],
|
token_set![AMP, STAR, EXCL, DOTDOT, MINUS],
|
||||||
atom::ATOM_EXPR_FIRST,
|
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)> {
|
fn lhs(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
|
||||||
let m;
|
let m;
|
||||||
|
@ -36,10 +36,11 @@ pub(crate) fn literal(p: &mut Parser) -> Option<CompletedMarker> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// E.g. for after the break in `if break {}`, this should not match
|
// 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,
|
LITERAL_FIRST,
|
||||||
token_set![
|
token_set![
|
||||||
L_PAREN,
|
L_PAREN,
|
||||||
|
L_CURLY,
|
||||||
L_BRACK,
|
L_BRACK,
|
||||||
PIPE,
|
PIPE,
|
||||||
MOVE_KW,
|
MOVE_KW,
|
||||||
@ -59,9 +60,6 @@ pub(crate) fn literal(p: &mut Parser) -> Option<CompletedMarker> {
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
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];
|
const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW];
|
||||||
|
|
||||||
pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option<(CompletedMarker, BlockLike)> {
|
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 {}
|
// for i in break {}
|
||||||
// match 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);
|
expr(p);
|
||||||
}
|
}
|
||||||
m.complete(p, BREAK_EXPR)
|
m.complete(p, BREAK_EXPR)
|
||||||
|
Loading…
Reference in New Issue
Block a user