From f797c81155e9b7371b24801efac3fcbd236fc9ab Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 7 Jan 2018 12:13:01 +0300 Subject: Smart eof for blocks --- src/parser/event_parser/grammar.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/parser/event_parser/grammar.rs') diff --git a/src/parser/event_parser/grammar.rs b/src/parser/event_parser/grammar.rs index d09579881..7425526ef 100644 --- a/src/parser/event_parser/grammar.rs +++ b/src/parser/event_parser/grammar.rs @@ -74,7 +74,7 @@ fn many bool>(p: &mut Parser, f: F) { fn comma_list bool>(p: &mut Parser, f: F) { many(p, |p| { f(p); - p.expect(COMMA) + p.is_eof() || p.expect(COMMA) }) } @@ -101,6 +101,14 @@ impl<'p> Parser<'p> { } pub(crate) fn expect(&mut self, kind: SyntaxKind) -> bool { - self.current_is(kind) && { self.bump(); true } + if self.current_is(kind) { + self.bump(); + true + } else { + self.error() + .message(format!("expected {:?}", kind)) + .emit(); + false + } } } \ No newline at end of file -- cgit v1.2.3