diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-12-21 10:47:47 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-21 10:47:47 +0000 |
commit | 90ef070db3dce0a7acb9cd11d0b0d72de13c9d79 (patch) | |
tree | c6fcc8c77fe4948b356e397fb5fe1f8e8ac39037 /crates/ra_syntax/test_data/parser/err | |
parent | 3ebf15c9b29b1fed6319d04f540ad48cd4bd6995 (diff) | |
parent | 4195c0e5f9a3db7646d4df28aa8c77a863c35759 (diff) |
Merge #2628
2628: Add macro 2.0 support in parser r=matklad a=edwin0cheng
This PR added a new syntax kind : `MACRO_DEF` and a keyword `MACRO_KW`
there are two syntax for declarative macro 2.0 :
1. Normal : `macro m { ($i:ident) => {} }` , which handle similar to legacy one.
2. Call like: `macro m($i:ident) {}`, it produces a single token tree which have two child token trees : `($i:ident)` and `{}`
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_syntax/test_data/parser/err')
-rw-r--r-- | crates/ra_syntax/test_data/parser/err/0028_macro_2.0.rs | 15 | ||||
-rw-r--r-- | crates/ra_syntax/test_data/parser/err/0028_macro_2.0.txt | 328 |
2 files changed, 0 insertions, 343 deletions
diff --git a/crates/ra_syntax/test_data/parser/err/0028_macro_2.0.rs b/crates/ra_syntax/test_data/parser/err/0028_macro_2.0.rs deleted file mode 100644 index 781047ba1..000000000 --- a/crates/ra_syntax/test_data/parser/err/0028_macro_2.0.rs +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
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 | } | ||
diff --git a/crates/ra_syntax/test_data/parser/err/0028_macro_2.0.txt b/crates/ra_syntax/test_data/parser/err/0028_macro_2.0.txt deleted file mode 100644 index c5be73a5a..000000000 --- a/crates/ra_syntax/test_data/parser/err/0028_macro_2.0.txt +++ /dev/null | |||
@@ -1,328 +0,0 @@ | |||
1 | SOURCE_FILE@[0; 349) | ||
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 | WHITESPACE@[5; 6) " " | ||
8 | NAME@[6; 21) | ||
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 | WHITESPACE@[41; 42) " " | ||
31 | ERROR@[42; 93) | ||
32 | L_CURLY@[42; 43) "{" | ||
33 | WHITESPACE@[43; 48) "\n " | ||
34 | MACRO_CALL@[48; 91) | ||
35 | PATH@[48; 51) | ||
36 | PATH_SEGMENT@[48; 51) | ||
37 | NAME_REF@[48; 51) | ||
38 | IDENT@[48; 51) "vec" | ||
39 | EXCL@[51; 52) "!" | ||
40 | TOKEN_TREE@[52; 91) | ||
41 | L_BRACK@[52; 53) "[" | ||
42 | WHITESPACE@[53; 62) "\n " | ||
43 | DOLLAR@[62; 63) "$" | ||
44 | TOKEN_TREE@[63; 84) | ||
45 | L_PAREN@[63; 64) "(" | ||
46 | IDENT@[64; 78) "parse_use_tree" | ||
47 | TOKEN_TREE@[78; 82) | ||
48 | L_PAREN@[78; 79) "(" | ||
49 | DOLLAR@[79; 80) "$" | ||
50 | IDENT@[80; 81) "s" | ||
51 | R_PAREN@[81; 82) ")" | ||
52 | COMMA@[82; 83) "," | ||
53 | R_PAREN@[83; 84) ")" | ||
54 | STAR@[84; 85) "*" | ||
55 | WHITESPACE@[85; 90) "\n " | ||
56 | R_BRACK@[90; 91) "]" | ||
57 | WHITESPACE@[91; 92) "\n" | ||
58 | R_CURLY@[92; 93) "}" | ||
59 | WHITESPACE@[93; 95) "\n\n" | ||
60 | FN_DEF@[95; 348) | ||
61 | ATTR@[95; 102) | ||
62 | POUND@[95; 96) "#" | ||
63 | L_BRACK@[96; 97) "[" | ||
64 | PATH@[97; 101) | ||
65 | PATH_SEGMENT@[97; 101) | ||
66 | NAME_REF@[97; 101) | ||
67 | IDENT@[97; 101) "test" | ||
68 | R_BRACK@[101; 102) "]" | ||
69 | WHITESPACE@[102; 103) "\n" | ||
70 | FN_KW@[103; 105) "fn" | ||
71 | WHITESPACE@[105; 106) " " | ||
72 | NAME@[106; 125) | ||
73 | IDENT@[106; 125) "test_use_tree_merge" | ||
74 | PARAM_LIST@[125; 127) | ||
75 | L_PAREN@[125; 126) "(" | ||
76 | R_PAREN@[126; 127) ")" | ||
77 | WHITESPACE@[127; 128) " " | ||
78 | BLOCK_EXPR@[128; 348) | ||
79 | BLOCK@[128; 348) | ||
80 | L_CURLY@[128; 129) "{" | ||
81 | WHITESPACE@[129; 134) "\n " | ||
82 | EXPR_STMT@[134; 139) | ||
83 | PATH_EXPR@[134; 139) | ||
84 | PATH@[134; 139) | ||
85 | PATH_SEGMENT@[134; 139) | ||
86 | NAME_REF@[134; 139) | ||
87 | IDENT@[134; 139) "macro" | ||
88 | WHITESPACE@[139; 140) " " | ||
89 | EXPR_STMT@[140; 154) | ||
90 | CALL_EXPR@[140; 154) | ||
91 | PATH_EXPR@[140; 150) | ||
92 | PATH@[140; 150) | ||
93 | PATH_SEGMENT@[140; 150) | ||
94 | NAME_REF@[140; 150) | ||
95 | IDENT@[140; 150) "test_merge" | ||
96 | ARG_LIST@[150; 154) | ||
97 | L_PAREN@[150; 151) "(" | ||
98 | ARRAY_EXPR@[151; 154) | ||
99 | L_BRACK@[151; 152) "[" | ||
100 | ERROR@[152; 153) | ||
101 | DOLLAR@[152; 153) "$" | ||
102 | PAREN_EXPR@[153; 154) | ||
103 | L_PAREN@[153; 154) "(" | ||
104 | EXPR_STMT@[154; 155) | ||
105 | ERROR@[154; 155) | ||
106 | DOLLAR@[154; 155) "$" | ||
107 | EXPR_STMT@[155; 160) | ||
108 | PATH_EXPR@[155; 160) | ||
109 | PATH@[155; 160) | ||
110 | PATH_SEGMENT@[155; 160) | ||
111 | NAME_REF@[155; 160) | ||
112 | IDENT@[155; 160) "input" | ||
113 | EXPR_STMT@[160; 161) | ||
114 | ERROR@[160; 161) | ||
115 | COLON@[160; 161) ":" | ||
116 | EXPR_STMT@[161; 165) | ||
117 | PATH_EXPR@[161; 165) | ||
118 | PATH@[161; 165) | ||
119 | PATH_SEGMENT@[161; 165) | ||
120 | NAME_REF@[161; 165) | ||
121 | IDENT@[161; 165) "expr" | ||
122 | EXPR_STMT@[165; 166) | ||
123 | ERROR@[165; 166) | ||
124 | R_PAREN@[165; 166) ")" | ||
125 | EXPR_STMT@[166; 167) | ||
126 | ERROR@[166; 167) | ||
127 | COMMA@[166; 167) "," | ||
128 | EXPR_STMT@[167; 170) | ||
129 | PREFIX_EXPR@[167; 170) | ||
130 | STAR@[167; 168) "*" | ||
131 | WHITESPACE@[168; 169) " " | ||
132 | ERROR@[169; 170) | ||
133 | DOLLAR@[169; 170) "$" | ||
134 | EXPR_STMT@[170; 171) | ||
135 | PAREN_EXPR@[170; 171) | ||
136 | L_PAREN@[170; 171) "(" | ||
137 | EXPR_STMT@[171; 172) | ||
138 | ERROR@[171; 172) | ||
139 | COMMA@[171; 172) "," | ||
140 | EXPR_STMT@[172; 173) | ||
141 | ERROR@[172; 173) | ||
142 | R_PAREN@[172; 173) ")" | ||
143 | EXPR_STMT@[173; 175) | ||
144 | PREFIX_EXPR@[173; 175) | ||
145 | STAR@[173; 174) "*" | ||
146 | ERROR@[174; 175) | ||
147 | R_BRACK@[174; 175) "]" | ||
148 | EXPR_STMT@[175; 176) | ||
149 | ERROR@[175; 176) | ||
150 | COMMA@[175; 176) "," | ||
151 | WHITESPACE@[176; 177) " " | ||
152 | EXPR_STMT@[177; 180) | ||
153 | ARRAY_EXPR@[177; 180) | ||
154 | L_BRACK@[177; 178) "[" | ||
155 | ERROR@[178; 179) | ||
156 | DOLLAR@[178; 179) "$" | ||
157 | PAREN_EXPR@[179; 180) | ||
158 | L_PAREN@[179; 180) "(" | ||
159 | EXPR_STMT@[180; 181) | ||
160 | ERROR@[180; 181) | ||
161 | DOLLAR@[180; 181) "$" | ||
162 | EXPR_STMT@[181; 187) | ||
163 | PATH_EXPR@[181; 187) | ||
164 | PATH@[181; 187) | ||
165 | PATH_SEGMENT@[181; 187) | ||
166 | NAME_REF@[181; 187) | ||
167 | IDENT@[181; 187) "output" | ||
168 | EXPR_STMT@[187; 188) | ||
169 | ERROR@[187; 188) | ||
170 | COLON@[187; 188) ":" | ||
171 | EXPR_STMT@[188; 192) | ||
172 | PATH_EXPR@[188; 192) | ||
173 | PATH@[188; 192) | ||
174 | PATH_SEGMENT@[188; 192) | ||
175 | NAME_REF@[188; 192) | ||
176 | IDENT@[188; 192) "expr" | ||
177 | EXPR_STMT@[192; 193) | ||
178 | ERROR@[192; 193) | ||
179 | R_PAREN@[192; 193) ")" | ||
180 | EXPR_STMT@[193; 194) | ||
181 | ERROR@[193; 194) | ||
182 | COMMA@[193; 194) "," | ||
183 | EXPR_STMT@[194; 197) | ||
184 | PREFIX_EXPR@[194; 197) | ||
185 | STAR@[194; 195) "*" | ||
186 | WHITESPACE@[195; 196) " " | ||
187 | ERROR@[196; 197) | ||
188 | DOLLAR@[196; 197) "$" | ||
189 | EXPR_STMT@[197; 198) | ||
190 | PAREN_EXPR@[197; 198) | ||
191 | L_PAREN@[197; 198) "(" | ||
192 | EXPR_STMT@[198; 199) | ||
193 | ERROR@[198; 199) | ||
194 | COMMA@[198; 199) "," | ||
195 | EXPR_STMT@[199; 200) | ||
196 | ERROR@[199; 200) | ||
197 | R_PAREN@[199; 200) ")" | ||
198 | EXPR_STMT@[200; 202) | ||
199 | PREFIX_EXPR@[200; 202) | ||
200 | STAR@[200; 201) "*" | ||
201 | ERROR@[201; 202) | ||
202 | R_BRACK@[201; 202) "]" | ||
203 | EXPR_STMT@[202; 203) | ||
204 | ERROR@[202; 203) | ||
205 | R_PAREN@[202; 203) ")" | ||
206 | WHITESPACE@[203; 204) " " | ||
207 | BLOCK_EXPR@[204; 346) | ||
208 | BLOCK@[204; 346) | ||
209 | L_CURLY@[204; 205) "{" | ||
210 | WHITESPACE@[205; 214) "\n " | ||
211 | EXPR_STMT@[214; 340) | ||
212 | MACRO_CALL@[214; 339) | ||
213 | PATH@[214; 223) | ||
214 | PATH_SEGMENT@[214; 223) | ||
215 | NAME_REF@[214; 223) | ||
216 | IDENT@[214; 223) "assert_eq" | ||
217 | EXCL@[223; 224) "!" | ||
218 | TOKEN_TREE@[224; 339) | ||
219 | L_PAREN@[224; 225) "(" | ||
220 | WHITESPACE@[225; 238) "\n " | ||
221 | IDENT@[238; 253) "merge_use_trees" | ||
222 | TOKEN_TREE@[253; 284) | ||
223 | L_PAREN@[253; 254) "(" | ||
224 | IDENT@[254; 269) "parse_use_trees" | ||
225 | EXCL@[269; 270) "!" | ||
226 | TOKEN_TREE@[270; 283) | ||
227 | L_PAREN@[270; 271) "(" | ||
228 | DOLLAR@[271; 272) "$" | ||
229 | TOKEN_TREE@[272; 281) | ||
230 | L_PAREN@[272; 273) "(" | ||
231 | DOLLAR@[273; 274) "$" | ||
232 | IDENT@[274; 279) "input" | ||
233 | COMMA@[279; 280) "," | ||
234 | R_PAREN@[280; 281) ")" | ||
235 | STAR@[281; 282) "*" | ||
236 | R_PAREN@[282; 283) ")" | ||
237 | R_PAREN@[283; 284) ")" | ||
238 | COMMA@[284; 285) "," | ||
239 | WHITESPACE@[285; 298) "\n " | ||
240 | IDENT@[298; 313) "parse_use_trees" | ||
241 | EXCL@[313; 314) "!" | ||
242 | TOKEN_TREE@[314; 328) | ||
243 | L_PAREN@[314; 315) "(" | ||
244 | DOLLAR@[315; 316) "$" | ||
245 | TOKEN_TREE@[316; 326) | ||
246 | L_PAREN@[316; 317) "(" | ||
247 | DOLLAR@[317; 318) "$" | ||
248 | IDENT@[318; 324) "output" | ||
249 | COMMA@[324; 325) "," | ||
250 | R_PAREN@[325; 326) ")" | ||
251 | STAR@[326; 327) "*" | ||
252 | R_PAREN@[327; 328) ")" | ||
253 | COMMA@[328; 329) "," | ||
254 | WHITESPACE@[329; 338) "\n " | ||
255 | R_PAREN@[338; 339) ")" | ||
256 | SEMI@[339; 340) ";" | ||
257 | WHITESPACE@[340; 345) "\n " | ||
258 | R_CURLY@[345; 346) "}" | ||
259 | WHITESPACE@[346; 347) "\n" | ||
260 | R_CURLY@[347; 348) "}" | ||
261 | WHITESPACE@[348; 349) "\n" | ||
262 | error 5: expected EXCL | ||
263 | error 41: expected SEMI | ||
264 | error 42: expected an item | ||
265 | error 139: expected SEMI | ||
266 | error 152: expected expression | ||
267 | error 153: expected COMMA | ||
268 | error 154: expected expression | ||
269 | error 154: expected R_PAREN | ||
270 | error 154: expected COMMA | ||
271 | error 154: expected expression | ||
272 | error 154: expected R_BRACK | ||
273 | error 154: expected COMMA | ||
274 | error 154: expected SEMI | ||
275 | error 154: expected expression | ||
276 | error 155: expected SEMI | ||
277 | error 160: expected SEMI | ||
278 | error 160: expected expression | ||
279 | error 161: expected SEMI | ||
280 | error 165: expected SEMI | ||
281 | error 165: expected expression | ||
282 | error 166: expected SEMI | ||
283 | error 166: expected expression | ||
284 | error 167: expected SEMI | ||
285 | error 169: expected expression | ||
286 | error 170: expected SEMI | ||
287 | error 171: expected expression | ||
288 | error 171: expected R_PAREN | ||
289 | error 171: expected SEMI | ||
290 | error 171: expected expression | ||
291 | error 172: expected SEMI | ||
292 | error 172: expected expression | ||
293 | error 173: expected SEMI | ||
294 | error 174: expected expression | ||
295 | error 175: expected SEMI | ||
296 | error 175: expected expression | ||
297 | error 176: expected SEMI | ||
298 | error 178: expected expression | ||
299 | error 179: expected COMMA | ||
300 | error 180: expected expression | ||
301 | error 180: expected R_PAREN | ||
302 | error 180: expected COMMA | ||
303 | error 180: expected expression | ||
304 | error 180: expected R_BRACK | ||
305 | error 180: expected SEMI | ||
306 | error 180: expected expression | ||
307 | error 181: expected SEMI | ||
308 | error 187: expected SEMI | ||
309 | error 187: expected expression | ||
310 | error 188: expected SEMI | ||
311 | error 192: expected SEMI | ||
312 | error 192: expected expression | ||
313 | error 193: expected SEMI | ||
314 | error 193: expected expression | ||
315 | error 194: expected SEMI | ||
316 | error 196: expected expression | ||
317 | error 197: expected SEMI | ||
318 | error 198: expected expression | ||
319 | error 198: expected R_PAREN | ||
320 | error 198: expected SEMI | ||
321 | error 198: expected expression | ||
322 | error 199: expected SEMI | ||
323 | error 199: expected expression | ||
324 | error 200: expected SEMI | ||
325 | error 201: expected expression | ||
326 | error 202: expected SEMI | ||
327 | error 202: expected expression | ||
328 | error 203: expected SEMI | ||