From 77f2381eea2ca4da6c6d7dc81322be542e3dbb87 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 4 Mar 2019 14:24:02 +0300 Subject: improve error recovery parse the contents of error block as an expression --- crates/ra_parser/src/grammar.rs | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'crates/ra_parser/src/grammar.rs') 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) { } fn error_block(p: &mut Parser, message: &str) { - go(p, Some(message)); - fn go(p: &mut Parser, message: Option<&str>) { - assert!(p.at(L_CURLY)); - let m = p.start(); - if let Some(message) = message { - p.error(message); - } - p.bump(); - while !p.at(EOF) && !p.at(R_CURLY) { - match p.current() { - L_CURLY => go(p, None), - _ => p.bump(), - } - } - p.eat(R_CURLY); - m.complete(p, ERROR); - } + assert!(p.at(L_CURLY)); + let m = p.start(); + p.error(message); + p.bump(); + expressions::expr_block_contents(p); + p.eat(R_CURLY); + m.complete(p, ERROR); } -- cgit v1.2.3