From b5034410c8e5aabf809d2665e38017ef79d05601 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 7 Jan 2018 16:01:30 +0300 Subject: G: function item --- src/parser/event_parser/grammar.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/parser/event_parser') diff --git a/src/parser/event_parser/grammar.rs b/src/parser/event_parser/grammar.rs index f26cbc4f6..09b2f02b2 100644 --- a/src/parser/event_parser/grammar.rs +++ b/src/parser/event_parser/grammar.rs @@ -22,8 +22,12 @@ fn inner_attributes(_: &mut Parser) { } fn item_first(p: &Parser) -> bool { - match p.current() { - Some(STRUCT_KW) => true, + let current = match p.current() { + Some(c) => c, + None => return false, + }; + match current { + STRUCT_KW | FN_KW => true, _ => false, } } @@ -31,7 +35,8 @@ fn item_first(p: &Parser) -> bool { fn item(p: &mut Parser) { outer_attributes(p); visibility(p); - node_if(p, STRUCT_KW, STRUCT_ITEM, struct_item); + node_if(p, STRUCT_KW, STRUCT_ITEM, struct_item) + || node_if(p, FN_KW, FN_ITEM, fn_item); } fn struct_item(p: &mut Parser) { @@ -45,6 +50,12 @@ fn struct_field(p: &mut Parser) -> bool { }) } +fn fn_item(p: &mut Parser) { + p.expect(IDENT) && p.expect(L_PAREN) && p.expect(R_PAREN) + && p.curly_block(|p| ()); +} + + // Paths, types, attributes, and stuff // fn outer_attributes(_: &mut Parser) { -- cgit v1.2.3