diff options
author | Aleksey Kladov <[email protected]> | 2018-01-07 09:13:01 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-01-07 09:13:01 +0000 |
commit | f797c81155e9b7371b24801efac3fcbd236fc9ab (patch) | |
tree | 27a2fd9e640962489e07d18b6225d3d30096bb39 /src/parser/event_parser/grammar.rs | |
parent | 8671a892c5169fe608d0467270a2af7797df8c36 (diff) |
Smart eof for blocks
Diffstat (limited to 'src/parser/event_parser/grammar.rs')
-rw-r--r-- | src/parser/event_parser/grammar.rs | 12 |
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) { | |||
74 | fn comma_list<F: Fn(&mut Parser) -> bool>(p: &mut Parser, f: F) { | 74 | fn 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 |