Add indexing to record_field_pat

This commit is contained in:
kjeremy 2019-09-20 11:43:34 -04:00
parent c733993658
commit 5a65d4d9fb
3 changed files with 92 additions and 2 deletions

View file

@ -168,6 +168,7 @@ fn record_field_pat_list(p: &mut Parser) {
T![.] if p.at(T![..]) => p.bump(T![..]),
IDENT if p.nth(1) == T![:] => record_field_pat(p),
INT_NUMBER if p.nth(1) == T![:] => record_field_pat(p),
T!['{'] => error_block(p, "expected ident"),
T![box] => {
box_pat(p);
@ -184,12 +185,22 @@ fn record_field_pat_list(p: &mut Parser) {
m.complete(p, RECORD_FIELD_PAT_LIST);
}
// test record_field_pat
// fn foo() {
// let S { 0: 1 } = ();
// let S { x: 1 } = ();
// }
fn record_field_pat(p: &mut Parser) {
assert!(p.at(IDENT));
assert!(p.at(IDENT) || p.at(INT_NUMBER));
assert!(p.nth(1) == T![:]);
let m = p.start();
name(p);
match p.current() {
IDENT => name(p),
_ => p.bump_any(),
}
p.bump_any();
pattern(p);
m.complete(p, RECORD_FIELD_PAT);