2018-01-09 14:32:18 -06:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
pub(crate) fn use_path(p: &mut Parser) {
|
|
|
|
if !AnyOf(&[IDENT, COLONCOLON]).is_ahead(p) {
|
|
|
|
return;
|
|
|
|
}
|
2018-01-12 11:59:19 -06:00
|
|
|
let mut prev = p.mark();
|
2018-01-09 14:32:18 -06:00
|
|
|
node(p, PATH, |p| {
|
2018-01-11 13:11:44 -06:00
|
|
|
path_segment(p, true);
|
2018-01-11 11:55:08 -06:00
|
|
|
});
|
|
|
|
many(p, |p| {
|
2018-01-12 11:59:19 -06:00
|
|
|
let curr = p.mark();
|
2018-01-11 11:55:08 -06:00
|
|
|
node_if(p, COLONCOLON, PATH, |p| {
|
2018-01-11 13:11:44 -06:00
|
|
|
path_segment(p, false);
|
2018-01-12 11:59:19 -06:00
|
|
|
p.forward_parent(prev, curr);
|
|
|
|
prev = curr;
|
2018-01-11 11:55:08 -06:00
|
|
|
})
|
|
|
|
});
|
2018-01-09 14:32:18 -06:00
|
|
|
}
|
|
|
|
|
2018-01-11 13:11:44 -06: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 14:32:18 -06:00
|
|
|
}
|