improve error recovery

parse the contents of error block as an expression
This commit is contained in:
Aleksey Kladov 2019-03-04 14:24:02 +03:00
parent 3000b13df2
commit 77f2381eea
4 changed files with 77 additions and 59 deletions

View file

@ -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);
}