aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parser/event_parser/grammar/mod.rs2
-rw-r--r--src/parser/event_parser/grammar/paths.rs4
-rw-r--r--tests/data/parser/ok/0010_use_path_segments.txt38
3 files changed, 24 insertions, 20 deletions
diff --git a/src/parser/event_parser/grammar/mod.rs b/src/parser/event_parser/grammar/mod.rs
index 76f62b714..3c4b223a9 100644
--- a/src/parser/event_parser/grammar/mod.rs
+++ b/src/parser/event_parser/grammar/mod.rs
@@ -40,7 +40,7 @@ fn node<F: FnOnce(&mut Parser)>(p: &mut Parser, node_kind: SyntaxKind, rest: F)
40 p.finish(); 40 p.finish();
41} 41}
42 42
43fn many<F: Fn(&mut Parser) -> bool>(p: &mut Parser, f: F) { 43fn many<F: FnMut(&mut Parser) -> bool>(p: &mut Parser, mut f: F) {
44 loop { 44 loop {
45 let pos = p.pos(); 45 let pos = p.pos();
46 if !f(p) { 46 if !f(p) {
diff --git a/src/parser/event_parser/grammar/paths.rs b/src/parser/event_parser/grammar/paths.rs
index 16a8ce239..108545bc2 100644
--- a/src/parser/event_parser/grammar/paths.rs
+++ b/src/parser/event_parser/grammar/paths.rs
@@ -4,12 +4,16 @@ pub(crate) fn use_path(p: &mut Parser) {
4 if !AnyOf(&[IDENT, COLONCOLON]).is_ahead(p) { 4 if !AnyOf(&[IDENT, COLONCOLON]).is_ahead(p) {
5 return; 5 return;
6 } 6 }
7 let mut prev = p.mark();
7 node(p, PATH, |p| { 8 node(p, PATH, |p| {
8 path_segment(p, true); 9 path_segment(p, true);
9 }); 10 });
10 many(p, |p| { 11 many(p, |p| {
12 let curr = p.mark();
11 node_if(p, COLONCOLON, PATH, |p| { 13 node_if(p, COLONCOLON, PATH, |p| {
12 path_segment(p, false); 14 path_segment(p, false);
15 p.forward_parent(prev, curr);
16 prev = curr;
13 }) 17 })
14 }); 18 });
15} 19}
diff --git a/tests/data/parser/ok/0010_use_path_segments.txt b/tests/data/parser/ok/0010_use_path_segments.txt
index 10f32793e..a407be826 100644
--- a/tests/data/parser/ok/0010_use_path_segments.txt
+++ b/tests/data/parser/ok/0010_use_path_segments.txt
@@ -1,16 +1,16 @@
1FILE@[0; 40) 1FILE@[0; 40)
2 USE_ITEM@[0; 21) 2 USE_ITEM@[0; 21)
3 USE_KW@[0; 3) 3 USE_KW@[0; 3)
4 PATH@[3; 9) 4 PATH@[3; 19)
5 PATH_SEGMENT@[3; 9) 5 PATH@[3; 14)
6 WHITESPACE@[3; 4) 6 PATH@[3; 9)
7 COLONCOLON@[4; 6) 7 PATH_SEGMENT@[3; 9)
8 IDENT@[6; 9) 8 WHITESPACE@[3; 4)
9 PATH@[9; 14) 9 COLONCOLON@[4; 6)
10 COLONCOLON@[9; 11) 10 IDENT@[6; 9)
11 PATH_SEGMENT@[11; 14) 11 COLONCOLON@[9; 11)
12 IDENT@[11; 14) 12 PATH_SEGMENT@[11; 14)
13 PATH@[14; 19) 13 IDENT@[11; 14)
14 COLONCOLON@[14; 16) 14 COLONCOLON@[14; 16)
15 PATH_SEGMENT@[16; 19) 15 PATH_SEGMENT@[16; 19)
16 IDENT@[16; 19) 16 IDENT@[16; 19)
@@ -18,15 +18,15 @@ FILE@[0; 40)
18 WHITESPACE@[20; 21) 18 WHITESPACE@[20; 21)
19 USE_ITEM@[21; 40) 19 USE_ITEM@[21; 40)
20 USE_KW@[21; 24) 20 USE_KW@[21; 24)
21 PATH@[24; 28) 21 PATH@[24; 38)
22 PATH_SEGMENT@[24; 28) 22 PATH@[24; 33)
23 WHITESPACE@[24; 25) 23 PATH@[24; 28)
24 IDENT@[25; 28) 24 PATH_SEGMENT@[24; 28)
25 PATH@[28; 33) 25 WHITESPACE@[24; 25)
26 COLONCOLON@[28; 30) 26 IDENT@[25; 28)
27 PATH_SEGMENT@[30; 33) 27 COLONCOLON@[28; 30)
28 IDENT@[30; 33) 28 PATH_SEGMENT@[30; 33)
29 PATH@[33; 38) 29 IDENT@[30; 33)
30 COLONCOLON@[33; 35) 30 COLONCOLON@[33; 35)
31 PATH_SEGMENT@[35; 38) 31 PATH_SEGMENT@[35; 38)
32 IDENT@[35; 38) 32 IDENT@[35; 38)