@@ -451,6 +451,27 @@ TryStatement: ast::Stmt = {
451451 },
452452 }
453453 },
454+ <location:@L> "try" ":" <body:Suite> <handlers:ExceptStarClause+> <else_suite:("else" ":" Suite)?> <finally:("finally" ":" Suite)?> <end_location:@R> => {
455+ let orelse = else_suite.map(|s| s.2).unwrap_or_default();
456+ let finalbody = finally.map(|s| s.2).unwrap_or_default();
457+ let end_location = finalbody
458+ .last()
459+ .or_else(|| orelse.last())
460+ .map(|last| last.end_location)
461+ .or_else(|| handlers.last().map(|last| last.end_location))
462+ .unwrap();
463+ ast::Stmt {
464+ custom: (),
465+ location,
466+ end_location,
467+ node: ast::StmtKind::TryStar {
468+ body,
469+ handlers,
470+ orelse,
471+ finalbody,
472+ },
473+ }
474+ },
454475 <location:@L> "try" ":" <body:Suite> <finally:("finally" ":" Suite)> => {
455476 let handlers = vec![];
456477 let orelse = vec![];
@@ -470,6 +491,34 @@ TryStatement: ast::Stmt = {
470491 },
471492};
472493
494+ ExceptStarClause: ast::Excepthandler = {
495+ <location:@L> "except" "*" <typ:Test<"all">> ":" <body:Suite> => {
496+ let end_location = body.last().unwrap().end_location.unwrap();
497+ ast::Excepthandler::new(
498+ location,
499+ end_location,
500+ ast::ExcepthandlerKind::ExceptHandler {
501+ type_: Some(Box::new(typ)),
502+ name: None,
503+ body,
504+ },
505+ )
506+ },
507+ <location:@L> "except" "*" <x:(Test<"all"> "as" Identifier)> ":" <body:Suite> => {
508+ let end_location = body.last().unwrap().end_location.unwrap();
509+ ast::Excepthandler::new(
510+ location,
511+ end_location,
512+ ast::ExcepthandlerKind::ExceptHandler {
513+ type_: Some(Box::new(x.0)),
514+ name: Some(x.2),
515+ body,
516+ },
517+ )
518+ },
519+ };
520+
521+
473522ExceptClause: ast::Excepthandler = {
474523 <location:@L> "except" <typ:Test<"all">?> ":" <body:Suite> => {
475524 let end_location = body.last().unwrap().end_location.unwrap();
0 commit comments