@@ -734,19 +734,19 @@ ClassPattern: ast::Pattern = {
734734}
735735
736736IfStatement: ast::Stmt = {
737- <location:@L> "if" <test:NamedExpressionTest> ":" <body:Suite> <s2:(@L "elif" NamedExpressionTest ":" Suite)*> <s3:("else" ":" Suite)?> => {
737+ <location:@L> "if" <test:NamedExpressionTest> ":" <body:Suite> <s2:(<@L> "elif" < NamedExpressionTest> ":" < Suite> )*> <s3:("else" ":" < Suite> )?> => {
738738 // Determine last else:
739- let mut last = s3.map(|s| s.2). unwrap_or_default();
739+ let mut last = s3.unwrap_or_default();
740740 let end_location = last
741741 .last()
742- .or_else(|| s2.last().and_then(|last| last.4 .last()))
742+ .or_else(|| s2.last().and_then(|last| last.2 .last()))
743743 .or_else(|| body.last())
744744 .unwrap()
745745 .end();
746746 // handle elif:
747747 for i in s2.into_iter().rev() {
748748 let x = ast::Stmt::If(
749- ast::StmtIf { test: Box::new(i.2 ), body: i.4 , orelse: last, range: (i.0..end_location).into() }
749+ ast::StmtIf { test: Box::new(i.1 ), body: i.2 , orelse: last, range: (i.0..end_location).into() }
750750 );
751751 last = vec![x];
752752 }
@@ -758,8 +758,8 @@ IfStatement: ast::Stmt = {
758758};
759759
760760WhileStatement: ast::Stmt = {
761- <location:@L> "while" <test:NamedExpressionTest> ":" <body:Suite> <s2:("else" ":" Suite)?> => {
762- let orelse = s2.map(|s| s.2). unwrap_or_default();
761+ <location:@L> "while" <test:NamedExpressionTest> ":" <body:Suite> <s2:("else" ":" < Suite> )?> => {
762+ let orelse = s2.unwrap_or_default();
763763 let end_location = orelse
764764 .last()
765765 .or_else(|| body.last())
@@ -777,8 +777,8 @@ WhileStatement: ast::Stmt = {
777777};
778778
779779ForStatement: ast::Stmt = {
780- <location:@L> <is_async:"async"?> "for" <target:ExpressionList> "in" <iter:TestList> ":" <body:Suite> <s2 :("else" ":" Suite)?> => {
781- let orelse = s2.map(|s| s.2) .unwrap_or_default();
780+ <location:@L> <is_async:"async"?> "for" <target:ExpressionList> "in" <iter:TestList> ":" <body:Suite> <orelse :("else" ":" < Suite> )?> => {
781+ let orelse = orelse .unwrap_or_default();
782782 let end_location = orelse
783783 .last()
784784 .or_else(|| body.last())
@@ -796,9 +796,9 @@ ForStatement: ast::Stmt = {
796796};
797797
798798TryStatement: ast::Stmt = {
799- <location:@L> "try" ":" <body:Suite> <handlers:ExceptClause+> <else_suite :("else" ":" Suite)?> <finally :("finally" ":" Suite)?> <end_location:@R> => {
800- let orelse = else_suite.map(|s| s.2) .unwrap_or_default();
801- let finalbody = finally.map(|s| s.2) .unwrap_or_default();
799+ <location:@L> "try" ":" <body:Suite> <handlers:ExceptClause+> <orelse :("else" ":" < Suite> )?> <finalbody :("finally" ":" < Suite> )?> <end_location:@R> => {
800+ let orelse = orelse .unwrap_or_default();
801+ let finalbody = finalbody .unwrap_or_default();
802802 let end_location = finalbody
803803 .last()
804804 .map(|last| last.end())
@@ -815,9 +815,9 @@ TryStatement: ast::Stmt = {
815815 },
816816 )
817817 },
818- <location:@L> "try" ":" <body:Suite> <handlers:ExceptStarClause+> <else_suite :("else" ":" Suite)?> <finally :("finally" ":" Suite)?> <end_location:@R> => {
819- let orelse = else_suite.map(|s| s.2) .unwrap_or_default();
820- let finalbody = finally.map(|s| s.2) .unwrap_or_default();
818+ <location:@L> "try" ":" <body:Suite> <handlers:ExceptStarClause+> <orelse :("else" ":" < Suite> )?> <finalbody :("finally" ":" < Suite> )?> <end_location:@R> => {
819+ let orelse = orelse .unwrap_or_default();
820+ let finalbody = finalbody .unwrap_or_default();
821821 let end_location = finalbody
822822 .last()
823823 .or_else(|| orelse.last())
@@ -834,10 +834,9 @@ TryStatement: ast::Stmt = {
834834 },
835835 )
836836 },
837- <location:@L> "try" ":" <body:Suite> <finally :("finally" ":" Suite)> => {
837+ <location:@L> "try" ":" <body:Suite> <finalbody :("finally" ":" < Suite> )> => {
838838 let handlers = vec![];
839839 let orelse = vec![];
840- let finalbody = finally.2;
841840 let end_location = finalbody.last().unwrap().end();
842841 ast::Stmt::Try(
843842 ast::StmtTry {
@@ -863,12 +862,12 @@ ExceptStarClause: ast::Excepthandler = {
863862 },
864863 )
865864 },
866- <location:@L> "except" "*" <x:(Test<"all"> "as" Identifier)> ":" <body:Suite> => {
865+ <location:@L> "except" "*" <x:(< Test<"all">> "as" < Identifier> )> ":" <body:Suite> => {
867866 let end_location = body.last().unwrap().end();
868867 ast::Excepthandler::ExceptHandler(
869868 ast::ExcepthandlerExceptHandler {
870869 type_: Some(Box::new(x.0)),
871- name: Some(x.2 ),
870+ name: Some(x.1 ),
872871 body,
873872 range: (location..end_location).into()
874873 },
@@ -889,12 +888,12 @@ ExceptClause: ast::Excepthandler = {
889888 },
890889 )
891890 },
892- <location:@L> "except" <x:(Test<"all"> "as" Identifier)> ":" <body:Suite> => {
891+ <location:@L> "except" <x:(< Test<"all">> "as" < Identifier> )> ":" <body:Suite> => {
893892 let end_location = body.last().unwrap().end();
894893 ast::Excepthandler::ExceptHandler(
895894 ast::ExcepthandlerExceptHandler {
896895 type_: Some(Box::new(x.0)),
897- name: Some(x.2 ),
896+ name: Some(x.1 ),
898897 body,
899898 range: (location..end_location).into()
900899 },
@@ -941,7 +940,7 @@ WithItem<Goal>: ast::Withitem = {
941940};
942941
943942FuncDef: ast::Stmt = {
944- <decorator_list:Decorator*> <location:@L> <is_async:"async"?> "def" <name:Identifier> <args:Parameters> <r:("->" <Test<"all">>)?> ":" <body:Suite> => {
943+ <decorator_list:Decorator*> <location:@L> <is_async:"async"?> "def" <name:Identifier> <args:Parameters> <r:("->" <Test<"all">>)?> ":" <body:Suite> => {
945944 let args = Box::new(args);
946945 let returns = r.map(|x| Box::new(x));
947946 let end_location = body.last().unwrap().end();
0 commit comments