aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-01-11 19:11:44 +0000
committerAleksey Kladov <[email protected]>2018-01-11 19:11:44 +0000
commit89699c4803a0d12155adf653742f463872667610 (patch)
tree38afef90c9b0e9d5aa28c52e525e93428698bfca
parent41bf98d2493138d09e8c127f0914b2cf034cfa34 (diff)
G: leading colon is a part of path segment
-rw-r--r--src/parser/event_parser/grammar/paths.rs14
-rw-r--r--tests/data/parser/ok/0009_use_item.txt6
-rw-r--r--tests/data/parser/ok/0010_use_path_segments.txt6
3 files changed, 15 insertions, 11 deletions
diff --git a/src/parser/event_parser/grammar/paths.rs b/src/parser/event_parser/grammar/paths.rs
index 74b0e0ed4..16a8ce239 100644
--- a/src/parser/event_parser/grammar/paths.rs
+++ b/src/parser/event_parser/grammar/paths.rs
@@ -5,16 +5,20 @@ pub(crate) fn use_path(p: &mut Parser) {
5 return; 5 return;
6 } 6 }
7 node(p, PATH, |p| { 7 node(p, PATH, |p| {
8 p.eat(COLONCOLON); 8 path_segment(p, true);
9 path_segment(p);
10 }); 9 });
11 many(p, |p| { 10 many(p, |p| {
12 node_if(p, COLONCOLON, PATH, |p| { 11 node_if(p, COLONCOLON, PATH, |p| {
13 path_segment(p); 12 path_segment(p, false);
14 }) 13 })
15 }); 14 });
16} 15}
17 16
18fn path_segment(p: &mut Parser) -> bool { 17fn path_segment(p: &mut Parser, first: bool) {
19 node_if(p, IDENT, PATH_SEGMENT, |_| ()) 18 node(p, PATH_SEGMENT, |p| {
19 if first {
20 p.eat(COLONCOLON);
21 }
22 p.expect(IDENT);
23 })
20} \ No newline at end of file 24} \ No newline at end of file
diff --git a/tests/data/parser/ok/0009_use_item.txt b/tests/data/parser/ok/0009_use_item.txt
index f0b2981f2..f15c30940 100644
--- a/tests/data/parser/ok/0009_use_item.txt
+++ b/tests/data/parser/ok/0009_use_item.txt
@@ -10,8 +10,8 @@ FILE@[0; 19)
10 USE_ITEM@[9; 19) 10 USE_ITEM@[9; 19)
11 USE_KW@[9; 12) 11 USE_KW@[9; 12)
12 PATH@[12; 18) 12 PATH@[12; 18)
13 WHITESPACE@[12; 13) 13 PATH_SEGMENT@[12; 18)
14 COLONCOLON@[13; 15) 14 WHITESPACE@[12; 13)
15 PATH_SEGMENT@[15; 18) 15 COLONCOLON@[13; 15)
16 IDENT@[15; 18) 16 IDENT@[15; 18)
17 SEMI@[18; 19) 17 SEMI@[18; 19)
diff --git a/tests/data/parser/ok/0010_use_path_segments.txt b/tests/data/parser/ok/0010_use_path_segments.txt
index cad609087..10f32793e 100644
--- a/tests/data/parser/ok/0010_use_path_segments.txt
+++ b/tests/data/parser/ok/0010_use_path_segments.txt
@@ -2,9 +2,9 @@ FILE@[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; 9)
5 WHITESPACE@[3; 4) 5 PATH_SEGMENT@[3; 9)
6 COLONCOLON@[4; 6) 6 WHITESPACE@[3; 4)
7 PATH_SEGMENT@[6; 9) 7 COLONCOLON@[4; 6)
8 IDENT@[6; 9) 8 IDENT@[6; 9)
9 PATH@[9; 14) 9 PATH@[9; 14)
10 COLONCOLON@[9; 11) 10 COLONCOLON@[9; 11)