@@ -1126,27 +1126,51 @@ KwargParameter<ArgType>: Option<Box<ast::Arg>> = {
11261126};
11271127
11281128ClassDef: ast::Stmt = {
1129- <decorator_list:Decorator*> <location:@L> "class" <name:Identifier> <a:("(" ArgumentList ")")?> ":" <body:Suite> => {
1129+ <decorator_list:Decorator*> <location:@L> "class" <name:Identifier> <type_params:TypeParamList?> < a:("(" ArgumentList ")")?> ":" <body:Suite> => {
11301130 let (bases, keywords) = match a {
11311131 Some((_, arg, _)) => (arg.args, arg.keywords),
11321132 None => (vec![], vec![]),
11331133 };
11341134 let end_location = body.last().unwrap().end();
1135- let type_params = Vec::new();
11361135 ast::Stmt::ClassDef(
11371136 ast::StmtClassDef {
11381137 name,
11391138 bases,
11401139 keywords,
11411140 body,
11421141 decorator_list,
1143- type_params,
1142+ type_params: type_params.unwrap_or_default() ,
11441143 range: (location..end_location).into()
11451144 },
11461145 )
11471146 },
11481147};
11491148
1149+
1150+ TypeParamList: Vec<ast::TypeParam> = {
1151+ <location:@L> "[" <vars:OneOrMore<TypeParam>> ","? "]" <end_location:@R> => {
1152+ vars
1153+ }
1154+ };
1155+
1156+ TypeParam: ast::TypeParam = {
1157+ <location:@L> <name:Identifier> <bound:(":" <Test<"all">>)?> <end_location:@R> => {
1158+ ast::TypeParam::TypeVar(
1159+ ast::TypeParamTypeVar { name, bound: bound.map(Box::new), range: (location..end_location).into() }
1160+ )
1161+ },
1162+ <location:@L> "*" <name:Identifier> <end_location:@R> => {
1163+ ast::TypeParam::TypeVarTuple(
1164+ ast::TypeParamTypeVarTuple { name, range: (location..end_location).into() }
1165+ )
1166+ },
1167+ <location:@L> "**" <name:Identifier> <end_location:@R> => {
1168+ ast::TypeParam::ParamSpec(
1169+ ast::TypeParamParamSpec { name, range: (location..end_location).into() }
1170+ )
1171+ }
1172+ };
1173+
11501174// Decorators:
11511175Decorator: ast::Expr = {
11521176 <location:@L> "@" <p:NamedExpressionTest> "\n" => {
0 commit comments