From 83aa6f0899fa3d8de87389d789d0e330739d0117 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 28 Jan 2018 12:57:03 +0300 Subject: Simplify item parsing --- src/parser/event_parser/grammar/items.rs | 9 ++++++--- src/parser/event_parser/grammar/mod.rs | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src/parser/event_parser/grammar') diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs index e569e5047..0638e3093 100644 --- a/src/parser/event_parser/grammar/items.rs +++ b/src/parser/event_parser/grammar/items.rs @@ -1,8 +1,8 @@ use super::*; -pub(super) fn mod_contents(p: &mut Parser) { +pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) { attributes::inner_attributes(p); - while !p.at(EOF) { + while !p.at(EOF) && !(stop_on_r_curly && p.at(R_CURLY)) { item(p); } } @@ -152,7 +152,10 @@ fn mod_item(p: &mut Parser) { p.bump(); if p.expect(IDENT) && !p.eat(SEMI) { - p.curly_block(mod_contents); + if p.expect(L_CURLY) { + mod_contents(p, true); + p.expect(R_CURLY); + } } } diff --git a/src/parser/event_parser/grammar/mod.rs b/src/parser/event_parser/grammar/mod.rs index 82f8b7f3e..b87f3ca8a 100644 --- a/src/parser/event_parser/grammar/mod.rs +++ b/src/parser/event_parser/grammar/mod.rs @@ -11,7 +11,7 @@ mod paths; pub(crate) fn file(p: &mut Parser) { let file = p.start(); p.eat(SHEBANG); - items::mod_contents(p); + items::mod_contents(p, false); file.complete(p, FILE); } -- cgit v1.2.3