aboutsummaryrefslogtreecommitdiff
path: root/src/parser
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-01-28 17:53:33 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-01-28 17:53:33 +0000
commit08def60f16a222895b242d907163d914348894c7 (patch)
treec47d0cef58945190e9e5dcf40317450cfe0db797 /src/parser
parent4adf0c20b71f8eb6365893cb1739b1cd33b081cc (diff)
parentd1d47e62445806a7ecfb747989d2cb34989d5d51 (diff)
Merge #30
30: Skip over balanced parens r=matklad a=matklad
Diffstat (limited to 'src/parser')
-rw-r--r--src/parser/event_parser/grammar/items.rs5
-rw-r--r--src/parser/event_parser/grammar/mod.rs17
2 files changed, 22 insertions, 0 deletions
diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs
index 309e4f4de..56e3208ac 100644
--- a/src/parser/event_parser/grammar/items.rs
+++ b/src/parser/event_parser/grammar/items.rs
@@ -36,6 +36,11 @@ fn item(p: &mut Parser) {
36 fn_item(p); 36 fn_item(p);
37 FN_ITEM 37 FN_ITEM
38 } 38 }
39 L_CURLY => {
40 item.abandon(p);
41 error_block(p, "expected item");
42 return;
43 }
39 err_token => { 44 err_token => {
40 item.abandon(p); 45 item.abandon(p);
41 let message = if err_token == SEMI { 46 let message = if err_token == SEMI {
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
52fn 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
52impl<'p> Parser<'p> { 69impl<'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)