aboutsummaryrefslogtreecommitdiff
path: root/src/parser/event_parser/grammar.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-01-07 09:13:01 +0000
committerAleksey Kladov <[email protected]>2018-01-07 09:13:01 +0000
commitf797c81155e9b7371b24801efac3fcbd236fc9ab (patch)
tree27a2fd9e640962489e07d18b6225d3d30096bb39 /src/parser/event_parser/grammar.rs
parent8671a892c5169fe608d0467270a2af7797df8c36 (diff)
Smart eof for blocks
Diffstat (limited to 'src/parser/event_parser/grammar.rs')
-rw-r--r--src/parser/event_parser/grammar.rs12
1 files changed, 10 insertions, 2 deletions
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<F: Fn(&mut Parser) -> bool>(p: &mut Parser, f: F) {
74fn comma_list<F: Fn(&mut Parser) -> bool>(p: &mut Parser, f: F) { 74fn comma_list<F: Fn(&mut Parser) -> bool>(p: &mut Parser, f: F) {
75 many(p, |p| { 75 many(p, |p| {
76 f(p); 76 f(p);
77 p.expect(COMMA) 77 p.is_eof() || p.expect(COMMA)
78 }) 78 })
79} 79}
80 80
@@ -101,6 +101,14 @@ impl<'p> Parser<'p> {
101 } 101 }
102 102
103 pub(crate) fn expect(&mut self, kind: SyntaxKind) -> bool { 103 pub(crate) fn expect(&mut self, kind: SyntaxKind) -> bool {
104 self.current_is(kind) && { self.bump(); true } 104 if self.current_is(kind) {
105 self.bump();
106 true
107 } else {
108 self.error()
109 .message(format!("expected {:?}", kind))
110 .emit();
111 false
112 }
105 } 113 }
106} \ No newline at end of file 114} \ No newline at end of file