fix curly braces parsing

This commit is contained in:
Aleksey Kladov 2018-08-26 19:04:44 +03:00
parent 71722c047f
commit 9b69c7df19
4 changed files with 248 additions and 3 deletions

View file

@ -2,7 +2,7 @@ use super::*;
pub(super) const PATTERN_FIRST: TokenSet =
token_set_union![
token_set![REF_KW, MUT_KW, L_PAREN, L_BRACK, AMP],
token_set![REF_KW, MUT_KW, L_PAREN, L_BRACK, AMP, UNDERSCORE],
expressions::LITERAL_FIRST,
paths::PATH_FIRST,
];
@ -97,7 +97,13 @@ fn tuple_pat_fields(p: &mut Parser) {
while !p.at(EOF) && !p.at(R_PAREN) {
match p.current() {
DOTDOT => p.bump(),
_ => pattern(p),
_ => {
if !PATTERN_FIRST.contains(p.current()) {
p.error("expected a pattern");
break;
}
pattern(p)
}
}
if !p.at(R_PAREN) {
p.expect(COMMA);
@ -125,6 +131,7 @@ fn field_pat_list(p: &mut Parser) {
p.bump();
pattern(p);
}
L_CURLY => error_block(p, "expected ident"),
_ => {
bind_pat(p, false);
}