From 41bf98d2493138d09e8c127f0914b2cf034cfa34 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 11 Jan 2018 20:55:08 +0300 Subject: G: multisegment paths --- src/parser/event_parser/grammar/paths.rs | 9 +++++-- tests/data/parser/ok/0010_use_path_segments.rs | 2 ++ tests/data/parser/ok/0010_use_path_segments.txt | 34 +++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 tests/data/parser/ok/0010_use_path_segments.rs create mode 100644 tests/data/parser/ok/0010_use_path_segments.txt diff --git a/src/parser/event_parser/grammar/paths.rs b/src/parser/event_parser/grammar/paths.rs index 96966b380..74b0e0ed4 100644 --- a/src/parser/event_parser/grammar/paths.rs +++ b/src/parser/event_parser/grammar/paths.rs @@ -7,9 +7,14 @@ pub(crate) fn use_path(p: &mut Parser) { node(p, PATH, |p| { p.eat(COLONCOLON); path_segment(p); - }) + }); + many(p, |p| { + node_if(p, COLONCOLON, PATH, |p| { + path_segment(p); + }) + }); } fn path_segment(p: &mut Parser) -> bool { - node_if(p, IDENT, PATH_SEGMENT, |p| ()) + node_if(p, IDENT, PATH_SEGMENT, |_| ()) } \ No newline at end of file diff --git a/tests/data/parser/ok/0010_use_path_segments.rs b/tests/data/parser/ok/0010_use_path_segments.rs new file mode 100644 index 000000000..1e71b7a6c --- /dev/null +++ b/tests/data/parser/ok/0010_use_path_segments.rs @@ -0,0 +1,2 @@ +use ::foo::bar::baz; +use foo::bar::baz; diff --git a/tests/data/parser/ok/0010_use_path_segments.txt b/tests/data/parser/ok/0010_use_path_segments.txt new file mode 100644 index 000000000..cad609087 --- /dev/null +++ b/tests/data/parser/ok/0010_use_path_segments.txt @@ -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) -- cgit v1.2.3