@@ -1180,7 +1180,7 @@ FuncDef: ast::Stmt = {
1180
1180
};
1181
1181
1182
1182
Parameters: ast::Arguments = {
1183
- "(" <a: (ParameterList<TypedParameter>)?> ")" =>? {
1183
+ "(" <a: (ParameterList<TypedParameter, StarTypedParameter >)?> ")" =>? {
1184
1184
let args = validate_arguments(
1185
1185
a.unwrap_or_else(|| ast::Arguments {
1186
1186
posonlyargs: vec![],
@@ -1199,8 +1199,8 @@ Parameters: ast::Arguments = {
1199
1199
1200
1200
// Note that this is a macro which is used once for function defs, and
1201
1201
// once for lambda defs.
1202
- ParameterList<ArgType>: ast::Arguments = {
1203
- <param1:ParameterDefs<ArgType>> <args2:("," ParameterListStarArgs<ArgType>)?> ","? =>? {
1202
+ ParameterList<ArgType, StarArgType >: ast::Arguments = {
1203
+ <param1:ParameterDefs<ArgType>> <args2:("," ParameterListStarArgs<ArgType, StarArgType >)?> ","? =>? {
1204
1204
let (posonlyargs, args, defaults) = parse_params(param1)?;
1205
1205
1206
1206
// Now gather rest of parameters:
@@ -1235,7 +1235,7 @@ ParameterList<ArgType>: ast::Arguments = {
1235
1235
kw_defaults,
1236
1236
})
1237
1237
},
1238
- <params:ParameterListStarArgs<ArgType>> ","? => {
1238
+ <params:ParameterListStarArgs<ArgType, StarArgType >> ","? => {
1239
1239
let (vararg, kwonlyargs, kw_defaults, kwarg) = params;
1240
1240
ast::Arguments {
1241
1241
posonlyargs: vec![],
@@ -1291,11 +1291,18 @@ TypedParameter: ast::Arg = {
1291
1291
},
1292
1292
};
1293
1293
1294
+ StarTypedParameter: ast::Arg = {
1295
+ <location:@L> <arg:Identifier> <a:(":" TestOrStarExpr)?> <end_location:@R> => {
1296
+ let annotation = a.map(|x| Box::new(x.1));
1297
+ ast::Arg::new(location, end_location, ast::ArgData { arg, annotation, type_comment: None })
1298
+ },
1299
+ };
1300
+
1294
1301
// Use inline here to make sure the "," is not creating an ambiguity.
1295
1302
// TODO: figure out another grammar that makes this inline no longer required.
1296
1303
#[inline]
1297
- ParameterListStarArgs<ArgType>: (Option<Box<ast::Arg>>, Vec<ast::Arg>, Vec<ast::Expr>, Option<Box<ast::Arg>>) = {
1298
- <location:@L> "*" <va:ArgType ?> <kw:("," ParameterDef<ArgType>)*> <kwarg:("," KwargParameter<ArgType>)?> =>? {
1304
+ ParameterListStarArgs<ArgType, StarArgType >: (Option<Box<ast::Arg>>, Vec<ast::Arg>, Vec<ast::Expr>, Option<Box<ast::Arg>>) = {
1305
+ <location:@L> "*" <va:StarArgType ?> <kw:("," ParameterDef<ArgType>)*> <kwarg:("," KwargParameter<ArgType>)?> =>? {
1299
1306
// Extract keyword arguments:
1300
1307
let mut kwonlyargs = Vec::new();
1301
1308
let mut kw_defaults = Vec::new();
@@ -1413,7 +1420,7 @@ NamedExpression: ast::Expr = {
1413
1420
};
1414
1421
1415
1422
LambdaDef: ast::Expr = {
1416
- <location:@L> "lambda" <p:ParameterList<UntypedParameter>?> ":" <body:Test<"all">> <end_location:@R> =>? {
1423
+ <location:@L> "lambda" <p:ParameterList<UntypedParameter, UntypedParameter >?> ":" <body:Test<"all">> <end_location:@R> =>? {
1417
1424
let p = validate_arguments(
1418
1425
p.unwrap_or_else(|| {
1419
1426
ast::Arguments {
0 commit comments