diff options
Diffstat (limited to 'xtask/src/codegen/rust.ungram')
-rw-r--r-- | xtask/src/codegen/rust.ungram | 529 |
1 files changed, 529 insertions, 0 deletions
diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram new file mode 100644 index 000000000..b6ec5d5e7 --- /dev/null +++ b/xtask/src/codegen/rust.ungram | |||
@@ -0,0 +1,529 @@ | |||
1 | SourceFile = | ||
2 | Attr* | ||
3 | items:ModuleItem* | ||
4 | |||
5 | FnDef = | ||
6 | Attr* Visibility? Abi? 'const' 'default' 'async' 'unsafe' 'fn' Name TypeParamList? | ||
7 | ParamList RetType? | ||
8 | WhereClause? | ||
9 | (body:BlockExpr | ';') | ||
10 | |||
11 | RetType = | ||
12 | '->' TypeRef | ||
13 | |||
14 | StructDef = | ||
15 | Attr* Visibility? 'struct' Name TypeParamList? ( | ||
16 | WhereClause? (RecordFieldDefList | ';') | ||
17 | | TupleFieldDefList WhereClause? ';' | ||
18 | ) | ||
19 | |||
20 | UnionDef = | ||
21 | Attr* Visibility? 'union' Name TypeParamList? WhereClause? | ||
22 | RecordFieldDefList | ||
23 | |||
24 | RecordFieldDefList = | ||
25 | '{' fields:RecordFieldDef* '}' | ||
26 | |||
27 | RecordFieldDef = | ||
28 | Attr* Visibility? Name ':' ascribed_type:TypeRef | ||
29 | |||
30 | TupleFieldDefList = | ||
31 | '(' fields:TupleFieldDef* ')' | ||
32 | |||
33 | TupleFieldDef = | ||
34 | Attr* Visibility? Name TypeRef | ||
35 | |||
36 | FieldDefList = | ||
37 | RecordFieldDefList | ||
38 | | TupleFieldDefList | ||
39 | |||
40 | EnumDef = | ||
41 | Attr* Visibility? 'enum' Name TypeParamList? WhereClause? | ||
42 | variant_list:EnumVariantList | ||
43 | |||
44 | EnumVariantList = | ||
45 | '{' variants:EnumVariant* '}' | ||
46 | |||
47 | EnumVariant = | ||
48 | Attr* Visibility? Name FieldDefList ('=' Expr)? | ||
49 | |||
50 | TraitDef = | ||
51 | Attr* Visibility? 'unsafe'? 'auto'? 'trait' Name TypeParamList | ||
52 | (':' TypeBoundList?)? WhereClause | ||
53 | ItemList | ||
54 | |||
55 | Module = | ||
56 | Attr* Visibility? 'mod' Name | ||
57 | (ItemList | ';') | ||
58 | |||
59 | ItemList = | ||
60 | '{' | ||
61 | AssocItem* | ||
62 | items:ModuleItem* | ||
63 | '}' | ||
64 | |||
65 | ConstDef = | ||
66 | Attr* Visibility? 'default'? 'const' Name ':' ascribed_type:TypeRef | ||
67 | '=' body:Expr ';' | ||
68 | |||
69 | StaticDef = | ||
70 | Attr* Visibility? 'static'? 'mut'? 'static' Name ':' ascribed_type:TypeRef | ||
71 | '=' body:Expr ';' | ||
72 | |||
73 | TypeAliasDef = | ||
74 | Attr* Visibility? 'default'? 'type' Name TypeParamList? WhereClause? (':' TypeBoundList?)? | ||
75 | '=' TypeRef ';' | ||
76 | |||
77 | ImplDef = | ||
78 | Attr* Visibility? 'const'? 'default'? 'unsafe'? 'impl' TypeParamList? '!'? 'for' | ||
79 | WhereClause? | ||
80 | ItemList | ||
81 | |||
82 | ParenType = | ||
83 | '(' TypeRef ')' | ||
84 | |||
85 | TupleType = | ||
86 | '(' fields:TypeRef* ')' | ||
87 | |||
88 | NeverType = | ||
89 | '!' | ||
90 | |||
91 | PathType = | ||
92 | Path | ||
93 | |||
94 | PointerType = | ||
95 | '*' ('const' | 'mut') TypeRef | ||
96 | |||
97 | ArrayType = | ||
98 | '[' TypeRef ';' Expr ']' | ||
99 | |||
100 | SliceType = | ||
101 | '[' TypeRef ']' | ||
102 | |||
103 | ReferenceType = | ||
104 | '&' 'lifetime'? 'mut'? TypeRef | ||
105 | |||
106 | PlaceholderType = | ||
107 | '_' | ||
108 | |||
109 | FnPointerType = | ||
110 | Abi 'unsafe'? 'fn' ParamList RetType? | ||
111 | |||
112 | ForType = | ||
113 | 'for' TypeParamList TypeRef | ||
114 | |||
115 | ImplTraitType = | ||
116 | 'impl' TypeBoundList | ||
117 | |||
118 | DynTraitType = | ||
119 | 'dyn' TypeBoundList | ||
120 | |||
121 | TupleExpr = | ||
122 | Attr* '(' Expr* ')' | ||
123 | |||
124 | ArrayExpr = | ||
125 | Attr* '[' (Expr* | Expr ';' Expr) ']' | ||
126 | |||
127 | ParenExpr = | ||
128 | Attr* '(' Expr ')' | ||
129 | |||
130 | PathExpr = | ||
131 | Path | ||
132 | |||
133 | LambdaExpr = | ||
134 | Attr* 'static'? 'async'? 'move'? ParamList RetType? | ||
135 | body:Expr | ||
136 | |||
137 | IfExpr = | ||
138 | Attr* 'if' Condition | ||
139 | |||
140 | Condition = | ||
141 | 'let' Pat '=' Expr | ||
142 | | Expr | ||
143 | |||
144 | EffectExpr = | ||
145 | Attr* Label? ('try' | 'unsafe' | 'async') BlockExpr | ||
146 | |||
147 | LoopExpr = | ||
148 | Attr* Label? 'loop' | ||
149 | loop_body:BlockExpr? | ||
150 | |||
151 | ForExpr = | ||
152 | Attr* Label? 'for' Pat 'in' iterable:Expr | ||
153 | loop_body:BlockExpr? | ||
154 | |||
155 | WhileExpr = | ||
156 | Attr* Label? 'while' Condition | ||
157 | loop_body:BlockExpr? | ||
158 | |||
159 | ContinueExpr = | ||
160 | Attr* 'continue' 'lifetime'? | ||
161 | |||
162 | BreakExpr = | ||
163 | Attr* 'break' 'lifetime'? Expr? | ||
164 | |||
165 | Label = | ||
166 | 'lifetime' | ||
167 | |||
168 | BlockExpr = | ||
169 | Attr* Label | ||
170 | '{' | ||
171 | items:ModuleItem* | ||
172 | statements:Stmt* | ||
173 | Expr? | ||
174 | '}' | ||
175 | |||
176 | ReturnExpr = | ||
177 | Attr* 'return' Expr | ||
178 | |||
179 | CallExpr = | ||
180 | Attr* Expr ArgList | ||
181 | |||
182 | MethodCallExpr = | ||
183 | Attr* Expr '.' NameRef TypeArgList? ArgList | ||
184 | |||
185 | ArgList = | ||
186 | '(' args:Expr* ')' | ||
187 | |||
188 | FieldExpr = | ||
189 | Attr* Expr '.' NameRef | ||
190 | |||
191 | IndexExpr = | ||
192 | Attr* '[' ']' | ||
193 | |||
194 | AwaitExpr = | ||
195 | Attr* Expr '.' 'await' | ||
196 | |||
197 | TryExpr = | ||
198 | Attr* Expr '?' | ||
199 | |||
200 | CastExpr = | ||
201 | Attr* Expr 'as' TypeRef | ||
202 | |||
203 | RefExpr = | ||
204 | Attr* '&' ('raw' | 'mut' | 'const') Expr | ||
205 | |||
206 | PrefixExpr = | ||
207 | Attr* Expr | ||
208 | |||
209 | BoxExpr = | ||
210 | Attr* 'box' Expr | ||
211 | |||
212 | RangeExpr = | ||
213 | Attr* | ||
214 | |||
215 | BinExpr = | ||
216 | Attr* | ||
217 | |||
218 | Literal = | ||
219 | 'int_number' | ||
220 | |||
221 | MatchExpr = | ||
222 | Attr* 'match' Expr MatchArmList | ||
223 | |||
224 | MatchArmList = | ||
225 | '{' arms:MatchArm* '}' | ||
226 | |||
227 | MatchArm = | ||
228 | Attr* Pat guard:MatchGuard? '=>' Expr | ||
229 | |||
230 | MatchGuard = | ||
231 | 'if' Expr | ||
232 | |||
233 | RecordLit = | ||
234 | Path RecordFieldList | ||
235 | |||
236 | RecordFieldList = | ||
237 | '{' | ||
238 | fields:RecordField* | ||
239 | ('..' spread:Expr)? | ||
240 | '}' | ||
241 | |||
242 | RecordField = | ||
243 | Attr* NameRef (':' Expr)? | ||
244 | |||
245 | OrPat = | ||
246 | Pat* | ||
247 | |||
248 | ParenPat = | ||
249 | '(' Pat ')' | ||
250 | |||
251 | RefPat = | ||
252 | '&' 'mut'? Pat | ||
253 | |||
254 | BoxPat = | ||
255 | 'box' Path | ||
256 | |||
257 | BindPat = | ||
258 | Attr* 'ref'? 'mut'? Name ('@' Pat)? | ||
259 | |||
260 | PlaceholderPat = | ||
261 | '_' | ||
262 | |||
263 | DotDotPat = | ||
264 | '..' | ||
265 | |||
266 | PathPat = | ||
267 | Path | ||
268 | |||
269 | SlicePat = | ||
270 | '[' args:Pat* ']' | ||
271 | |||
272 | RangePat = | ||
273 | '..' | '..=' | ||
274 | |||
275 | LiteralPat = | ||
276 | Literal | ||
277 | |||
278 | MacroPat = | ||
279 | MacroCall | ||
280 | |||
281 | RecordPat = | ||
282 | Path RecordFieldPatList | ||
283 | |||
284 | RecordFieldPatList = | ||
285 | '{' | ||
286 | record_field_pats:RecordFieldPat* | ||
287 | BindPat* | ||
288 | '..'? | ||
289 | '}' | ||
290 | |||
291 | RecordFieldPat = | ||
292 | Attr* NameRef ':' Pat | ||
293 | |||
294 | TupleStructPat = | ||
295 | Path '(' args:Pat* ')' | ||
296 | |||
297 | TuplePat = | ||
298 | '(' args:Pat* ')' | ||
299 | |||
300 | Visibility = | ||
301 | 'pub' ('(' 'super' | 'self' | 'crate' | 'in' Path ')')? | ||
302 | |||
303 | Name = | ||
304 | 'ident' | ||
305 | |||
306 | NameRef = | ||
307 | 'ident' | 'int_number' | ||
308 | |||
309 | MacroCall = | ||
310 | Attr* Path '!' Name? TokenTree ';'? | ||
311 | |||
312 | MacroDef = | ||
313 | Name TokenTree | ||
314 | |||
315 | TokenTree = | ||
316 | '(' ')' | '{' '}' | '[' ']' | ||
317 | |||
318 | MacroItems = | ||
319 | items:ModuleItem* | ||
320 | |||
321 | MacroStmts = | ||
322 | statements:Stmt* | ||
323 | Expr? | ||
324 | |||
325 | Attr = | ||
326 | '#' '!'? '[' Path ('=' input:AttrInput)? ']' | ||
327 | |||
328 | TypeParamList = | ||
329 | '<' | ||
330 | TypeParam* | ||
331 | LifetimeParam* | ||
332 | ConstParam* | ||
333 | '>' | ||
334 | |||
335 | TypeParam = | ||
336 | Attr* Name (':' TypeBoundList?)? | ||
337 | ('=' default_type:TypeRef)? | ||
338 | |||
339 | ConstParam = | ||
340 | Attr* 'const' Name ':' ascribed_type:TypeRef | ||
341 | ('=' default_val:Expr)? | ||
342 | |||
343 | LifetimeParam = | ||
344 | Attr* 'lifetime' | ||
345 | |||
346 | TypeBound = | ||
347 | 'lifetime' | 'const'? TypeRef | ||
348 | |||
349 | TypeBoundList = | ||
350 | bounds:TypeBound* | ||
351 | |||
352 | WherePred = | ||
353 | ('for' TypeParamList)? ('lifetime' | TypeRef) ':' TypeBoundList | ||
354 | |||
355 | WhereClause = | ||
356 | 'where' predicates:WherePred* | ||
357 | |||
358 | Abi = | ||
359 | 'string' | ||
360 | |||
361 | ExprStmt = | ||
362 | Attr* Expr ';' | ||
363 | |||
364 | LetStmt = | ||
365 | Attr* 'let' Pat (':' ascribed_type:TypeRef) | ||
366 | '=' initializer:Expr ';' | ||
367 | |||
368 | ParamList = | ||
369 | '(' SelfParam Param* ')' | ||
370 | |||
371 | SelfParam = | ||
372 | Attr* ('&' 'lifetime'?)? 'mut'? 'self' (':' ascribed_type:TypeRef) | ||
373 | |||
374 | Param = | ||
375 | Attr* Pat (':' ascribed_type:TypeRef) | ||
376 | | '...' | ||
377 | |||
378 | UseItem = | ||
379 | Attr* Visibility? 'use' UseTree ';' | ||
380 | |||
381 | UseTree = | ||
382 | Path ('::' ('*' | UseTreeList)) Alias? | ||
383 | |||
384 | UseTreeList = | ||
385 | '{' UseTree* '}' | ||
386 | |||
387 | Alias = | ||
388 | 'as' Name | ||
389 | |||
390 | ExternCrateItem = | ||
391 | Attr* Visibility? 'extern' 'crate' (NameRef | 'self') Alias? ';' | ||
392 | |||
393 | Path = | ||
394 | (qualifier:Path '::')? segment:PathSegment | ||
395 | |||
396 | PathSegment = | ||
397 | '::' | 'crate' | 'self' | 'super' | ||
398 | | '<' NameRef TypeArgList ParamList RetType PathType '>' | ||
399 | |||
400 | TypeArgList = | ||
401 | '::'? '<' | ||
402 | TypeArg* | ||
403 | LifetimeArg* | ||
404 | AssocTypeArg* | ||
405 | ConstArg* | ||
406 | '>' | ||
407 | |||
408 | TypeArg = | ||
409 | TypeRef | ||
410 | |||
411 | AssocTypeArg = | ||
412 | NameRef (':' TypeBoundList | '=' TypeRef) | ||
413 | |||
414 | LifetimeArg = | ||
415 | 'lifetime' | ||
416 | |||
417 | ConstArg = | ||
418 | Literal | BlockExpr BlockExpr | ||
419 | |||
420 | ExternBlock = | ||
421 | Attr* Abi ExternItemList | ||
422 | |||
423 | ExternItemList = | ||
424 | '{' extern_items:ExternItem* '}' | ||
425 | |||
426 | MetaItem = | ||
427 | Path '=' AttrInput nested_meta_items:MetaItem* | ||
428 | |||
429 | AdtDef = | ||
430 | StructDef | ||
431 | | EnumDef | ||
432 | | UnionDef | ||
433 | |||
434 | TypeRef = | ||
435 | ParenType | ||
436 | | TupleType | ||
437 | | NeverType | ||
438 | | PathType | ||
439 | | PointerType | ||
440 | | ArrayType | ||
441 | | SliceType | ||
442 | | ReferenceType | ||
443 | | PlaceholderType | ||
444 | | FnPointerType | ||
445 | | ForType | ||
446 | | ImplTraitType | ||
447 | | DynTraitType | ||
448 | |||
449 | AssocItem = | ||
450 | FnDef | ||
451 | | TypeAliasDef | ||
452 | | ConstDef | ||
453 | |||
454 | ExternItem = | ||
455 | FnDef | StaticDef | ||
456 | |||
457 | ModuleItem = | ||
458 | StructDef | ||
459 | | UnionDef | ||
460 | | EnumDef | ||
461 | | FnDef | ||
462 | | TraitDef | ||
463 | | TypeAliasDef | ||
464 | | ImplDef | ||
465 | | UseItem | ||
466 | | ExternCrateItem | ||
467 | | ConstDef | ||
468 | | StaticDef | ||
469 | | Module | ||
470 | | MacroCall | ||
471 | | ExternBlock | ||
472 | |||
473 | AttrInput = | ||
474 | Literal | ||
475 | | TokenTree | ||
476 | |||
477 | Stmt = | ||
478 | LetStmt | ||
479 | | ExprStmt | ||
480 | |||
481 | Pat = | ||
482 | OrPat | ||
483 | | ParenPat | ||
484 | | RefPat | ||
485 | | BoxPat | ||
486 | | BindPat | ||
487 | | PlaceholderPat | ||
488 | | DotDotPat | ||
489 | | PathPat | ||
490 | | RecordPat | ||
491 | | TupleStructPat | ||
492 | | TuplePat | ||
493 | | SlicePat | ||
494 | | RangePat | ||
495 | | LiteralPat | ||
496 | | MacroPat | ||
497 | |||
498 | Expr = | ||
499 | TupleExpr | ||
500 | | ArrayExpr | ||
501 | | ParenExpr | ||
502 | | PathExpr | ||
503 | | LambdaExpr | ||
504 | | IfExpr | ||
505 | | LoopExpr | ||
506 | | ForExpr | ||
507 | | WhileExpr | ||
508 | | ContinueExpr | ||
509 | | BreakExpr | ||
510 | | Label | ||
511 | | BlockExpr | ||
512 | | ReturnExpr | ||
513 | | MatchExpr | ||
514 | | RecordLit | ||
515 | | CallExpr | ||
516 | | IndexExpr | ||
517 | | MethodCallExpr | ||
518 | | FieldExpr | ||
519 | | AwaitExpr | ||
520 | | TryExpr | ||
521 | | EffectExpr | ||
522 | | CastExpr | ||
523 | | RefExpr | ||
524 | | PrefixExpr | ||
525 | | RangeExpr | ||
526 | | BinExpr | ||
527 | | Literal | ||
528 | | MacroCall | ||
529 | | BoxExpr | ||