diff options
author | Aleksey Kladov <[email protected]> | 2018-08-28 17:35:09 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-28 17:35:09 +0100 |
commit | dea6ed73fac6f3f4daf38b1cb6df4c8fb68872b7 (patch) | |
tree | 7aff1c3b0fbb32f142fce778c7ac6b16fab65756 /crates/libsyntax2/src/grammar/patterns.rs | |
parent | 537ea620bb2a73a5e79872f414af23cf4bf03179 (diff) |
better pattern recovery
Diffstat (limited to 'crates/libsyntax2/src/grammar/patterns.rs')
-rw-r--r-- | crates/libsyntax2/src/grammar/patterns.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/libsyntax2/src/grammar/patterns.rs b/crates/libsyntax2/src/grammar/patterns.rs index 114964651..065570b99 100644 --- a/crates/libsyntax2/src/grammar/patterns.rs +++ b/crates/libsyntax2/src/grammar/patterns.rs | |||
@@ -22,6 +22,10 @@ pub(super) fn pattern(p: &mut Parser) { | |||
22 | } | 22 | } |
23 | } | 23 | } |
24 | 24 | ||
25 | const PAT_RECOVERY_SET: TokenSet = | ||
26 | token_set![LET_KW, IF_KW, WHILE_KW, LOOP_KW, MATCH_KW]; | ||
27 | |||
28 | |||
25 | fn atom_pat(p: &mut Parser) -> Option<CompletedMarker> { | 29 | fn atom_pat(p: &mut Parser) -> Option<CompletedMarker> { |
26 | let la0 = p.nth(0); | 30 | let la0 = p.nth(0); |
27 | let la1 = p.nth(1); | 31 | let la1 = p.nth(1); |
@@ -52,7 +56,7 @@ fn atom_pat(p: &mut Parser) -> Option<CompletedMarker> { | |||
52 | L_PAREN => tuple_pat(p), | 56 | L_PAREN => tuple_pat(p), |
53 | L_BRACK => slice_pat(p), | 57 | L_BRACK => slice_pat(p), |
54 | _ => { | 58 | _ => { |
55 | p.err_and_bump("expected pattern"); | 59 | p.err_recover("expected pattern", PAT_RECOVERY_SET); |
56 | return None; | 60 | return None; |
57 | } | 61 | } |
58 | }; | 62 | }; |