From b7ae5bbba22cb7968756b40240bcbca1f64ff6b0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 28 Jan 2018 01:12:49 +0300 Subject: Simplify --- src/parser/event_parser/grammar/items.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs index 38a4657aa..7706690cc 100644 --- a/src/parser/event_parser/grammar/items.rs +++ b/src/parser/event_parser/grammar/items.rs @@ -103,18 +103,27 @@ fn struct_item(p: &mut Parser) { } fn named_fields(p: &mut Parser) { - p.curly_block(|p| comma_list(p, EOF, |p| { + assert!(p.at(L_CURLY)); + p.bump(); + while !p.at(R_CURLY) && !p.at(EOF) { named_field(p); - true - })); + if !p.at(R_CURLY) { + p.expect(COMMA); + } + } + p.expect(R_CURLY); fn named_field(p: &mut Parser) { let field = p.start(); visibility(p); - if p.expect(IDENT) && p.expect(COLON) { + if p.expect(IDENT) { + p.expect(COLON); types::type_ref(p); - }; - field.complete(p, NAMED_FIELD); + field.complete(p, NAMED_FIELD); + } else { + field.abandon(p); + p.err_and_bump("expected field declaration"); + } } } -- cgit v1.2.3