diff options
author | Aleksey Kladov <[email protected]> | 2018-09-08 08:13:32 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-09-08 08:13:32 +0100 |
commit | bd3a26493f101039fb6fe97561a15bcfffea82f0 (patch) | |
tree | f2dc8fd63c50ceed11a96fa7a0736819f8dbbf18 /crates | |
parent | 44334f6f56bd99635f650796af0db8047e4c21c4 (diff) |
fix stuck parser
Diffstat (limited to 'crates')
7 files changed, 719 insertions, 2 deletions
diff --git a/crates/libsyntax2/src/grammar/expressions/atom.rs b/crates/libsyntax2/src/grammar/expressions/atom.rs index f8b50b355..2536bac80 100644 --- a/crates/libsyntax2/src/grammar/expressions/atom.rs +++ b/crates/libsyntax2/src/grammar/expressions/atom.rs | |||
@@ -140,9 +140,14 @@ fn array_expr(p: &mut Parser) -> CompletedMarker { | |||
140 | } | 140 | } |
141 | while !p.at(EOF) && !p.at(R_BRACK) { | 141 | while !p.at(EOF) && !p.at(R_BRACK) { |
142 | p.expect(COMMA); | 142 | p.expect(COMMA); |
143 | if !p.at(R_BRACK) { | 143 | if p.at(R_BRACK) { |
144 | expr(p); | 144 | break; |
145 | } | ||
146 | if !EXPR_FIRST.contains(p.current()) { | ||
147 | p.error("expected expression"); | ||
148 | break; | ||
145 | } | 149 | } |
150 | expr(p); | ||
146 | } | 151 | } |
147 | p.expect(R_BRACK); | 152 | p.expect(R_BRACK); |
148 | m.complete(p, ARRAY_EXPR) | 153 | m.complete(p, ARRAY_EXPR) |
diff --git a/crates/libsyntax2/src/grammar/expressions/mod.rs b/crates/libsyntax2/src/grammar/expressions/mod.rs index 9379ed938..f7b9f7086 100644 --- a/crates/libsyntax2/src/grammar/expressions/mod.rs +++ b/crates/libsyntax2/src/grammar/expressions/mod.rs | |||
@@ -376,6 +376,10 @@ fn arg_list(p: &mut Parser) { | |||
376 | let m = p.start(); | 376 | let m = p.start(); |
377 | p.bump(); | 377 | p.bump(); |
378 | while !p.at(R_PAREN) && !p.at(EOF) { | 378 | while !p.at(R_PAREN) && !p.at(EOF) { |
379 | if !EXPR_FIRST.contains(p.current()) { | ||
380 | p.error("expected expression"); | ||
381 | break; | ||
382 | } | ||
379 | expr(p); | 383 | expr(p); |
380 | if !p.at(R_PAREN) && !p.expect(COMMA) { | 384 | if !p.at(R_PAREN) && !p.expect(COMMA) { |
381 | break; | 385 | break; |
diff --git a/crates/libsyntax2/tests/data/parser/err/0022_bad_exprs.rs b/crates/libsyntax2/tests/data/parser/err/0022_bad_exprs.rs new file mode 100644 index 000000000..cd2d493a1 --- /dev/null +++ b/crates/libsyntax2/tests/data/parser/err/0022_bad_exprs.rs | |||
@@ -0,0 +1,3 @@ | |||
1 | fn a() { [1, 2, @, struct, let] } | ||
2 | fn b() { foo(1, 2, @, impl, let) } | ||
3 | fn c() { foo.bar(1, 2, @, ], trait, let) } | ||
diff --git a/crates/libsyntax2/tests/data/parser/err/0022_bad_exprs.txt b/crates/libsyntax2/tests/data/parser/err/0022_bad_exprs.txt new file mode 100644 index 000000000..287e56ac4 --- /dev/null +++ b/crates/libsyntax2/tests/data/parser/err/0022_bad_exprs.txt | |||
@@ -0,0 +1,189 @@ | |||
1 | ROOT@[0; 112) | ||
2 | FN_DEF@[0; 33) | ||
3 | FN_KW@[0; 2) | ||
4 | WHITESPACE@[2; 3) | ||
5 | NAME@[3; 4) | ||
6 | IDENT@[3; 4) "a" | ||
7 | PARAM_LIST@[4; 6) | ||
8 | L_PAREN@[4; 5) | ||
9 | R_PAREN@[5; 6) | ||
10 | WHITESPACE@[6; 7) | ||
11 | BLOCK@[7; 33) | ||
12 | L_CURLY@[7; 8) | ||
13 | WHITESPACE@[8; 9) | ||
14 | EXPR_STMT@[9; 15) | ||
15 | ARRAY_EXPR@[9; 15) | ||
16 | L_BRACK@[9; 10) | ||
17 | LITERAL@[10; 11) | ||
18 | INT_NUMBER@[10; 11) "1" | ||
19 | COMMA@[11; 12) | ||
20 | WHITESPACE@[12; 13) | ||
21 | LITERAL@[13; 14) | ||
22 | INT_NUMBER@[13; 14) "2" | ||
23 | COMMA@[14; 15) | ||
24 | err: `expected expression` | ||
25 | err: `expected R_BRACK` | ||
26 | err: `expected SEMI` | ||
27 | WHITESPACE@[15; 16) | ||
28 | err: `expected expression` | ||
29 | EXPR_STMT@[16; 17) | ||
30 | ERROR@[16; 17) | ||
31 | AT@[16; 17) | ||
32 | err: `expected SEMI` | ||
33 | err: `expected expression` | ||
34 | EXPR_STMT@[17; 18) | ||
35 | ERROR@[17; 18) | ||
36 | COMMA@[17; 18) | ||
37 | err: `expected SEMI` | ||
38 | WHITESPACE@[18; 19) | ||
39 | STRUCT_DEF@[19; 26) | ||
40 | STRUCT_KW@[19; 25) | ||
41 | err: `expected a name` | ||
42 | ERROR@[25; 26) | ||
43 | COMMA@[25; 26) | ||
44 | err: `expected `;`, `{`, or `(`` | ||
45 | WHITESPACE@[26; 27) | ||
46 | LET_STMT@[27; 31) | ||
47 | LET_KW@[27; 30) | ||
48 | err: `expected pattern` | ||
49 | ERROR@[30; 31) | ||
50 | R_BRACK@[30; 31) | ||
51 | err: `expected SEMI` | ||
52 | WHITESPACE@[31; 32) | ||
53 | R_CURLY@[32; 33) | ||
54 | WHITESPACE@[33; 34) | ||
55 | FN_DEF@[34; 68) | ||
56 | FN_KW@[34; 36) | ||
57 | WHITESPACE@[36; 37) | ||
58 | NAME@[37; 38) | ||
59 | IDENT@[37; 38) "b" | ||
60 | PARAM_LIST@[38; 40) | ||
61 | L_PAREN@[38; 39) | ||
62 | R_PAREN@[39; 40) | ||
63 | WHITESPACE@[40; 41) | ||
64 | BLOCK@[41; 68) | ||
65 | L_CURLY@[41; 42) | ||
66 | WHITESPACE@[42; 43) | ||
67 | EXPR_STMT@[43; 52) | ||
68 | CALL_EXPR@[43; 52) | ||
69 | PATH_EXPR@[43; 46) | ||
70 | PATH@[43; 46) | ||
71 | PATH_SEGMENT@[43; 46) | ||
72 | NAME_REF@[43; 46) | ||
73 | IDENT@[43; 46) "foo" | ||
74 | ARG_LIST@[46; 52) | ||
75 | L_PAREN@[46; 47) | ||
76 | LITERAL@[47; 48) | ||
77 | INT_NUMBER@[47; 48) "1" | ||
78 | COMMA@[48; 49) | ||
79 | WHITESPACE@[49; 50) | ||
80 | LITERAL@[50; 51) | ||
81 | INT_NUMBER@[50; 51) "2" | ||
82 | COMMA@[51; 52) | ||
83 | err: `expected expression` | ||
84 | err: `expected SEMI` | ||
85 | WHITESPACE@[52; 53) | ||
86 | err: `expected expression` | ||
87 | EXPR_STMT@[53; 54) | ||
88 | ERROR@[53; 54) | ||
89 | AT@[53; 54) | ||
90 | err: `expected SEMI` | ||
91 | err: `expected expression` | ||
92 | EXPR_STMT@[54; 55) | ||
93 | ERROR@[54; 55) | ||
94 | COMMA@[54; 55) | ||
95 | err: `expected SEMI` | ||
96 | WHITESPACE@[55; 56) | ||
97 | IMPL_ITEM@[56; 60) | ||
98 | IMPL_KW@[56; 60) | ||
99 | err: `expected type` | ||
100 | err: `expected `{`` | ||
101 | err: `expected expression` | ||
102 | EXPR_STMT@[60; 61) | ||
103 | ERROR@[60; 61) | ||
104 | COMMA@[60; 61) | ||
105 | err: `expected SEMI` | ||
106 | WHITESPACE@[61; 62) | ||
107 | LET_STMT@[62; 65) | ||
108 | LET_KW@[62; 65) | ||
109 | err: `expected pattern` | ||
110 | err: `expected SEMI` | ||
111 | err: `expected expression` | ||
112 | ERROR@[65; 66) | ||
113 | R_PAREN@[65; 66) | ||
114 | WHITESPACE@[66; 67) | ||
115 | R_CURLY@[67; 68) | ||
116 | WHITESPACE@[68; 69) | ||
117 | FN_DEF@[69; 111) | ||
118 | FN_KW@[69; 71) | ||
119 | WHITESPACE@[71; 72) | ||
120 | NAME@[72; 73) | ||
121 | IDENT@[72; 73) "c" | ||
122 | PARAM_LIST@[73; 75) | ||
123 | L_PAREN@[73; 74) | ||
124 | R_PAREN@[74; 75) | ||
125 | WHITESPACE@[75; 76) | ||
126 | BLOCK@[76; 111) | ||
127 | L_CURLY@[76; 77) | ||
128 | WHITESPACE@[77; 78) | ||
129 | EXPR_STMT@[78; 91) | ||
130 | METHOD_CALL_EXPR@[78; 91) | ||
131 | PATH_EXPR@[78; 81) | ||
132 | PATH@[78; 81) | ||
133 | PATH_SEGMENT@[78; 81) | ||
134 | NAME_REF@[78; 81) | ||
135 | IDENT@[78; 81) "foo" | ||
136 | DOT@[81; 82) | ||
137 | NAME_REF@[82; 85) | ||
138 | IDENT@[82; 85) "bar" | ||
139 | ARG_LIST@[85; 91) | ||
140 | L_PAREN@[85; 86) | ||
141 | LITERAL@[86; 87) | ||
142 | INT_NUMBER@[86; 87) "1" | ||
143 | COMMA@[87; 88) | ||
144 | WHITESPACE@[88; 89) | ||
145 | LITERAL@[89; 90) | ||
146 | INT_NUMBER@[89; 90) "2" | ||
147 | COMMA@[90; 91) | ||
148 | err: `expected expression` | ||
149 | err: `expected SEMI` | ||
150 | WHITESPACE@[91; 92) | ||
151 | err: `expected expression` | ||
152 | EXPR_STMT@[92; 93) | ||
153 | ERROR@[92; 93) | ||
154 | AT@[92; 93) | ||
155 | err: `expected SEMI` | ||
156 | err: `expected expression` | ||
157 | EXPR_STMT@[93; 94) | ||
158 | ERROR@[93; 94) | ||
159 | COMMA@[93; 94) | ||
160 | err: `expected SEMI` | ||
161 | WHITESPACE@[94; 95) | ||
162 | err: `expected expression` | ||
163 | EXPR_STMT@[95; 96) | ||
164 | ERROR@[95; 96) | ||
165 | R_BRACK@[95; 96) | ||
166 | err: `expected SEMI` | ||
167 | err: `expected expression` | ||
168 | EXPR_STMT@[96; 97) | ||
169 | ERROR@[96; 97) | ||
170 | COMMA@[96; 97) | ||
171 | err: `expected SEMI` | ||
172 | WHITESPACE@[97; 98) | ||
173 | TRAIT_DEF@[98; 104) | ||
174 | TRAIT_KW@[98; 103) | ||
175 | err: `expected a name` | ||
176 | ERROR@[103; 104) | ||
177 | COMMA@[103; 104) | ||
178 | err: `expected `{`` | ||
179 | WHITESPACE@[104; 105) | ||
180 | LET_STMT@[105; 108) | ||
181 | LET_KW@[105; 108) | ||
182 | err: `expected pattern` | ||
183 | err: `expected SEMI` | ||
184 | err: `expected expression` | ||
185 | ERROR@[108; 109) | ||
186 | R_PAREN@[108; 109) | ||
187 | WHITESPACE@[109; 110) | ||
188 | R_CURLY@[110; 111) | ||
189 | WHITESPACE@[111; 112) | ||
diff --git a/crates/libsyntax2/tests/data/parser/ok/0034_macro_2.0.rs b/crates/libsyntax2/tests/data/parser/ok/0034_macro_2.0.rs new file mode 100644 index 000000000..2a70ee83a --- /dev/null +++ b/crates/libsyntax2/tests/data/parser/ok/0034_macro_2.0.rs | |||
@@ -0,0 +1,16 @@ | |||
1 | macro parse_use_trees($($s:expr),* $(,)*) { | ||
2 | vec![ | ||
3 | $(parse_use_tree($s),)* | ||
4 | ] | ||
5 | } | ||
6 | |||
7 | #[test] | ||
8 | fn test_use_tree_merge() { | ||
9 | macro test_merge([$($input:expr),* $(,)*], [$($output:expr),* $(,)*]) { | ||
10 | assert_eq!( | ||
11 | merge_use_trees(parse_use_trees!($($input,)*)), | ||
12 | parse_use_trees!($($output,)*), | ||
13 | ); | ||
14 | } | ||
15 | } | ||
16 | |||
diff --git a/crates/libsyntax2/tests/data/parser/ok/0034_macro_2.0.txt b/crates/libsyntax2/tests/data/parser/ok/0034_macro_2.0.txt new file mode 100644 index 000000000..1a8ca761d --- /dev/null +++ b/crates/libsyntax2/tests/data/parser/ok/0034_macro_2.0.txt | |||
@@ -0,0 +1,250 @@ | |||
1 | ROOT@[0; 350) | ||
2 | MACRO_CALL@[0; 41) | ||
3 | PATH@[0; 5) | ||
4 | PATH_SEGMENT@[0; 5) | ||
5 | NAME_REF@[0; 5) | ||
6 | IDENT@[0; 5) "macro" | ||
7 | err: `expected EXCL` | ||
8 | WHITESPACE@[5; 6) | ||
9 | IDENT@[6; 21) "parse_use_trees" | ||
10 | TOKEN_TREE@[21; 41) | ||
11 | L_PAREN@[21; 22) | ||
12 | DOLLAR@[22; 23) | ||
13 | TOKEN_TREE@[23; 32) | ||
14 | L_PAREN@[23; 24) | ||
15 | DOLLAR@[24; 25) | ||
16 | IDENT@[25; 26) "s" | ||
17 | COLON@[26; 27) | ||
18 | IDENT@[27; 31) "expr" | ||
19 | R_PAREN@[31; 32) | ||
20 | COMMA@[32; 33) | ||
21 | STAR@[33; 34) | ||
22 | WHITESPACE@[34; 35) | ||
23 | DOLLAR@[35; 36) | ||
24 | TOKEN_TREE@[36; 39) | ||
25 | L_PAREN@[36; 37) | ||
26 | COMMA@[37; 38) | ||
27 | R_PAREN@[38; 39) | ||
28 | STAR@[39; 40) | ||
29 | R_PAREN@[40; 41) | ||
30 | err: `expected SEMI` | ||
31 | WHITESPACE@[41; 42) | ||
32 | err: `expected an item` | ||
33 | ERROR@[42; 93) | ||
34 | L_CURLY@[42; 43) | ||
35 | WHITESPACE@[43; 48) | ||
36 | IDENT@[48; 51) "vec" | ||
37 | EXCL@[51; 52) | ||
38 | L_BRACK@[52; 53) | ||
39 | WHITESPACE@[53; 62) | ||
40 | DOLLAR@[62; 63) | ||
41 | L_PAREN@[63; 64) | ||
42 | IDENT@[64; 78) "parse_use_tree" | ||
43 | L_PAREN@[78; 79) | ||
44 | DOLLAR@[79; 80) | ||
45 | IDENT@[80; 81) "s" | ||
46 | R_PAREN@[81; 82) | ||
47 | COMMA@[82; 83) | ||
48 | R_PAREN@[83; 84) | ||
49 | STAR@[84; 85) | ||
50 | WHITESPACE@[85; 90) | ||
51 | R_BRACK@[90; 91) | ||
52 | WHITESPACE@[91; 92) | ||
53 | R_CURLY@[92; 93) | ||
54 | WHITESPACE@[93; 95) | ||
55 | FN_DEF@[95; 348) | ||
56 | ATTR@[95; 102) | ||
57 | POUND@[95; 96) | ||
58 | TOKEN_TREE@[96; 102) | ||
59 | L_BRACK@[96; 97) | ||
60 | IDENT@[97; 101) "test" | ||
61 | R_BRACK@[101; 102) | ||
62 | WHITESPACE@[102; 103) | ||
63 | FN_KW@[103; 105) | ||
64 | WHITESPACE@[105; 106) | ||
65 | NAME@[106; 125) | ||
66 | IDENT@[106; 125) "test_use_tree_merge" | ||
67 | PARAM_LIST@[125; 127) | ||
68 | L_PAREN@[125; 126) | ||
69 | R_PAREN@[126; 127) | ||
70 | WHITESPACE@[127; 128) | ||
71 | BLOCK@[128; 348) | ||
72 | L_CURLY@[128; 129) | ||
73 | WHITESPACE@[129; 134) | ||
74 | EXPR_STMT@[134; 139) | ||
75 | PATH_EXPR@[134; 139) | ||
76 | PATH@[134; 139) | ||
77 | PATH_SEGMENT@[134; 139) | ||
78 | NAME_REF@[134; 139) | ||
79 | IDENT@[134; 139) "macro" | ||
80 | err: `expected SEMI` | ||
81 | WHITESPACE@[139; 140) | ||
82 | EXPR_STMT@[140; 203) | ||
83 | CALL_EXPR@[140; 203) | ||
84 | PATH_EXPR@[140; 150) | ||
85 | PATH@[140; 150) | ||
86 | PATH_SEGMENT@[140; 150) | ||
87 | NAME_REF@[140; 150) | ||
88 | IDENT@[140; 150) "test_merge" | ||
89 | ARG_LIST@[150; 203) | ||
90 | L_PAREN@[150; 151) | ||
91 | ARRAY_EXPR@[151; 202) | ||
92 | L_BRACK@[151; 152) | ||
93 | err: `expected expression` | ||
94 | ERROR@[152; 153) | ||
95 | DOLLAR@[152; 153) | ||
96 | err: `expected COMMA` | ||
97 | TUPLE_EXPR@[153; 166) | ||
98 | L_PAREN@[153; 154) | ||
99 | err: `expected expression` | ||
100 | ERROR@[154; 155) | ||
101 | DOLLAR@[154; 155) | ||
102 | err: `expected COMMA` | ||
103 | PATH_EXPR@[155; 160) | ||
104 | PATH@[155; 160) | ||
105 | PATH_SEGMENT@[155; 160) | ||
106 | NAME_REF@[155; 160) | ||
107 | IDENT@[155; 160) "input" | ||
108 | err: `expected COMMA` | ||
109 | err: `expected expression` | ||
110 | ERROR@[160; 161) | ||
111 | COLON@[160; 161) | ||
112 | err: `expected COMMA` | ||
113 | PATH_EXPR@[161; 165) | ||
114 | PATH@[161; 165) | ||
115 | PATH_SEGMENT@[161; 165) | ||
116 | NAME_REF@[161; 165) | ||
117 | IDENT@[161; 165) "expr" | ||
118 | R_PAREN@[165; 166) | ||
119 | COMMA@[166; 167) | ||
120 | PREFIX_EXPR@[167; 170) | ||
121 | STAR@[167; 168) | ||
122 | WHITESPACE@[168; 169) | ||
123 | err: `expected expression` | ||
124 | ERROR@[169; 170) | ||
125 | DOLLAR@[169; 170) | ||
126 | err: `expected COMMA` | ||
127 | BIN_EXPR@[170; 175) | ||
128 | PAREN_EXPR@[170; 173) | ||
129 | L_PAREN@[170; 171) | ||
130 | err: `expected expression` | ||
131 | ERROR@[171; 172) | ||
132 | COMMA@[171; 172) | ||
133 | R_PAREN@[172; 173) | ||
134 | STAR@[173; 174) | ||
135 | err: `expected expression` | ||
136 | ERROR@[174; 175) | ||
137 | R_BRACK@[174; 175) | ||
138 | COMMA@[175; 176) | ||
139 | WHITESPACE@[176; 177) | ||
140 | ARRAY_EXPR@[177; 202) | ||
141 | L_BRACK@[177; 178) | ||
142 | err: `expected expression` | ||
143 | ERROR@[178; 179) | ||
144 | DOLLAR@[178; 179) | ||
145 | err: `expected COMMA` | ||
146 | TUPLE_EXPR@[179; 193) | ||
147 | L_PAREN@[179; 180) | ||
148 | err: `expected expression` | ||
149 | ERROR@[180; 181) | ||
150 | DOLLAR@[180; 181) | ||
151 | err: `expected COMMA` | ||
152 | PATH_EXPR@[181; 187) | ||
153 | PATH@[181; 187) | ||
154 | PATH_SEGMENT@[181; 187) | ||
155 | NAME_REF@[181; 187) | ||
156 | IDENT@[181; 187) "output" | ||
157 | err: `expected COMMA` | ||
158 | err: `expected expression` | ||
159 | ERROR@[187; 188) | ||
160 | COLON@[187; 188) | ||
161 | err: `expected COMMA` | ||
162 | PATH_EXPR@[188; 192) | ||
163 | PATH@[188; 192) | ||
164 | PATH_SEGMENT@[188; 192) | ||
165 | NAME_REF@[188; 192) | ||
166 | IDENT@[188; 192) "expr" | ||
167 | R_PAREN@[192; 193) | ||
168 | COMMA@[193; 194) | ||
169 | PREFIX_EXPR@[194; 197) | ||
170 | STAR@[194; 195) | ||
171 | WHITESPACE@[195; 196) | ||
172 | err: `expected expression` | ||
173 | ERROR@[196; 197) | ||
174 | DOLLAR@[196; 197) | ||
175 | err: `expected COMMA` | ||
176 | BIN_EXPR@[197; 202) | ||
177 | PAREN_EXPR@[197; 200) | ||
178 | L_PAREN@[197; 198) | ||
179 | err: `expected expression` | ||
180 | ERROR@[198; 199) | ||
181 | COMMA@[198; 199) | ||
182 | R_PAREN@[199; 200) | ||
183 | STAR@[200; 201) | ||
184 | err: `expected expression` | ||
185 | ERROR@[201; 202) | ||
186 | R_BRACK@[201; 202) | ||
187 | err: `expected COMMA` | ||
188 | err: `expected expression` | ||
189 | err: `expected R_BRACK` | ||
190 | err: `expected COMMA` | ||
191 | err: `expected expression` | ||
192 | err: `expected R_BRACK` | ||
193 | R_PAREN@[202; 203) | ||
194 | err: `expected SEMI` | ||
195 | WHITESPACE@[203; 204) | ||
196 | BLOCK_EXPR@[204; 346) | ||
197 | BLOCK@[204; 346) | ||
198 | L_CURLY@[204; 205) | ||
199 | WHITESPACE@[205; 214) | ||
200 | EXPR_STMT@[214; 340) | ||
201 | MACRO_CALL@[214; 339) | ||
202 | PATH@[214; 223) | ||
203 | PATH_SEGMENT@[214; 223) | ||
204 | NAME_REF@[214; 223) | ||
205 | IDENT@[214; 223) "assert_eq" | ||
206 | EXCL@[223; 224) | ||
207 | TOKEN_TREE@[224; 339) | ||
208 | L_PAREN@[224; 225) | ||
209 | WHITESPACE@[225; 238) | ||
210 | IDENT@[238; 253) "merge_use_trees" | ||
211 | TOKEN_TREE@[253; 284) | ||
212 | L_PAREN@[253; 254) | ||
213 | IDENT@[254; 269) "parse_use_trees" | ||
214 | EXCL@[269; 270) | ||
215 | TOKEN_TREE@[270; 283) | ||
216 | L_PAREN@[270; 271) | ||
217 | DOLLAR@[271; 272) | ||
218 | TOKEN_TREE@[272; 281) | ||
219 | L_PAREN@[272; 273) | ||
220 | DOLLAR@[273; 274) | ||
221 | IDENT@[274; 279) "input" | ||
222 | COMMA@[279; 280) | ||
223 | R_PAREN@[280; 281) | ||
224 | STAR@[281; 282) | ||
225 | R_PAREN@[282; 283) | ||
226 | R_PAREN@[283; 284) | ||
227 | COMMA@[284; 285) | ||
228 | WHITESPACE@[285; 298) | ||
229 | IDENT@[298; 313) "parse_use_trees" | ||
230 | EXCL@[313; 314) | ||
231 | TOKEN_TREE@[314; 328) | ||
232 | L_PAREN@[314; 315) | ||
233 | DOLLAR@[315; 316) | ||
234 | TOKEN_TREE@[316; 326) | ||
235 | L_PAREN@[316; 317) | ||
236 | DOLLAR@[317; 318) | ||
237 | IDENT@[318; 324) "output" | ||
238 | COMMA@[324; 325) | ||
239 | R_PAREN@[325; 326) | ||
240 | STAR@[326; 327) | ||
241 | R_PAREN@[327; 328) | ||
242 | COMMA@[328; 329) | ||
243 | WHITESPACE@[329; 338) | ||
244 | R_PAREN@[338; 339) | ||
245 | SEMI@[339; 340) | ||
246 | WHITESPACE@[340; 345) | ||
247 | R_CURLY@[345; 346) | ||
248 | WHITESPACE@[346; 347) | ||
249 | R_CURLY@[347; 348) | ||
250 | WHITESPACE@[348; 350) | ||
diff --git a/crates/libsyntax2/tests/data/parser/ok/0034_macro_stuck.txt b/crates/libsyntax2/tests/data/parser/ok/0034_macro_stuck.txt new file mode 100644 index 000000000..1a8ca761d --- /dev/null +++ b/crates/libsyntax2/tests/data/parser/ok/0034_macro_stuck.txt | |||
@@ -0,0 +1,250 @@ | |||
1 | ROOT@[0; 350) | ||
2 | MACRO_CALL@[0; 41) | ||
3 | PATH@[0; 5) | ||
4 | PATH_SEGMENT@[0; 5) | ||
5 | NAME_REF@[0; 5) | ||
6 | IDENT@[0; 5) "macro" | ||
7 | err: `expected EXCL` | ||
8 | WHITESPACE@[5; 6) | ||
9 | IDENT@[6; 21) "parse_use_trees" | ||
10 | TOKEN_TREE@[21; 41) | ||
11 | L_PAREN@[21; 22) | ||
12 | DOLLAR@[22; 23) | ||
13 | TOKEN_TREE@[23; 32) | ||
14 | L_PAREN@[23; 24) | ||
15 | DOLLAR@[24; 25) | ||
16 | IDENT@[25; 26) "s" | ||
17 | COLON@[26; 27) | ||
18 | IDENT@[27; 31) "expr" | ||
19 | R_PAREN@[31; 32) | ||
20 | COMMA@[32; 33) | ||
21 | STAR@[33; 34) | ||
22 | WHITESPACE@[34; 35) | ||
23 | DOLLAR@[35; 36) | ||
24 | TOKEN_TREE@[36; 39) | ||
25 | L_PAREN@[36; 37) | ||
26 | COMMA@[37; 38) | ||
27 | R_PAREN@[38; 39) | ||
28 | STAR@[39; 40) | ||
29 | R_PAREN@[40; 41) | ||
30 | err: `expected SEMI` | ||
31 | WHITESPACE@[41; 42) | ||
32 | err: `expected an item` | ||
33 | ERROR@[42; 93) | ||
34 | L_CURLY@[42; 43) | ||
35 | WHITESPACE@[43; 48) | ||
36 | IDENT@[48; 51) "vec" | ||
37 | EXCL@[51; 52) | ||
38 | L_BRACK@[52; 53) | ||
39 | WHITESPACE@[53; 62) | ||
40 | DOLLAR@[62; 63) | ||
41 | L_PAREN@[63; 64) | ||
42 | IDENT@[64; 78) "parse_use_tree" | ||
43 | L_PAREN@[78; 79) | ||
44 | DOLLAR@[79; 80) | ||
45 | IDENT@[80; 81) "s" | ||
46 | R_PAREN@[81; 82) | ||
47 | COMMA@[82; 83) | ||
48 | R_PAREN@[83; 84) | ||
49 | STAR@[84; 85) | ||
50 | WHITESPACE@[85; 90) | ||
51 | R_BRACK@[90; 91) | ||
52 | WHITESPACE@[91; 92) | ||
53 | R_CURLY@[92; 93) | ||
54 | WHITESPACE@[93; 95) | ||
55 | FN_DEF@[95; 348) | ||
56 | ATTR@[95; 102) | ||
57 | POUND@[95; 96) | ||
58 | TOKEN_TREE@[96; 102) | ||
59 | L_BRACK@[96; 97) | ||
60 | IDENT@[97; 101) "test" | ||
61 | R_BRACK@[101; 102) | ||
62 | WHITESPACE@[102; 103) | ||
63 | FN_KW@[103; 105) | ||
64 | WHITESPACE@[105; 106) | ||
65 | NAME@[106; 125) | ||
66 | IDENT@[106; 125) "test_use_tree_merge" | ||
67 | PARAM_LIST@[125; 127) | ||
68 | L_PAREN@[125; 126) | ||
69 | R_PAREN@[126; 127) | ||
70 | WHITESPACE@[127; 128) | ||
71 | BLOCK@[128; 348) | ||
72 | L_CURLY@[128; 129) | ||
73 | WHITESPACE@[129; 134) | ||
74 | EXPR_STMT@[134; 139) | ||
75 | PATH_EXPR@[134; 139) | ||
76 | PATH@[134; 139) | ||
77 | PATH_SEGMENT@[134; 139) | ||
78 | NAME_REF@[134; 139) | ||
79 | IDENT@[134; 139) "macro" | ||
80 | err: `expected SEMI` | ||
81 | WHITESPACE@[139; 140) | ||
82 | EXPR_STMT@[140; 203) | ||
83 | CALL_EXPR@[140; 203) | ||
84 | PATH_EXPR@[140; 150) | ||
85 | PATH@[140; 150) | ||
86 | PATH_SEGMENT@[140; 150) | ||
87 | NAME_REF@[140; 150) | ||
88 | IDENT@[140; 150) "test_merge" | ||
89 | ARG_LIST@[150; 203) | ||
90 | L_PAREN@[150; 151) | ||
91 | ARRAY_EXPR@[151; 202) | ||
92 | L_BRACK@[151; 152) | ||
93 | err: `expected expression` | ||
94 | ERROR@[152; 153) | ||
95 | DOLLAR@[152; 153) | ||
96 | err: `expected COMMA` | ||
97 | TUPLE_EXPR@[153; 166) | ||
98 | L_PAREN@[153; 154) | ||
99 | err: `expected expression` | ||
100 | ERROR@[154; 155) | ||
101 | DOLLAR@[154; 155) | ||
102 | err: `expected COMMA` | ||
103 | PATH_EXPR@[155; 160) | ||
104 | PATH@[155; 160) | ||
105 | PATH_SEGMENT@[155; 160) | ||
106 | NAME_REF@[155; 160) | ||
107 | IDENT@[155; 160) "input" | ||
108 | err: `expected COMMA` | ||
109 | err: `expected expression` | ||
110 | ERROR@[160; 161) | ||
111 | COLON@[160; 161) | ||
112 | err: `expected COMMA` | ||
113 | PATH_EXPR@[161; 165) | ||
114 | PATH@[161; 165) | ||
115 | PATH_SEGMENT@[161; 165) | ||
116 | NAME_REF@[161; 165) | ||
117 | IDENT@[161; 165) "expr" | ||
118 | R_PAREN@[165; 166) | ||
119 | COMMA@[166; 167) | ||
120 | PREFIX_EXPR@[167; 170) | ||
121 | STAR@[167; 168) | ||
122 | WHITESPACE@[168; 169) | ||
123 | err: `expected expression` | ||
124 | ERROR@[169; 170) | ||
125 | DOLLAR@[169; 170) | ||
126 | err: `expected COMMA` | ||
127 | BIN_EXPR@[170; 175) | ||
128 | PAREN_EXPR@[170; 173) | ||
129 | L_PAREN@[170; 171) | ||
130 | err: `expected expression` | ||
131 | ERROR@[171; 172) | ||
132 | COMMA@[171; 172) | ||
133 | R_PAREN@[172; 173) | ||
134 | STAR@[173; 174) | ||
135 | err: `expected expression` | ||
136 | ERROR@[174; 175) | ||
137 | R_BRACK@[174; 175) | ||
138 | COMMA@[175; 176) | ||
139 | WHITESPACE@[176; 177) | ||
140 | ARRAY_EXPR@[177; 202) | ||
141 | L_BRACK@[177; 178) | ||
142 | err: `expected expression` | ||
143 | ERROR@[178; 179) | ||
144 | DOLLAR@[178; 179) | ||
145 | err: `expected COMMA` | ||
146 | TUPLE_EXPR@[179; 193) | ||
147 | L_PAREN@[179; 180) | ||
148 | err: `expected expression` | ||
149 | ERROR@[180; 181) | ||
150 | DOLLAR@[180; 181) | ||
151 | err: `expected COMMA` | ||
152 | PATH_EXPR@[181; 187) | ||
153 | PATH@[181; 187) | ||
154 | PATH_SEGMENT@[181; 187) | ||
155 | NAME_REF@[181; 187) | ||
156 | IDENT@[181; 187) "output" | ||
157 | err: `expected COMMA` | ||
158 | err: `expected expression` | ||
159 | ERROR@[187; 188) | ||
160 | COLON@[187; 188) | ||
161 | err: `expected COMMA` | ||
162 | PATH_EXPR@[188; 192) | ||
163 | PATH@[188; 192) | ||
164 | PATH_SEGMENT@[188; 192) | ||
165 | NAME_REF@[188; 192) | ||
166 | IDENT@[188; 192) "expr" | ||
167 | R_PAREN@[192; 193) | ||
168 | COMMA@[193; 194) | ||
169 | PREFIX_EXPR@[194; 197) | ||
170 | STAR@[194; 195) | ||
171 | WHITESPACE@[195; 196) | ||
172 | err: `expected expression` | ||
173 | ERROR@[196; 197) | ||
174 | DOLLAR@[196; 197) | ||
175 | err: `expected COMMA` | ||
176 | BIN_EXPR@[197; 202) | ||
177 | PAREN_EXPR@[197; 200) | ||
178 | L_PAREN@[197; 198) | ||
179 | err: `expected expression` | ||
180 | ERROR@[198; 199) | ||
181 | COMMA@[198; 199) | ||
182 | R_PAREN@[199; 200) | ||
183 | STAR@[200; 201) | ||
184 | err: `expected expression` | ||
185 | ERROR@[201; 202) | ||
186 | R_BRACK@[201; 202) | ||
187 | err: `expected COMMA` | ||
188 | err: `expected expression` | ||
189 | err: `expected R_BRACK` | ||
190 | err: `expected COMMA` | ||
191 | err: `expected expression` | ||
192 | err: `expected R_BRACK` | ||
193 | R_PAREN@[202; 203) | ||
194 | err: `expected SEMI` | ||
195 | WHITESPACE@[203; 204) | ||
196 | BLOCK_EXPR@[204; 346) | ||
197 | BLOCK@[204; 346) | ||
198 | L_CURLY@[204; 205) | ||
199 | WHITESPACE@[205; 214) | ||
200 | EXPR_STMT@[214; 340) | ||
201 | MACRO_CALL@[214; 339) | ||
202 | PATH@[214; 223) | ||
203 | PATH_SEGMENT@[214; 223) | ||
204 | NAME_REF@[214; 223) | ||
205 | IDENT@[214; 223) "assert_eq" | ||
206 | EXCL@[223; 224) | ||
207 | TOKEN_TREE@[224; 339) | ||
208 | L_PAREN@[224; 225) | ||
209 | WHITESPACE@[225; 238) | ||
210 | IDENT@[238; 253) "merge_use_trees" | ||
211 | TOKEN_TREE@[253; 284) | ||
212 | L_PAREN@[253; 254) | ||
213 | IDENT@[254; 269) "parse_use_trees" | ||
214 | EXCL@[269; 270) | ||
215 | TOKEN_TREE@[270; 283) | ||
216 | L_PAREN@[270; 271) | ||
217 | DOLLAR@[271; 272) | ||
218 | TOKEN_TREE@[272; 281) | ||
219 | L_PAREN@[272; 273) | ||
220 | DOLLAR@[273; 274) | ||
221 | IDENT@[274; 279) "input" | ||
222 | COMMA@[279; 280) | ||
223 | R_PAREN@[280; 281) | ||
224 | STAR@[281; 282) | ||
225 | R_PAREN@[282; 283) | ||
226 | R_PAREN@[283; 284) | ||
227 | COMMA@[284; 285) | ||
228 | WHITESPACE@[285; 298) | ||
229 | IDENT@[298; 313) "parse_use_trees" | ||
230 | EXCL@[313; 314) | ||
231 | TOKEN_TREE@[314; 328) | ||
232 | L_PAREN@[314; 315) | ||
233 | DOLLAR@[315; 316) | ||
234 | TOKEN_TREE@[316; 326) | ||
235 | L_PAREN@[316; 317) | ||
236 | DOLLAR@[317; 318) | ||
237 | IDENT@[318; 324) "output" | ||
238 | COMMA@[324; 325) | ||
239 | R_PAREN@[325; 326) | ||
240 | STAR@[326; 327) | ||
241 | R_PAREN@[327; 328) | ||
242 | COMMA@[328; 329) | ||
243 | WHITESPACE@[329; 338) | ||
244 | R_PAREN@[338; 339) | ||
245 | SEMI@[339; 340) | ||
246 | WHITESPACE@[340; 345) | ||
247 | R_CURLY@[345; 346) | ||
248 | WHITESPACE@[346; 347) | ||
249 | R_CURLY@[347; 348) | ||
250 | WHITESPACE@[348; 350) | ||