diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-01-28 17:53:33 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-01-28 17:53:33 +0000 |
commit | 08def60f16a222895b242d907163d914348894c7 (patch) | |
tree | c47d0cef58945190e9e5dcf40317450cfe0db797 /src/parser/event_parser/grammar/mod.rs | |
parent | 4adf0c20b71f8eb6365893cb1739b1cd33b081cc (diff) | |
parent | d1d47e62445806a7ecfb747989d2cb34989d5d51 (diff) |
Merge #30
30: Skip over balanced parens r=matklad a=matklad
Diffstat (limited to 'src/parser/event_parser/grammar/mod.rs')
-rw-r--r-- | src/parser/event_parser/grammar/mod.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/parser/event_parser/grammar/mod.rs b/src/parser/event_parser/grammar/mod.rs index 92125acd1..e7f1915d2 100644 --- a/src/parser/event_parser/grammar/mod.rs +++ b/src/parser/event_parser/grammar/mod.rs | |||
@@ -49,6 +49,23 @@ fn alias(p: &mut Parser) -> bool { | |||
49 | true //FIXME: return false if three are errors | 49 | true //FIXME: return false if three are errors |
50 | } | 50 | } |
51 | 51 | ||
52 | fn error_block(p: &mut Parser, message: &str) { | ||
53 | assert!(p.at(L_CURLY)); | ||
54 | let err = p.start(); | ||
55 | p.error().message(message).emit(); | ||
56 | p.bump(); | ||
57 | let mut level: u32 = 1; | ||
58 | while level > 0 && !p.at(EOF) { | ||
59 | match p.current() { | ||
60 | L_CURLY => level += 1, | ||
61 | R_CURLY => level -= 1, | ||
62 | _ => (), | ||
63 | } | ||
64 | p.bump(); | ||
65 | } | ||
66 | err.complete(p, ERROR); | ||
67 | } | ||
68 | |||
52 | impl<'p> Parser<'p> { | 69 | impl<'p> Parser<'p> { |
53 | fn at<L: Lookahead>(&self, l: L) -> bool { | 70 | fn at<L: Lookahead>(&self, l: L) -> bool { |
54 | l.is_ahead(self) | 71 | l.is_ahead(self) |