rust/crates/ra_syntax/src/grammar/attributes.rs

32 lines
578 B
Rust
Raw Normal View History

2018-01-07 21:46:10 +03:00
use super::*;
pub(super) fn inner_attributes(p: &mut Parser) {
2018-02-11 13:13:06 +03:00
while p.current() == POUND && p.nth(1) == EXCL {
2018-01-21 00:31:29 +03:00
attribute(p, true)
}
2018-01-07 21:46:10 +03:00
}
2018-01-11 23:01:12 +03:00
pub(super) fn outer_attributes(p: &mut Parser) {
2018-01-21 00:31:29 +03:00
while p.at(POUND) {
attribute(p, false)
}
2018-01-07 21:46:10 +03:00
}
2018-01-27 18:31:23 -05:00
fn attribute(p: &mut Parser, inner: bool) {
2018-01-21 00:31:29 +03:00
let attr = p.start();
assert!(p.at(POUND));
p.bump();
if inner {
assert!(p.at(EXCL));
2018-01-20 21:49:58 +03:00
p.bump();
2018-01-08 22:40:14 +03:00
}
2018-01-21 00:31:29 +03:00
2018-08-16 12:51:40 +03:00
if p.at(L_BRACK) {
items::token_tree(p);
2018-01-20 21:49:58 +03:00
} else {
2018-08-16 12:51:40 +03:00
p.error("expected `[`");
2018-01-21 00:31:29 +03:00
}
2018-08-16 12:51:40 +03:00
attr.complete(p, ATTR);
2018-01-21 00:31:29 +03:00
}