24 lines
482 B
Rust
Raw Normal View History

2018-01-09 23:32:18 +03:00
use super::*;
pub(crate) fn use_path(p: &mut Parser) {
if !AnyOf(&[IDENT, COLONCOLON]).is_ahead(p) {
return;
}
node(p, PATH, |p| {
path_segment(p, true);
2018-01-11 20:55:08 +03:00
});
many(p, |p| {
node_if(p, COLONCOLON, PATH, |p| {
path_segment(p, false);
2018-01-11 20:55:08 +03:00
})
});
2018-01-09 23:32:18 +03:00
}
fn path_segment(p: &mut Parser, first: bool) {
node(p, PATH_SEGMENT, |p| {
if first {
p.eat(COLONCOLON);
}
p.expect(IDENT);
})
2018-01-09 23:32:18 +03:00
}