diff options
-rw-r--r-- | grammar.ron | 1 | ||||
-rw-r--r-- | src/parser/event_parser/grammar/items.rs | 56 | ||||
-rw-r--r-- | src/parser/event_parser/grammar/paths.rs | 22 | ||||
-rw-r--r-- | src/parser/mod.rs | 2 | ||||
-rw-r--r-- | src/syntax_kinds.rs | 14 | ||||
-rw-r--r-- | tests/data/parser/err/0004_use_path_bad_segment.txt | 17 | ||||
-rw-r--r-- | tests/data/parser/ok/0009_use_item.txt | 20 | ||||
-rw-r--r-- | tests/data/parser/ok/0010_use_path_segments.txt | 52 | ||||
-rw-r--r-- | tests/data/parser/ok/0013_use_path_self_super.txt | 77 | ||||
-rw-r--r-- | tests/data/parser/ok/0014_use_tree.rs | 7 | ||||
-rw-r--r-- | tests/data/parser/ok/0014_use_tree.txt | 85 | ||||
-rw-r--r-- | tests/data/parser/ok/0015_use_tree.rs | 2 | ||||
-rw-r--r-- | tests/data/parser/ok/0015_use_tree.txt | 57 |
13 files changed, 319 insertions, 93 deletions
diff --git a/grammar.ron b/grammar.ron index ca6299f23..fe0ec8406 100644 --- a/grammar.ron +++ b/grammar.ron | |||
@@ -80,6 +80,7 @@ Grammar( | |||
80 | "META_ITEM", | 80 | "META_ITEM", |
81 | "MOD_ITEM", | 81 | "MOD_ITEM", |
82 | "USE_ITEM", | 82 | "USE_ITEM", |
83 | "USE_TREE", | ||
83 | "PATH", | 84 | "PATH", |
84 | "PATH_SEGMENT", | 85 | "PATH_SEGMENT", |
85 | "LITERAL", | 86 | "LITERAL", |
diff --git a/src/parser/event_parser/grammar/items.rs b/src/parser/event_parser/grammar/items.rs index f7310c09a..2f64111ab 100644 --- a/src/parser/event_parser/grammar/items.rs +++ b/src/parser/event_parser/grammar/items.rs | |||
@@ -74,9 +74,63 @@ fn mod_item(p: &mut Parser) { | |||
74 | p.curly_block(mod_contents); | 74 | p.curly_block(mod_contents); |
75 | } | 75 | } |
76 | 76 | ||
77 | pub(super) fn is_use_tree_start(kind: SyntaxKind) -> bool { | ||
78 | kind == STAR || kind == L_CURLY | ||
79 | } | ||
80 | |||
77 | fn use_item(p: &mut Parser) { | 81 | fn use_item(p: &mut Parser) { |
78 | paths::use_path(p); | 82 | use_tree(p); |
79 | p.expect(SEMI); | 83 | p.expect(SEMI); |
84 | |||
85 | fn use_tree(p: &mut Parser) -> bool{ | ||
86 | if node_if(p, STAR, USE_TREE, |_| ()) { | ||
87 | return true | ||
88 | } | ||
89 | if node_if(p, [COLONCOLON, STAR], USE_TREE, |_| ()) { | ||
90 | return true | ||
91 | } | ||
92 | if [COLONCOLON, L_CURLY].is_ahead(p) || L_CURLY.is_ahead(p) { | ||
93 | node(p, USE_TREE, |p| { | ||
94 | p.eat(COLONCOLON); | ||
95 | p.curly_block(|p| { | ||
96 | comma_list(p, EOF, use_tree); | ||
97 | }); | ||
98 | }); | ||
99 | return true; | ||
100 | } | ||
101 | if paths::is_path_start(p) { | ||
102 | node(p, USE_TREE, |p| { | ||
103 | paths::use_path(p); | ||
104 | match p.current() { | ||
105 | AS_KW => { | ||
106 | alias(p); | ||
107 | } | ||
108 | COLONCOLON => { | ||
109 | p.bump(); | ||
110 | match p.current() { | ||
111 | STAR => { | ||
112 | p.bump(); | ||
113 | } | ||
114 | L_CURLY => { | ||
115 | p.curly_block(|p| { | ||
116 | comma_list(p, EOF, use_tree); | ||
117 | }); | ||
118 | } | ||
119 | _ => { | ||
120 | // is this unreachable? | ||
121 | p.error() | ||
122 | .message("expected `{` or `*`") | ||
123 | .emit(); | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | _ => (), | ||
128 | } | ||
129 | }); | ||
130 | return true; | ||
131 | } | ||
132 | false | ||
133 | } | ||
80 | } | 134 | } |
81 | 135 | ||
82 | fn struct_field(p: &mut Parser) -> bool { | 136 | fn struct_field(p: &mut Parser) -> bool { |
diff --git a/src/parser/event_parser/grammar/paths.rs b/src/parser/event_parser/grammar/paths.rs index d6887a9ba..62d1a3bb2 100644 --- a/src/parser/event_parser/grammar/paths.rs +++ b/src/parser/event_parser/grammar/paths.rs | |||
@@ -1,7 +1,11 @@ | |||
1 | use super::*; | 1 | use super::*; |
2 | 2 | ||
3 | pub (crate) fn is_path_start(p: &Parser) -> bool { | ||
4 | AnyOf(&[IDENT, SELF_KW, SUPER_KW, COLONCOLON]).is_ahead(p) | ||
5 | } | ||
6 | |||
3 | pub(crate) fn use_path(p: &mut Parser) { | 7 | pub(crate) fn use_path(p: &mut Parser) { |
4 | if !AnyOf(&[IDENT, SELF_KW, SUPER_KW, COLONCOLON]).is_ahead(p) { | 8 | if !is_path_start(p) { |
5 | return; | 9 | return; |
6 | } | 10 | } |
7 | let mut prev = p.mark(); | 11 | let mut prev = p.mark(); |
@@ -10,11 +14,17 @@ pub(crate) fn use_path(p: &mut Parser) { | |||
10 | }); | 14 | }); |
11 | many(p, |p| { | 15 | many(p, |p| { |
12 | let curr = p.mark(); | 16 | let curr = p.mark(); |
13 | node_if(p, COLONCOLON, PATH, |p| { | 17 | if p.current() == COLONCOLON && !items::is_use_tree_start(p.raw_lookahead(1)) { |
14 | path_segment(p, false); | 18 | node(p, PATH, |p| { |
15 | p.forward_parent(prev, curr); | 19 | p.bump(); |
16 | prev = curr; | 20 | path_segment(p, false); |
17 | }) | 21 | p.forward_parent(prev, curr); |
22 | prev = curr; | ||
23 | }); | ||
24 | true | ||
25 | } else { | ||
26 | false | ||
27 | } | ||
18 | }); | 28 | }); |
19 | } | 29 | } |
20 | 30 | ||
diff --git a/src/parser/mod.rs b/src/parser/mod.rs index c08d32d08..0c29442f9 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs | |||
@@ -29,7 +29,7 @@ fn from_events_to_file( | |||
29 | } | 29 | } |
30 | 30 | ||
31 | match event { | 31 | match event { |
32 | &Event::Start { kind, forward_parent } => { | 32 | &Event::Start { .. } => { |
33 | forward_parents.clear(); | 33 | forward_parents.clear(); |
34 | let mut idx = i; | 34 | let mut idx = i; |
35 | loop { | 35 | loop { |
diff --git a/src/syntax_kinds.rs b/src/syntax_kinds.rs index 48f55fa97..8bc63a210 100644 --- a/src/syntax_kinds.rs +++ b/src/syntax_kinds.rs | |||
@@ -77,13 +77,14 @@ pub const ATTR: SyntaxKind = SyntaxKind(72); | |||
77 | pub const META_ITEM: SyntaxKind = SyntaxKind(73); | 77 | pub const META_ITEM: SyntaxKind = SyntaxKind(73); |
78 | pub const MOD_ITEM: SyntaxKind = SyntaxKind(74); | 78 | pub const MOD_ITEM: SyntaxKind = SyntaxKind(74); |
79 | pub const USE_ITEM: SyntaxKind = SyntaxKind(75); | 79 | pub const USE_ITEM: SyntaxKind = SyntaxKind(75); |
80 | pub const PATH: SyntaxKind = SyntaxKind(76); | 80 | pub const USE_TREE: SyntaxKind = SyntaxKind(76); |
81 | pub const PATH_SEGMENT: SyntaxKind = SyntaxKind(77); | 81 | pub const PATH: SyntaxKind = SyntaxKind(77); |
82 | pub const LITERAL: SyntaxKind = SyntaxKind(78); | 82 | pub const PATH_SEGMENT: SyntaxKind = SyntaxKind(78); |
83 | pub const ALIAS: SyntaxKind = SyntaxKind(79); | 83 | pub const LITERAL: SyntaxKind = SyntaxKind(79); |
84 | pub const VISIBILITY: SyntaxKind = SyntaxKind(80); | 84 | pub const ALIAS: SyntaxKind = SyntaxKind(80); |
85 | pub const VISIBILITY: SyntaxKind = SyntaxKind(81); | ||
85 | 86 | ||
86 | static INFOS: [SyntaxInfo; 81] = [ | 87 | static INFOS: [SyntaxInfo; 82] = [ |
87 | SyntaxInfo { name: "USE_KW" }, | 88 | SyntaxInfo { name: "USE_KW" }, |
88 | SyntaxInfo { name: "FN_KW" }, | 89 | SyntaxInfo { name: "FN_KW" }, |
89 | SyntaxInfo { name: "STRUCT_KW" }, | 90 | SyntaxInfo { name: "STRUCT_KW" }, |
@@ -160,6 +161,7 @@ static INFOS: [SyntaxInfo; 81] = [ | |||
160 | SyntaxInfo { name: "META_ITEM" }, | 161 | SyntaxInfo { name: "META_ITEM" }, |
161 | SyntaxInfo { name: "MOD_ITEM" }, | 162 | SyntaxInfo { name: "MOD_ITEM" }, |
162 | SyntaxInfo { name: "USE_ITEM" }, | 163 | SyntaxInfo { name: "USE_ITEM" }, |
164 | SyntaxInfo { name: "USE_TREE" }, | ||
163 | SyntaxInfo { name: "PATH" }, | 165 | SyntaxInfo { name: "PATH" }, |
164 | SyntaxInfo { name: "PATH_SEGMENT" }, | 166 | SyntaxInfo { name: "PATH_SEGMENT" }, |
165 | SyntaxInfo { name: "LITERAL" }, | 167 | SyntaxInfo { name: "LITERAL" }, |
diff --git a/tests/data/parser/err/0004_use_path_bad_segment.txt b/tests/data/parser/err/0004_use_path_bad_segment.txt index 241ee8562..cd7e86d68 100644 --- a/tests/data/parser/err/0004_use_path_bad_segment.txt +++ b/tests/data/parser/err/0004_use_path_bad_segment.txt | |||
@@ -1,14 +1,15 @@ | |||
1 | FILE@[0; 12) | 1 | FILE@[0; 12) |
2 | USE_ITEM@[0; 9) | 2 | USE_ITEM@[0; 9) |
3 | USE_KW@[0; 3) | 3 | USE_KW@[0; 3) |
4 | PATH@[3; 9) | 4 | USE_TREE@[3; 9) |
5 | PATH@[3; 7) | 5 | PATH@[3; 9) |
6 | PATH_SEGMENT@[3; 7) | 6 | PATH@[3; 7) |
7 | WHITESPACE@[3; 4) | 7 | PATH_SEGMENT@[3; 7) |
8 | IDENT@[4; 7) | 8 | WHITESPACE@[3; 4) |
9 | COLONCOLON@[7; 9) | 9 | IDENT@[4; 7) |
10 | PATH_SEGMENT@[9; 9) | 10 | COLONCOLON@[7; 9) |
11 | err: `expected identifier` | 11 | PATH_SEGMENT@[9; 9) |
12 | err: `expected identifier` | ||
12 | err: `expected SEMI` | 13 | err: `expected SEMI` |
13 | ERROR@[9; 12) | 14 | ERROR@[9; 12) |
14 | err: `expected item` | 15 | err: `expected item` |
diff --git a/tests/data/parser/ok/0009_use_item.txt b/tests/data/parser/ok/0009_use_item.txt index f15c30940..63274125d 100644 --- a/tests/data/parser/ok/0009_use_item.txt +++ b/tests/data/parser/ok/0009_use_item.txt | |||
@@ -1,17 +1,19 @@ | |||
1 | FILE@[0; 19) | 1 | FILE@[0; 19) |
2 | USE_ITEM@[0; 9) | 2 | USE_ITEM@[0; 9) |
3 | USE_KW@[0; 3) | 3 | USE_KW@[0; 3) |
4 | PATH@[3; 7) | 4 | USE_TREE@[3; 7) |
5 | PATH_SEGMENT@[3; 7) | 5 | PATH@[3; 7) |
6 | WHITESPACE@[3; 4) | 6 | PATH_SEGMENT@[3; 7) |
7 | IDENT@[4; 7) | 7 | WHITESPACE@[3; 4) |
8 | IDENT@[4; 7) | ||
8 | SEMI@[7; 8) | 9 | SEMI@[7; 8) |
9 | WHITESPACE@[8; 9) | 10 | WHITESPACE@[8; 9) |
10 | USE_ITEM@[9; 19) | 11 | USE_ITEM@[9; 19) |
11 | USE_KW@[9; 12) | 12 | USE_KW@[9; 12) |
12 | PATH@[12; 18) | 13 | USE_TREE@[12; 18) |
13 | PATH_SEGMENT@[12; 18) | 14 | PATH@[12; 18) |
14 | WHITESPACE@[12; 13) | 15 | PATH_SEGMENT@[12; 18) |
15 | COLONCOLON@[13; 15) | 16 | WHITESPACE@[12; 13) |
16 | IDENT@[15; 18) | 17 | COLONCOLON@[13; 15) |
18 | IDENT@[15; 18) | ||
17 | SEMI@[18; 19) | 19 | 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 a407be826..d0f2033ce 100644 --- a/tests/data/parser/ok/0010_use_path_segments.txt +++ b/tests/data/parser/ok/0010_use_path_segments.txt | |||
@@ -1,34 +1,36 @@ | |||
1 | FILE@[0; 40) | 1 | 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; 19) | 4 | USE_TREE@[3; 19) |
5 | PATH@[3; 14) | 5 | PATH@[3; 19) |
6 | PATH@[3; 9) | 6 | PATH@[3; 14) |
7 | PATH_SEGMENT@[3; 9) | 7 | PATH@[3; 9) |
8 | WHITESPACE@[3; 4) | 8 | PATH_SEGMENT@[3; 9) |
9 | COLONCOLON@[4; 6) | 9 | WHITESPACE@[3; 4) |
10 | IDENT@[6; 9) | 10 | COLONCOLON@[4; 6) |
11 | COLONCOLON@[9; 11) | 11 | IDENT@[6; 9) |
12 | PATH_SEGMENT@[11; 14) | 12 | COLONCOLON@[9; 11) |
13 | IDENT@[11; 14) | 13 | PATH_SEGMENT@[11; 14) |
14 | COLONCOLON@[14; 16) | 14 | IDENT@[11; 14) |
15 | PATH_SEGMENT@[16; 19) | 15 | COLONCOLON@[14; 16) |
16 | IDENT@[16; 19) | 16 | PATH_SEGMENT@[16; 19) |
17 | IDENT@[16; 19) | ||
17 | SEMI@[19; 20) | 18 | SEMI@[19; 20) |
18 | WHITESPACE@[20; 21) | 19 | WHITESPACE@[20; 21) |
19 | USE_ITEM@[21; 40) | 20 | USE_ITEM@[21; 40) |
20 | USE_KW@[21; 24) | 21 | USE_KW@[21; 24) |
21 | PATH@[24; 38) | 22 | USE_TREE@[24; 38) |
22 | PATH@[24; 33) | 23 | PATH@[24; 38) |
23 | PATH@[24; 28) | 24 | PATH@[24; 33) |
24 | PATH_SEGMENT@[24; 28) | 25 | PATH@[24; 28) |
25 | WHITESPACE@[24; 25) | 26 | PATH_SEGMENT@[24; 28) |
26 | IDENT@[25; 28) | 27 | WHITESPACE@[24; 25) |
27 | COLONCOLON@[28; 30) | 28 | IDENT@[25; 28) |
28 | PATH_SEGMENT@[30; 33) | 29 | COLONCOLON@[28; 30) |
29 | IDENT@[30; 33) | 30 | PATH_SEGMENT@[30; 33) |
30 | COLONCOLON@[33; 35) | 31 | IDENT@[30; 33) |
31 | PATH_SEGMENT@[35; 38) | 32 | COLONCOLON@[33; 35) |
32 | IDENT@[35; 38) | 33 | PATH_SEGMENT@[35; 38) |
34 | IDENT@[35; 38) | ||
33 | SEMI@[38; 39) | 35 | SEMI@[38; 39) |
34 | WHITESPACE@[39; 40) | 36 | WHITESPACE@[39; 40) |
diff --git a/tests/data/parser/ok/0013_use_path_self_super.txt b/tests/data/parser/ok/0013_use_path_self_super.txt index 90bbb9b2d..2b0934e97 100644 --- a/tests/data/parser/ok/0013_use_path_self_super.txt +++ b/tests/data/parser/ok/0013_use_path_self_super.txt | |||
@@ -1,50 +1,53 @@ | |||
1 | FILE@[0; 65) | 1 | FILE@[0; 65) |
2 | USE_ITEM@[0; 15) | 2 | USE_ITEM@[0; 15) |
3 | USE_KW@[0; 3) | 3 | USE_KW@[0; 3) |
4 | PATH@[3; 13) | 4 | USE_TREE@[3; 13) |
5 | PATH@[3; 8) | 5 | PATH@[3; 13) |
6 | PATH_SEGMENT@[3; 8) | 6 | PATH@[3; 8) |
7 | WHITESPACE@[3; 4) | 7 | PATH_SEGMENT@[3; 8) |
8 | SELF_KW@[4; 8) | 8 | WHITESPACE@[3; 4) |
9 | COLONCOLON@[8; 10) | 9 | SELF_KW@[4; 8) |
10 | PATH_SEGMENT@[10; 13) | 10 | COLONCOLON@[8; 10) |
11 | IDENT@[10; 13) | 11 | PATH_SEGMENT@[10; 13) |
12 | IDENT@[10; 13) | ||
12 | SEMI@[13; 14) | 13 | SEMI@[13; 14) |
13 | WHITESPACE@[14; 15) | 14 | WHITESPACE@[14; 15) |
14 | USE_ITEM@[15; 38) | 15 | USE_ITEM@[15; 38) |
15 | USE_KW@[15; 18) | 16 | USE_KW@[15; 18) |
16 | PATH@[18; 36) | 17 | USE_TREE@[18; 36) |
17 | PATH@[18; 31) | 18 | PATH@[18; 36) |
18 | PATH@[18; 24) | 19 | PATH@[18; 31) |
19 | PATH_SEGMENT@[18; 24) | 20 | PATH@[18; 24) |
20 | WHITESPACE@[18; 19) | 21 | PATH_SEGMENT@[18; 24) |
21 | SUPER_KW@[19; 24) | 22 | WHITESPACE@[18; 19) |
22 | COLONCOLON@[24; 26) | 23 | SUPER_KW@[19; 24) |
23 | PATH_SEGMENT@[26; 31) | 24 | COLONCOLON@[24; 26) |
24 | SUPER_KW@[26; 31) | 25 | PATH_SEGMENT@[26; 31) |
25 | COLONCOLON@[31; 33) | 26 | SUPER_KW@[26; 31) |
26 | PATH_SEGMENT@[33; 36) | 27 | COLONCOLON@[31; 33) |
27 | IDENT@[33; 36) | 28 | PATH_SEGMENT@[33; 36) |
29 | IDENT@[33; 36) | ||
28 | SEMI@[36; 37) | 30 | SEMI@[36; 37) |
29 | WHITESPACE@[37; 38) | 31 | WHITESPACE@[37; 38) |
30 | USE_ITEM@[38; 65) | 32 | USE_ITEM@[38; 65) |
31 | USE_KW@[38; 41) | 33 | USE_KW@[38; 41) |
32 | PATH@[41; 63) | 34 | USE_TREE@[41; 63) |
33 | PATH@[41; 58) | 35 | PATH@[41; 63) |
34 | PATH@[41; 51) | 36 | PATH@[41; 58) |
35 | PATH@[41; 48) | 37 | PATH@[41; 51) |
36 | PATH_SEGMENT@[41; 48) | 38 | PATH@[41; 48) |
37 | WHITESPACE@[41; 42) | 39 | PATH_SEGMENT@[41; 48) |
38 | COLONCOLON@[42; 44) | 40 | WHITESPACE@[41; 42) |
39 | SELF_KW@[44; 48) | 41 | COLONCOLON@[42; 44) |
40 | COLONCOLON@[48; 50) | 42 | SELF_KW@[44; 48) |
41 | PATH_SEGMENT@[50; 51) | 43 | COLONCOLON@[48; 50) |
42 | IDENT@[50; 51) | 44 | PATH_SEGMENT@[50; 51) |
43 | COLONCOLON@[51; 53) | 45 | IDENT@[50; 51) |
44 | PATH_SEGMENT@[53; 58) | 46 | COLONCOLON@[51; 53) |
45 | SUPER_KW@[53; 58) | 47 | PATH_SEGMENT@[53; 58) |
46 | COLONCOLON@[58; 60) | 48 | SUPER_KW@[53; 58) |
47 | PATH_SEGMENT@[60; 63) | 49 | COLONCOLON@[58; 60) |
48 | IDENT@[60; 63) | 50 | PATH_SEGMENT@[60; 63) |
51 | IDENT@[60; 63) | ||
49 | SEMI@[63; 64) | 52 | SEMI@[63; 64) |
50 | WHITESPACE@[64; 65) | 53 | WHITESPACE@[64; 65) |
diff --git a/tests/data/parser/ok/0014_use_tree.rs b/tests/data/parser/ok/0014_use_tree.rs new file mode 100644 index 000000000..5e4aa3a33 --- /dev/null +++ b/tests/data/parser/ok/0014_use_tree.rs | |||
@@ -0,0 +1,7 @@ | |||
1 | use *; | ||
2 | use ::*; | ||
3 | use ::{}; | ||
4 | use {}; | ||
5 | use foo::*; | ||
6 | use foo::{}; | ||
7 | use ::foo::{a, b, c}; | ||
diff --git a/tests/data/parser/ok/0014_use_tree.txt b/tests/data/parser/ok/0014_use_tree.txt new file mode 100644 index 000000000..ca91e63e1 --- /dev/null +++ b/tests/data/parser/ok/0014_use_tree.txt | |||
@@ -0,0 +1,85 @@ | |||
1 | FILE@[0; 81) | ||
2 | USE_ITEM@[0; 7) | ||
3 | USE_KW@[0; 3) | ||
4 | USE_TREE@[3; 5) | ||
5 | WHITESPACE@[3; 4) | ||
6 | STAR@[4; 5) | ||
7 | SEMI@[5; 6) | ||
8 | WHITESPACE@[6; 7) | ||
9 | USE_ITEM@[7; 16) | ||
10 | USE_KW@[7; 10) | ||
11 | USE_TREE@[10; 14) | ||
12 | WHITESPACE@[10; 11) | ||
13 | COLONCOLON@[11; 13) | ||
14 | STAR@[13; 14) | ||
15 | SEMI@[14; 15) | ||
16 | WHITESPACE@[15; 16) | ||
17 | USE_ITEM@[16; 26) | ||
18 | USE_KW@[16; 19) | ||
19 | USE_TREE@[19; 24) | ||
20 | WHITESPACE@[19; 20) | ||
21 | COLONCOLON@[20; 22) | ||
22 | L_CURLY@[22; 23) | ||
23 | R_CURLY@[23; 24) | ||
24 | SEMI@[24; 25) | ||
25 | WHITESPACE@[25; 26) | ||
26 | USE_ITEM@[26; 34) | ||
27 | USE_KW@[26; 29) | ||
28 | USE_TREE@[29; 32) | ||
29 | WHITESPACE@[29; 30) | ||
30 | L_CURLY@[30; 31) | ||
31 | R_CURLY@[31; 32) | ||
32 | SEMI@[32; 33) | ||
33 | WHITESPACE@[33; 34) | ||
34 | USE_ITEM@[34; 46) | ||
35 | USE_KW@[34; 37) | ||
36 | USE_TREE@[37; 44) | ||
37 | PATH@[37; 41) | ||
38 | PATH_SEGMENT@[37; 41) | ||
39 | WHITESPACE@[37; 38) | ||
40 | IDENT@[38; 41) | ||
41 | COLONCOLON@[41; 43) | ||
42 | STAR@[43; 44) | ||
43 | SEMI@[44; 45) | ||
44 | WHITESPACE@[45; 46) | ||
45 | USE_ITEM@[46; 59) | ||
46 | USE_KW@[46; 49) | ||
47 | USE_TREE@[49; 57) | ||
48 | PATH@[49; 53) | ||
49 | PATH_SEGMENT@[49; 53) | ||
50 | WHITESPACE@[49; 50) | ||
51 | IDENT@[50; 53) | ||
52 | COLONCOLON@[53; 55) | ||
53 | L_CURLY@[55; 56) | ||
54 | R_CURLY@[56; 57) | ||
55 | SEMI@[57; 58) | ||
56 | WHITESPACE@[58; 59) | ||
57 | USE_ITEM@[59; 81) | ||
58 | USE_KW@[59; 62) | ||
59 | USE_TREE@[62; 79) | ||
60 | PATH@[62; 68) | ||
61 | PATH_SEGMENT@[62; 68) | ||
62 | WHITESPACE@[62; 63) | ||
63 | COLONCOLON@[63; 65) | ||
64 | IDENT@[65; 68) | ||
65 | COLONCOLON@[68; 70) | ||
66 | L_CURLY@[70; 71) | ||
67 | USE_TREE@[71; 72) | ||
68 | PATH@[71; 72) | ||
69 | PATH_SEGMENT@[71; 72) | ||
70 | IDENT@[71; 72) | ||
71 | COMMA@[72; 73) | ||
72 | USE_TREE@[73; 75) | ||
73 | PATH@[73; 75) | ||
74 | PATH_SEGMENT@[73; 75) | ||
75 | WHITESPACE@[73; 74) | ||
76 | IDENT@[74; 75) | ||
77 | COMMA@[75; 76) | ||
78 | USE_TREE@[76; 78) | ||
79 | PATH@[76; 78) | ||
80 | PATH_SEGMENT@[76; 78) | ||
81 | WHITESPACE@[76; 77) | ||
82 | IDENT@[77; 78) | ||
83 | R_CURLY@[78; 79) | ||
84 | SEMI@[79; 80) | ||
85 | WHITESPACE@[80; 81) | ||
diff --git a/tests/data/parser/ok/0015_use_tree.rs b/tests/data/parser/ok/0015_use_tree.rs new file mode 100644 index 000000000..46a0783a2 --- /dev/null +++ b/tests/data/parser/ok/0015_use_tree.rs | |||
@@ -0,0 +1,2 @@ | |||
1 | use foo as bar; | ||
2 | use foo::{a as b, *, ::*, ::foo as x}; | ||
diff --git a/tests/data/parser/ok/0015_use_tree.txt b/tests/data/parser/ok/0015_use_tree.txt new file mode 100644 index 000000000..c1975f6cb --- /dev/null +++ b/tests/data/parser/ok/0015_use_tree.txt | |||
@@ -0,0 +1,57 @@ | |||
1 | FILE@[0; 55) | ||
2 | USE_ITEM@[0; 16) | ||
3 | USE_KW@[0; 3) | ||
4 | USE_TREE@[3; 14) | ||
5 | PATH@[3; 8) | ||
6 | PATH_SEGMENT@[3; 8) | ||
7 | WHITESPACE@[3; 4) | ||
8 | IDENT@[4; 7) | ||
9 | WHITESPACE@[7; 8) | ||
10 | ALIAS@[8; 14) | ||
11 | AS_KW@[8; 10) | ||
12 | WHITESPACE@[10; 11) | ||
13 | IDENT@[11; 14) | ||
14 | SEMI@[14; 15) | ||
15 | WHITESPACE@[15; 16) | ||
16 | USE_ITEM@[16; 55) | ||
17 | USE_KW@[16; 19) | ||
18 | USE_TREE@[19; 53) | ||
19 | PATH@[19; 23) | ||
20 | PATH_SEGMENT@[19; 23) | ||
21 | WHITESPACE@[19; 20) | ||
22 | IDENT@[20; 23) | ||
23 | COLONCOLON@[23; 25) | ||
24 | L_CURLY@[25; 26) | ||
25 | USE_TREE@[26; 32) | ||
26 | PATH@[26; 28) | ||
27 | PATH_SEGMENT@[26; 28) | ||
28 | IDENT@[26; 27) | ||
29 | WHITESPACE@[27; 28) | ||
30 | ALIAS@[28; 32) | ||
31 | AS_KW@[28; 30) | ||
32 | WHITESPACE@[30; 31) | ||
33 | IDENT@[31; 32) | ||
34 | COMMA@[32; 33) | ||
35 | USE_TREE@[33; 35) | ||
36 | WHITESPACE@[33; 34) | ||
37 | STAR@[34; 35) | ||
38 | COMMA@[35; 36) | ||
39 | USE_TREE@[36; 40) | ||
40 | WHITESPACE@[36; 37) | ||
41 | COLONCOLON@[37; 39) | ||
42 | STAR@[39; 40) | ||
43 | COMMA@[40; 41) | ||
44 | USE_TREE@[41; 52) | ||
45 | PATH@[41; 48) | ||
46 | PATH_SEGMENT@[41; 48) | ||
47 | WHITESPACE@[41; 42) | ||
48 | COLONCOLON@[42; 44) | ||
49 | IDENT@[44; 47) | ||
50 | WHITESPACE@[47; 48) | ||
51 | ALIAS@[48; 52) | ||
52 | AS_KW@[48; 50) | ||
53 | WHITESPACE@[50; 51) | ||
54 | IDENT@[51; 52) | ||
55 | R_CURLY@[52; 53) | ||
56 | SEMI@[53; 54) | ||
57 | WHITESPACE@[54; 55) | ||