File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ pub struct Program {
21
21
#[ derive( Clone , PartialEq , Eq , Debug ) ]
22
22
pub enum Item {
23
23
StructDefn ( StructDefn ) ,
24
+ FnDefn ( FnDefn ) ,
24
25
TraitDefn ( TraitDefn ) ,
25
26
OpaqueTyDefn ( OpaqueTyDefn ) ,
26
27
Impl ( Impl ) ,
@@ -42,6 +43,19 @@ pub struct StructFlags {
42
43
pub fundamental : bool ,
43
44
}
44
45
46
+ #[ derive( Clone , PartialEq , Eq , Debug ) ]
47
+ pub struct FnDefn {
48
+ pub name : Identifier ,
49
+ pub variable_kinds : Vec < VariableKind > ,
50
+ pub where_clauses : Vec < QuantifiedWhereClause > ,
51
+ pub argument_types : Vec < Ty > ,
52
+ pub return_type : Ty ,
53
+ pub flags : FnDefFlags ,
54
+ }
55
+
56
+ #[ derive( Clone , PartialEq , Eq , Debug ) ]
57
+ pub struct FnDefFlags { }
58
+
45
59
#[ derive( Clone , PartialEq , Eq , Debug ) ]
46
60
pub struct TraitDefn {
47
61
pub name : Identifier ,
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ Items: Vec<Item> = {
14
14
Item: Option<Item> = {
15
15
Comment => None,
16
16
StructDefn => Some(Item::StructDefn(<>)),
17
+ FnDefn => Some(Item::FnDefn(<>)),
17
18
TraitDefn => Some(Item::TraitDefn(<>)),
18
19
OpaqueTyDefn => Some(Item::OpaqueTyDefn(<>)),
19
20
Impl => Some(Item::Impl(<>)),
@@ -67,6 +68,32 @@ StructDefn: StructDefn = {
67
68
}
68
69
};
69
70
71
+ FnReturn: Ty = {
72
+ "->" <ty:Ty> => ty,
73
+ };
74
+
75
+ FnDefn: FnDefn = {
76
+ "fn" <n:Id> <p:Angle<VariableKind>>"(" <args:FnArgs> ")"
77
+ <ret_ty:FnReturn?> <w:QuantifiedWhereClauses> ";" => FnDefn
78
+ {
79
+ name: n,
80
+ variable_kinds: p,
81
+ where_clauses: w,
82
+ argument_types: args,
83
+ return_type: ret_ty.unwrap_or_else(|| Ty::Tuple { types: Vec::new() }),
84
+ flags: FnDefFlags {
85
+ },
86
+ }
87
+ };
88
+
89
+ FnArg: Ty = {
90
+ Id ":" <arg_ty: Ty> => arg_ty
91
+ };
92
+
93
+ FnArgs: Vec<Ty> = {
94
+ <Comma<FnArg>>
95
+ };
96
+
70
97
TraitDefn: TraitDefn = {
71
98
<auto:AutoKeyword?> <marker:MarkerKeyword?> <upstream:UpstreamKeyword?> <fundamental:FundamentalKeyword?> <non_enumerable:NonEnumerableKeyword?> <coinductive:CoinductiveKeyword?> <object_safe:ObjectSafeKeyword?> <well_known:WellKnownTrait?> "trait" <n:Id><p:Angle<VariableKind>>
72
99
<w:QuantifiedWhereClauses> "{" <a:AssocTyDefn*> "}" => TraitDefn
You can’t perform that action at this time.
0 commit comments