From edf2b17a572b56371cfc29bbc3a686edcb12782c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 31 Jul 2018 17:43:44 +0300 Subject: allow items inside blocks --- src/parser/grammar/items/mod.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/parser/grammar/items') diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs index 9147df87d..12bcf7924 100644 --- a/src/parser/grammar/items/mod.rs +++ b/src/parser/grammar/items/mod.rs @@ -248,16 +248,19 @@ fn fn_item(p: &mut Parser) { while !p.at(EOF) && !p.at(R_CURLY) { match p.current() { LET_KW => let_stmt(p), - _ => { - let expr_stmt = p.start(); - expressions::expr(p); - if p.eat(SEMI) { - expr_stmt.complete(p, EXPR_STMT); - if p.at(R_CURLY) { - break; - } + c => { + // test block_items + // fn a() { fn b() {} } + if ITEM_FIRST.contains(c) { + item(p) } else { - expr_stmt.abandon(p); + let expr_stmt = p.start(); + expressions::expr(p); + if p.eat(SEMI) { + expr_stmt.complete(p, EXPR_STMT); + } else { + expr_stmt.abandon(p); + } } } } -- cgit v1.2.3