mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
internal: parser cleanups
This commit is contained in:
parent
00b19846c9
commit
f632b5e481
3 changed files with 38 additions and 39 deletions
|
@ -12,6 +12,28 @@ pub(super) fn outer_attrs(p: &mut Parser) {
|
|||
}
|
||||
}
|
||||
|
||||
fn attr(p: &mut Parser, inner: bool) {
|
||||
assert!(p.at(T![#]));
|
||||
|
||||
let attr = p.start();
|
||||
p.bump(T![#]);
|
||||
|
||||
if inner {
|
||||
p.bump(T![!]);
|
||||
}
|
||||
|
||||
if p.eat(T!['[']) {
|
||||
meta(p);
|
||||
|
||||
if !p.eat(T![']']) {
|
||||
p.error("expected `]`");
|
||||
}
|
||||
} else {
|
||||
p.error("expected `[`");
|
||||
}
|
||||
attr.complete(p, ATTR);
|
||||
}
|
||||
|
||||
pub(super) fn meta(p: &mut Parser) {
|
||||
let meta = p.start();
|
||||
paths::use_path(p);
|
||||
|
@ -29,25 +51,3 @@ pub(super) fn meta(p: &mut Parser) {
|
|||
|
||||
meta.complete(p, META);
|
||||
}
|
||||
|
||||
fn attr(p: &mut Parser, inner: bool) {
|
||||
let attr = p.start();
|
||||
assert!(p.at(T![#]));
|
||||
p.bump(T![#]);
|
||||
|
||||
if inner {
|
||||
assert!(p.at(T![!]));
|
||||
p.bump(T![!]);
|
||||
}
|
||||
|
||||
if p.eat(T!['[']) {
|
||||
meta(p);
|
||||
|
||||
if !p.eat(T![']']) {
|
||||
p.error("expected `]`");
|
||||
}
|
||||
} else {
|
||||
p.error("expected `[`");
|
||||
}
|
||||
attr.complete(p, ATTR);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue