Parse correct AttrInput

This commit is contained in:
uHOOCCOOHu 2019-09-30 04:44:33 +08:00
parent c913b48928
commit 71efdaa636
No known key found for this signature in database
GPG key ID: CED392DE0C483D00
33 changed files with 844 additions and 601 deletions

View file

@ -22,8 +22,25 @@ fn attribute(p: &mut Parser, inner: bool) {
p.bump(T![!]);
}
if p.at(T!['[']) {
items::token_tree(p);
if p.eat(T!['[']) {
paths::use_path(p);
let is_delimiter = |p: &mut Parser| match p.current() {
T!['('] | T!['['] | T!['{'] => true,
_ => false,
};
if p.eat(T![=]) {
if expressions::literal(p).is_none() {
p.error("expected literal");
}
} else if is_delimiter(p) {
items::token_tree(p);
}
if !p.eat(T![']']) {
p.error("expected `]`");
}
} else {
p.error("expected `[`");
}