From d82a21ab202b2f5e8c96847802d806735ec74ad3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 31 Jul 2018 23:13:08 +0300 Subject: lambda expressions --- src/parser/grammar/items/mod.rs | 63 ++--------------------------------------- 1 file changed, 3 insertions(+), 60 deletions(-) (limited to 'src/parser/grammar/items') diff --git a/src/parser/grammar/items/mod.rs b/src/parser/grammar/items/mod.rs index d1da1ecb4..8c2704be5 100644 --- a/src/parser/grammar/items/mod.rs +++ b/src/parser/grammar/items/mod.rs @@ -15,7 +15,7 @@ pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { pub(super) const ITEM_FIRST: TokenSet = token_set![EXTERN_KW, MOD_KW, USE_KW, STRUCT_KW, ENUM_KW, FN_KW, PUB_KW, POUND]; -fn item(p: &mut Parser) { +pub(super) fn item(p: &mut Parser) { let item = p.start(); attributes::outer_attributes(p); visibility(p); @@ -239,7 +239,7 @@ fn fn_item(p: &mut Parser) { type_params::list(p); if p.at(L_PAREN) { - fn_value_parameters(p); + params::list(p); } else { p.error("expected function arguments"); } @@ -252,64 +252,7 @@ fn fn_item(p: &mut Parser) { // fn foo() where T: Copy {} type_params::where_clause(p); - block(p); - - // test block - // fn a() {} - // fn b() { let _ = 1; } - // fn c() { 1; 2; } - // fn d() { 1; 2 } - fn block(p: &mut Parser) { - if !p.at(L_CURLY) { - p.error("expected block"); - } - let m = p.start(); - p.bump(); - while !p.at(EOF) && !p.at(R_CURLY) { - match p.current() { - LET_KW => let_stmt(p), - c => { - // test block_items - // fn a() { fn b() {} } - if ITEM_FIRST.contains(c) { - item(p) - } else { - let expr_stmt = p.start(); - expressions::expr(p); - if p.eat(SEMI) { - expr_stmt.complete(p, EXPR_STMT); - } else { - expr_stmt.abandon(p); - } - } - } - } - } - p.expect(R_CURLY); - m.complete(p, BLOCK); - } - - // test let_stmt; - // fn foo() { - // let a; - // let b: i32; - // let c = 92; - // let d: i32 = 92; - // } - fn let_stmt(p: &mut Parser) { - assert!(p.at(LET_KW)); - let m = p.start(); - p.bump(); - patterns::pattern(p); - if p.at(COLON) { - types::ascription(p); - } - if p.eat(EQ) { - expressions::expr(p); - } - p.expect(SEMI); - m.complete(p, LET_STMT); - } + expressions::block(p); } // test type_item -- cgit v1.2.3