@@ -861,7 +861,8 @@ VALIDATER(listmaker); VALIDATER(yield_stmt);
861861VALIDATER (testlist1 ); VALIDATER (gen_for );
862862VALIDATER (gen_iter ); VALIDATER (gen_if );
863863VALIDATER (testlist_gexp ); VALIDATER (yield_expr );
864- VALIDATER (yield_or_testlist );
864+ VALIDATER (yield_or_testlist ); VALIDATER (or_test );
865+ VALIDATER (old_test ); VALIDATER (old_lambdef );
865866
866867#undef VALIDATER
867868
@@ -1095,7 +1096,7 @@ static int
10951096validate_testlist_safe (node * tree )
10961097{
10971098 return (validate_repeating_list (tree , testlist_safe ,
1098- validate_test , "testlist_safe" ));
1099+ validate_old_test , "testlist_safe" ));
10991100}
11001101
11011102
@@ -1315,7 +1316,7 @@ validate_gen_for(node *tree)
13151316 res = (validate_name (CHILD (tree , 0 ), "for" )
13161317 && validate_exprlist (CHILD (tree , 1 ))
13171318 && validate_name (CHILD (tree , 2 ), "in" )
1318- && validate_test (CHILD (tree , 3 )));
1319+ && validate_or_test (CHILD (tree , 3 )));
13191320
13201321 return res ;
13211322}
@@ -2047,6 +2048,37 @@ validate_test(node *tree)
20472048 res = ((nch == 1 )
20482049 && validate_lambdef (CHILD (tree , 0 )));
20492050 else if (res ) {
2051+ res = validate_or_test (CHILD (tree , 0 ));
2052+ res = (res && (nch == 1 || (nch == 5 &&
2053+ validate_name (CHILD (tree , 1 ), "if" ) &&
2054+ validate_or_test (CHILD (tree , 2 )) &&
2055+ validate_name (CHILD (tree , 3 ), "else" ) &&
2056+ validate_test (CHILD (tree , 4 )))));
2057+ }
2058+ return (res );
2059+ }
2060+
2061+ static int
2062+ validate_old_test (node * tree )
2063+ {
2064+ int nch = NCH (tree );
2065+ int res = validate_ntype (tree , old_test ) && (nch == 1 );
2066+
2067+ if (res && (TYPE (CHILD (tree , 0 )) == old_lambdef ))
2068+ res = (validate_old_lambdef (CHILD (tree , 0 )));
2069+ else if (res ) {
2070+ res = (validate_or_test (CHILD (tree , 0 )));
2071+ }
2072+ return (res );
2073+ }
2074+
2075+ static int
2076+ validate_or_test (node * tree )
2077+ {
2078+ int nch = NCH (tree );
2079+ int res = validate_ntype (tree , or_test ) && is_odd (nch );
2080+
2081+ if (res ) {
20502082 int pos ;
20512083 res = validate_and_test (CHILD (tree , 0 ));
20522084 for (pos = 1 ; res && (pos < nch ); pos += 2 )
@@ -2533,6 +2565,25 @@ validate_lambdef(node *tree)
25332565}
25342566
25352567
2568+ static int
2569+ validate_old_lambdef (node * tree )
2570+ {
2571+ int nch = NCH (tree );
2572+ int res = (validate_ntype (tree , old_lambdef )
2573+ && ((nch == 3 ) || (nch == 4 ))
2574+ && validate_name (CHILD (tree , 0 ), "lambda" )
2575+ && validate_colon (CHILD (tree , nch - 2 ))
2576+ && validate_test (CHILD (tree , nch - 1 )));
2577+
2578+ if (res && (nch == 4 ))
2579+ res = validate_varargslist (CHILD (tree , 1 ));
2580+ else if (!res && !PyErr_Occurred ())
2581+ (void ) validate_numnodes (tree , 3 , "old_lambdef" );
2582+
2583+ return (res );
2584+ }
2585+
2586+
25362587/* arglist:
25372588 *
25382589 * (argument ',')* (argument [','] | '*' test [',' '**' test] | '**' test)
0 commit comments