simplify parsing blocks a bit

This commit is contained in:
Aleksey Kladov 2019-03-17 13:14:17 +03:00
parent 7d3f48cdaf
commit a8271cb31f

View File

@ -43,13 +43,15 @@ pub(crate) fn expr_block_contents(p: &mut Parser) {
attributes::inner_attributes(p);
while !p.at(EOF) && !p.at(R_CURLY) {
match p.current() {
// test nocontentexpr
// fn foo(){
// ;;;some_expr();;;;{;;;};;;;Ok(())
// }
SEMI => p.bump(),
_ => {
if p.current() == SEMI {
p.bump();
continue;
}
// test block_items
// fn a() { fn b() {} }
let m = p.start();
@ -57,7 +59,9 @@ pub(crate) fn expr_block_contents(p: &mut Parser) {
attributes::outer_attributes(p);
if p.at(LET_KW) {
let_stmt(p, m);
} else {
continue;
}
match items::maybe_item(p, items::ItemFlavor::Mod) {
items::MaybeItem::Item(kind) => {
m.complete(p, kind);
@ -71,9 +75,7 @@ pub(crate) fn expr_block_contents(p: &mut Parser) {
items::MaybeItem::None => {
if has_attrs {
m.abandon(p);
p.error(
"expected a let statement or an item after attributes in block",
);
p.error("expected a let statement or an item after attributes in block");
} else {
let is_blocklike = expressions::expr_stmt(p) == BlockLike::Block;
if p.at(R_CURLY) {
@ -104,9 +106,6 @@ pub(crate) fn expr_block_contents(p: &mut Parser) {
}
}
}
}
}
}
// test let_stmt;
// fn foo() {