diff options
Diffstat (limited to 'xtask/src/codegen/rust.ungram')
-rw-r--r-- | xtask/src/codegen/rust.ungram | 164 |
1 files changed, 86 insertions, 78 deletions
diff --git a/xtask/src/codegen/rust.ungram b/xtask/src/codegen/rust.ungram index 449b0242f..ef7c3e50e 100644 --- a/xtask/src/codegen/rust.ungram +++ b/xtask/src/codegen/rust.ungram | |||
@@ -4,19 +4,19 @@ SourceFile = | |||
4 | Item* | 4 | Item* |
5 | 5 | ||
6 | Item = | 6 | Item = |
7 | ConstDef | 7 | Const |
8 | | EnumDef | 8 | | Enum |
9 | | ExternBlock | 9 | | ExternBlock |
10 | | ExternCrate | 10 | | ExternCrate |
11 | | FnDef | 11 | | Fn |
12 | | ImplDef | 12 | | ImplDef |
13 | | MacroCall | 13 | | MacroCall |
14 | | Module | 14 | | Module |
15 | | StaticDef | 15 | | Static |
16 | | StructDef | 16 | | Struct |
17 | | TraitDef | 17 | | TraitDef |
18 | | TypeAliasDef | 18 | | TypeAlias |
19 | | UnionDef | 19 | | Union |
20 | | Use | 20 | | Use |
21 | 21 | ||
22 | Module = | 22 | Module = |
@@ -42,73 +42,94 @@ UseTree = | |||
42 | UseTreeList = | 42 | UseTreeList = |
43 | '{' (UseTree (',' UseTree)* ','?)? '}' | 43 | '{' (UseTree (',' UseTree)* ','?)? '}' |
44 | 44 | ||
45 | FnDef = | 45 | Fn = |
46 | Attr* Visibility? Abi? 'const' 'default' 'async' 'unsafe' 'fn' Name TypeParamList? | 46 | Attr* Visibility? |
47 | ParamList RetType? | 47 | 'default'? ('async' | 'const')? 'unsafe'? Abi? |
48 | 'fn' Name GenericParamList? ParamList RetType? | ||
48 | WhereClause? | 49 | WhereClause? |
49 | (body:BlockExpr | ';') | 50 | (body:BlockExpr | ';') |
50 | 51 | ||
52 | Abi = | ||
53 | 'extern' 'string'? | ||
54 | |||
55 | ParamList = | ||
56 | '('( | ||
57 | (Param (',' Param)* ','?)? | ||
58 | | SelfParam ','? | ||
59 | | SelfParam ',' (Param (',' Param)* ','?) | ||
60 | )')' | ||
61 | |||
62 | SelfParam = | ||
63 | Attr* ( | ||
64 | ('&' 'lifetime'?)? 'mut'? 'self' | ||
65 | | 'mut'? 'self' ':' ascribed_type:TypeRef | ||
66 | ) | ||
67 | |||
68 | Param = | ||
69 | Attr* Pat (':' ascribed_type:TypeRef) | ||
70 | | '...' | ||
71 | |||
51 | RetType = | 72 | RetType = |
52 | '->' TypeRef | 73 | '->' TypeRef |
53 | 74 | ||
54 | StructDef = | 75 | TypeAlias = |
55 | Attr* Visibility? 'struct' Name TypeParamList? ( | 76 | Attr* Visibility? 'default'? 'type' Name GenericParamList? (':' TypeBoundList?)? WhereClause? |
56 | WhereClause? (RecordFieldDefList | ';') | 77 | '=' TypeRef ';' |
57 | | TupleFieldDefList WhereClause? ';' | ||
58 | ) | ||
59 | 78 | ||
60 | UnionDef = | 79 | Struct = |
61 | Attr* Visibility? 'union' Name TypeParamList? WhereClause? | 80 | Attr* Visibility? 'struct' Name GenericParamList? ( |
62 | RecordFieldDefList | 81 | WhereClause? (RecordFieldList | ';') |
82 | | TupleFieldList WhereClause? ';' | ||
83 | ) | ||
63 | 84 | ||
64 | RecordFieldDefList = | 85 | RecordFieldList = |
65 | '{' fields:RecordFieldDef* '}' | 86 | '{' fields:(RecordField (',' RecordField)* ','?)? '}' |
66 | 87 | ||
67 | RecordFieldDef = | 88 | RecordField = |
68 | Attr* Visibility? Name ':' ascribed_type:TypeRef | 89 | Attr* Visibility? Name ':' ascribed_type:TypeRef |
69 | 90 | ||
70 | TupleFieldDefList = | 91 | TupleFieldList = |
71 | '(' fields:TupleFieldDef* ')' | 92 | '(' fields:(TupleField (',' TupleField)* ','?)? ')' |
93 | |||
94 | TupleField = | ||
95 | Attr* Visibility? TypeRef | ||
72 | 96 | ||
73 | TupleFieldDef = | 97 | FieldList = |
74 | Attr* Visibility? Name TypeRef | 98 | RecordFieldList |
99 | | TupleFieldList | ||
75 | 100 | ||
76 | FieldDefList = | 101 | Enum = |
77 | RecordFieldDefList | 102 | Attr* Visibility? 'enum' Name GenericParamList? WhereClause? |
78 | | TupleFieldDefList | 103 | VariantList |
79 | 104 | ||
80 | EnumDef = | 105 | VariantList = |
81 | Attr* Visibility? 'enum' Name TypeParamList? WhereClause? | 106 | '{' (Variant (',' Variant)* ','?)? '}' |
82 | variant_list:EnumVariantList | ||
83 | 107 | ||
84 | EnumVariantList = | 108 | Variant = |
85 | '{' variants:EnumVariant* '}' | 109 | Attr* Visibility? Name FieldList ('=' Expr)? |
86 | 110 | ||
87 | EnumVariant = | 111 | Union = |
88 | Attr* Visibility? Name FieldDefList ('=' Expr)? | 112 | Attr* Visibility? 'union' Name GenericParamList? WhereClause? |
113 | RecordFieldList | ||
114 | |||
115 | Const = | ||
116 | Attr* Visibility? 'default'? 'const' (Name | '_') ':' ascribed_type:TypeRef | ||
117 | '=' body:Expr ';' | ||
118 | |||
119 | Static = | ||
120 | Attr* Visibility? 'static'? 'mut'? Name ':' ascribed_type:TypeRef | ||
121 | '=' body:Expr ';' | ||
89 | 122 | ||
90 | TraitDef = | 123 | TraitDef = |
91 | Attr* Visibility? 'unsafe'? 'auto'? 'trait' Name TypeParamList | 124 | Attr* Visibility? 'unsafe'? 'auto'? 'trait' Name GenericParamList |
92 | (':' TypeBoundList?)? WhereClause | 125 | (':' TypeBoundList?)? WhereClause |
93 | AssocItemList | 126 | AssocItemList |
94 | 127 | ||
95 | AssocItemList = | 128 | AssocItemList = |
96 | '{' AssocItem* '}' | 129 | '{' AssocItem* '}' |
97 | 130 | ||
98 | ConstDef = | ||
99 | Attr* Visibility? 'default'? 'const' Name ':' ascribed_type:TypeRef | ||
100 | '=' body:Expr ';' | ||
101 | |||
102 | StaticDef = | ||
103 | Attr* Visibility? 'static'? 'mut'? 'static' Name ':' ascribed_type:TypeRef | ||
104 | '=' body:Expr ';' | ||
105 | |||
106 | TypeAliasDef = | ||
107 | Attr* Visibility? 'default'? 'type' Name TypeParamList? WhereClause? (':' TypeBoundList?)? | ||
108 | '=' TypeRef ';' | ||
109 | |||
110 | ImplDef = | 131 | ImplDef = |
111 | Attr* Visibility? 'const'? 'default'? 'unsafe'? 'impl' TypeParamList? '!'? 'for' | 132 | Attr* Visibility? 'const'? 'default'? 'unsafe'? 'impl' GenericParamList? '!'? 'for' |
112 | WhereClause? | 133 | WhereClause? |
113 | AssocItemList | 134 | AssocItemList |
114 | 135 | ||
@@ -143,7 +164,7 @@ FnPointerType = | |||
143 | Abi 'unsafe'? 'fn' ParamList RetType? | 164 | Abi 'unsafe'? 'fn' ParamList RetType? |
144 | 165 | ||
145 | ForType = | 166 | ForType = |
146 | 'for' TypeParamList TypeRef | 167 | 'for' GenericParamList TypeRef |
147 | 168 | ||
148 | ImplTraitType = | 169 | ImplTraitType = |
149 | 'impl' TypeBoundList | 170 | 'impl' TypeBoundList |
@@ -263,16 +284,16 @@ MatchArm = | |||
263 | MatchGuard = | 284 | MatchGuard = |
264 | 'if' Expr | 285 | 'if' Expr |
265 | 286 | ||
266 | RecordLit = | 287 | RecordExpr = |
267 | Path RecordFieldList | 288 | Path RecordExprFieldList |
268 | 289 | ||
269 | RecordFieldList = | 290 | RecordExprFieldList = |
270 | '{' | 291 | '{' |
271 | fields:RecordField* | 292 | fields:RecordExprField* |
272 | ('..' spread:Expr)? | 293 | ('..' spread:Expr)? |
273 | '}' | 294 | '}' |
274 | 295 | ||
275 | RecordField = | 296 | RecordExprField = |
276 | Attr* NameRef (':' Expr)? | 297 | Attr* NameRef (':' Expr)? |
277 | 298 | ||
278 | OrPat = | 299 | OrPat = |
@@ -358,7 +379,7 @@ MacroStmts = | |||
358 | Attr = | 379 | Attr = |
359 | '#' '!'? '[' Path ('=' input:AttrInput)? ']' | 380 | '#' '!'? '[' Path ('=' input:AttrInput)? ']' |
360 | 381 | ||
361 | TypeParamList = | 382 | GenericParamList = |
362 | '<' | 383 | '<' |
363 | TypeParam* | 384 | TypeParam* |
364 | LifetimeParam* | 385 | LifetimeParam* |
@@ -383,14 +404,11 @@ TypeBoundList = | |||
383 | bounds:TypeBound* | 404 | bounds:TypeBound* |
384 | 405 | ||
385 | WherePred = | 406 | WherePred = |
386 | ('for' TypeParamList)? ('lifetime' | TypeRef) ':' TypeBoundList | 407 | ('for' GenericParamList)? ('lifetime' | TypeRef) ':' TypeBoundList |
387 | 408 | ||
388 | WhereClause = | 409 | WhereClause = |
389 | 'where' predicates:WherePred* | 410 | 'where' predicates:WherePred* |
390 | 411 | ||
391 | Abi = | ||
392 | 'string' | ||
393 | |||
394 | ExprStmt = | 412 | ExprStmt = |
395 | Attr* Expr ';' | 413 | Attr* Expr ';' |
396 | 414 | ||
@@ -398,16 +416,6 @@ LetStmt = | |||
398 | Attr* 'let' Pat (':' ascribed_type:TypeRef) | 416 | Attr* 'let' Pat (':' ascribed_type:TypeRef) |
399 | '=' initializer:Expr ';' | 417 | '=' initializer:Expr ';' |
400 | 418 | ||
401 | ParamList = | ||
402 | '(' SelfParam Param* ')' | ||
403 | |||
404 | SelfParam = | ||
405 | Attr* ('&' 'lifetime'?)? 'mut'? 'self' (':' ascribed_type:TypeRef) | ||
406 | |||
407 | Param = | ||
408 | Attr* Pat (':' ascribed_type:TypeRef) | ||
409 | | '...' | ||
410 | |||
411 | Path = | 419 | Path = |
412 | (qualifier:Path '::')? segment:PathSegment | 420 | (qualifier:Path '::')? segment:PathSegment |
413 | 421 | ||
@@ -445,9 +453,9 @@ MetaItem = | |||
445 | Path '=' AttrInput nested_meta_items:MetaItem* | 453 | Path '=' AttrInput nested_meta_items:MetaItem* |
446 | 454 | ||
447 | AdtDef = | 455 | AdtDef = |
448 | StructDef | 456 | Struct |
449 | | EnumDef | 457 | | Enum |
450 | | UnionDef | 458 | | Union |
451 | 459 | ||
452 | TypeRef = | 460 | TypeRef = |
453 | ParenType | 461 | ParenType |
@@ -465,13 +473,13 @@ TypeRef = | |||
465 | | DynTraitType | 473 | | DynTraitType |
466 | 474 | ||
467 | AssocItem = | 475 | AssocItem = |
468 | FnDef | 476 | Fn |
469 | | TypeAliasDef | 477 | | TypeAlias |
470 | | ConstDef | 478 | | Const |
471 | | MacroCall | 479 | | MacroCall |
472 | 480 | ||
473 | ExternItem = | 481 | ExternItem = |
474 | FnDef | StaticDef | 482 | Fn | Static |
475 | 483 | ||
476 | AttrInput = | 484 | AttrInput = |
477 | Literal | 485 | Literal |
@@ -514,7 +522,7 @@ Expr = | |||
514 | | BlockExpr | 522 | | BlockExpr |
515 | | ReturnExpr | 523 | | ReturnExpr |
516 | | MatchExpr | 524 | | MatchExpr |
517 | | RecordLit | 525 | | RecordExpr |
518 | | CallExpr | 526 | | CallExpr |
519 | | IndexExpr | 527 | | IndexExpr |
520 | | MethodCallExpr | 528 | | MethodCallExpr |