Nest paths
This commit is contained in:
parent
ca0c5ea38b
commit
c111a1f7b8
@ -40,7 +40,7 @@ fn node<F: FnOnce(&mut Parser)>(p: &mut Parser, node_kind: SyntaxKind, rest: F)
|
||||
p.finish();
|
||||
}
|
||||
|
||||
fn many<F: Fn(&mut Parser) -> bool>(p: &mut Parser, f: F) {
|
||||
fn many<F: FnMut(&mut Parser) -> bool>(p: &mut Parser, mut f: F) {
|
||||
loop {
|
||||
let pos = p.pos();
|
||||
if !f(p) {
|
||||
|
@ -4,12 +4,16 @@ pub(crate) fn use_path(p: &mut Parser) {
|
||||
if !AnyOf(&[IDENT, COLONCOLON]).is_ahead(p) {
|
||||
return;
|
||||
}
|
||||
let mut prev = p.mark();
|
||||
node(p, PATH, |p| {
|
||||
path_segment(p, true);
|
||||
});
|
||||
many(p, |p| {
|
||||
let curr = p.mark();
|
||||
node_if(p, COLONCOLON, PATH, |p| {
|
||||
path_segment(p, false);
|
||||
p.forward_parent(prev, curr);
|
||||
prev = curr;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
FILE@[0; 40)
|
||||
USE_ITEM@[0; 21)
|
||||
USE_KW@[0; 3)
|
||||
PATH@[3; 9)
|
||||
PATH_SEGMENT@[3; 9)
|
||||
WHITESPACE@[3; 4)
|
||||
COLONCOLON@[4; 6)
|
||||
IDENT@[6; 9)
|
||||
PATH@[9; 14)
|
||||
COLONCOLON@[9; 11)
|
||||
PATH_SEGMENT@[11; 14)
|
||||
IDENT@[11; 14)
|
||||
PATH@[14; 19)
|
||||
PATH@[3; 19)
|
||||
PATH@[3; 14)
|
||||
PATH@[3; 9)
|
||||
PATH_SEGMENT@[3; 9)
|
||||
WHITESPACE@[3; 4)
|
||||
COLONCOLON@[4; 6)
|
||||
IDENT@[6; 9)
|
||||
COLONCOLON@[9; 11)
|
||||
PATH_SEGMENT@[11; 14)
|
||||
IDENT@[11; 14)
|
||||
COLONCOLON@[14; 16)
|
||||
PATH_SEGMENT@[16; 19)
|
||||
IDENT@[16; 19)
|
||||
@ -18,15 +18,15 @@ FILE@[0; 40)
|
||||
WHITESPACE@[20; 21)
|
||||
USE_ITEM@[21; 40)
|
||||
USE_KW@[21; 24)
|
||||
PATH@[24; 28)
|
||||
PATH_SEGMENT@[24; 28)
|
||||
WHITESPACE@[24; 25)
|
||||
IDENT@[25; 28)
|
||||
PATH@[28; 33)
|
||||
COLONCOLON@[28; 30)
|
||||
PATH_SEGMENT@[30; 33)
|
||||
IDENT@[30; 33)
|
||||
PATH@[33; 38)
|
||||
PATH@[24; 38)
|
||||
PATH@[24; 33)
|
||||
PATH@[24; 28)
|
||||
PATH_SEGMENT@[24; 28)
|
||||
WHITESPACE@[24; 25)
|
||||
IDENT@[25; 28)
|
||||
COLONCOLON@[28; 30)
|
||||
PATH_SEGMENT@[30; 33)
|
||||
IDENT@[30; 33)
|
||||
COLONCOLON@[33; 35)
|
||||
PATH_SEGMENT@[35; 38)
|
||||
IDENT@[35; 38)
|
||||
|
Loading…
Reference in New Issue
Block a user