aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-03-04 12:42:21 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-03-04 12:42:21 +0000
commit8a5d48b6c6e180017e47175a07f77f4f7ec6549d (patch)
treea6d825136ef86cef49f57d1cf358911d24735b21 /crates/ra_parser/src/grammar.rs
parent5197e1664856fa4fef5a4c4dd43b6915e9fa847d (diff)
parent77f2381eea2ca4da6c6d7dc81322be542e3dbb87 (diff)
Merge #925
925: improve error recovery r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_parser/src/grammar.rs')
-rw-r--r--crates/ra_parser/src/grammar.rs24
1 files changed, 7 insertions, 17 deletions
diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs
index 15aab6c6f..f94702e97 100644
--- a/crates/ra_parser/src/grammar.rs
+++ b/crates/ra_parser/src/grammar.rs
@@ -182,21 +182,11 @@ fn name_ref(p: &mut Parser) {
182} 182}
183 183
184fn error_block(p: &mut Parser, message: &str) { 184fn error_block(p: &mut Parser, message: &str) {
185 go(p, Some(message)); 185 assert!(p.at(L_CURLY));
186 fn go(p: &mut Parser, message: Option<&str>) { 186 let m = p.start();
187 assert!(p.at(L_CURLY)); 187 p.error(message);
188 let m = p.start(); 188 p.bump();
189 if let Some(message) = message { 189 expressions::expr_block_contents(p);
190 p.error(message); 190 p.eat(R_CURLY);
191 } 191 m.complete(p, ERROR);
192 p.bump();
193 while !p.at(EOF) && !p.at(R_CURLY) {
194 match p.current() {
195 L_CURLY => go(p, None),
196 _ => p.bump(),
197 }
198 }
199 p.eat(R_CURLY);
200 m.complete(p, ERROR);
201 }
202} 192}