From 2fa90e736b026ee979d9eb59178dc1f792228250 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 28 Aug 2018 11:12:42 +0300 Subject: better recovery for exprs --- crates/libsyntax2/src/grammar/expressions/atom.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'crates/libsyntax2/src/grammar') diff --git a/crates/libsyntax2/src/grammar/expressions/atom.rs b/crates/libsyntax2/src/grammar/expressions/atom.rs index ab4aa49d2..0769bb5a8 100644 --- a/crates/libsyntax2/src/grammar/expressions/atom.rs +++ b/crates/libsyntax2/src/grammar/expressions/atom.rs @@ -33,6 +33,9 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet = RETURN_KW, IDENT, SELF_KW, SUPER_KW, COLONCOLON, BREAK_KW, CONTINUE_KW, LIFETIME ], ]; +const EXPR_RECOVERY_SET: TokenSet = + token_set![LET_KW]; + pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option { match literal(p) { Some(m) => return Some(m), @@ -73,7 +76,7 @@ pub(super) fn atom_expr(p: &mut Parser, r: Restrictions) -> Option continue_expr(p), BREAK_KW => break_expr(p), _ => { - p.err_and_bump("expected expression"); + p.err_recover("expected expression", EXPR_RECOVERY_SET); return None; } }; -- cgit v1.2.3