G: multisegment paths

This commit is contained in:
Aleksey Kladov 2018-01-11 20:55:08 +03:00
parent adb8378827
commit 41bf98d249
3 changed files with 43 additions and 2 deletions

View File

@ -7,9 +7,14 @@ pub(crate) fn use_path(p: &mut Parser) {
node(p, PATH, |p| { node(p, PATH, |p| {
p.eat(COLONCOLON); p.eat(COLONCOLON);
path_segment(p); path_segment(p);
});
many(p, |p| {
node_if(p, COLONCOLON, PATH, |p| {
path_segment(p);
}) })
});
} }
fn path_segment(p: &mut Parser) -> bool { fn path_segment(p: &mut Parser) -> bool {
node_if(p, IDENT, PATH_SEGMENT, |p| ()) node_if(p, IDENT, PATH_SEGMENT, |_| ())
} }

View File

@ -0,0 +1,2 @@
use ::foo::bar::baz;
use foo::bar::baz;

View File

@ -0,0 +1,34 @@
FILE@[0; 40)
USE_ITEM@[0; 21)
USE_KW@[0; 3)
PATH@[3; 9)
WHITESPACE@[3; 4)
COLONCOLON@[4; 6)
PATH_SEGMENT@[6; 9)
IDENT@[6; 9)
PATH@[9; 14)
COLONCOLON@[9; 11)
PATH_SEGMENT@[11; 14)
IDENT@[11; 14)
PATH@[14; 19)
COLONCOLON@[14; 16)
PATH_SEGMENT@[16; 19)
IDENT@[16; 19)
SEMI@[19; 20)
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)
COLONCOLON@[33; 35)
PATH_SEGMENT@[35; 38)
IDENT@[35; 38)
SEMI@[38; 39)
WHITESPACE@[39; 40)