Introduce GenericParam

This commit is contained in:
Aleksey Kladov 2020-07-30 18:52:02 +02:00
parent 917c89c103
commit 3dce34aaf8
5 changed files with 170 additions and 103 deletions

View file

@ -204,6 +204,7 @@ pub(crate) const KINDS_SRC: KindsSrc = KindsSrc {
"LET_STMT",
"EXPR_STMT",
"GENERIC_PARAM_LIST",
"GENERIC_PARAM",
"LIFETIME_PARAM",
"TYPE_PARAM",
"CONST_PARAM",

View file

@ -154,6 +154,25 @@ ExternItemList =
ExternItem =
Fn | Static | MacroCall
GenericParamList =
'<' (GenericParam (',' GenericParam)* ','?)? '>'
GenericParam =
LifetimeParam
| TypeParam
| ConstParam
TypeParam =
Attr* Name (':' TypeBoundList?)?
('=' default_type:TypeRef)?
ConstParam =
Attr* 'const' Name ':' ascribed_type:TypeRef
('=' default_val:Expr)?
LifetimeParam =
Attr* 'lifetime'
ParenType =
'(' TypeRef ')'
@ -400,24 +419,6 @@ MacroStmts =
Attr =
'#' '!'? '[' Path ('=' input:AttrInput)? ']'
GenericParamList =
'<'
TypeParam*
LifetimeParam*
ConstParam*
'>'
TypeParam =
Attr* Name (':' TypeBoundList?)?
('=' default_type:TypeRef)?
ConstParam =
Attr* 'const' Name ':' ascribed_type:TypeRef
('=' default_val:Expr)?
LifetimeParam =
Attr* 'lifetime'
TypeBound =
'lifetime' | 'const'? TypeRef