Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1 | // @generated by pegen.py from ./Grammar/python.gram |
| 2 | #include "pegen.h" |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 3 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4 | #if defined(Py_DEBUG) && defined(Py_BUILD_CORE) |
Victor Stinner | 6af528b | 2021-03-18 09:54:13 +0100 | [diff] [blame] | 5 | # define D(x) if (Py_DebugFlag) x; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 6 | #else |
Victor Stinner | 6af528b | 2021-03-18 09:54:13 +0100 | [diff] [blame] | 7 | # define D(x) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 8 | #endif |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9 | static const int n_keyword_lists = 9; |
| 10 | static KeywordToken *reserved_keywords[] = { |
Pablo Galindo | 1ac0cbc | 2020-07-06 20:31:16 +0100 | [diff] [blame] | 11 | (KeywordToken[]) {{NULL, -1}}, |
| 12 | (KeywordToken[]) {{NULL, -1}}, |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13 | (KeywordToken[]) { |
| 14 | {"if", 510}, |
| 15 | {"in", 518}, |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16 | {"as", 520}, |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 17 | {"is", 530}, |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18 | {"or", 531}, |
| 19 | {NULL, -1}, |
| 20 | }, |
| 21 | (KeywordToken[]) { |
| 22 | {"del", 503}, |
| 23 | {"try", 511}, |
| 24 | {"for", 517}, |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25 | {"def", 526}, |
| 26 | {"not", 529}, |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27 | {"and", 532}, |
| 28 | {NULL, -1}, |
| 29 | }, |
| 30 | (KeywordToken[]) { |
| 31 | {"pass", 502}, |
| 32 | {"from", 514}, |
| 33 | {"elif", 515}, |
| 34 | {"else", 516}, |
| 35 | {"with", 519}, |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 36 | {"None", 523}, |
| 37 | {"True", 524}, |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 38 | {NULL, -1}, |
| 39 | }, |
| 40 | (KeywordToken[]) { |
| 41 | {"raise", 501}, |
| 42 | {"yield", 504}, |
| 43 | {"break", 506}, |
| 44 | {"while", 512}, |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 45 | {"False", 525}, |
| 46 | {"class", 527}, |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 47 | {NULL, -1}, |
| 48 | }, |
| 49 | (KeywordToken[]) { |
| 50 | {"return", 500}, |
| 51 | {"assert", 505}, |
| 52 | {"global", 508}, |
| 53 | {"import", 513}, |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 54 | {"except", 521}, |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 55 | {"lambda", 528}, |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 56 | {NULL, -1}, |
| 57 | }, |
| 58 | (KeywordToken[]) { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 59 | {"finally", 522}, |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 60 | {NULL, -1}, |
| 61 | }, |
| 62 | (KeywordToken[]) { |
| 63 | {"continue", 507}, |
| 64 | {"nonlocal", 509}, |
| 65 | {NULL, -1}, |
| 66 | }, |
| 67 | }; |
| 68 | #define file_type 1000 |
| 69 | #define interactive_type 1001 |
| 70 | #define eval_type 1002 |
| 71 | #define func_type_type 1003 |
| 72 | #define fstring_type 1004 |
| 73 | #define type_expressions_type 1005 |
| 74 | #define statements_type 1006 |
| 75 | #define statement_type 1007 |
| 76 | #define statement_newline_type 1008 |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 77 | #define simple_stmts_type 1009 |
| 78 | #define simple_stmt_type 1010 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 79 | #define compound_stmt_type 1011 |
| 80 | #define assignment_type 1012 |
| 81 | #define augassign_type 1013 |
| 82 | #define global_stmt_type 1014 |
| 83 | #define nonlocal_stmt_type 1015 |
| 84 | #define yield_stmt_type 1016 |
| 85 | #define assert_stmt_type 1017 |
| 86 | #define del_stmt_type 1018 |
| 87 | #define import_stmt_type 1019 |
| 88 | #define import_name_type 1020 |
| 89 | #define import_from_type 1021 |
| 90 | #define import_from_targets_type 1022 |
| 91 | #define import_from_as_names_type 1023 |
| 92 | #define import_from_as_name_type 1024 |
| 93 | #define dotted_as_names_type 1025 |
| 94 | #define dotted_as_name_type 1026 |
| 95 | #define dotted_name_type 1027 // Left-recursive |
| 96 | #define if_stmt_type 1028 |
| 97 | #define elif_stmt_type 1029 |
| 98 | #define else_block_type 1030 |
| 99 | #define while_stmt_type 1031 |
| 100 | #define for_stmt_type 1032 |
| 101 | #define with_stmt_type 1033 |
| 102 | #define with_item_type 1034 |
| 103 | #define try_stmt_type 1035 |
| 104 | #define except_block_type 1036 |
| 105 | #define finally_block_type 1037 |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 106 | #define match_stmt_type 1038 |
| 107 | #define subject_expr_type 1039 |
| 108 | #define case_block_type 1040 |
| 109 | #define guard_type 1041 |
| 110 | #define patterns_type 1042 |
| 111 | #define pattern_type 1043 |
| 112 | #define as_pattern_type 1044 |
| 113 | #define or_pattern_type 1045 |
| 114 | #define closed_pattern_type 1046 |
| 115 | #define literal_pattern_type 1047 |
| 116 | #define signed_number_type 1048 |
| 117 | #define capture_pattern_type 1049 |
| 118 | #define wildcard_pattern_type 1050 |
| 119 | #define value_pattern_type 1051 |
| 120 | #define attr_type 1052 // Left-recursive |
| 121 | #define name_or_attr_type 1053 // Left-recursive |
| 122 | #define group_pattern_type 1054 |
| 123 | #define sequence_pattern_type 1055 |
| 124 | #define open_sequence_pattern_type 1056 |
| 125 | #define maybe_sequence_pattern_type 1057 |
| 126 | #define maybe_star_pattern_type 1058 |
| 127 | #define star_pattern_type 1059 |
| 128 | #define mapping_pattern_type 1060 |
| 129 | #define items_pattern_type 1061 |
| 130 | #define key_value_pattern_type 1062 |
| 131 | #define double_star_pattern_type 1063 |
| 132 | #define class_pattern_type 1064 |
| 133 | #define positional_patterns_type 1065 |
| 134 | #define keyword_patterns_type 1066 |
| 135 | #define keyword_pattern_type 1067 |
| 136 | #define return_stmt_type 1068 |
| 137 | #define raise_stmt_type 1069 |
| 138 | #define function_def_type 1070 |
| 139 | #define function_def_raw_type 1071 |
| 140 | #define func_type_comment_type 1072 |
| 141 | #define params_type 1073 |
| 142 | #define parameters_type 1074 |
| 143 | #define slash_no_default_type 1075 |
| 144 | #define slash_with_default_type 1076 |
| 145 | #define star_etc_type 1077 |
| 146 | #define kwds_type 1078 |
| 147 | #define param_no_default_type 1079 |
| 148 | #define param_with_default_type 1080 |
| 149 | #define param_maybe_default_type 1081 |
| 150 | #define param_type 1082 |
| 151 | #define annotation_type 1083 |
| 152 | #define default_type 1084 |
| 153 | #define decorators_type 1085 |
| 154 | #define class_def_type 1086 |
| 155 | #define class_def_raw_type 1087 |
| 156 | #define block_type 1088 |
| 157 | #define star_expressions_type 1089 |
| 158 | #define star_expression_type 1090 |
| 159 | #define star_named_expressions_type 1091 |
| 160 | #define star_named_expression_type 1092 |
| 161 | #define named_expression_type 1093 |
| 162 | #define annotated_rhs_type 1094 |
| 163 | #define expressions_type 1095 |
| 164 | #define expression_type 1096 |
| 165 | #define lambdef_type 1097 |
| 166 | #define lambda_params_type 1098 |
| 167 | #define lambda_parameters_type 1099 |
| 168 | #define lambda_slash_no_default_type 1100 |
| 169 | #define lambda_slash_with_default_type 1101 |
| 170 | #define lambda_star_etc_type 1102 |
| 171 | #define lambda_kwds_type 1103 |
| 172 | #define lambda_param_no_default_type 1104 |
| 173 | #define lambda_param_with_default_type 1105 |
| 174 | #define lambda_param_maybe_default_type 1106 |
| 175 | #define lambda_param_type 1107 |
| 176 | #define disjunction_type 1108 |
| 177 | #define conjunction_type 1109 |
| 178 | #define inversion_type 1110 |
| 179 | #define comparison_type 1111 |
| 180 | #define compare_op_bitwise_or_pair_type 1112 |
| 181 | #define eq_bitwise_or_type 1113 |
| 182 | #define noteq_bitwise_or_type 1114 |
| 183 | #define lte_bitwise_or_type 1115 |
| 184 | #define lt_bitwise_or_type 1116 |
| 185 | #define gte_bitwise_or_type 1117 |
| 186 | #define gt_bitwise_or_type 1118 |
| 187 | #define notin_bitwise_or_type 1119 |
| 188 | #define in_bitwise_or_type 1120 |
| 189 | #define isnot_bitwise_or_type 1121 |
| 190 | #define is_bitwise_or_type 1122 |
| 191 | #define bitwise_or_type 1123 // Left-recursive |
| 192 | #define bitwise_xor_type 1124 // Left-recursive |
| 193 | #define bitwise_and_type 1125 // Left-recursive |
| 194 | #define shift_expr_type 1126 // Left-recursive |
| 195 | #define sum_type 1127 // Left-recursive |
| 196 | #define term_type 1128 // Left-recursive |
| 197 | #define factor_type 1129 |
| 198 | #define power_type 1130 |
| 199 | #define await_primary_type 1131 |
| 200 | #define primary_type 1132 // Left-recursive |
| 201 | #define slices_type 1133 |
| 202 | #define slice_type 1134 |
| 203 | #define atom_type 1135 |
| 204 | #define strings_type 1136 |
| 205 | #define list_type 1137 |
| 206 | #define listcomp_type 1138 |
| 207 | #define tuple_type 1139 |
| 208 | #define group_type 1140 |
| 209 | #define genexp_type 1141 |
| 210 | #define set_type 1142 |
| 211 | #define setcomp_type 1143 |
| 212 | #define dict_type 1144 |
| 213 | #define dictcomp_type 1145 |
| 214 | #define double_starred_kvpairs_type 1146 |
| 215 | #define double_starred_kvpair_type 1147 |
| 216 | #define kvpair_type 1148 |
| 217 | #define for_if_clauses_type 1149 |
| 218 | #define for_if_clause_type 1150 |
| 219 | #define yield_expr_type 1151 |
| 220 | #define arguments_type 1152 |
| 221 | #define args_type 1153 |
| 222 | #define kwargs_type 1154 |
| 223 | #define starred_expression_type 1155 |
| 224 | #define kwarg_or_starred_type 1156 |
| 225 | #define kwarg_or_double_starred_type 1157 |
| 226 | #define star_targets_type 1158 |
| 227 | #define star_targets_list_seq_type 1159 |
| 228 | #define star_targets_tuple_seq_type 1160 |
| 229 | #define star_target_type 1161 |
| 230 | #define target_with_star_atom_type 1162 |
| 231 | #define star_atom_type 1163 |
| 232 | #define single_target_type 1164 |
| 233 | #define single_subscript_attribute_target_type 1165 |
| 234 | #define del_targets_type 1166 |
| 235 | #define del_target_type 1167 |
| 236 | #define del_t_atom_type 1168 |
| 237 | #define targets_type 1169 |
| 238 | #define target_type 1170 |
| 239 | #define t_primary_type 1171 // Left-recursive |
| 240 | #define t_lookahead_type 1172 |
| 241 | #define t_atom_type 1173 |
| 242 | #define invalid_arguments_type 1174 |
| 243 | #define invalid_kwarg_type 1175 |
| 244 | #define invalid_named_expression_type 1176 |
| 245 | #define invalid_assignment_type 1177 |
| 246 | #define invalid_ann_assign_target_type 1178 |
| 247 | #define invalid_del_stmt_type 1179 |
| 248 | #define invalid_block_type 1180 |
| 249 | #define invalid_primary_type 1181 // Left-recursive |
| 250 | #define invalid_comprehension_type 1182 |
| 251 | #define invalid_dict_comprehension_type 1183 |
| 252 | #define invalid_parameters_type 1184 |
| 253 | #define invalid_parameters_helper_type 1185 |
| 254 | #define invalid_lambda_parameters_type 1186 |
| 255 | #define invalid_lambda_parameters_helper_type 1187 |
| 256 | #define invalid_star_etc_type 1188 |
| 257 | #define invalid_lambda_star_etc_type 1189 |
| 258 | #define invalid_double_type_comments_type 1190 |
| 259 | #define invalid_with_item_type 1191 |
| 260 | #define invalid_for_target_type 1192 |
| 261 | #define invalid_group_type 1193 |
| 262 | #define invalid_import_from_targets_type 1194 |
| 263 | #define invalid_with_stmt_type 1195 |
| 264 | #define invalid_except_block_type 1196 |
Pablo Galindo | 08fb8ac | 2021-03-18 01:03:11 +0000 | [diff] [blame] | 265 | #define invalid_match_stmt_type 1197 |
| 266 | #define invalid_case_block_type 1198 |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 267 | #define invalid_if_stmt_type 1199 |
| 268 | #define invalid_elif_stmt_type 1200 |
| 269 | #define invalid_while_stmt_type 1201 |
| 270 | #define _loop0_1_type 1202 |
| 271 | #define _loop0_2_type 1203 |
| 272 | #define _loop0_4_type 1204 |
| 273 | #define _gather_3_type 1205 |
| 274 | #define _loop0_6_type 1206 |
| 275 | #define _gather_5_type 1207 |
| 276 | #define _loop0_8_type 1208 |
| 277 | #define _gather_7_type 1209 |
| 278 | #define _loop0_10_type 1210 |
| 279 | #define _gather_9_type 1211 |
| 280 | #define _loop1_11_type 1212 |
| 281 | #define _loop0_13_type 1213 |
| 282 | #define _gather_12_type 1214 |
| 283 | #define _tmp_14_type 1215 |
| 284 | #define _tmp_15_type 1216 |
| 285 | #define _tmp_16_type 1217 |
| 286 | #define _tmp_17_type 1218 |
| 287 | #define _tmp_18_type 1219 |
| 288 | #define _tmp_19_type 1220 |
| 289 | #define _tmp_20_type 1221 |
| 290 | #define _tmp_21_type 1222 |
| 291 | #define _loop1_22_type 1223 |
| 292 | #define _tmp_23_type 1224 |
| 293 | #define _tmp_24_type 1225 |
| 294 | #define _loop0_26_type 1226 |
| 295 | #define _gather_25_type 1227 |
| 296 | #define _loop0_28_type 1228 |
| 297 | #define _gather_27_type 1229 |
| 298 | #define _tmp_29_type 1230 |
| 299 | #define _tmp_30_type 1231 |
| 300 | #define _loop0_31_type 1232 |
| 301 | #define _loop1_32_type 1233 |
| 302 | #define _loop0_34_type 1234 |
| 303 | #define _gather_33_type 1235 |
| 304 | #define _tmp_35_type 1236 |
| 305 | #define _loop0_37_type 1237 |
| 306 | #define _gather_36_type 1238 |
| 307 | #define _tmp_38_type 1239 |
| 308 | #define _loop0_40_type 1240 |
| 309 | #define _gather_39_type 1241 |
| 310 | #define _loop0_42_type 1242 |
| 311 | #define _gather_41_type 1243 |
| 312 | #define _loop0_44_type 1244 |
| 313 | #define _gather_43_type 1245 |
| 314 | #define _loop0_46_type 1246 |
| 315 | #define _gather_45_type 1247 |
| 316 | #define _tmp_47_type 1248 |
| 317 | #define _loop1_48_type 1249 |
| 318 | #define _tmp_49_type 1250 |
| 319 | #define _loop1_50_type 1251 |
| 320 | #define _loop0_52_type 1252 |
| 321 | #define _gather_51_type 1253 |
| 322 | #define _tmp_53_type 1254 |
| 323 | #define _tmp_54_type 1255 |
| 324 | #define _tmp_55_type 1256 |
| 325 | #define _loop0_57_type 1257 |
| 326 | #define _gather_56_type 1258 |
| 327 | #define _tmp_58_type 1259 |
| 328 | #define _loop0_60_type 1260 |
| 329 | #define _gather_59_type 1261 |
| 330 | #define _tmp_61_type 1262 |
| 331 | #define _loop0_63_type 1263 |
| 332 | #define _gather_62_type 1264 |
| 333 | #define _loop0_65_type 1265 |
| 334 | #define _gather_64_type 1266 |
| 335 | #define _tmp_66_type 1267 |
| 336 | #define _tmp_67_type 1268 |
| 337 | #define _tmp_68_type 1269 |
| 338 | #define _tmp_69_type 1270 |
| 339 | #define _loop0_70_type 1271 |
| 340 | #define _loop0_71_type 1272 |
| 341 | #define _loop0_72_type 1273 |
| 342 | #define _loop1_73_type 1274 |
| 343 | #define _loop0_74_type 1275 |
| 344 | #define _loop1_75_type 1276 |
| 345 | #define _loop1_76_type 1277 |
| 346 | #define _loop1_77_type 1278 |
| 347 | #define _loop0_78_type 1279 |
| 348 | #define _loop1_79_type 1280 |
| 349 | #define _loop0_80_type 1281 |
| 350 | #define _loop1_81_type 1282 |
| 351 | #define _loop0_82_type 1283 |
| 352 | #define _loop1_83_type 1284 |
| 353 | #define _loop1_84_type 1285 |
| 354 | #define _tmp_85_type 1286 |
| 355 | #define _loop1_86_type 1287 |
| 356 | #define _loop0_88_type 1288 |
| 357 | #define _gather_87_type 1289 |
| 358 | #define _loop1_89_type 1290 |
| 359 | #define _loop0_90_type 1291 |
| 360 | #define _loop0_91_type 1292 |
| 361 | #define _loop0_92_type 1293 |
| 362 | #define _loop1_93_type 1294 |
| 363 | #define _loop0_94_type 1295 |
| 364 | #define _loop1_95_type 1296 |
| 365 | #define _loop1_96_type 1297 |
| 366 | #define _loop1_97_type 1298 |
| 367 | #define _loop0_98_type 1299 |
| 368 | #define _loop1_99_type 1300 |
| 369 | #define _loop0_100_type 1301 |
| 370 | #define _loop1_101_type 1302 |
| 371 | #define _loop0_102_type 1303 |
| 372 | #define _loop1_103_type 1304 |
| 373 | #define _loop1_104_type 1305 |
| 374 | #define _loop1_105_type 1306 |
| 375 | #define _loop1_106_type 1307 |
| 376 | #define _tmp_107_type 1308 |
| 377 | #define _loop0_109_type 1309 |
| 378 | #define _gather_108_type 1310 |
| 379 | #define _tmp_110_type 1311 |
| 380 | #define _tmp_111_type 1312 |
| 381 | #define _tmp_112_type 1313 |
| 382 | #define _tmp_113_type 1314 |
| 383 | #define _loop1_114_type 1315 |
| 384 | #define _tmp_115_type 1316 |
| 385 | #define _tmp_116_type 1317 |
| 386 | #define _loop0_118_type 1318 |
| 387 | #define _gather_117_type 1319 |
| 388 | #define _loop1_119_type 1320 |
| 389 | #define _loop0_120_type 1321 |
| 390 | #define _loop0_121_type 1322 |
| 391 | #define _loop0_123_type 1323 |
| 392 | #define _gather_122_type 1324 |
| 393 | #define _tmp_124_type 1325 |
| 394 | #define _loop0_126_type 1326 |
| 395 | #define _gather_125_type 1327 |
| 396 | #define _loop0_128_type 1328 |
| 397 | #define _gather_127_type 1329 |
| 398 | #define _loop0_130_type 1330 |
| 399 | #define _gather_129_type 1331 |
| 400 | #define _loop0_132_type 1332 |
| 401 | #define _gather_131_type 1333 |
| 402 | #define _loop0_133_type 1334 |
| 403 | #define _loop0_135_type 1335 |
| 404 | #define _gather_134_type 1336 |
| 405 | #define _loop1_136_type 1337 |
| 406 | #define _tmp_137_type 1338 |
| 407 | #define _loop0_139_type 1339 |
| 408 | #define _gather_138_type 1340 |
| 409 | #define _loop0_141_type 1341 |
| 410 | #define _gather_140_type 1342 |
| 411 | #define _tmp_142_type 1343 |
| 412 | #define _tmp_143_type 1344 |
| 413 | #define _tmp_144_type 1345 |
| 414 | #define _tmp_145_type 1346 |
| 415 | #define _loop0_146_type 1347 |
| 416 | #define _loop0_147_type 1348 |
| 417 | #define _loop0_148_type 1349 |
| 418 | #define _tmp_149_type 1350 |
| 419 | #define _tmp_150_type 1351 |
| 420 | #define _tmp_151_type 1352 |
| 421 | #define _loop0_152_type 1353 |
| 422 | #define _loop1_153_type 1354 |
| 423 | #define _loop0_154_type 1355 |
| 424 | #define _loop1_155_type 1356 |
| 425 | #define _tmp_156_type 1357 |
| 426 | #define _tmp_157_type 1358 |
| 427 | #define _tmp_158_type 1359 |
| 428 | #define _loop0_160_type 1360 |
| 429 | #define _gather_159_type 1361 |
| 430 | #define _loop0_162_type 1362 |
| 431 | #define _gather_161_type 1363 |
| 432 | #define _tmp_163_type 1364 |
| 433 | #define _tmp_164_type 1365 |
| 434 | #define _tmp_165_type 1366 |
| 435 | #define _tmp_166_type 1367 |
| 436 | #define _tmp_167_type 1368 |
| 437 | #define _tmp_168_type 1369 |
| 438 | #define _tmp_169_type 1370 |
| 439 | #define _tmp_170_type 1371 |
| 440 | #define _tmp_171_type 1372 |
| 441 | #define _tmp_172_type 1373 |
| 442 | #define _tmp_173_type 1374 |
| 443 | #define _tmp_174_type 1375 |
| 444 | #define _tmp_175_type 1376 |
| 445 | #define _tmp_176_type 1377 |
| 446 | #define _tmp_177_type 1378 |
| 447 | #define _tmp_178_type 1379 |
| 448 | #define _tmp_179_type 1380 |
| 449 | #define _tmp_180_type 1381 |
| 450 | #define _tmp_181_type 1382 |
| 451 | #define _tmp_182_type 1383 |
| 452 | #define _tmp_183_type 1384 |
| 453 | #define _tmp_184_type 1385 |
| 454 | #define _tmp_185_type 1386 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 455 | |
| 456 | static mod_ty file_rule(Parser *p); |
| 457 | static mod_ty interactive_rule(Parser *p); |
| 458 | static mod_ty eval_rule(Parser *p); |
| 459 | static mod_ty func_type_rule(Parser *p); |
| 460 | static expr_ty fstring_rule(Parser *p); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 461 | static asdl_expr_seq* type_expressions_rule(Parser *p); |
| 462 | static asdl_stmt_seq* statements_rule(Parser *p); |
| 463 | static asdl_stmt_seq* statement_rule(Parser *p); |
| 464 | static asdl_stmt_seq* statement_newline_rule(Parser *p); |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 465 | static asdl_stmt_seq* simple_stmts_rule(Parser *p); |
| 466 | static stmt_ty simple_stmt_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 467 | static stmt_ty compound_stmt_rule(Parser *p); |
| 468 | static stmt_ty assignment_rule(Parser *p); |
| 469 | static AugOperator* augassign_rule(Parser *p); |
| 470 | static stmt_ty global_stmt_rule(Parser *p); |
| 471 | static stmt_ty nonlocal_stmt_rule(Parser *p); |
| 472 | static stmt_ty yield_stmt_rule(Parser *p); |
| 473 | static stmt_ty assert_stmt_rule(Parser *p); |
| 474 | static stmt_ty del_stmt_rule(Parser *p); |
| 475 | static stmt_ty import_stmt_rule(Parser *p); |
| 476 | static stmt_ty import_name_rule(Parser *p); |
| 477 | static stmt_ty import_from_rule(Parser *p); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 478 | static asdl_alias_seq* import_from_targets_rule(Parser *p); |
| 479 | static asdl_alias_seq* import_from_as_names_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 480 | static alias_ty import_from_as_name_rule(Parser *p); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 481 | static asdl_alias_seq* dotted_as_names_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 482 | static alias_ty dotted_as_name_rule(Parser *p); |
| 483 | static expr_ty dotted_name_rule(Parser *p); |
| 484 | static stmt_ty if_stmt_rule(Parser *p); |
| 485 | static stmt_ty elif_stmt_rule(Parser *p); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 486 | static asdl_stmt_seq* else_block_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 487 | static stmt_ty while_stmt_rule(Parser *p); |
| 488 | static stmt_ty for_stmt_rule(Parser *p); |
| 489 | static stmt_ty with_stmt_rule(Parser *p); |
| 490 | static withitem_ty with_item_rule(Parser *p); |
| 491 | static stmt_ty try_stmt_rule(Parser *p); |
| 492 | static excepthandler_ty except_block_rule(Parser *p); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 493 | static asdl_stmt_seq* finally_block_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 494 | static stmt_ty match_stmt_rule(Parser *p); |
| 495 | static expr_ty subject_expr_rule(Parser *p); |
| 496 | static match_case_ty case_block_rule(Parser *p); |
| 497 | static expr_ty guard_rule(Parser *p); |
| 498 | static expr_ty patterns_rule(Parser *p); |
| 499 | static expr_ty pattern_rule(Parser *p); |
| 500 | static expr_ty as_pattern_rule(Parser *p); |
| 501 | static expr_ty or_pattern_rule(Parser *p); |
| 502 | static expr_ty closed_pattern_rule(Parser *p); |
| 503 | static expr_ty literal_pattern_rule(Parser *p); |
| 504 | static expr_ty signed_number_rule(Parser *p); |
| 505 | static expr_ty capture_pattern_rule(Parser *p); |
| 506 | static expr_ty wildcard_pattern_rule(Parser *p); |
| 507 | static expr_ty value_pattern_rule(Parser *p); |
| 508 | static expr_ty attr_rule(Parser *p); |
| 509 | static expr_ty name_or_attr_rule(Parser *p); |
| 510 | static expr_ty group_pattern_rule(Parser *p); |
| 511 | static expr_ty sequence_pattern_rule(Parser *p); |
| 512 | static asdl_seq* open_sequence_pattern_rule(Parser *p); |
| 513 | static asdl_seq* maybe_sequence_pattern_rule(Parser *p); |
| 514 | static expr_ty maybe_star_pattern_rule(Parser *p); |
| 515 | static expr_ty star_pattern_rule(Parser *p); |
| 516 | static expr_ty mapping_pattern_rule(Parser *p); |
| 517 | static asdl_seq* items_pattern_rule(Parser *p); |
| 518 | static KeyValuePair* key_value_pattern_rule(Parser *p); |
| 519 | static KeyValuePair* double_star_pattern_rule(Parser *p); |
| 520 | static expr_ty class_pattern_rule(Parser *p); |
| 521 | static asdl_expr_seq* positional_patterns_rule(Parser *p); |
| 522 | static asdl_keyword_seq* keyword_patterns_rule(Parser *p); |
| 523 | static keyword_ty keyword_pattern_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 524 | static stmt_ty return_stmt_rule(Parser *p); |
| 525 | static stmt_ty raise_stmt_rule(Parser *p); |
| 526 | static stmt_ty function_def_rule(Parser *p); |
| 527 | static stmt_ty function_def_raw_rule(Parser *p); |
| 528 | static Token* func_type_comment_rule(Parser *p); |
| 529 | static arguments_ty params_rule(Parser *p); |
| 530 | static arguments_ty parameters_rule(Parser *p); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 531 | static asdl_arg_seq* slash_no_default_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 532 | static SlashWithDefault* slash_with_default_rule(Parser *p); |
| 533 | static StarEtc* star_etc_rule(Parser *p); |
| 534 | static arg_ty kwds_rule(Parser *p); |
| 535 | static arg_ty param_no_default_rule(Parser *p); |
| 536 | static NameDefaultPair* param_with_default_rule(Parser *p); |
| 537 | static NameDefaultPair* param_maybe_default_rule(Parser *p); |
| 538 | static arg_ty param_rule(Parser *p); |
| 539 | static expr_ty annotation_rule(Parser *p); |
| 540 | static expr_ty default_rule(Parser *p); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 541 | static asdl_expr_seq* decorators_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 542 | static stmt_ty class_def_rule(Parser *p); |
| 543 | static stmt_ty class_def_raw_rule(Parser *p); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 544 | static asdl_stmt_seq* block_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 545 | static expr_ty star_expressions_rule(Parser *p); |
| 546 | static expr_ty star_expression_rule(Parser *p); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 547 | static asdl_expr_seq* star_named_expressions_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 548 | static expr_ty star_named_expression_rule(Parser *p); |
| 549 | static expr_ty named_expression_rule(Parser *p); |
| 550 | static expr_ty annotated_rhs_rule(Parser *p); |
| 551 | static expr_ty expressions_rule(Parser *p); |
| 552 | static expr_ty expression_rule(Parser *p); |
| 553 | static expr_ty lambdef_rule(Parser *p); |
| 554 | static arguments_ty lambda_params_rule(Parser *p); |
| 555 | static arguments_ty lambda_parameters_rule(Parser *p); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 556 | static asdl_arg_seq* lambda_slash_no_default_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 557 | static SlashWithDefault* lambda_slash_with_default_rule(Parser *p); |
| 558 | static StarEtc* lambda_star_etc_rule(Parser *p); |
| 559 | static arg_ty lambda_kwds_rule(Parser *p); |
| 560 | static arg_ty lambda_param_no_default_rule(Parser *p); |
| 561 | static NameDefaultPair* lambda_param_with_default_rule(Parser *p); |
| 562 | static NameDefaultPair* lambda_param_maybe_default_rule(Parser *p); |
| 563 | static arg_ty lambda_param_rule(Parser *p); |
| 564 | static expr_ty disjunction_rule(Parser *p); |
| 565 | static expr_ty conjunction_rule(Parser *p); |
| 566 | static expr_ty inversion_rule(Parser *p); |
| 567 | static expr_ty comparison_rule(Parser *p); |
| 568 | static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p); |
| 569 | static CmpopExprPair* eq_bitwise_or_rule(Parser *p); |
| 570 | static CmpopExprPair* noteq_bitwise_or_rule(Parser *p); |
| 571 | static CmpopExprPair* lte_bitwise_or_rule(Parser *p); |
| 572 | static CmpopExprPair* lt_bitwise_or_rule(Parser *p); |
| 573 | static CmpopExprPair* gte_bitwise_or_rule(Parser *p); |
| 574 | static CmpopExprPair* gt_bitwise_or_rule(Parser *p); |
| 575 | static CmpopExprPair* notin_bitwise_or_rule(Parser *p); |
| 576 | static CmpopExprPair* in_bitwise_or_rule(Parser *p); |
| 577 | static CmpopExprPair* isnot_bitwise_or_rule(Parser *p); |
| 578 | static CmpopExprPair* is_bitwise_or_rule(Parser *p); |
| 579 | static expr_ty bitwise_or_rule(Parser *p); |
| 580 | static expr_ty bitwise_xor_rule(Parser *p); |
| 581 | static expr_ty bitwise_and_rule(Parser *p); |
| 582 | static expr_ty shift_expr_rule(Parser *p); |
| 583 | static expr_ty sum_rule(Parser *p); |
| 584 | static expr_ty term_rule(Parser *p); |
| 585 | static expr_ty factor_rule(Parser *p); |
| 586 | static expr_ty power_rule(Parser *p); |
| 587 | static expr_ty await_primary_rule(Parser *p); |
| 588 | static expr_ty primary_rule(Parser *p); |
| 589 | static expr_ty slices_rule(Parser *p); |
| 590 | static expr_ty slice_rule(Parser *p); |
| 591 | static expr_ty atom_rule(Parser *p); |
| 592 | static expr_ty strings_rule(Parser *p); |
| 593 | static expr_ty list_rule(Parser *p); |
| 594 | static expr_ty listcomp_rule(Parser *p); |
| 595 | static expr_ty tuple_rule(Parser *p); |
| 596 | static expr_ty group_rule(Parser *p); |
| 597 | static expr_ty genexp_rule(Parser *p); |
| 598 | static expr_ty set_rule(Parser *p); |
| 599 | static expr_ty setcomp_rule(Parser *p); |
| 600 | static expr_ty dict_rule(Parser *p); |
| 601 | static expr_ty dictcomp_rule(Parser *p); |
| 602 | static asdl_seq* double_starred_kvpairs_rule(Parser *p); |
| 603 | static KeyValuePair* double_starred_kvpair_rule(Parser *p); |
| 604 | static KeyValuePair* kvpair_rule(Parser *p); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 605 | static asdl_comprehension_seq* for_if_clauses_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 606 | static comprehension_ty for_if_clause_rule(Parser *p); |
| 607 | static expr_ty yield_expr_rule(Parser *p); |
| 608 | static expr_ty arguments_rule(Parser *p); |
| 609 | static expr_ty args_rule(Parser *p); |
| 610 | static asdl_seq* kwargs_rule(Parser *p); |
| 611 | static expr_ty starred_expression_rule(Parser *p); |
| 612 | static KeywordOrStarred* kwarg_or_starred_rule(Parser *p); |
| 613 | static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p); |
| 614 | static expr_ty star_targets_rule(Parser *p); |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 615 | static asdl_expr_seq* star_targets_list_seq_rule(Parser *p); |
| 616 | static asdl_expr_seq* star_targets_tuple_seq_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 617 | static expr_ty star_target_rule(Parser *p); |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 618 | static expr_ty target_with_star_atom_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 619 | static expr_ty star_atom_rule(Parser *p); |
| 620 | static expr_ty single_target_rule(Parser *p); |
| 621 | static expr_ty single_subscript_attribute_target_rule(Parser *p); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 622 | static asdl_expr_seq* del_targets_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 623 | static expr_ty del_target_rule(Parser *p); |
| 624 | static expr_ty del_t_atom_rule(Parser *p); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 625 | static asdl_expr_seq* targets_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 626 | static expr_ty target_rule(Parser *p); |
| 627 | static expr_ty t_primary_rule(Parser *p); |
| 628 | static void *t_lookahead_rule(Parser *p); |
| 629 | static expr_ty t_atom_rule(Parser *p); |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 630 | static void *invalid_arguments_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 631 | static void *invalid_kwarg_rule(Parser *p); |
| 632 | static void *invalid_named_expression_rule(Parser *p); |
| 633 | static void *invalid_assignment_rule(Parser *p); |
Batuhan Taskaya | c8f29ad | 2020-06-27 21:33:08 +0300 | [diff] [blame] | 634 | static expr_ty invalid_ann_assign_target_rule(Parser *p); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 635 | static void *invalid_del_stmt_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 636 | static void *invalid_block_rule(Parser *p); |
Lysandros Nikolaou | 15acc4e | 2020-10-27 20:54:20 +0200 | [diff] [blame] | 637 | static void *invalid_primary_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 638 | static void *invalid_comprehension_rule(Parser *p); |
| 639 | static void *invalid_dict_comprehension_rule(Parser *p); |
| 640 | static void *invalid_parameters_rule(Parser *p); |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 641 | static void *invalid_parameters_helper_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 642 | static void *invalid_lambda_parameters_rule(Parser *p); |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 643 | static void *invalid_lambda_parameters_helper_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 644 | static void *invalid_star_etc_rule(Parser *p); |
| 645 | static void *invalid_lambda_star_etc_rule(Parser *p); |
| 646 | static void *invalid_double_type_comments_rule(Parser *p); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 647 | static void *invalid_with_item_rule(Parser *p); |
| 648 | static void *invalid_for_target_rule(Parser *p); |
| 649 | static void *invalid_group_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 650 | static void *invalid_import_from_targets_rule(Parser *p); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 651 | static void *invalid_with_stmt_rule(Parser *p); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 652 | static void *invalid_except_block_rule(Parser *p); |
Pablo Galindo | 08fb8ac | 2021-03-18 01:03:11 +0000 | [diff] [blame] | 653 | static void *invalid_match_stmt_rule(Parser *p); |
| 654 | static void *invalid_case_block_rule(Parser *p); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 655 | static void *invalid_if_stmt_rule(Parser *p); |
| 656 | static void *invalid_elif_stmt_rule(Parser *p); |
| 657 | static void *invalid_while_stmt_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 658 | static asdl_seq *_loop0_1_rule(Parser *p); |
| 659 | static asdl_seq *_loop0_2_rule(Parser *p); |
| 660 | static asdl_seq *_loop0_4_rule(Parser *p); |
| 661 | static asdl_seq *_gather_3_rule(Parser *p); |
| 662 | static asdl_seq *_loop0_6_rule(Parser *p); |
| 663 | static asdl_seq *_gather_5_rule(Parser *p); |
| 664 | static asdl_seq *_loop0_8_rule(Parser *p); |
| 665 | static asdl_seq *_gather_7_rule(Parser *p); |
| 666 | static asdl_seq *_loop0_10_rule(Parser *p); |
| 667 | static asdl_seq *_gather_9_rule(Parser *p); |
| 668 | static asdl_seq *_loop1_11_rule(Parser *p); |
| 669 | static asdl_seq *_loop0_13_rule(Parser *p); |
| 670 | static asdl_seq *_gather_12_rule(Parser *p); |
| 671 | static void *_tmp_14_rule(Parser *p); |
| 672 | static void *_tmp_15_rule(Parser *p); |
| 673 | static void *_tmp_16_rule(Parser *p); |
| 674 | static void *_tmp_17_rule(Parser *p); |
| 675 | static void *_tmp_18_rule(Parser *p); |
| 676 | static void *_tmp_19_rule(Parser *p); |
| 677 | static void *_tmp_20_rule(Parser *p); |
| 678 | static void *_tmp_21_rule(Parser *p); |
| 679 | static asdl_seq *_loop1_22_rule(Parser *p); |
| 680 | static void *_tmp_23_rule(Parser *p); |
| 681 | static void *_tmp_24_rule(Parser *p); |
| 682 | static asdl_seq *_loop0_26_rule(Parser *p); |
| 683 | static asdl_seq *_gather_25_rule(Parser *p); |
| 684 | static asdl_seq *_loop0_28_rule(Parser *p); |
| 685 | static asdl_seq *_gather_27_rule(Parser *p); |
| 686 | static void *_tmp_29_rule(Parser *p); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 687 | static void *_tmp_30_rule(Parser *p); |
| 688 | static asdl_seq *_loop0_31_rule(Parser *p); |
| 689 | static asdl_seq *_loop1_32_rule(Parser *p); |
| 690 | static asdl_seq *_loop0_34_rule(Parser *p); |
| 691 | static asdl_seq *_gather_33_rule(Parser *p); |
| 692 | static void *_tmp_35_rule(Parser *p); |
| 693 | static asdl_seq *_loop0_37_rule(Parser *p); |
| 694 | static asdl_seq *_gather_36_rule(Parser *p); |
| 695 | static void *_tmp_38_rule(Parser *p); |
| 696 | static asdl_seq *_loop0_40_rule(Parser *p); |
| 697 | static asdl_seq *_gather_39_rule(Parser *p); |
| 698 | static asdl_seq *_loop0_42_rule(Parser *p); |
| 699 | static asdl_seq *_gather_41_rule(Parser *p); |
| 700 | static asdl_seq *_loop0_44_rule(Parser *p); |
| 701 | static asdl_seq *_gather_43_rule(Parser *p); |
| 702 | static asdl_seq *_loop0_46_rule(Parser *p); |
| 703 | static asdl_seq *_gather_45_rule(Parser *p); |
| 704 | static void *_tmp_47_rule(Parser *p); |
| 705 | static asdl_seq *_loop1_48_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 706 | static void *_tmp_49_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 707 | static asdl_seq *_loop1_50_rule(Parser *p); |
| 708 | static asdl_seq *_loop0_52_rule(Parser *p); |
| 709 | static asdl_seq *_gather_51_rule(Parser *p); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 710 | static void *_tmp_53_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 711 | static void *_tmp_54_rule(Parser *p); |
| 712 | static void *_tmp_55_rule(Parser *p); |
| 713 | static asdl_seq *_loop0_57_rule(Parser *p); |
| 714 | static asdl_seq *_gather_56_rule(Parser *p); |
| 715 | static void *_tmp_58_rule(Parser *p); |
| 716 | static asdl_seq *_loop0_60_rule(Parser *p); |
| 717 | static asdl_seq *_gather_59_rule(Parser *p); |
| 718 | static void *_tmp_61_rule(Parser *p); |
| 719 | static asdl_seq *_loop0_63_rule(Parser *p); |
| 720 | static asdl_seq *_gather_62_rule(Parser *p); |
| 721 | static asdl_seq *_loop0_65_rule(Parser *p); |
| 722 | static asdl_seq *_gather_64_rule(Parser *p); |
| 723 | static void *_tmp_66_rule(Parser *p); |
| 724 | static void *_tmp_67_rule(Parser *p); |
| 725 | static void *_tmp_68_rule(Parser *p); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 726 | static void *_tmp_69_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 727 | static asdl_seq *_loop0_70_rule(Parser *p); |
| 728 | static asdl_seq *_loop0_71_rule(Parser *p); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 729 | static asdl_seq *_loop0_72_rule(Parser *p); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 730 | static asdl_seq *_loop1_73_rule(Parser *p); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 731 | static asdl_seq *_loop0_74_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 732 | static asdl_seq *_loop1_75_rule(Parser *p); |
| 733 | static asdl_seq *_loop1_76_rule(Parser *p); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 734 | static asdl_seq *_loop1_77_rule(Parser *p); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 735 | static asdl_seq *_loop0_78_rule(Parser *p); |
| 736 | static asdl_seq *_loop1_79_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 737 | static asdl_seq *_loop0_80_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 738 | static asdl_seq *_loop1_81_rule(Parser *p); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 739 | static asdl_seq *_loop0_82_rule(Parser *p); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 740 | static asdl_seq *_loop1_83_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 741 | static asdl_seq *_loop1_84_rule(Parser *p); |
| 742 | static void *_tmp_85_rule(Parser *p); |
| 743 | static asdl_seq *_loop1_86_rule(Parser *p); |
| 744 | static asdl_seq *_loop0_88_rule(Parser *p); |
| 745 | static asdl_seq *_gather_87_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 746 | static asdl_seq *_loop1_89_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 747 | static asdl_seq *_loop0_90_rule(Parser *p); |
| 748 | static asdl_seq *_loop0_91_rule(Parser *p); |
| 749 | static asdl_seq *_loop0_92_rule(Parser *p); |
| 750 | static asdl_seq *_loop1_93_rule(Parser *p); |
| 751 | static asdl_seq *_loop0_94_rule(Parser *p); |
| 752 | static asdl_seq *_loop1_95_rule(Parser *p); |
| 753 | static asdl_seq *_loop1_96_rule(Parser *p); |
| 754 | static asdl_seq *_loop1_97_rule(Parser *p); |
| 755 | static asdl_seq *_loop0_98_rule(Parser *p); |
| 756 | static asdl_seq *_loop1_99_rule(Parser *p); |
| 757 | static asdl_seq *_loop0_100_rule(Parser *p); |
| 758 | static asdl_seq *_loop1_101_rule(Parser *p); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 759 | static asdl_seq *_loop0_102_rule(Parser *p); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 760 | static asdl_seq *_loop1_103_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 761 | static asdl_seq *_loop1_104_rule(Parser *p); |
| 762 | static asdl_seq *_loop1_105_rule(Parser *p); |
| 763 | static asdl_seq *_loop1_106_rule(Parser *p); |
| 764 | static void *_tmp_107_rule(Parser *p); |
| 765 | static asdl_seq *_loop0_109_rule(Parser *p); |
| 766 | static asdl_seq *_gather_108_rule(Parser *p); |
| 767 | static void *_tmp_110_rule(Parser *p); |
| 768 | static void *_tmp_111_rule(Parser *p); |
| 769 | static void *_tmp_112_rule(Parser *p); |
| 770 | static void *_tmp_113_rule(Parser *p); |
| 771 | static asdl_seq *_loop1_114_rule(Parser *p); |
| 772 | static void *_tmp_115_rule(Parser *p); |
| 773 | static void *_tmp_116_rule(Parser *p); |
| 774 | static asdl_seq *_loop0_118_rule(Parser *p); |
| 775 | static asdl_seq *_gather_117_rule(Parser *p); |
| 776 | static asdl_seq *_loop1_119_rule(Parser *p); |
| 777 | static asdl_seq *_loop0_120_rule(Parser *p); |
| 778 | static asdl_seq *_loop0_121_rule(Parser *p); |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 779 | static asdl_seq *_loop0_123_rule(Parser *p); |
| 780 | static asdl_seq *_gather_122_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 781 | static void *_tmp_124_rule(Parser *p); |
| 782 | static asdl_seq *_loop0_126_rule(Parser *p); |
| 783 | static asdl_seq *_gather_125_rule(Parser *p); |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 784 | static asdl_seq *_loop0_128_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 785 | static asdl_seq *_gather_127_rule(Parser *p); |
| 786 | static asdl_seq *_loop0_130_rule(Parser *p); |
| 787 | static asdl_seq *_gather_129_rule(Parser *p); |
| 788 | static asdl_seq *_loop0_132_rule(Parser *p); |
| 789 | static asdl_seq *_gather_131_rule(Parser *p); |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 790 | static asdl_seq *_loop0_133_rule(Parser *p); |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 791 | static asdl_seq *_loop0_135_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 792 | static asdl_seq *_gather_134_rule(Parser *p); |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 793 | static asdl_seq *_loop1_136_rule(Parser *p); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 794 | static void *_tmp_137_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 795 | static asdl_seq *_loop0_139_rule(Parser *p); |
| 796 | static asdl_seq *_gather_138_rule(Parser *p); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 797 | static asdl_seq *_loop0_141_rule(Parser *p); |
| 798 | static asdl_seq *_gather_140_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 799 | static void *_tmp_142_rule(Parser *p); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 800 | static void *_tmp_143_rule(Parser *p); |
| 801 | static void *_tmp_144_rule(Parser *p); |
| 802 | static void *_tmp_145_rule(Parser *p); |
| 803 | static asdl_seq *_loop0_146_rule(Parser *p); |
| 804 | static asdl_seq *_loop0_147_rule(Parser *p); |
| 805 | static asdl_seq *_loop0_148_rule(Parser *p); |
| 806 | static void *_tmp_149_rule(Parser *p); |
| 807 | static void *_tmp_150_rule(Parser *p); |
| 808 | static void *_tmp_151_rule(Parser *p); |
| 809 | static asdl_seq *_loop0_152_rule(Parser *p); |
| 810 | static asdl_seq *_loop1_153_rule(Parser *p); |
| 811 | static asdl_seq *_loop0_154_rule(Parser *p); |
| 812 | static asdl_seq *_loop1_155_rule(Parser *p); |
| 813 | static void *_tmp_156_rule(Parser *p); |
| 814 | static void *_tmp_157_rule(Parser *p); |
| 815 | static void *_tmp_158_rule(Parser *p); |
| 816 | static asdl_seq *_loop0_160_rule(Parser *p); |
| 817 | static asdl_seq *_gather_159_rule(Parser *p); |
| 818 | static asdl_seq *_loop0_162_rule(Parser *p); |
| 819 | static asdl_seq *_gather_161_rule(Parser *p); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 820 | static void *_tmp_163_rule(Parser *p); |
| 821 | static void *_tmp_164_rule(Parser *p); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 822 | static void *_tmp_165_rule(Parser *p); |
| 823 | static void *_tmp_166_rule(Parser *p); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 824 | static void *_tmp_167_rule(Parser *p); |
| 825 | static void *_tmp_168_rule(Parser *p); |
| 826 | static void *_tmp_169_rule(Parser *p); |
| 827 | static void *_tmp_170_rule(Parser *p); |
| 828 | static void *_tmp_171_rule(Parser *p); |
| 829 | static void *_tmp_172_rule(Parser *p); |
| 830 | static void *_tmp_173_rule(Parser *p); |
| 831 | static void *_tmp_174_rule(Parser *p); |
| 832 | static void *_tmp_175_rule(Parser *p); |
| 833 | static void *_tmp_176_rule(Parser *p); |
| 834 | static void *_tmp_177_rule(Parser *p); |
| 835 | static void *_tmp_178_rule(Parser *p); |
| 836 | static void *_tmp_179_rule(Parser *p); |
| 837 | static void *_tmp_180_rule(Parser *p); |
| 838 | static void *_tmp_181_rule(Parser *p); |
| 839 | static void *_tmp_182_rule(Parser *p); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 840 | static void *_tmp_183_rule(Parser *p); |
| 841 | static void *_tmp_184_rule(Parser *p); |
| 842 | static void *_tmp_185_rule(Parser *p); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 843 | |
| 844 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 845 | // file: statements? $ |
| 846 | static mod_ty |
| 847 | file_rule(Parser *p) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 848 | { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 849 | D(p->level++); |
| 850 | if (p->error_indicator) { |
| 851 | D(p->level--); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 852 | return NULL; |
| 853 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 854 | mod_ty _res = NULL; |
| 855 | int _mark = p->mark; |
| 856 | { // statements? $ |
| 857 | if (p->error_indicator) { |
| 858 | D(p->level--); |
| 859 | return NULL; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 860 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 861 | D(fprintf(stderr, "%*c> file[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statements? $")); |
| 862 | void *a; |
| 863 | Token * endmarker_var; |
| 864 | if ( |
| 865 | (a = statements_rule(p), 1) // statements? |
| 866 | && |
| 867 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
| 868 | ) |
| 869 | { |
| 870 | D(fprintf(stderr, "%*c+ file[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "statements? $")); |
| 871 | _res = _PyPegen_make_module ( p , a ); |
| 872 | if (_res == NULL && PyErr_Occurred()) { |
| 873 | p->error_indicator = 1; |
| 874 | D(p->level--); |
| 875 | return NULL; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 876 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 877 | goto done; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 878 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 879 | p->mark = _mark; |
| 880 | D(fprintf(stderr, "%*c%s file[%d-%d]: %s failed!\n", p->level, ' ', |
| 881 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statements? $")); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 882 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 883 | _res = NULL; |
| 884 | done: |
| 885 | D(p->level--); |
| 886 | return _res; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 887 | } |
| 888 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 889 | // interactive: statement_newline |
| 890 | static mod_ty |
| 891 | interactive_rule(Parser *p) |
Guido van Rossum | b09f7ed | 2001-07-15 21:08:29 +0000 | [diff] [blame] | 892 | { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 893 | D(p->level++); |
| 894 | if (p->error_indicator) { |
| 895 | D(p->level--); |
| 896 | return NULL; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 897 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 898 | mod_ty _res = NULL; |
| 899 | int _mark = p->mark; |
| 900 | { // statement_newline |
| 901 | if (p->error_indicator) { |
| 902 | D(p->level--); |
| 903 | return NULL; |
| 904 | } |
| 905 | D(fprintf(stderr, "%*c> interactive[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement_newline")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 906 | asdl_stmt_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 907 | if ( |
| 908 | (a = statement_newline_rule(p)) // statement_newline |
| 909 | ) |
| 910 | { |
| 911 | D(fprintf(stderr, "%*c+ interactive[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "statement_newline")); |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 912 | _res = _PyAST_Interactive ( a , p -> arena ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 913 | if (_res == NULL && PyErr_Occurred()) { |
| 914 | p->error_indicator = 1; |
| 915 | D(p->level--); |
| 916 | return NULL; |
| 917 | } |
| 918 | goto done; |
| 919 | } |
| 920 | p->mark = _mark; |
| 921 | D(fprintf(stderr, "%*c%s interactive[%d-%d]: %s failed!\n", p->level, ' ', |
| 922 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement_newline")); |
| 923 | } |
| 924 | _res = NULL; |
| 925 | done: |
| 926 | D(p->level--); |
| 927 | return _res; |
Guido van Rossum | b09f7ed | 2001-07-15 21:08:29 +0000 | [diff] [blame] | 928 | } |
| 929 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 930 | // eval: expressions NEWLINE* $ |
| 931 | static mod_ty |
| 932 | eval_rule(Parser *p) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 933 | { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 934 | D(p->level++); |
| 935 | if (p->error_indicator) { |
| 936 | D(p->level--); |
| 937 | return NULL; |
| 938 | } |
| 939 | mod_ty _res = NULL; |
| 940 | int _mark = p->mark; |
| 941 | { // expressions NEWLINE* $ |
| 942 | if (p->error_indicator) { |
| 943 | D(p->level--); |
| 944 | return NULL; |
| 945 | } |
| 946 | D(fprintf(stderr, "%*c> eval[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions NEWLINE* $")); |
| 947 | asdl_seq * _loop0_1_var; |
| 948 | expr_ty a; |
| 949 | Token * endmarker_var; |
| 950 | if ( |
| 951 | (a = expressions_rule(p)) // expressions |
| 952 | && |
| 953 | (_loop0_1_var = _loop0_1_rule(p)) // NEWLINE* |
| 954 | && |
| 955 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
| 956 | ) |
| 957 | { |
| 958 | D(fprintf(stderr, "%*c+ eval[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions NEWLINE* $")); |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 959 | _res = _PyAST_Expression ( a , p -> arena ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 960 | if (_res == NULL && PyErr_Occurred()) { |
| 961 | p->error_indicator = 1; |
| 962 | D(p->level--); |
| 963 | return NULL; |
| 964 | } |
| 965 | goto done; |
| 966 | } |
| 967 | p->mark = _mark; |
| 968 | D(fprintf(stderr, "%*c%s eval[%d-%d]: %s failed!\n", p->level, ' ', |
| 969 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expressions NEWLINE* $")); |
| 970 | } |
| 971 | _res = NULL; |
| 972 | done: |
| 973 | D(p->level--); |
| 974 | return _res; |
| 975 | } |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 976 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 977 | // func_type: '(' type_expressions? ')' '->' expression NEWLINE* $ |
| 978 | static mod_ty |
| 979 | func_type_rule(Parser *p) |
| 980 | { |
| 981 | D(p->level++); |
| 982 | if (p->error_indicator) { |
| 983 | D(p->level--); |
| 984 | return NULL; |
| 985 | } |
| 986 | mod_ty _res = NULL; |
| 987 | int _mark = p->mark; |
| 988 | { // '(' type_expressions? ')' '->' expression NEWLINE* $ |
| 989 | if (p->error_indicator) { |
| 990 | D(p->level--); |
| 991 | return NULL; |
| 992 | } |
| 993 | D(fprintf(stderr, "%*c> func_type[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' type_expressions? ')' '->' expression NEWLINE* $")); |
| 994 | Token * _literal; |
| 995 | Token * _literal_1; |
| 996 | Token * _literal_2; |
| 997 | asdl_seq * _loop0_2_var; |
| 998 | void *a; |
| 999 | expr_ty b; |
| 1000 | Token * endmarker_var; |
| 1001 | if ( |
| 1002 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 1003 | && |
| 1004 | (a = type_expressions_rule(p), 1) // type_expressions? |
| 1005 | && |
| 1006 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 1007 | && |
| 1008 | (_literal_2 = _PyPegen_expect_token(p, 51)) // token='->' |
| 1009 | && |
| 1010 | (b = expression_rule(p)) // expression |
| 1011 | && |
| 1012 | (_loop0_2_var = _loop0_2_rule(p)) // NEWLINE* |
| 1013 | && |
| 1014 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
| 1015 | ) |
| 1016 | { |
| 1017 | D(fprintf(stderr, "%*c+ func_type[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' type_expressions? ')' '->' expression NEWLINE* $")); |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 1018 | _res = _PyAST_FunctionType ( a , b , p -> arena ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1019 | if (_res == NULL && PyErr_Occurred()) { |
| 1020 | p->error_indicator = 1; |
| 1021 | D(p->level--); |
| 1022 | return NULL; |
| 1023 | } |
| 1024 | goto done; |
| 1025 | } |
| 1026 | p->mark = _mark; |
| 1027 | D(fprintf(stderr, "%*c%s func_type[%d-%d]: %s failed!\n", p->level, ' ', |
| 1028 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' type_expressions? ')' '->' expression NEWLINE* $")); |
| 1029 | } |
| 1030 | _res = NULL; |
| 1031 | done: |
| 1032 | D(p->level--); |
| 1033 | return _res; |
| 1034 | } |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 1035 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1036 | // fstring: star_expressions |
| 1037 | static expr_ty |
| 1038 | fstring_rule(Parser *p) |
| 1039 | { |
| 1040 | D(p->level++); |
| 1041 | if (p->error_indicator) { |
| 1042 | D(p->level--); |
| 1043 | return NULL; |
| 1044 | } |
| 1045 | expr_ty _res = NULL; |
| 1046 | int _mark = p->mark; |
| 1047 | { // star_expressions |
| 1048 | if (p->error_indicator) { |
| 1049 | D(p->level--); |
| 1050 | return NULL; |
| 1051 | } |
| 1052 | D(fprintf(stderr, "%*c> fstring[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
| 1053 | expr_ty star_expressions_var; |
| 1054 | if ( |
| 1055 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
| 1056 | ) |
| 1057 | { |
| 1058 | D(fprintf(stderr, "%*c+ fstring[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
| 1059 | _res = star_expressions_var; |
| 1060 | goto done; |
| 1061 | } |
| 1062 | p->mark = _mark; |
| 1063 | D(fprintf(stderr, "%*c%s fstring[%d-%d]: %s failed!\n", p->level, ' ', |
| 1064 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); |
| 1065 | } |
| 1066 | _res = NULL; |
| 1067 | done: |
| 1068 | D(p->level--); |
| 1069 | return _res; |
| 1070 | } |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 1071 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1072 | // type_expressions: |
| 1073 | // | ','.expression+ ',' '*' expression ',' '**' expression |
| 1074 | // | ','.expression+ ',' '*' expression |
| 1075 | // | ','.expression+ ',' '**' expression |
| 1076 | // | '*' expression ',' '**' expression |
| 1077 | // | '*' expression |
| 1078 | // | '**' expression |
| 1079 | // | ','.expression+ |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1080 | static asdl_expr_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1081 | type_expressions_rule(Parser *p) |
| 1082 | { |
| 1083 | D(p->level++); |
| 1084 | if (p->error_indicator) { |
| 1085 | D(p->level--); |
| 1086 | return NULL; |
| 1087 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1088 | asdl_expr_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1089 | int _mark = p->mark; |
| 1090 | { // ','.expression+ ',' '*' expression ',' '**' expression |
| 1091 | if (p->error_indicator) { |
| 1092 | D(p->level--); |
| 1093 | return NULL; |
| 1094 | } |
| 1095 | D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression")); |
| 1096 | Token * _literal; |
| 1097 | Token * _literal_1; |
| 1098 | Token * _literal_2; |
| 1099 | Token * _literal_3; |
| 1100 | asdl_seq * a; |
| 1101 | expr_ty b; |
| 1102 | expr_ty c; |
| 1103 | if ( |
| 1104 | (a = _gather_3_rule(p)) // ','.expression+ |
| 1105 | && |
| 1106 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 1107 | && |
| 1108 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
| 1109 | && |
| 1110 | (b = expression_rule(p)) // expression |
| 1111 | && |
| 1112 | (_literal_2 = _PyPegen_expect_token(p, 12)) // token=',' |
| 1113 | && |
| 1114 | (_literal_3 = _PyPegen_expect_token(p, 35)) // token='**' |
| 1115 | && |
| 1116 | (c = expression_rule(p)) // expression |
| 1117 | ) |
| 1118 | { |
| 1119 | D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression")); |
Lysandros Nikolaou | 2e5ca9e | 2020-10-21 22:53:14 +0300 | [diff] [blame] | 1120 | _res = ( asdl_expr_seq * ) _PyPegen_seq_append_to_end ( p , CHECK ( asdl_seq * , _PyPegen_seq_append_to_end ( p , a , b ) ) , c ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1121 | if (_res == NULL && PyErr_Occurred()) { |
| 1122 | p->error_indicator = 1; |
| 1123 | D(p->level--); |
| 1124 | return NULL; |
| 1125 | } |
| 1126 | goto done; |
| 1127 | } |
| 1128 | p->mark = _mark; |
| 1129 | D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 1130 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression")); |
| 1131 | } |
| 1132 | { // ','.expression+ ',' '*' expression |
| 1133 | if (p->error_indicator) { |
| 1134 | D(p->level--); |
| 1135 | return NULL; |
| 1136 | } |
| 1137 | D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression")); |
| 1138 | Token * _literal; |
| 1139 | Token * _literal_1; |
| 1140 | asdl_seq * a; |
| 1141 | expr_ty b; |
| 1142 | if ( |
| 1143 | (a = _gather_5_rule(p)) // ','.expression+ |
| 1144 | && |
| 1145 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 1146 | && |
| 1147 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
| 1148 | && |
| 1149 | (b = expression_rule(p)) // expression |
| 1150 | ) |
| 1151 | { |
| 1152 | D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1153 | _res = ( asdl_expr_seq * ) _PyPegen_seq_append_to_end ( p , a , b ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1154 | if (_res == NULL && PyErr_Occurred()) { |
| 1155 | p->error_indicator = 1; |
| 1156 | D(p->level--); |
| 1157 | return NULL; |
| 1158 | } |
| 1159 | goto done; |
| 1160 | } |
| 1161 | p->mark = _mark; |
| 1162 | D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 1163 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '*' expression")); |
| 1164 | } |
| 1165 | { // ','.expression+ ',' '**' expression |
| 1166 | if (p->error_indicator) { |
| 1167 | D(p->level--); |
| 1168 | return NULL; |
| 1169 | } |
| 1170 | D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '**' expression")); |
| 1171 | Token * _literal; |
| 1172 | Token * _literal_1; |
| 1173 | asdl_seq * a; |
| 1174 | expr_ty b; |
| 1175 | if ( |
| 1176 | (a = _gather_7_rule(p)) // ','.expression+ |
| 1177 | && |
| 1178 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 1179 | && |
| 1180 | (_literal_1 = _PyPegen_expect_token(p, 35)) // token='**' |
| 1181 | && |
| 1182 | (b = expression_rule(p)) // expression |
| 1183 | ) |
| 1184 | { |
| 1185 | D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '**' expression")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1186 | _res = ( asdl_expr_seq * ) _PyPegen_seq_append_to_end ( p , a , b ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1187 | if (_res == NULL && PyErr_Occurred()) { |
| 1188 | p->error_indicator = 1; |
| 1189 | D(p->level--); |
| 1190 | return NULL; |
| 1191 | } |
| 1192 | goto done; |
| 1193 | } |
| 1194 | p->mark = _mark; |
| 1195 | D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 1196 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '**' expression")); |
| 1197 | } |
| 1198 | { // '*' expression ',' '**' expression |
| 1199 | if (p->error_indicator) { |
| 1200 | D(p->level--); |
| 1201 | return NULL; |
| 1202 | } |
| 1203 | D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression ',' '**' expression")); |
| 1204 | Token * _literal; |
| 1205 | Token * _literal_1; |
| 1206 | Token * _literal_2; |
| 1207 | expr_ty a; |
| 1208 | expr_ty b; |
| 1209 | if ( |
| 1210 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 1211 | && |
| 1212 | (a = expression_rule(p)) // expression |
| 1213 | && |
| 1214 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
| 1215 | && |
| 1216 | (_literal_2 = _PyPegen_expect_token(p, 35)) // token='**' |
| 1217 | && |
| 1218 | (b = expression_rule(p)) // expression |
| 1219 | ) |
| 1220 | { |
| 1221 | D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression ',' '**' expression")); |
Lysandros Nikolaou | 2e5ca9e | 2020-10-21 22:53:14 +0300 | [diff] [blame] | 1222 | _res = ( asdl_expr_seq * ) _PyPegen_seq_append_to_end ( p , CHECK ( asdl_seq * , _PyPegen_singleton_seq ( p , a ) ) , b ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1223 | if (_res == NULL && PyErr_Occurred()) { |
| 1224 | p->error_indicator = 1; |
| 1225 | D(p->level--); |
| 1226 | return NULL; |
| 1227 | } |
| 1228 | goto done; |
| 1229 | } |
| 1230 | p->mark = _mark; |
| 1231 | D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 1232 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression ',' '**' expression")); |
| 1233 | } |
| 1234 | { // '*' expression |
| 1235 | if (p->error_indicator) { |
| 1236 | D(p->level--); |
| 1237 | return NULL; |
| 1238 | } |
| 1239 | D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression")); |
| 1240 | Token * _literal; |
| 1241 | expr_ty a; |
| 1242 | if ( |
| 1243 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 1244 | && |
| 1245 | (a = expression_rule(p)) // expression |
| 1246 | ) |
| 1247 | { |
| 1248 | D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1249 | _res = ( asdl_expr_seq * ) _PyPegen_singleton_seq ( p , a ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1250 | if (_res == NULL && PyErr_Occurred()) { |
| 1251 | p->error_indicator = 1; |
| 1252 | D(p->level--); |
| 1253 | return NULL; |
| 1254 | } |
| 1255 | goto done; |
| 1256 | } |
| 1257 | p->mark = _mark; |
| 1258 | D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 1259 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression")); |
| 1260 | } |
| 1261 | { // '**' expression |
| 1262 | if (p->error_indicator) { |
| 1263 | D(p->level--); |
| 1264 | return NULL; |
| 1265 | } |
| 1266 | D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' expression")); |
| 1267 | Token * _literal; |
| 1268 | expr_ty a; |
| 1269 | if ( |
| 1270 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
| 1271 | && |
| 1272 | (a = expression_rule(p)) // expression |
| 1273 | ) |
| 1274 | { |
| 1275 | D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' expression")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1276 | _res = ( asdl_expr_seq * ) _PyPegen_singleton_seq ( p , a ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1277 | if (_res == NULL && PyErr_Occurred()) { |
| 1278 | p->error_indicator = 1; |
| 1279 | D(p->level--); |
| 1280 | return NULL; |
| 1281 | } |
| 1282 | goto done; |
| 1283 | } |
| 1284 | p->mark = _mark; |
| 1285 | D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 1286 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' expression")); |
| 1287 | } |
| 1288 | { // ','.expression+ |
| 1289 | if (p->error_indicator) { |
| 1290 | D(p->level--); |
| 1291 | return NULL; |
| 1292 | } |
| 1293 | D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1294 | asdl_expr_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1295 | if ( |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1296 | (a = (asdl_expr_seq*)_gather_9_rule(p)) // ','.expression+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1297 | ) |
| 1298 | { |
| 1299 | D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1300 | _res = a; |
| 1301 | if (_res == NULL && PyErr_Occurred()) { |
| 1302 | p->error_indicator = 1; |
| 1303 | D(p->level--); |
| 1304 | return NULL; |
| 1305 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1306 | goto done; |
| 1307 | } |
| 1308 | p->mark = _mark; |
| 1309 | D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 1310 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+")); |
| 1311 | } |
| 1312 | _res = NULL; |
| 1313 | done: |
| 1314 | D(p->level--); |
| 1315 | return _res; |
| 1316 | } |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 1317 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1318 | // statements: statement+ |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1319 | static asdl_stmt_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1320 | statements_rule(Parser *p) |
| 1321 | { |
| 1322 | D(p->level++); |
| 1323 | if (p->error_indicator) { |
| 1324 | D(p->level--); |
| 1325 | return NULL; |
| 1326 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1327 | asdl_stmt_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1328 | int _mark = p->mark; |
| 1329 | { // statement+ |
| 1330 | if (p->error_indicator) { |
| 1331 | D(p->level--); |
| 1332 | return NULL; |
| 1333 | } |
| 1334 | D(fprintf(stderr, "%*c> statements[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement+")); |
| 1335 | asdl_seq * a; |
| 1336 | if ( |
| 1337 | (a = _loop1_11_rule(p)) // statement+ |
| 1338 | ) |
| 1339 | { |
| 1340 | D(fprintf(stderr, "%*c+ statements[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "statement+")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1341 | _res = ( asdl_stmt_seq * ) _PyPegen_seq_flatten ( p , a ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1342 | if (_res == NULL && PyErr_Occurred()) { |
| 1343 | p->error_indicator = 1; |
| 1344 | D(p->level--); |
| 1345 | return NULL; |
| 1346 | } |
| 1347 | goto done; |
| 1348 | } |
| 1349 | p->mark = _mark; |
| 1350 | D(fprintf(stderr, "%*c%s statements[%d-%d]: %s failed!\n", p->level, ' ', |
| 1351 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement+")); |
| 1352 | } |
| 1353 | _res = NULL; |
| 1354 | done: |
| 1355 | D(p->level--); |
| 1356 | return _res; |
| 1357 | } |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 1358 | |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1359 | // statement: compound_stmt | simple_stmts |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1360 | static asdl_stmt_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1361 | statement_rule(Parser *p) |
| 1362 | { |
| 1363 | D(p->level++); |
| 1364 | if (p->error_indicator) { |
| 1365 | D(p->level--); |
| 1366 | return NULL; |
| 1367 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1368 | asdl_stmt_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1369 | int _mark = p->mark; |
| 1370 | { // compound_stmt |
| 1371 | if (p->error_indicator) { |
| 1372 | D(p->level--); |
| 1373 | return NULL; |
| 1374 | } |
| 1375 | D(fprintf(stderr, "%*c> statement[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compound_stmt")); |
| 1376 | stmt_ty a; |
| 1377 | if ( |
| 1378 | (a = compound_stmt_rule(p)) // compound_stmt |
| 1379 | ) |
| 1380 | { |
| 1381 | D(fprintf(stderr, "%*c+ statement[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "compound_stmt")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1382 | _res = ( asdl_stmt_seq * ) _PyPegen_singleton_seq ( p , a ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1383 | if (_res == NULL && PyErr_Occurred()) { |
| 1384 | p->error_indicator = 1; |
| 1385 | D(p->level--); |
| 1386 | return NULL; |
| 1387 | } |
| 1388 | goto done; |
| 1389 | } |
| 1390 | p->mark = _mark; |
| 1391 | D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ', |
| 1392 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt")); |
| 1393 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1394 | { // simple_stmts |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1395 | if (p->error_indicator) { |
| 1396 | D(p->level--); |
| 1397 | return NULL; |
| 1398 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1399 | D(fprintf(stderr, "%*c> statement[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmts")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1400 | asdl_stmt_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1401 | if ( |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1402 | (a = (asdl_stmt_seq*)simple_stmts_rule(p)) // simple_stmts |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1403 | ) |
| 1404 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1405 | D(fprintf(stderr, "%*c+ statement[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmts")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1406 | _res = a; |
| 1407 | if (_res == NULL && PyErr_Occurred()) { |
| 1408 | p->error_indicator = 1; |
| 1409 | D(p->level--); |
| 1410 | return NULL; |
| 1411 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1412 | goto done; |
| 1413 | } |
| 1414 | p->mark = _mark; |
| 1415 | D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1416 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmts")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1417 | } |
| 1418 | _res = NULL; |
| 1419 | done: |
| 1420 | D(p->level--); |
| 1421 | return _res; |
| 1422 | } |
| 1423 | |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1424 | // statement_newline: compound_stmt NEWLINE | simple_stmts | NEWLINE | $ |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1425 | static asdl_stmt_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1426 | statement_newline_rule(Parser *p) |
| 1427 | { |
| 1428 | D(p->level++); |
| 1429 | if (p->error_indicator) { |
| 1430 | D(p->level--); |
| 1431 | return NULL; |
| 1432 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1433 | asdl_stmt_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1434 | int _mark = p->mark; |
| 1435 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1436 | p->error_indicator = 1; |
| 1437 | D(p->level--); |
| 1438 | return NULL; |
| 1439 | } |
| 1440 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1441 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1442 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1443 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 1444 | { // compound_stmt NEWLINE |
| 1445 | if (p->error_indicator) { |
| 1446 | D(p->level--); |
| 1447 | return NULL; |
| 1448 | } |
| 1449 | D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compound_stmt NEWLINE")); |
| 1450 | stmt_ty a; |
| 1451 | Token * newline_var; |
| 1452 | if ( |
| 1453 | (a = compound_stmt_rule(p)) // compound_stmt |
| 1454 | && |
| 1455 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 1456 | ) |
| 1457 | { |
| 1458 | D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "compound_stmt NEWLINE")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1459 | _res = ( asdl_stmt_seq * ) _PyPegen_singleton_seq ( p , a ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1460 | if (_res == NULL && PyErr_Occurred()) { |
| 1461 | p->error_indicator = 1; |
| 1462 | D(p->level--); |
| 1463 | return NULL; |
| 1464 | } |
| 1465 | goto done; |
| 1466 | } |
| 1467 | p->mark = _mark; |
| 1468 | D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ', |
| 1469 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt NEWLINE")); |
| 1470 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1471 | { // simple_stmts |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1472 | if (p->error_indicator) { |
| 1473 | D(p->level--); |
| 1474 | return NULL; |
| 1475 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1476 | D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmts")); |
| 1477 | asdl_stmt_seq* simple_stmts_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1478 | if ( |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1479 | (simple_stmts_var = simple_stmts_rule(p)) // simple_stmts |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1480 | ) |
| 1481 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1482 | D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmts")); |
| 1483 | _res = simple_stmts_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1484 | goto done; |
| 1485 | } |
| 1486 | p->mark = _mark; |
| 1487 | D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1488 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmts")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1489 | } |
| 1490 | { // NEWLINE |
| 1491 | if (p->error_indicator) { |
| 1492 | D(p->level--); |
| 1493 | return NULL; |
| 1494 | } |
| 1495 | D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); |
| 1496 | Token * newline_var; |
| 1497 | if ( |
| 1498 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 1499 | ) |
| 1500 | { |
| 1501 | D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); |
| 1502 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1503 | if (_token == NULL) { |
| 1504 | D(p->level--); |
| 1505 | return NULL; |
| 1506 | } |
| 1507 | int _end_lineno = _token->end_lineno; |
| 1508 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1509 | int _end_col_offset = _token->end_col_offset; |
| 1510 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 1511 | _res = ( asdl_stmt_seq * ) _PyPegen_singleton_seq ( p , CHECK ( stmt_ty , _PyAST_Pass ( EXTRA ) ) ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1512 | if (_res == NULL && PyErr_Occurred()) { |
| 1513 | p->error_indicator = 1; |
| 1514 | D(p->level--); |
| 1515 | return NULL; |
| 1516 | } |
| 1517 | goto done; |
| 1518 | } |
| 1519 | p->mark = _mark; |
| 1520 | D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ', |
| 1521 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); |
| 1522 | } |
| 1523 | { // $ |
| 1524 | if (p->error_indicator) { |
| 1525 | D(p->level--); |
| 1526 | return NULL; |
| 1527 | } |
| 1528 | D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "$")); |
| 1529 | Token * endmarker_var; |
| 1530 | if ( |
| 1531 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
| 1532 | ) |
| 1533 | { |
| 1534 | D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "$")); |
| 1535 | _res = _PyPegen_interactive_exit ( p ); |
| 1536 | if (_res == NULL && PyErr_Occurred()) { |
| 1537 | p->error_indicator = 1; |
| 1538 | D(p->level--); |
| 1539 | return NULL; |
| 1540 | } |
| 1541 | goto done; |
| 1542 | } |
| 1543 | p->mark = _mark; |
| 1544 | D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ', |
| 1545 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "$")); |
| 1546 | } |
| 1547 | _res = NULL; |
| 1548 | done: |
| 1549 | D(p->level--); |
| 1550 | return _res; |
| 1551 | } |
| 1552 | |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1553 | // simple_stmts: simple_stmt !';' NEWLINE | ';'.simple_stmt+ ';'? NEWLINE |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1554 | static asdl_stmt_seq* |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1555 | simple_stmts_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1556 | { |
| 1557 | D(p->level++); |
| 1558 | if (p->error_indicator) { |
| 1559 | D(p->level--); |
| 1560 | return NULL; |
| 1561 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1562 | asdl_stmt_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1563 | int _mark = p->mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1564 | { // simple_stmt !';' NEWLINE |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1565 | if (p->error_indicator) { |
| 1566 | D(p->level--); |
| 1567 | return NULL; |
| 1568 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1569 | D(fprintf(stderr, "%*c> simple_stmts[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt !';' NEWLINE")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1570 | stmt_ty a; |
| 1571 | Token * newline_var; |
| 1572 | if ( |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1573 | (a = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1574 | && |
| 1575 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';' |
| 1576 | && |
| 1577 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 1578 | ) |
| 1579 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1580 | D(fprintf(stderr, "%*c+ simple_stmts[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt !';' NEWLINE")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1581 | _res = ( asdl_stmt_seq * ) _PyPegen_singleton_seq ( p , a ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1582 | if (_res == NULL && PyErr_Occurred()) { |
| 1583 | p->error_indicator = 1; |
| 1584 | D(p->level--); |
| 1585 | return NULL; |
| 1586 | } |
| 1587 | goto done; |
| 1588 | } |
| 1589 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1590 | D(fprintf(stderr, "%*c%s simple_stmts[%d-%d]: %s failed!\n", p->level, ' ', |
| 1591 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt !';' NEWLINE")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1592 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1593 | { // ';'.simple_stmt+ ';'? NEWLINE |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1594 | if (p->error_indicator) { |
| 1595 | D(p->level--); |
| 1596 | return NULL; |
| 1597 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1598 | D(fprintf(stderr, "%*c> simple_stmts[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'.simple_stmt+ ';'? NEWLINE")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1599 | void *_opt_var; |
| 1600 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 1601 | asdl_stmt_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1602 | Token * newline_var; |
| 1603 | if ( |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1604 | (a = (asdl_stmt_seq*)_gather_12_rule(p)) // ';'.simple_stmt+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1605 | && |
| 1606 | (_opt_var = _PyPegen_expect_token(p, 13), 1) // ';'? |
| 1607 | && |
| 1608 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 1609 | ) |
| 1610 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1611 | D(fprintf(stderr, "%*c+ simple_stmts[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'.simple_stmt+ ';'? NEWLINE")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1612 | _res = a; |
| 1613 | if (_res == NULL && PyErr_Occurred()) { |
| 1614 | p->error_indicator = 1; |
| 1615 | D(p->level--); |
| 1616 | return NULL; |
| 1617 | } |
| 1618 | goto done; |
| 1619 | } |
| 1620 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1621 | D(fprintf(stderr, "%*c%s simple_stmts[%d-%d]: %s failed!\n", p->level, ' ', |
| 1622 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'.simple_stmt+ ';'? NEWLINE")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1623 | } |
| 1624 | _res = NULL; |
| 1625 | done: |
| 1626 | D(p->level--); |
| 1627 | return _res; |
| 1628 | } |
| 1629 | |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1630 | // simple_stmt: |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1631 | // | assignment |
| 1632 | // | star_expressions |
| 1633 | // | &'return' return_stmt |
| 1634 | // | &('import' | 'from') import_stmt |
| 1635 | // | &'raise' raise_stmt |
| 1636 | // | 'pass' |
| 1637 | // | &'del' del_stmt |
| 1638 | // | &'yield' yield_stmt |
| 1639 | // | &'assert' assert_stmt |
| 1640 | // | 'break' |
| 1641 | // | 'continue' |
| 1642 | // | &'global' global_stmt |
| 1643 | // | &'nonlocal' nonlocal_stmt |
| 1644 | static stmt_ty |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1645 | simple_stmt_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1646 | { |
| 1647 | D(p->level++); |
| 1648 | if (p->error_indicator) { |
| 1649 | D(p->level--); |
| 1650 | return NULL; |
| 1651 | } |
| 1652 | stmt_ty _res = NULL; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1653 | if (_PyPegen_is_memoized(p, simple_stmt_type, &_res)) { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1654 | D(p->level--); |
| 1655 | return _res; |
| 1656 | } |
| 1657 | int _mark = p->mark; |
| 1658 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1659 | p->error_indicator = 1; |
| 1660 | D(p->level--); |
| 1661 | return NULL; |
| 1662 | } |
| 1663 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1664 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1665 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1666 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 1667 | { // assignment |
| 1668 | if (p->error_indicator) { |
| 1669 | D(p->level--); |
| 1670 | return NULL; |
| 1671 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1672 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1673 | stmt_ty assignment_var; |
| 1674 | if ( |
| 1675 | (assignment_var = assignment_rule(p)) // assignment |
| 1676 | ) |
| 1677 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1678 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1679 | _res = assignment_var; |
| 1680 | goto done; |
| 1681 | } |
| 1682 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1683 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1684 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment")); |
| 1685 | } |
| 1686 | { // star_expressions |
| 1687 | if (p->error_indicator) { |
| 1688 | D(p->level--); |
| 1689 | return NULL; |
| 1690 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1691 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1692 | expr_ty e; |
| 1693 | if ( |
| 1694 | (e = star_expressions_rule(p)) // star_expressions |
| 1695 | ) |
| 1696 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1697 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1698 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1699 | if (_token == NULL) { |
| 1700 | D(p->level--); |
| 1701 | return NULL; |
| 1702 | } |
| 1703 | int _end_lineno = _token->end_lineno; |
| 1704 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1705 | int _end_col_offset = _token->end_col_offset; |
| 1706 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 1707 | _res = _PyAST_Expr ( e , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1708 | if (_res == NULL && PyErr_Occurred()) { |
| 1709 | p->error_indicator = 1; |
| 1710 | D(p->level--); |
| 1711 | return NULL; |
| 1712 | } |
| 1713 | goto done; |
| 1714 | } |
| 1715 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1716 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1717 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); |
| 1718 | } |
| 1719 | { // &'return' return_stmt |
| 1720 | if (p->error_indicator) { |
| 1721 | D(p->level--); |
| 1722 | return NULL; |
| 1723 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1724 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1725 | stmt_ty return_stmt_var; |
| 1726 | if ( |
| 1727 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return' |
| 1728 | && |
| 1729 | (return_stmt_var = return_stmt_rule(p)) // return_stmt |
| 1730 | ) |
| 1731 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1732 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1733 | _res = return_stmt_var; |
| 1734 | goto done; |
| 1735 | } |
| 1736 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1737 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1738 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'return' return_stmt")); |
| 1739 | } |
| 1740 | { // &('import' | 'from') import_stmt |
| 1741 | if (p->error_indicator) { |
| 1742 | D(p->level--); |
| 1743 | return NULL; |
| 1744 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1745 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1746 | stmt_ty import_stmt_var; |
| 1747 | if ( |
| 1748 | _PyPegen_lookahead(1, _tmp_14_rule, p) |
| 1749 | && |
| 1750 | (import_stmt_var = import_stmt_rule(p)) // import_stmt |
| 1751 | ) |
| 1752 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1753 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1754 | _res = import_stmt_var; |
| 1755 | goto done; |
| 1756 | } |
| 1757 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1758 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1759 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('import' | 'from') import_stmt")); |
| 1760 | } |
| 1761 | { // &'raise' raise_stmt |
| 1762 | if (p->error_indicator) { |
| 1763 | D(p->level--); |
| 1764 | return NULL; |
| 1765 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1766 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1767 | stmt_ty raise_stmt_var; |
| 1768 | if ( |
| 1769 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501) // token='raise' |
| 1770 | && |
| 1771 | (raise_stmt_var = raise_stmt_rule(p)) // raise_stmt |
| 1772 | ) |
| 1773 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1774 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1775 | _res = raise_stmt_var; |
| 1776 | goto done; |
| 1777 | } |
| 1778 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1779 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1780 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'raise' raise_stmt")); |
| 1781 | } |
| 1782 | { // 'pass' |
| 1783 | if (p->error_indicator) { |
| 1784 | D(p->level--); |
| 1785 | return NULL; |
| 1786 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1787 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'pass'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1788 | Token * _keyword; |
| 1789 | if ( |
| 1790 | (_keyword = _PyPegen_expect_token(p, 502)) // token='pass' |
| 1791 | ) |
| 1792 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1793 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'pass'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1794 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1795 | if (_token == NULL) { |
| 1796 | D(p->level--); |
| 1797 | return NULL; |
| 1798 | } |
| 1799 | int _end_lineno = _token->end_lineno; |
| 1800 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1801 | int _end_col_offset = _token->end_col_offset; |
| 1802 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 1803 | _res = _PyAST_Pass ( EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1804 | if (_res == NULL && PyErr_Occurred()) { |
| 1805 | p->error_indicator = 1; |
| 1806 | D(p->level--); |
| 1807 | return NULL; |
| 1808 | } |
| 1809 | goto done; |
| 1810 | } |
| 1811 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1812 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1813 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'pass'")); |
| 1814 | } |
| 1815 | { // &'del' del_stmt |
| 1816 | if (p->error_indicator) { |
| 1817 | D(p->level--); |
| 1818 | return NULL; |
| 1819 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1820 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1821 | stmt_ty del_stmt_var; |
| 1822 | if ( |
| 1823 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) // token='del' |
| 1824 | && |
| 1825 | (del_stmt_var = del_stmt_rule(p)) // del_stmt |
| 1826 | ) |
| 1827 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1828 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1829 | _res = del_stmt_var; |
| 1830 | goto done; |
| 1831 | } |
| 1832 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1833 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1834 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'del' del_stmt")); |
| 1835 | } |
| 1836 | { // &'yield' yield_stmt |
| 1837 | if (p->error_indicator) { |
| 1838 | D(p->level--); |
| 1839 | return NULL; |
| 1840 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1841 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1842 | stmt_ty yield_stmt_var; |
| 1843 | if ( |
| 1844 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield' |
| 1845 | && |
| 1846 | (yield_stmt_var = yield_stmt_rule(p)) // yield_stmt |
| 1847 | ) |
| 1848 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1849 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1850 | _res = yield_stmt_var; |
| 1851 | goto done; |
| 1852 | } |
| 1853 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1854 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1855 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'yield' yield_stmt")); |
| 1856 | } |
| 1857 | { // &'assert' assert_stmt |
| 1858 | if (p->error_indicator) { |
| 1859 | D(p->level--); |
| 1860 | return NULL; |
| 1861 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1862 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1863 | stmt_ty assert_stmt_var; |
| 1864 | if ( |
| 1865 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) // token='assert' |
| 1866 | && |
| 1867 | (assert_stmt_var = assert_stmt_rule(p)) // assert_stmt |
| 1868 | ) |
| 1869 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1870 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1871 | _res = assert_stmt_var; |
| 1872 | goto done; |
| 1873 | } |
| 1874 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1875 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1876 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'assert' assert_stmt")); |
| 1877 | } |
| 1878 | { // 'break' |
| 1879 | if (p->error_indicator) { |
| 1880 | D(p->level--); |
| 1881 | return NULL; |
| 1882 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1883 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'break'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1884 | Token * _keyword; |
| 1885 | if ( |
| 1886 | (_keyword = _PyPegen_expect_token(p, 506)) // token='break' |
| 1887 | ) |
| 1888 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1889 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'break'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1890 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1891 | if (_token == NULL) { |
| 1892 | D(p->level--); |
| 1893 | return NULL; |
| 1894 | } |
| 1895 | int _end_lineno = _token->end_lineno; |
| 1896 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1897 | int _end_col_offset = _token->end_col_offset; |
| 1898 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 1899 | _res = _PyAST_Break ( EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1900 | if (_res == NULL && PyErr_Occurred()) { |
| 1901 | p->error_indicator = 1; |
| 1902 | D(p->level--); |
| 1903 | return NULL; |
| 1904 | } |
| 1905 | goto done; |
| 1906 | } |
| 1907 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1908 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1909 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'break'")); |
| 1910 | } |
| 1911 | { // 'continue' |
| 1912 | if (p->error_indicator) { |
| 1913 | D(p->level--); |
| 1914 | return NULL; |
| 1915 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1916 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'continue'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1917 | Token * _keyword; |
| 1918 | if ( |
| 1919 | (_keyword = _PyPegen_expect_token(p, 507)) // token='continue' |
| 1920 | ) |
| 1921 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1922 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'continue'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1923 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1924 | if (_token == NULL) { |
| 1925 | D(p->level--); |
| 1926 | return NULL; |
| 1927 | } |
| 1928 | int _end_lineno = _token->end_lineno; |
| 1929 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1930 | int _end_col_offset = _token->end_col_offset; |
| 1931 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 1932 | _res = _PyAST_Continue ( EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1933 | if (_res == NULL && PyErr_Occurred()) { |
| 1934 | p->error_indicator = 1; |
| 1935 | D(p->level--); |
| 1936 | return NULL; |
| 1937 | } |
| 1938 | goto done; |
| 1939 | } |
| 1940 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1941 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1942 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'continue'")); |
| 1943 | } |
| 1944 | { // &'global' global_stmt |
| 1945 | if (p->error_indicator) { |
| 1946 | D(p->level--); |
| 1947 | return NULL; |
| 1948 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1949 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1950 | stmt_ty global_stmt_var; |
| 1951 | if ( |
| 1952 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global' |
| 1953 | && |
| 1954 | (global_stmt_var = global_stmt_rule(p)) // global_stmt |
| 1955 | ) |
| 1956 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1957 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1958 | _res = global_stmt_var; |
| 1959 | goto done; |
| 1960 | } |
| 1961 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1962 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1963 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'global' global_stmt")); |
| 1964 | } |
| 1965 | { // &'nonlocal' nonlocal_stmt |
| 1966 | if (p->error_indicator) { |
| 1967 | D(p->level--); |
| 1968 | return NULL; |
| 1969 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1970 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1971 | stmt_ty nonlocal_stmt_var; |
| 1972 | if ( |
| 1973 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal' |
| 1974 | && |
| 1975 | (nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt |
| 1976 | ) |
| 1977 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1978 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1979 | _res = nonlocal_stmt_var; |
| 1980 | goto done; |
| 1981 | } |
| 1982 | p->mark = _mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1983 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1984 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'nonlocal' nonlocal_stmt")); |
| 1985 | } |
| 1986 | _res = NULL; |
| 1987 | done: |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 1988 | _PyPegen_insert_memo(p, _mark, simple_stmt_type, _res); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 1989 | D(p->level--); |
| 1990 | return _res; |
| 1991 | } |
| 1992 | |
| 1993 | // compound_stmt: |
| 1994 | // | &('def' | '@' | ASYNC) function_def |
| 1995 | // | &'if' if_stmt |
| 1996 | // | &('class' | '@') class_def |
| 1997 | // | &('with' | ASYNC) with_stmt |
| 1998 | // | &('for' | ASYNC) for_stmt |
| 1999 | // | &'try' try_stmt |
| 2000 | // | &'while' while_stmt |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 2001 | // | match_stmt |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2002 | static stmt_ty |
| 2003 | compound_stmt_rule(Parser *p) |
| 2004 | { |
| 2005 | D(p->level++); |
| 2006 | if (p->error_indicator) { |
| 2007 | D(p->level--); |
| 2008 | return NULL; |
| 2009 | } |
| 2010 | stmt_ty _res = NULL; |
| 2011 | int _mark = p->mark; |
| 2012 | { // &('def' | '@' | ASYNC) function_def |
| 2013 | if (p->error_indicator) { |
| 2014 | D(p->level--); |
| 2015 | return NULL; |
| 2016 | } |
| 2017 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('def' | '@' | ASYNC) function_def")); |
| 2018 | stmt_ty function_def_var; |
| 2019 | if ( |
| 2020 | _PyPegen_lookahead(1, _tmp_15_rule, p) |
| 2021 | && |
| 2022 | (function_def_var = function_def_rule(p)) // function_def |
| 2023 | ) |
| 2024 | { |
| 2025 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('def' | '@' | ASYNC) function_def")); |
| 2026 | _res = function_def_var; |
| 2027 | goto done; |
| 2028 | } |
| 2029 | p->mark = _mark; |
| 2030 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2031 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('def' | '@' | ASYNC) function_def")); |
| 2032 | } |
| 2033 | { // &'if' if_stmt |
| 2034 | if (p->error_indicator) { |
| 2035 | D(p->level--); |
| 2036 | return NULL; |
| 2037 | } |
| 2038 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'if' if_stmt")); |
| 2039 | stmt_ty if_stmt_var; |
| 2040 | if ( |
| 2041 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 510) // token='if' |
| 2042 | && |
| 2043 | (if_stmt_var = if_stmt_rule(p)) // if_stmt |
| 2044 | ) |
| 2045 | { |
| 2046 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'if' if_stmt")); |
| 2047 | _res = if_stmt_var; |
| 2048 | goto done; |
| 2049 | } |
| 2050 | p->mark = _mark; |
| 2051 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2052 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'if' if_stmt")); |
| 2053 | } |
| 2054 | { // &('class' | '@') class_def |
| 2055 | if (p->error_indicator) { |
| 2056 | D(p->level--); |
| 2057 | return NULL; |
| 2058 | } |
| 2059 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('class' | '@') class_def")); |
| 2060 | stmt_ty class_def_var; |
| 2061 | if ( |
| 2062 | _PyPegen_lookahead(1, _tmp_16_rule, p) |
| 2063 | && |
| 2064 | (class_def_var = class_def_rule(p)) // class_def |
| 2065 | ) |
| 2066 | { |
| 2067 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('class' | '@') class_def")); |
| 2068 | _res = class_def_var; |
| 2069 | goto done; |
| 2070 | } |
| 2071 | p->mark = _mark; |
| 2072 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2073 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('class' | '@') class_def")); |
| 2074 | } |
| 2075 | { // &('with' | ASYNC) with_stmt |
| 2076 | if (p->error_indicator) { |
| 2077 | D(p->level--); |
| 2078 | return NULL; |
| 2079 | } |
| 2080 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('with' | ASYNC) with_stmt")); |
| 2081 | stmt_ty with_stmt_var; |
| 2082 | if ( |
| 2083 | _PyPegen_lookahead(1, _tmp_17_rule, p) |
| 2084 | && |
| 2085 | (with_stmt_var = with_stmt_rule(p)) // with_stmt |
| 2086 | ) |
| 2087 | { |
| 2088 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('with' | ASYNC) with_stmt")); |
| 2089 | _res = with_stmt_var; |
| 2090 | goto done; |
| 2091 | } |
| 2092 | p->mark = _mark; |
| 2093 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2094 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('with' | ASYNC) with_stmt")); |
| 2095 | } |
| 2096 | { // &('for' | ASYNC) for_stmt |
| 2097 | if (p->error_indicator) { |
| 2098 | D(p->level--); |
| 2099 | return NULL; |
| 2100 | } |
| 2101 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('for' | ASYNC) for_stmt")); |
| 2102 | stmt_ty for_stmt_var; |
| 2103 | if ( |
| 2104 | _PyPegen_lookahead(1, _tmp_18_rule, p) |
| 2105 | && |
| 2106 | (for_stmt_var = for_stmt_rule(p)) // for_stmt |
| 2107 | ) |
| 2108 | { |
| 2109 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('for' | ASYNC) for_stmt")); |
| 2110 | _res = for_stmt_var; |
| 2111 | goto done; |
| 2112 | } |
| 2113 | p->mark = _mark; |
| 2114 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2115 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('for' | ASYNC) for_stmt")); |
| 2116 | } |
| 2117 | { // &'try' try_stmt |
| 2118 | if (p->error_indicator) { |
| 2119 | D(p->level--); |
| 2120 | return NULL; |
| 2121 | } |
| 2122 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'try' try_stmt")); |
| 2123 | stmt_ty try_stmt_var; |
| 2124 | if ( |
| 2125 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 511) // token='try' |
| 2126 | && |
| 2127 | (try_stmt_var = try_stmt_rule(p)) // try_stmt |
| 2128 | ) |
| 2129 | { |
| 2130 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'try' try_stmt")); |
| 2131 | _res = try_stmt_var; |
| 2132 | goto done; |
| 2133 | } |
| 2134 | p->mark = _mark; |
| 2135 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2136 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'try' try_stmt")); |
| 2137 | } |
| 2138 | { // &'while' while_stmt |
| 2139 | if (p->error_indicator) { |
| 2140 | D(p->level--); |
| 2141 | return NULL; |
| 2142 | } |
| 2143 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'while' while_stmt")); |
| 2144 | stmt_ty while_stmt_var; |
| 2145 | if ( |
| 2146 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 512) // token='while' |
| 2147 | && |
| 2148 | (while_stmt_var = while_stmt_rule(p)) // while_stmt |
| 2149 | ) |
| 2150 | { |
| 2151 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'while' while_stmt")); |
| 2152 | _res = while_stmt_var; |
| 2153 | goto done; |
| 2154 | } |
| 2155 | p->mark = _mark; |
| 2156 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2157 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'while' while_stmt")); |
| 2158 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 2159 | { // match_stmt |
| 2160 | if (p->error_indicator) { |
| 2161 | D(p->level--); |
| 2162 | return NULL; |
| 2163 | } |
| 2164 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "match_stmt")); |
| 2165 | stmt_ty match_stmt_var; |
| 2166 | if ( |
| 2167 | (match_stmt_var = match_stmt_rule(p)) // match_stmt |
| 2168 | ) |
| 2169 | { |
| 2170 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "match_stmt")); |
| 2171 | _res = match_stmt_var; |
| 2172 | goto done; |
| 2173 | } |
| 2174 | p->mark = _mark; |
| 2175 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2176 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "match_stmt")); |
| 2177 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2178 | _res = NULL; |
| 2179 | done: |
| 2180 | D(p->level--); |
| 2181 | return _res; |
| 2182 | } |
| 2183 | |
| 2184 | // assignment: |
| 2185 | // | NAME ':' expression ['=' annotated_rhs] |
| 2186 | // | ('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs] |
| 2187 | // | ((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT? |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 2188 | // | single_target augassign ~ (yield_expr | star_expressions) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2189 | // | invalid_assignment |
| 2190 | static stmt_ty |
| 2191 | assignment_rule(Parser *p) |
| 2192 | { |
| 2193 | D(p->level++); |
| 2194 | if (p->error_indicator) { |
| 2195 | D(p->level--); |
| 2196 | return NULL; |
| 2197 | } |
| 2198 | stmt_ty _res = NULL; |
| 2199 | int _mark = p->mark; |
| 2200 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2201 | p->error_indicator = 1; |
| 2202 | D(p->level--); |
| 2203 | return NULL; |
| 2204 | } |
| 2205 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2206 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2207 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2208 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 2209 | { // NAME ':' expression ['=' annotated_rhs] |
| 2210 | if (p->error_indicator) { |
| 2211 | D(p->level--); |
| 2212 | return NULL; |
| 2213 | } |
| 2214 | D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':' expression ['=' annotated_rhs]")); |
| 2215 | Token * _literal; |
| 2216 | expr_ty a; |
| 2217 | expr_ty b; |
| 2218 | void *c; |
| 2219 | if ( |
| 2220 | (a = _PyPegen_name_token(p)) // NAME |
| 2221 | && |
| 2222 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 2223 | && |
| 2224 | (b = expression_rule(p)) // expression |
| 2225 | && |
| 2226 | (c = _tmp_19_rule(p), 1) // ['=' annotated_rhs] |
| 2227 | ) |
| 2228 | { |
| 2229 | D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ':' expression ['=' annotated_rhs]")); |
| 2230 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2231 | if (_token == NULL) { |
| 2232 | D(p->level--); |
| 2233 | return NULL; |
| 2234 | } |
| 2235 | int _end_lineno = _token->end_lineno; |
| 2236 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2237 | int _end_col_offset = _token->end_col_offset; |
| 2238 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 2239 | _res = CHECK_VERSION ( stmt_ty , 6 , "Variable annotation syntax is" , _PyAST_AnnAssign ( CHECK ( expr_ty , _PyPegen_set_expr_context ( p , a , Store ) ) , b , c , 1 , EXTRA ) ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2240 | if (_res == NULL && PyErr_Occurred()) { |
| 2241 | p->error_indicator = 1; |
| 2242 | D(p->level--); |
| 2243 | return NULL; |
| 2244 | } |
| 2245 | goto done; |
| 2246 | } |
| 2247 | p->mark = _mark; |
| 2248 | D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 2249 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':' expression ['=' annotated_rhs]")); |
| 2250 | } |
| 2251 | { // ('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs] |
| 2252 | if (p->error_indicator) { |
| 2253 | D(p->level--); |
| 2254 | return NULL; |
| 2255 | } |
| 2256 | D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]")); |
| 2257 | Token * _literal; |
| 2258 | void *a; |
| 2259 | expr_ty b; |
| 2260 | void *c; |
| 2261 | if ( |
| 2262 | (a = _tmp_20_rule(p)) // '(' single_target ')' | single_subscript_attribute_target |
| 2263 | && |
| 2264 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 2265 | && |
| 2266 | (b = expression_rule(p)) // expression |
| 2267 | && |
| 2268 | (c = _tmp_21_rule(p), 1) // ['=' annotated_rhs] |
| 2269 | ) |
| 2270 | { |
| 2271 | D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]")); |
| 2272 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2273 | if (_token == NULL) { |
| 2274 | D(p->level--); |
| 2275 | return NULL; |
| 2276 | } |
| 2277 | int _end_lineno = _token->end_lineno; |
| 2278 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2279 | int _end_col_offset = _token->end_col_offset; |
| 2280 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 2281 | _res = CHECK_VERSION ( stmt_ty , 6 , "Variable annotations syntax is" , _PyAST_AnnAssign ( a , b , c , 0 , EXTRA ) ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2282 | if (_res == NULL && PyErr_Occurred()) { |
| 2283 | p->error_indicator = 1; |
| 2284 | D(p->level--); |
| 2285 | return NULL; |
| 2286 | } |
| 2287 | goto done; |
| 2288 | } |
| 2289 | p->mark = _mark; |
| 2290 | D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 2291 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]")); |
| 2292 | } |
| 2293 | { // ((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT? |
| 2294 | if (p->error_indicator) { |
| 2295 | D(p->level--); |
| 2296 | return NULL; |
| 2297 | } |
| 2298 | D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 2299 | asdl_expr_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2300 | void *b; |
| 2301 | void *tc; |
| 2302 | if ( |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 2303 | (a = (asdl_expr_seq*)_loop1_22_rule(p)) // ((star_targets '='))+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2304 | && |
| 2305 | (b = _tmp_23_rule(p)) // yield_expr | star_expressions |
| 2306 | && |
| 2307 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' |
| 2308 | && |
| 2309 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
| 2310 | ) |
| 2311 | { |
| 2312 | D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?")); |
| 2313 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2314 | if (_token == NULL) { |
| 2315 | D(p->level--); |
| 2316 | return NULL; |
| 2317 | } |
| 2318 | int _end_lineno = _token->end_lineno; |
| 2319 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2320 | int _end_col_offset = _token->end_col_offset; |
| 2321 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 2322 | _res = _PyAST_Assign ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2323 | if (_res == NULL && PyErr_Occurred()) { |
| 2324 | p->error_indicator = 1; |
| 2325 | D(p->level--); |
| 2326 | return NULL; |
| 2327 | } |
| 2328 | goto done; |
| 2329 | } |
| 2330 | p->mark = _mark; |
| 2331 | D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 2332 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?")); |
| 2333 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 2334 | { // single_target augassign ~ (yield_expr | star_expressions) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2335 | if (p->error_indicator) { |
| 2336 | D(p->level--); |
| 2337 | return NULL; |
| 2338 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 2339 | D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_target augassign ~ (yield_expr | star_expressions)")); |
| 2340 | int _cut_var = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2341 | expr_ty a; |
| 2342 | AugOperator* b; |
| 2343 | void *c; |
| 2344 | if ( |
| 2345 | (a = single_target_rule(p)) // single_target |
| 2346 | && |
| 2347 | (b = augassign_rule(p)) // augassign |
| 2348 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 2349 | (_cut_var = 1) |
| 2350 | && |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2351 | (c = _tmp_24_rule(p)) // yield_expr | star_expressions |
| 2352 | ) |
| 2353 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 2354 | D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_target augassign ~ (yield_expr | star_expressions)")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2355 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2356 | if (_token == NULL) { |
| 2357 | D(p->level--); |
| 2358 | return NULL; |
| 2359 | } |
| 2360 | int _end_lineno = _token->end_lineno; |
| 2361 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2362 | int _end_col_offset = _token->end_col_offset; |
| 2363 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 2364 | _res = _PyAST_AugAssign ( a , b -> kind , c , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2365 | if (_res == NULL && PyErr_Occurred()) { |
| 2366 | p->error_indicator = 1; |
| 2367 | D(p->level--); |
| 2368 | return NULL; |
| 2369 | } |
| 2370 | goto done; |
| 2371 | } |
| 2372 | p->mark = _mark; |
| 2373 | D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 2374 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_target augassign ~ (yield_expr | star_expressions)")); |
| 2375 | if (_cut_var) { |
| 2376 | D(p->level--); |
| 2377 | return NULL; |
| 2378 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2379 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 2380 | if (p->call_invalid_rules) { // invalid_assignment |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2381 | if (p->error_indicator) { |
| 2382 | D(p->level--); |
| 2383 | return NULL; |
| 2384 | } |
| 2385 | D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_assignment")); |
| 2386 | void *invalid_assignment_var; |
| 2387 | if ( |
| 2388 | (invalid_assignment_var = invalid_assignment_rule(p)) // invalid_assignment |
| 2389 | ) |
| 2390 | { |
| 2391 | D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_assignment")); |
| 2392 | _res = invalid_assignment_var; |
| 2393 | goto done; |
| 2394 | } |
| 2395 | p->mark = _mark; |
| 2396 | D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 2397 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_assignment")); |
| 2398 | } |
| 2399 | _res = NULL; |
| 2400 | done: |
| 2401 | D(p->level--); |
| 2402 | return _res; |
| 2403 | } |
| 2404 | |
| 2405 | // augassign: |
| 2406 | // | '+=' |
| 2407 | // | '-=' |
| 2408 | // | '*=' |
| 2409 | // | '@=' |
| 2410 | // | '/=' |
| 2411 | // | '%=' |
| 2412 | // | '&=' |
| 2413 | // | '|=' |
| 2414 | // | '^=' |
| 2415 | // | '<<=' |
| 2416 | // | '>>=' |
| 2417 | // | '**=' |
| 2418 | // | '//=' |
| 2419 | static AugOperator* |
| 2420 | augassign_rule(Parser *p) |
| 2421 | { |
| 2422 | D(p->level++); |
| 2423 | if (p->error_indicator) { |
| 2424 | D(p->level--); |
| 2425 | return NULL; |
| 2426 | } |
| 2427 | AugOperator* _res = NULL; |
| 2428 | int _mark = p->mark; |
| 2429 | { // '+=' |
| 2430 | if (p->error_indicator) { |
| 2431 | D(p->level--); |
| 2432 | return NULL; |
| 2433 | } |
| 2434 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+='")); |
| 2435 | Token * _literal; |
| 2436 | if ( |
| 2437 | (_literal = _PyPegen_expect_token(p, 36)) // token='+=' |
| 2438 | ) |
| 2439 | { |
| 2440 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+='")); |
| 2441 | _res = _PyPegen_augoperator ( p , Add ); |
| 2442 | if (_res == NULL && PyErr_Occurred()) { |
| 2443 | p->error_indicator = 1; |
| 2444 | D(p->level--); |
| 2445 | return NULL; |
| 2446 | } |
| 2447 | goto done; |
| 2448 | } |
| 2449 | p->mark = _mark; |
| 2450 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2451 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+='")); |
| 2452 | } |
| 2453 | { // '-=' |
| 2454 | if (p->error_indicator) { |
| 2455 | D(p->level--); |
| 2456 | return NULL; |
| 2457 | } |
| 2458 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-='")); |
| 2459 | Token * _literal; |
| 2460 | if ( |
| 2461 | (_literal = _PyPegen_expect_token(p, 37)) // token='-=' |
| 2462 | ) |
| 2463 | { |
| 2464 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-='")); |
| 2465 | _res = _PyPegen_augoperator ( p , Sub ); |
| 2466 | if (_res == NULL && PyErr_Occurred()) { |
| 2467 | p->error_indicator = 1; |
| 2468 | D(p->level--); |
| 2469 | return NULL; |
| 2470 | } |
| 2471 | goto done; |
| 2472 | } |
| 2473 | p->mark = _mark; |
| 2474 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2475 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-='")); |
| 2476 | } |
| 2477 | { // '*=' |
| 2478 | if (p->error_indicator) { |
| 2479 | D(p->level--); |
| 2480 | return NULL; |
| 2481 | } |
| 2482 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*='")); |
| 2483 | Token * _literal; |
| 2484 | if ( |
| 2485 | (_literal = _PyPegen_expect_token(p, 38)) // token='*=' |
| 2486 | ) |
| 2487 | { |
| 2488 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*='")); |
| 2489 | _res = _PyPegen_augoperator ( p , Mult ); |
| 2490 | if (_res == NULL && PyErr_Occurred()) { |
| 2491 | p->error_indicator = 1; |
| 2492 | D(p->level--); |
| 2493 | return NULL; |
| 2494 | } |
| 2495 | goto done; |
| 2496 | } |
| 2497 | p->mark = _mark; |
| 2498 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2499 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*='")); |
| 2500 | } |
| 2501 | { // '@=' |
| 2502 | if (p->error_indicator) { |
| 2503 | D(p->level--); |
| 2504 | return NULL; |
| 2505 | } |
| 2506 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@='")); |
| 2507 | Token * _literal; |
| 2508 | if ( |
| 2509 | (_literal = _PyPegen_expect_token(p, 50)) // token='@=' |
| 2510 | ) |
| 2511 | { |
| 2512 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@='")); |
Lysandros Nikolaou | 2e5ca9e | 2020-10-21 22:53:14 +0300 | [diff] [blame] | 2513 | _res = CHECK_VERSION ( AugOperator * , 5 , "The '@' operator is" , _PyPegen_augoperator ( p , MatMult ) ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2514 | if (_res == NULL && PyErr_Occurred()) { |
| 2515 | p->error_indicator = 1; |
| 2516 | D(p->level--); |
| 2517 | return NULL; |
| 2518 | } |
| 2519 | goto done; |
| 2520 | } |
| 2521 | p->mark = _mark; |
| 2522 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2523 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@='")); |
| 2524 | } |
| 2525 | { // '/=' |
| 2526 | if (p->error_indicator) { |
| 2527 | D(p->level--); |
| 2528 | return NULL; |
| 2529 | } |
| 2530 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/='")); |
| 2531 | Token * _literal; |
| 2532 | if ( |
| 2533 | (_literal = _PyPegen_expect_token(p, 39)) // token='/=' |
| 2534 | ) |
| 2535 | { |
| 2536 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/='")); |
| 2537 | _res = _PyPegen_augoperator ( p , Div ); |
| 2538 | if (_res == NULL && PyErr_Occurred()) { |
| 2539 | p->error_indicator = 1; |
| 2540 | D(p->level--); |
| 2541 | return NULL; |
| 2542 | } |
| 2543 | goto done; |
| 2544 | } |
| 2545 | p->mark = _mark; |
| 2546 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2547 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'/='")); |
| 2548 | } |
| 2549 | { // '%=' |
| 2550 | if (p->error_indicator) { |
| 2551 | D(p->level--); |
| 2552 | return NULL; |
| 2553 | } |
| 2554 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'%='")); |
| 2555 | Token * _literal; |
| 2556 | if ( |
| 2557 | (_literal = _PyPegen_expect_token(p, 40)) // token='%=' |
| 2558 | ) |
| 2559 | { |
| 2560 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'%='")); |
| 2561 | _res = _PyPegen_augoperator ( p , Mod ); |
| 2562 | if (_res == NULL && PyErr_Occurred()) { |
| 2563 | p->error_indicator = 1; |
| 2564 | D(p->level--); |
| 2565 | return NULL; |
| 2566 | } |
| 2567 | goto done; |
| 2568 | } |
| 2569 | p->mark = _mark; |
| 2570 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2571 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'%='")); |
| 2572 | } |
| 2573 | { // '&=' |
| 2574 | if (p->error_indicator) { |
| 2575 | D(p->level--); |
| 2576 | return NULL; |
| 2577 | } |
| 2578 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'&='")); |
| 2579 | Token * _literal; |
| 2580 | if ( |
| 2581 | (_literal = _PyPegen_expect_token(p, 41)) // token='&=' |
| 2582 | ) |
| 2583 | { |
| 2584 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'&='")); |
| 2585 | _res = _PyPegen_augoperator ( p , BitAnd ); |
| 2586 | if (_res == NULL && PyErr_Occurred()) { |
| 2587 | p->error_indicator = 1; |
| 2588 | D(p->level--); |
| 2589 | return NULL; |
| 2590 | } |
| 2591 | goto done; |
| 2592 | } |
| 2593 | p->mark = _mark; |
| 2594 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2595 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'&='")); |
| 2596 | } |
| 2597 | { // '|=' |
| 2598 | if (p->error_indicator) { |
| 2599 | D(p->level--); |
| 2600 | return NULL; |
| 2601 | } |
| 2602 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|='")); |
| 2603 | Token * _literal; |
| 2604 | if ( |
| 2605 | (_literal = _PyPegen_expect_token(p, 42)) // token='|=' |
| 2606 | ) |
| 2607 | { |
| 2608 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'|='")); |
| 2609 | _res = _PyPegen_augoperator ( p , BitOr ); |
| 2610 | if (_res == NULL && PyErr_Occurred()) { |
| 2611 | p->error_indicator = 1; |
| 2612 | D(p->level--); |
| 2613 | return NULL; |
| 2614 | } |
| 2615 | goto done; |
| 2616 | } |
| 2617 | p->mark = _mark; |
| 2618 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2619 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|='")); |
| 2620 | } |
| 2621 | { // '^=' |
| 2622 | if (p->error_indicator) { |
| 2623 | D(p->level--); |
| 2624 | return NULL; |
| 2625 | } |
| 2626 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'^='")); |
| 2627 | Token * _literal; |
| 2628 | if ( |
| 2629 | (_literal = _PyPegen_expect_token(p, 43)) // token='^=' |
| 2630 | ) |
| 2631 | { |
| 2632 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'^='")); |
| 2633 | _res = _PyPegen_augoperator ( p , BitXor ); |
| 2634 | if (_res == NULL && PyErr_Occurred()) { |
| 2635 | p->error_indicator = 1; |
| 2636 | D(p->level--); |
| 2637 | return NULL; |
| 2638 | } |
| 2639 | goto done; |
| 2640 | } |
| 2641 | p->mark = _mark; |
| 2642 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2643 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'^='")); |
| 2644 | } |
| 2645 | { // '<<=' |
| 2646 | if (p->error_indicator) { |
| 2647 | D(p->level--); |
| 2648 | return NULL; |
| 2649 | } |
| 2650 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<<='")); |
| 2651 | Token * _literal; |
| 2652 | if ( |
| 2653 | (_literal = _PyPegen_expect_token(p, 44)) // token='<<=' |
| 2654 | ) |
| 2655 | { |
| 2656 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<<='")); |
| 2657 | _res = _PyPegen_augoperator ( p , LShift ); |
| 2658 | if (_res == NULL && PyErr_Occurred()) { |
| 2659 | p->error_indicator = 1; |
| 2660 | D(p->level--); |
| 2661 | return NULL; |
| 2662 | } |
| 2663 | goto done; |
| 2664 | } |
| 2665 | p->mark = _mark; |
| 2666 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2667 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<<='")); |
| 2668 | } |
| 2669 | { // '>>=' |
| 2670 | if (p->error_indicator) { |
| 2671 | D(p->level--); |
| 2672 | return NULL; |
| 2673 | } |
| 2674 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>>='")); |
| 2675 | Token * _literal; |
| 2676 | if ( |
| 2677 | (_literal = _PyPegen_expect_token(p, 45)) // token='>>=' |
| 2678 | ) |
| 2679 | { |
| 2680 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>>='")); |
| 2681 | _res = _PyPegen_augoperator ( p , RShift ); |
| 2682 | if (_res == NULL && PyErr_Occurred()) { |
| 2683 | p->error_indicator = 1; |
| 2684 | D(p->level--); |
| 2685 | return NULL; |
| 2686 | } |
| 2687 | goto done; |
| 2688 | } |
| 2689 | p->mark = _mark; |
| 2690 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2691 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>>='")); |
| 2692 | } |
| 2693 | { // '**=' |
| 2694 | if (p->error_indicator) { |
| 2695 | D(p->level--); |
| 2696 | return NULL; |
| 2697 | } |
| 2698 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**='")); |
| 2699 | Token * _literal; |
| 2700 | if ( |
| 2701 | (_literal = _PyPegen_expect_token(p, 46)) // token='**=' |
| 2702 | ) |
| 2703 | { |
| 2704 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**='")); |
| 2705 | _res = _PyPegen_augoperator ( p , Pow ); |
| 2706 | if (_res == NULL && PyErr_Occurred()) { |
| 2707 | p->error_indicator = 1; |
| 2708 | D(p->level--); |
| 2709 | return NULL; |
| 2710 | } |
| 2711 | goto done; |
| 2712 | } |
| 2713 | p->mark = _mark; |
| 2714 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2715 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**='")); |
| 2716 | } |
| 2717 | { // '//=' |
| 2718 | if (p->error_indicator) { |
| 2719 | D(p->level--); |
| 2720 | return NULL; |
| 2721 | } |
| 2722 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'//='")); |
| 2723 | Token * _literal; |
| 2724 | if ( |
| 2725 | (_literal = _PyPegen_expect_token(p, 48)) // token='//=' |
| 2726 | ) |
| 2727 | { |
| 2728 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'//='")); |
| 2729 | _res = _PyPegen_augoperator ( p , FloorDiv ); |
| 2730 | if (_res == NULL && PyErr_Occurred()) { |
| 2731 | p->error_indicator = 1; |
| 2732 | D(p->level--); |
| 2733 | return NULL; |
| 2734 | } |
| 2735 | goto done; |
| 2736 | } |
| 2737 | p->mark = _mark; |
| 2738 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2739 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'//='")); |
| 2740 | } |
| 2741 | _res = NULL; |
| 2742 | done: |
| 2743 | D(p->level--); |
| 2744 | return _res; |
| 2745 | } |
| 2746 | |
| 2747 | // global_stmt: 'global' ','.NAME+ |
| 2748 | static stmt_ty |
| 2749 | global_stmt_rule(Parser *p) |
| 2750 | { |
| 2751 | D(p->level++); |
| 2752 | if (p->error_indicator) { |
| 2753 | D(p->level--); |
| 2754 | return NULL; |
| 2755 | } |
| 2756 | stmt_ty _res = NULL; |
| 2757 | int _mark = p->mark; |
| 2758 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2759 | p->error_indicator = 1; |
| 2760 | D(p->level--); |
| 2761 | return NULL; |
| 2762 | } |
| 2763 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2764 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2765 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2766 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 2767 | { // 'global' ','.NAME+ |
| 2768 | if (p->error_indicator) { |
| 2769 | D(p->level--); |
| 2770 | return NULL; |
| 2771 | } |
| 2772 | D(fprintf(stderr, "%*c> global_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'global' ','.NAME+")); |
| 2773 | Token * _keyword; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 2774 | asdl_expr_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2775 | if ( |
| 2776 | (_keyword = _PyPegen_expect_token(p, 508)) // token='global' |
| 2777 | && |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 2778 | (a = (asdl_expr_seq*)_gather_25_rule(p)) // ','.NAME+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2779 | ) |
| 2780 | { |
| 2781 | D(fprintf(stderr, "%*c+ global_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'global' ','.NAME+")); |
| 2782 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2783 | if (_token == NULL) { |
| 2784 | D(p->level--); |
| 2785 | return NULL; |
| 2786 | } |
| 2787 | int _end_lineno = _token->end_lineno; |
| 2788 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2789 | int _end_col_offset = _token->end_col_offset; |
| 2790 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 2791 | _res = _PyAST_Global ( CHECK ( asdl_identifier_seq * , _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2792 | if (_res == NULL && PyErr_Occurred()) { |
| 2793 | p->error_indicator = 1; |
| 2794 | D(p->level--); |
| 2795 | return NULL; |
| 2796 | } |
| 2797 | goto done; |
| 2798 | } |
| 2799 | p->mark = _mark; |
| 2800 | D(fprintf(stderr, "%*c%s global_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2801 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'global' ','.NAME+")); |
| 2802 | } |
| 2803 | _res = NULL; |
| 2804 | done: |
| 2805 | D(p->level--); |
| 2806 | return _res; |
| 2807 | } |
| 2808 | |
| 2809 | // nonlocal_stmt: 'nonlocal' ','.NAME+ |
| 2810 | static stmt_ty |
| 2811 | nonlocal_stmt_rule(Parser *p) |
| 2812 | { |
| 2813 | D(p->level++); |
| 2814 | if (p->error_indicator) { |
| 2815 | D(p->level--); |
| 2816 | return NULL; |
| 2817 | } |
| 2818 | stmt_ty _res = NULL; |
| 2819 | int _mark = p->mark; |
| 2820 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2821 | p->error_indicator = 1; |
| 2822 | D(p->level--); |
| 2823 | return NULL; |
| 2824 | } |
| 2825 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2826 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2827 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2828 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 2829 | { // 'nonlocal' ','.NAME+ |
| 2830 | if (p->error_indicator) { |
| 2831 | D(p->level--); |
| 2832 | return NULL; |
| 2833 | } |
| 2834 | D(fprintf(stderr, "%*c> nonlocal_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'nonlocal' ','.NAME+")); |
| 2835 | Token * _keyword; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 2836 | asdl_expr_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2837 | if ( |
| 2838 | (_keyword = _PyPegen_expect_token(p, 509)) // token='nonlocal' |
| 2839 | && |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 2840 | (a = (asdl_expr_seq*)_gather_27_rule(p)) // ','.NAME+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2841 | ) |
| 2842 | { |
| 2843 | D(fprintf(stderr, "%*c+ nonlocal_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'nonlocal' ','.NAME+")); |
| 2844 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2845 | if (_token == NULL) { |
| 2846 | D(p->level--); |
| 2847 | return NULL; |
| 2848 | } |
| 2849 | int _end_lineno = _token->end_lineno; |
| 2850 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2851 | int _end_col_offset = _token->end_col_offset; |
| 2852 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 2853 | _res = _PyAST_Nonlocal ( CHECK ( asdl_identifier_seq * , _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2854 | if (_res == NULL && PyErr_Occurred()) { |
| 2855 | p->error_indicator = 1; |
| 2856 | D(p->level--); |
| 2857 | return NULL; |
| 2858 | } |
| 2859 | goto done; |
| 2860 | } |
| 2861 | p->mark = _mark; |
| 2862 | D(fprintf(stderr, "%*c%s nonlocal_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2863 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'nonlocal' ','.NAME+")); |
| 2864 | } |
| 2865 | _res = NULL; |
| 2866 | done: |
| 2867 | D(p->level--); |
| 2868 | return _res; |
| 2869 | } |
| 2870 | |
| 2871 | // yield_stmt: yield_expr |
| 2872 | static stmt_ty |
| 2873 | yield_stmt_rule(Parser *p) |
| 2874 | { |
| 2875 | D(p->level++); |
| 2876 | if (p->error_indicator) { |
| 2877 | D(p->level--); |
| 2878 | return NULL; |
| 2879 | } |
| 2880 | stmt_ty _res = NULL; |
| 2881 | int _mark = p->mark; |
| 2882 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2883 | p->error_indicator = 1; |
| 2884 | D(p->level--); |
| 2885 | return NULL; |
| 2886 | } |
| 2887 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2888 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2889 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2890 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 2891 | { // yield_expr |
| 2892 | if (p->error_indicator) { |
| 2893 | D(p->level--); |
| 2894 | return NULL; |
| 2895 | } |
| 2896 | D(fprintf(stderr, "%*c> yield_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
| 2897 | expr_ty y; |
| 2898 | if ( |
| 2899 | (y = yield_expr_rule(p)) // yield_expr |
| 2900 | ) |
| 2901 | { |
| 2902 | D(fprintf(stderr, "%*c+ yield_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
| 2903 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2904 | if (_token == NULL) { |
| 2905 | D(p->level--); |
| 2906 | return NULL; |
| 2907 | } |
| 2908 | int _end_lineno = _token->end_lineno; |
| 2909 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2910 | int _end_col_offset = _token->end_col_offset; |
| 2911 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 2912 | _res = _PyAST_Expr ( y , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2913 | if (_res == NULL && PyErr_Occurred()) { |
| 2914 | p->error_indicator = 1; |
| 2915 | D(p->level--); |
| 2916 | return NULL; |
| 2917 | } |
| 2918 | goto done; |
| 2919 | } |
| 2920 | p->mark = _mark; |
| 2921 | D(fprintf(stderr, "%*c%s yield_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2922 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); |
| 2923 | } |
| 2924 | _res = NULL; |
| 2925 | done: |
| 2926 | D(p->level--); |
| 2927 | return _res; |
| 2928 | } |
| 2929 | |
| 2930 | // assert_stmt: 'assert' expression [',' expression] |
| 2931 | static stmt_ty |
| 2932 | assert_stmt_rule(Parser *p) |
| 2933 | { |
| 2934 | D(p->level++); |
| 2935 | if (p->error_indicator) { |
| 2936 | D(p->level--); |
| 2937 | return NULL; |
| 2938 | } |
| 2939 | stmt_ty _res = NULL; |
| 2940 | int _mark = p->mark; |
| 2941 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2942 | p->error_indicator = 1; |
| 2943 | D(p->level--); |
| 2944 | return NULL; |
| 2945 | } |
| 2946 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2947 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2948 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2949 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 2950 | { // 'assert' expression [',' expression] |
| 2951 | if (p->error_indicator) { |
| 2952 | D(p->level--); |
| 2953 | return NULL; |
| 2954 | } |
| 2955 | D(fprintf(stderr, "%*c> assert_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'assert' expression [',' expression]")); |
| 2956 | Token * _keyword; |
| 2957 | expr_ty a; |
| 2958 | void *b; |
| 2959 | if ( |
| 2960 | (_keyword = _PyPegen_expect_token(p, 505)) // token='assert' |
| 2961 | && |
| 2962 | (a = expression_rule(p)) // expression |
| 2963 | && |
| 2964 | (b = _tmp_29_rule(p), 1) // [',' expression] |
| 2965 | ) |
| 2966 | { |
| 2967 | D(fprintf(stderr, "%*c+ assert_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'assert' expression [',' expression]")); |
| 2968 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2969 | if (_token == NULL) { |
| 2970 | D(p->level--); |
| 2971 | return NULL; |
| 2972 | } |
| 2973 | int _end_lineno = _token->end_lineno; |
| 2974 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2975 | int _end_col_offset = _token->end_col_offset; |
| 2976 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 2977 | _res = _PyAST_Assert ( a , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2978 | if (_res == NULL && PyErr_Occurred()) { |
| 2979 | p->error_indicator = 1; |
| 2980 | D(p->level--); |
| 2981 | return NULL; |
| 2982 | } |
| 2983 | goto done; |
| 2984 | } |
| 2985 | p->mark = _mark; |
| 2986 | D(fprintf(stderr, "%*c%s assert_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2987 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'assert' expression [',' expression]")); |
| 2988 | } |
| 2989 | _res = NULL; |
| 2990 | done: |
| 2991 | D(p->level--); |
| 2992 | return _res; |
| 2993 | } |
| 2994 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 2995 | // del_stmt: 'del' del_targets &(';' | NEWLINE) | invalid_del_stmt |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 2996 | static stmt_ty |
| 2997 | del_stmt_rule(Parser *p) |
| 2998 | { |
| 2999 | D(p->level++); |
| 3000 | if (p->error_indicator) { |
| 3001 | D(p->level--); |
| 3002 | return NULL; |
| 3003 | } |
| 3004 | stmt_ty _res = NULL; |
| 3005 | int _mark = p->mark; |
| 3006 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3007 | p->error_indicator = 1; |
| 3008 | D(p->level--); |
| 3009 | return NULL; |
| 3010 | } |
| 3011 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3012 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3013 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3014 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 3015 | { // 'del' del_targets &(';' | NEWLINE) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3016 | if (p->error_indicator) { |
| 3017 | D(p->level--); |
| 3018 | return NULL; |
| 3019 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 3020 | D(fprintf(stderr, "%*c> del_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'del' del_targets &(';' | NEWLINE)")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3021 | Token * _keyword; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3022 | asdl_expr_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3023 | if ( |
| 3024 | (_keyword = _PyPegen_expect_token(p, 503)) // token='del' |
| 3025 | && |
| 3026 | (a = del_targets_rule(p)) // del_targets |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 3027 | && |
| 3028 | _PyPegen_lookahead(1, _tmp_30_rule, p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3029 | ) |
| 3030 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 3031 | D(fprintf(stderr, "%*c+ del_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'del' del_targets &(';' | NEWLINE)")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3032 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3033 | if (_token == NULL) { |
| 3034 | D(p->level--); |
| 3035 | return NULL; |
| 3036 | } |
| 3037 | int _end_lineno = _token->end_lineno; |
| 3038 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3039 | int _end_col_offset = _token->end_col_offset; |
| 3040 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 3041 | _res = _PyAST_Delete ( a , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3042 | if (_res == NULL && PyErr_Occurred()) { |
| 3043 | p->error_indicator = 1; |
| 3044 | D(p->level--); |
| 3045 | return NULL; |
| 3046 | } |
| 3047 | goto done; |
| 3048 | } |
| 3049 | p->mark = _mark; |
| 3050 | D(fprintf(stderr, "%*c%s del_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 3051 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'del' del_targets &(';' | NEWLINE)")); |
| 3052 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 3053 | if (p->call_invalid_rules) { // invalid_del_stmt |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 3054 | if (p->error_indicator) { |
| 3055 | D(p->level--); |
| 3056 | return NULL; |
| 3057 | } |
| 3058 | D(fprintf(stderr, "%*c> del_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_del_stmt")); |
| 3059 | void *invalid_del_stmt_var; |
| 3060 | if ( |
| 3061 | (invalid_del_stmt_var = invalid_del_stmt_rule(p)) // invalid_del_stmt |
| 3062 | ) |
| 3063 | { |
| 3064 | D(fprintf(stderr, "%*c+ del_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_del_stmt")); |
| 3065 | _res = invalid_del_stmt_var; |
| 3066 | goto done; |
| 3067 | } |
| 3068 | p->mark = _mark; |
| 3069 | D(fprintf(stderr, "%*c%s del_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 3070 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_del_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3071 | } |
| 3072 | _res = NULL; |
| 3073 | done: |
| 3074 | D(p->level--); |
| 3075 | return _res; |
| 3076 | } |
| 3077 | |
| 3078 | // import_stmt: import_name | import_from |
| 3079 | static stmt_ty |
| 3080 | import_stmt_rule(Parser *p) |
| 3081 | { |
| 3082 | D(p->level++); |
| 3083 | if (p->error_indicator) { |
| 3084 | D(p->level--); |
| 3085 | return NULL; |
| 3086 | } |
| 3087 | stmt_ty _res = NULL; |
| 3088 | int _mark = p->mark; |
| 3089 | { // import_name |
| 3090 | if (p->error_indicator) { |
| 3091 | D(p->level--); |
| 3092 | return NULL; |
| 3093 | } |
| 3094 | D(fprintf(stderr, "%*c> import_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_name")); |
| 3095 | stmt_ty import_name_var; |
| 3096 | if ( |
| 3097 | (import_name_var = import_name_rule(p)) // import_name |
| 3098 | ) |
| 3099 | { |
| 3100 | D(fprintf(stderr, "%*c+ import_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_name")); |
| 3101 | _res = import_name_var; |
| 3102 | goto done; |
| 3103 | } |
| 3104 | p->mark = _mark; |
| 3105 | D(fprintf(stderr, "%*c%s import_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 3106 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_name")); |
| 3107 | } |
| 3108 | { // import_from |
| 3109 | if (p->error_indicator) { |
| 3110 | D(p->level--); |
| 3111 | return NULL; |
| 3112 | } |
| 3113 | D(fprintf(stderr, "%*c> import_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from")); |
| 3114 | stmt_ty import_from_var; |
| 3115 | if ( |
| 3116 | (import_from_var = import_from_rule(p)) // import_from |
| 3117 | ) |
| 3118 | { |
| 3119 | D(fprintf(stderr, "%*c+ import_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from")); |
| 3120 | _res = import_from_var; |
| 3121 | goto done; |
| 3122 | } |
| 3123 | p->mark = _mark; |
| 3124 | D(fprintf(stderr, "%*c%s import_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 3125 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from")); |
| 3126 | } |
| 3127 | _res = NULL; |
| 3128 | done: |
| 3129 | D(p->level--); |
| 3130 | return _res; |
| 3131 | } |
| 3132 | |
| 3133 | // import_name: 'import' dotted_as_names |
| 3134 | static stmt_ty |
| 3135 | import_name_rule(Parser *p) |
| 3136 | { |
| 3137 | D(p->level++); |
| 3138 | if (p->error_indicator) { |
| 3139 | D(p->level--); |
| 3140 | return NULL; |
| 3141 | } |
| 3142 | stmt_ty _res = NULL; |
| 3143 | int _mark = p->mark; |
| 3144 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3145 | p->error_indicator = 1; |
| 3146 | D(p->level--); |
| 3147 | return NULL; |
| 3148 | } |
| 3149 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3150 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3151 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3152 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 3153 | { // 'import' dotted_as_names |
| 3154 | if (p->error_indicator) { |
| 3155 | D(p->level--); |
| 3156 | return NULL; |
| 3157 | } |
| 3158 | D(fprintf(stderr, "%*c> import_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import' dotted_as_names")); |
| 3159 | Token * _keyword; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3160 | asdl_alias_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3161 | if ( |
| 3162 | (_keyword = _PyPegen_expect_token(p, 513)) // token='import' |
| 3163 | && |
| 3164 | (a = dotted_as_names_rule(p)) // dotted_as_names |
| 3165 | ) |
| 3166 | { |
| 3167 | D(fprintf(stderr, "%*c+ import_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import' dotted_as_names")); |
| 3168 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3169 | if (_token == NULL) { |
| 3170 | D(p->level--); |
| 3171 | return NULL; |
| 3172 | } |
| 3173 | int _end_lineno = _token->end_lineno; |
| 3174 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3175 | int _end_col_offset = _token->end_col_offset; |
| 3176 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 3177 | _res = _PyAST_Import ( a , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3178 | if (_res == NULL && PyErr_Occurred()) { |
| 3179 | p->error_indicator = 1; |
| 3180 | D(p->level--); |
| 3181 | return NULL; |
| 3182 | } |
| 3183 | goto done; |
| 3184 | } |
| 3185 | p->mark = _mark; |
| 3186 | D(fprintf(stderr, "%*c%s import_name[%d-%d]: %s failed!\n", p->level, ' ', |
| 3187 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import' dotted_as_names")); |
| 3188 | } |
| 3189 | _res = NULL; |
| 3190 | done: |
| 3191 | D(p->level--); |
| 3192 | return _res; |
| 3193 | } |
| 3194 | |
| 3195 | // import_from: |
| 3196 | // | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
| 3197 | // | 'from' (('.' | '...'))+ 'import' import_from_targets |
| 3198 | static stmt_ty |
| 3199 | import_from_rule(Parser *p) |
| 3200 | { |
| 3201 | D(p->level++); |
| 3202 | if (p->error_indicator) { |
| 3203 | D(p->level--); |
| 3204 | return NULL; |
| 3205 | } |
| 3206 | stmt_ty _res = NULL; |
| 3207 | int _mark = p->mark; |
| 3208 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3209 | p->error_indicator = 1; |
| 3210 | D(p->level--); |
| 3211 | return NULL; |
| 3212 | } |
| 3213 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3214 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3215 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3216 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 3217 | { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
| 3218 | if (p->error_indicator) { |
| 3219 | D(p->level--); |
| 3220 | return NULL; |
| 3221 | } |
| 3222 | D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); |
| 3223 | Token * _keyword; |
| 3224 | Token * _keyword_1; |
| 3225 | asdl_seq * a; |
| 3226 | expr_ty b; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3227 | asdl_alias_seq* c; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3228 | if ( |
| 3229 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
| 3230 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 3231 | (a = _loop0_31_rule(p)) // (('.' | '...'))* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3232 | && |
| 3233 | (b = dotted_name_rule(p)) // dotted_name |
| 3234 | && |
| 3235 | (_keyword_1 = _PyPegen_expect_token(p, 513)) // token='import' |
| 3236 | && |
| 3237 | (c = import_from_targets_rule(p)) // import_from_targets |
| 3238 | ) |
| 3239 | { |
| 3240 | D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); |
| 3241 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3242 | if (_token == NULL) { |
| 3243 | D(p->level--); |
| 3244 | return NULL; |
| 3245 | } |
| 3246 | int _end_lineno = _token->end_lineno; |
| 3247 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3248 | int _end_col_offset = _token->end_col_offset; |
| 3249 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 3250 | _res = _PyAST_ImportFrom ( b -> v . Name . id , c , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3251 | if (_res == NULL && PyErr_Occurred()) { |
| 3252 | p->error_indicator = 1; |
| 3253 | D(p->level--); |
| 3254 | return NULL; |
| 3255 | } |
| 3256 | goto done; |
| 3257 | } |
| 3258 | p->mark = _mark; |
| 3259 | D(fprintf(stderr, "%*c%s import_from[%d-%d]: %s failed!\n", p->level, ' ', |
| 3260 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); |
| 3261 | } |
| 3262 | { // 'from' (('.' | '...'))+ 'import' import_from_targets |
| 3263 | if (p->error_indicator) { |
| 3264 | D(p->level--); |
| 3265 | return NULL; |
| 3266 | } |
| 3267 | D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets")); |
| 3268 | Token * _keyword; |
| 3269 | Token * _keyword_1; |
| 3270 | asdl_seq * a; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3271 | asdl_alias_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3272 | if ( |
| 3273 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
| 3274 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 3275 | (a = _loop1_32_rule(p)) // (('.' | '...'))+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3276 | && |
| 3277 | (_keyword_1 = _PyPegen_expect_token(p, 513)) // token='import' |
| 3278 | && |
| 3279 | (b = import_from_targets_rule(p)) // import_from_targets |
| 3280 | ) |
| 3281 | { |
| 3282 | D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets")); |
| 3283 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3284 | if (_token == NULL) { |
| 3285 | D(p->level--); |
| 3286 | return NULL; |
| 3287 | } |
| 3288 | int _end_lineno = _token->end_lineno; |
| 3289 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3290 | int _end_col_offset = _token->end_col_offset; |
| 3291 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 3292 | _res = _PyAST_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3293 | if (_res == NULL && PyErr_Occurred()) { |
| 3294 | p->error_indicator = 1; |
| 3295 | D(p->level--); |
| 3296 | return NULL; |
| 3297 | } |
| 3298 | goto done; |
| 3299 | } |
| 3300 | p->mark = _mark; |
| 3301 | D(fprintf(stderr, "%*c%s import_from[%d-%d]: %s failed!\n", p->level, ' ', |
| 3302 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets")); |
| 3303 | } |
| 3304 | _res = NULL; |
| 3305 | done: |
| 3306 | D(p->level--); |
| 3307 | return _res; |
| 3308 | } |
| 3309 | |
| 3310 | // import_from_targets: |
| 3311 | // | '(' import_from_as_names ','? ')' |
| 3312 | // | import_from_as_names !',' |
| 3313 | // | '*' |
| 3314 | // | invalid_import_from_targets |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3315 | static asdl_alias_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3316 | import_from_targets_rule(Parser *p) |
| 3317 | { |
| 3318 | D(p->level++); |
| 3319 | if (p->error_indicator) { |
| 3320 | D(p->level--); |
| 3321 | return NULL; |
| 3322 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3323 | asdl_alias_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3324 | int _mark = p->mark; |
Matthew Suozzo | 75a06f0 | 2021-04-10 16:56:28 -0400 | [diff] [blame] | 3325 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3326 | p->error_indicator = 1; |
| 3327 | D(p->level--); |
| 3328 | return NULL; |
| 3329 | } |
| 3330 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3331 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3332 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3333 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3334 | { // '(' import_from_as_names ','? ')' |
| 3335 | if (p->error_indicator) { |
| 3336 | D(p->level--); |
| 3337 | return NULL; |
| 3338 | } |
| 3339 | D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' import_from_as_names ','? ')'")); |
| 3340 | Token * _literal; |
| 3341 | Token * _literal_1; |
| 3342 | void *_opt_var; |
| 3343 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3344 | asdl_alias_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3345 | if ( |
| 3346 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 3347 | && |
| 3348 | (a = import_from_as_names_rule(p)) // import_from_as_names |
| 3349 | && |
| 3350 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 3351 | && |
| 3352 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 3353 | ) |
| 3354 | { |
| 3355 | D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' import_from_as_names ','? ')'")); |
| 3356 | _res = a; |
| 3357 | if (_res == NULL && PyErr_Occurred()) { |
| 3358 | p->error_indicator = 1; |
| 3359 | D(p->level--); |
| 3360 | return NULL; |
| 3361 | } |
| 3362 | goto done; |
| 3363 | } |
| 3364 | p->mark = _mark; |
| 3365 | D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 3366 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' import_from_as_names ','? ')'")); |
| 3367 | } |
| 3368 | { // import_from_as_names !',' |
| 3369 | if (p->error_indicator) { |
| 3370 | D(p->level--); |
| 3371 | return NULL; |
| 3372 | } |
| 3373 | D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_names !','")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3374 | asdl_alias_seq* import_from_as_names_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3375 | if ( |
| 3376 | (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names |
| 3377 | && |
| 3378 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
| 3379 | ) |
| 3380 | { |
| 3381 | D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_names !','")); |
| 3382 | _res = import_from_as_names_var; |
| 3383 | goto done; |
| 3384 | } |
| 3385 | p->mark = _mark; |
| 3386 | D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 3387 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_names !','")); |
| 3388 | } |
| 3389 | { // '*' |
| 3390 | if (p->error_indicator) { |
| 3391 | D(p->level--); |
| 3392 | return NULL; |
| 3393 | } |
| 3394 | D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); |
| 3395 | Token * _literal; |
| 3396 | if ( |
| 3397 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 3398 | ) |
| 3399 | { |
| 3400 | D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); |
Matthew Suozzo | 75a06f0 | 2021-04-10 16:56:28 -0400 | [diff] [blame] | 3401 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3402 | if (_token == NULL) { |
| 3403 | D(p->level--); |
| 3404 | return NULL; |
| 3405 | } |
| 3406 | int _end_lineno = _token->end_lineno; |
| 3407 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3408 | int _end_col_offset = _token->end_col_offset; |
| 3409 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3410 | _res = ( asdl_alias_seq * ) _PyPegen_singleton_seq ( p , CHECK ( alias_ty , _PyPegen_alias_for_star ( p , EXTRA ) ) ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3411 | if (_res == NULL && PyErr_Occurred()) { |
| 3412 | p->error_indicator = 1; |
| 3413 | D(p->level--); |
| 3414 | return NULL; |
| 3415 | } |
| 3416 | goto done; |
| 3417 | } |
| 3418 | p->mark = _mark; |
| 3419 | D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 3420 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); |
| 3421 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 3422 | if (p->call_invalid_rules) { // invalid_import_from_targets |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3423 | if (p->error_indicator) { |
| 3424 | D(p->level--); |
| 3425 | return NULL; |
| 3426 | } |
| 3427 | D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_import_from_targets")); |
| 3428 | void *invalid_import_from_targets_var; |
| 3429 | if ( |
| 3430 | (invalid_import_from_targets_var = invalid_import_from_targets_rule(p)) // invalid_import_from_targets |
| 3431 | ) |
| 3432 | { |
| 3433 | D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_import_from_targets")); |
| 3434 | _res = invalid_import_from_targets_var; |
| 3435 | goto done; |
| 3436 | } |
| 3437 | p->mark = _mark; |
| 3438 | D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 3439 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_import_from_targets")); |
| 3440 | } |
| 3441 | _res = NULL; |
| 3442 | done: |
| 3443 | D(p->level--); |
| 3444 | return _res; |
| 3445 | } |
| 3446 | |
| 3447 | // import_from_as_names: ','.import_from_as_name+ |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3448 | static asdl_alias_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3449 | import_from_as_names_rule(Parser *p) |
| 3450 | { |
| 3451 | D(p->level++); |
| 3452 | if (p->error_indicator) { |
| 3453 | D(p->level--); |
| 3454 | return NULL; |
| 3455 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3456 | asdl_alias_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3457 | int _mark = p->mark; |
| 3458 | { // ','.import_from_as_name+ |
| 3459 | if (p->error_indicator) { |
| 3460 | D(p->level--); |
| 3461 | return NULL; |
| 3462 | } |
| 3463 | D(fprintf(stderr, "%*c> import_from_as_names[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.import_from_as_name+")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3464 | asdl_alias_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3465 | if ( |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3466 | (a = (asdl_alias_seq*)_gather_33_rule(p)) // ','.import_from_as_name+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3467 | ) |
| 3468 | { |
| 3469 | D(fprintf(stderr, "%*c+ import_from_as_names[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.import_from_as_name+")); |
| 3470 | _res = a; |
| 3471 | if (_res == NULL && PyErr_Occurred()) { |
| 3472 | p->error_indicator = 1; |
| 3473 | D(p->level--); |
| 3474 | return NULL; |
| 3475 | } |
| 3476 | goto done; |
| 3477 | } |
| 3478 | p->mark = _mark; |
| 3479 | D(fprintf(stderr, "%*c%s import_from_as_names[%d-%d]: %s failed!\n", p->level, ' ', |
| 3480 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.import_from_as_name+")); |
| 3481 | } |
| 3482 | _res = NULL; |
| 3483 | done: |
| 3484 | D(p->level--); |
| 3485 | return _res; |
| 3486 | } |
| 3487 | |
| 3488 | // import_from_as_name: NAME ['as' NAME] |
| 3489 | static alias_ty |
| 3490 | import_from_as_name_rule(Parser *p) |
| 3491 | { |
| 3492 | D(p->level++); |
| 3493 | if (p->error_indicator) { |
| 3494 | D(p->level--); |
| 3495 | return NULL; |
| 3496 | } |
| 3497 | alias_ty _res = NULL; |
| 3498 | int _mark = p->mark; |
Matthew Suozzo | 75a06f0 | 2021-04-10 16:56:28 -0400 | [diff] [blame] | 3499 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3500 | p->error_indicator = 1; |
| 3501 | D(p->level--); |
| 3502 | return NULL; |
| 3503 | } |
| 3504 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3505 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3506 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3507 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3508 | { // NAME ['as' NAME] |
| 3509 | if (p->error_indicator) { |
| 3510 | D(p->level--); |
| 3511 | return NULL; |
| 3512 | } |
| 3513 | D(fprintf(stderr, "%*c> import_from_as_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ['as' NAME]")); |
| 3514 | expr_ty a; |
| 3515 | void *b; |
| 3516 | if ( |
| 3517 | (a = _PyPegen_name_token(p)) // NAME |
| 3518 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 3519 | (b = _tmp_35_rule(p), 1) // ['as' NAME] |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3520 | ) |
| 3521 | { |
| 3522 | D(fprintf(stderr, "%*c+ import_from_as_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ['as' NAME]")); |
Matthew Suozzo | 75a06f0 | 2021-04-10 16:56:28 -0400 | [diff] [blame] | 3523 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3524 | if (_token == NULL) { |
| 3525 | D(p->level--); |
| 3526 | return NULL; |
| 3527 | } |
| 3528 | int _end_lineno = _token->end_lineno; |
| 3529 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3530 | int _end_col_offset = _token->end_col_offset; |
| 3531 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3532 | _res = _PyAST_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3533 | if (_res == NULL && PyErr_Occurred()) { |
| 3534 | p->error_indicator = 1; |
| 3535 | D(p->level--); |
| 3536 | return NULL; |
| 3537 | } |
| 3538 | goto done; |
| 3539 | } |
| 3540 | p->mark = _mark; |
| 3541 | D(fprintf(stderr, "%*c%s import_from_as_name[%d-%d]: %s failed!\n", p->level, ' ', |
| 3542 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ['as' NAME]")); |
| 3543 | } |
| 3544 | _res = NULL; |
| 3545 | done: |
| 3546 | D(p->level--); |
| 3547 | return _res; |
| 3548 | } |
| 3549 | |
| 3550 | // dotted_as_names: ','.dotted_as_name+ |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3551 | static asdl_alias_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3552 | dotted_as_names_rule(Parser *p) |
| 3553 | { |
| 3554 | D(p->level++); |
| 3555 | if (p->error_indicator) { |
| 3556 | D(p->level--); |
| 3557 | return NULL; |
| 3558 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3559 | asdl_alias_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3560 | int _mark = p->mark; |
| 3561 | { // ','.dotted_as_name+ |
| 3562 | if (p->error_indicator) { |
| 3563 | D(p->level--); |
| 3564 | return NULL; |
| 3565 | } |
| 3566 | D(fprintf(stderr, "%*c> dotted_as_names[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.dotted_as_name+")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3567 | asdl_alias_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3568 | if ( |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3569 | (a = (asdl_alias_seq*)_gather_36_rule(p)) // ','.dotted_as_name+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3570 | ) |
| 3571 | { |
| 3572 | D(fprintf(stderr, "%*c+ dotted_as_names[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.dotted_as_name+")); |
| 3573 | _res = a; |
| 3574 | if (_res == NULL && PyErr_Occurred()) { |
| 3575 | p->error_indicator = 1; |
| 3576 | D(p->level--); |
| 3577 | return NULL; |
| 3578 | } |
| 3579 | goto done; |
| 3580 | } |
| 3581 | p->mark = _mark; |
| 3582 | D(fprintf(stderr, "%*c%s dotted_as_names[%d-%d]: %s failed!\n", p->level, ' ', |
| 3583 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.dotted_as_name+")); |
| 3584 | } |
| 3585 | _res = NULL; |
| 3586 | done: |
| 3587 | D(p->level--); |
| 3588 | return _res; |
| 3589 | } |
| 3590 | |
| 3591 | // dotted_as_name: dotted_name ['as' NAME] |
| 3592 | static alias_ty |
| 3593 | dotted_as_name_rule(Parser *p) |
| 3594 | { |
| 3595 | D(p->level++); |
| 3596 | if (p->error_indicator) { |
| 3597 | D(p->level--); |
| 3598 | return NULL; |
| 3599 | } |
| 3600 | alias_ty _res = NULL; |
| 3601 | int _mark = p->mark; |
Matthew Suozzo | 75a06f0 | 2021-04-10 16:56:28 -0400 | [diff] [blame] | 3602 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3603 | p->error_indicator = 1; |
| 3604 | D(p->level--); |
| 3605 | return NULL; |
| 3606 | } |
| 3607 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3608 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3609 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3610 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3611 | { // dotted_name ['as' NAME] |
| 3612 | if (p->error_indicator) { |
| 3613 | D(p->level--); |
| 3614 | return NULL; |
| 3615 | } |
| 3616 | D(fprintf(stderr, "%*c> dotted_as_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_name ['as' NAME]")); |
| 3617 | expr_ty a; |
| 3618 | void *b; |
| 3619 | if ( |
| 3620 | (a = dotted_name_rule(p)) // dotted_name |
| 3621 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 3622 | (b = _tmp_38_rule(p), 1) // ['as' NAME] |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3623 | ) |
| 3624 | { |
| 3625 | D(fprintf(stderr, "%*c+ dotted_as_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_name ['as' NAME]")); |
Matthew Suozzo | 75a06f0 | 2021-04-10 16:56:28 -0400 | [diff] [blame] | 3626 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3627 | if (_token == NULL) { |
| 3628 | D(p->level--); |
| 3629 | return NULL; |
| 3630 | } |
| 3631 | int _end_lineno = _token->end_lineno; |
| 3632 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3633 | int _end_col_offset = _token->end_col_offset; |
| 3634 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3635 | _res = _PyAST_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3636 | if (_res == NULL && PyErr_Occurred()) { |
| 3637 | p->error_indicator = 1; |
| 3638 | D(p->level--); |
| 3639 | return NULL; |
| 3640 | } |
| 3641 | goto done; |
| 3642 | } |
| 3643 | p->mark = _mark; |
| 3644 | D(fprintf(stderr, "%*c%s dotted_as_name[%d-%d]: %s failed!\n", p->level, ' ', |
| 3645 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_name ['as' NAME]")); |
| 3646 | } |
| 3647 | _res = NULL; |
| 3648 | done: |
| 3649 | D(p->level--); |
| 3650 | return _res; |
| 3651 | } |
| 3652 | |
| 3653 | // Left-recursive |
| 3654 | // dotted_name: dotted_name '.' NAME | NAME |
| 3655 | static expr_ty dotted_name_raw(Parser *); |
| 3656 | static expr_ty |
| 3657 | dotted_name_rule(Parser *p) |
| 3658 | { |
| 3659 | D(p->level++); |
| 3660 | expr_ty _res = NULL; |
| 3661 | if (_PyPegen_is_memoized(p, dotted_name_type, &_res)) { |
| 3662 | D(p->level--); |
| 3663 | return _res; |
| 3664 | } |
| 3665 | int _mark = p->mark; |
| 3666 | int _resmark = p->mark; |
| 3667 | while (1) { |
| 3668 | int tmpvar_0 = _PyPegen_update_memo(p, _mark, dotted_name_type, _res); |
| 3669 | if (tmpvar_0) { |
| 3670 | D(p->level--); |
| 3671 | return _res; |
| 3672 | } |
| 3673 | p->mark = _mark; |
| 3674 | void *_raw = dotted_name_raw(p); |
Lysandros Nikolaou | 02cdfc9 | 2020-10-31 20:31:41 +0200 | [diff] [blame] | 3675 | if (p->error_indicator) |
| 3676 | return NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3677 | if (_raw == NULL || p->mark <= _resmark) |
| 3678 | break; |
| 3679 | _resmark = p->mark; |
| 3680 | _res = _raw; |
| 3681 | } |
| 3682 | p->mark = _resmark; |
| 3683 | D(p->level--); |
| 3684 | return _res; |
| 3685 | } |
| 3686 | static expr_ty |
| 3687 | dotted_name_raw(Parser *p) |
| 3688 | { |
| 3689 | D(p->level++); |
| 3690 | if (p->error_indicator) { |
| 3691 | D(p->level--); |
| 3692 | return NULL; |
| 3693 | } |
| 3694 | expr_ty _res = NULL; |
| 3695 | int _mark = p->mark; |
| 3696 | { // dotted_name '.' NAME |
| 3697 | if (p->error_indicator) { |
| 3698 | D(p->level--); |
| 3699 | return NULL; |
| 3700 | } |
| 3701 | D(fprintf(stderr, "%*c> dotted_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_name '.' NAME")); |
| 3702 | Token * _literal; |
| 3703 | expr_ty a; |
| 3704 | expr_ty b; |
| 3705 | if ( |
| 3706 | (a = dotted_name_rule(p)) // dotted_name |
| 3707 | && |
| 3708 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 3709 | && |
| 3710 | (b = _PyPegen_name_token(p)) // NAME |
| 3711 | ) |
| 3712 | { |
| 3713 | D(fprintf(stderr, "%*c+ dotted_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_name '.' NAME")); |
| 3714 | _res = _PyPegen_join_names_with_dot ( p , a , b ); |
| 3715 | if (_res == NULL && PyErr_Occurred()) { |
| 3716 | p->error_indicator = 1; |
| 3717 | D(p->level--); |
| 3718 | return NULL; |
| 3719 | } |
| 3720 | goto done; |
| 3721 | } |
| 3722 | p->mark = _mark; |
| 3723 | D(fprintf(stderr, "%*c%s dotted_name[%d-%d]: %s failed!\n", p->level, ' ', |
| 3724 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_name '.' NAME")); |
| 3725 | } |
| 3726 | { // NAME |
| 3727 | if (p->error_indicator) { |
| 3728 | D(p->level--); |
| 3729 | return NULL; |
| 3730 | } |
| 3731 | D(fprintf(stderr, "%*c> dotted_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); |
| 3732 | expr_ty name_var; |
| 3733 | if ( |
| 3734 | (name_var = _PyPegen_name_token(p)) // NAME |
| 3735 | ) |
| 3736 | { |
| 3737 | D(fprintf(stderr, "%*c+ dotted_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); |
| 3738 | _res = name_var; |
| 3739 | goto done; |
| 3740 | } |
| 3741 | p->mark = _mark; |
| 3742 | D(fprintf(stderr, "%*c%s dotted_name[%d-%d]: %s failed!\n", p->level, ' ', |
| 3743 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); |
| 3744 | } |
| 3745 | _res = NULL; |
| 3746 | done: |
| 3747 | D(p->level--); |
| 3748 | return _res; |
| 3749 | } |
| 3750 | |
| 3751 | // if_stmt: |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3752 | // | 'if' named_expression ':' block elif_stmt |
| 3753 | // | 'if' named_expression ':' block else_block? |
| 3754 | // | invalid_if_stmt |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3755 | static stmt_ty |
| 3756 | if_stmt_rule(Parser *p) |
| 3757 | { |
| 3758 | D(p->level++); |
| 3759 | if (p->error_indicator) { |
| 3760 | D(p->level--); |
| 3761 | return NULL; |
| 3762 | } |
| 3763 | stmt_ty _res = NULL; |
| 3764 | int _mark = p->mark; |
| 3765 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3766 | p->error_indicator = 1; |
| 3767 | D(p->level--); |
| 3768 | return NULL; |
| 3769 | } |
| 3770 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3771 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3772 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3773 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3774 | { // 'if' named_expression ':' block elif_stmt |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3775 | if (p->error_indicator) { |
| 3776 | D(p->level--); |
| 3777 | return NULL; |
| 3778 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3779 | D(fprintf(stderr, "%*c> if_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block elif_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3780 | Token * _keyword; |
| 3781 | Token * _literal; |
| 3782 | expr_ty a; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3783 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3784 | stmt_ty c; |
| 3785 | if ( |
| 3786 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
| 3787 | && |
| 3788 | (a = named_expression_rule(p)) // named_expression |
| 3789 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3790 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3791 | && |
| 3792 | (b = block_rule(p)) // block |
| 3793 | && |
| 3794 | (c = elif_stmt_rule(p)) // elif_stmt |
| 3795 | ) |
| 3796 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3797 | D(fprintf(stderr, "%*c+ if_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block elif_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3798 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3799 | if (_token == NULL) { |
| 3800 | D(p->level--); |
| 3801 | return NULL; |
| 3802 | } |
| 3803 | int _end_lineno = _token->end_lineno; |
| 3804 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3805 | int _end_col_offset = _token->end_col_offset; |
| 3806 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 3807 | _res = _PyAST_If ( a , b , CHECK ( asdl_stmt_seq * , _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3808 | if (_res == NULL && PyErr_Occurred()) { |
| 3809 | p->error_indicator = 1; |
| 3810 | D(p->level--); |
| 3811 | return NULL; |
| 3812 | } |
| 3813 | goto done; |
| 3814 | } |
| 3815 | p->mark = _mark; |
| 3816 | D(fprintf(stderr, "%*c%s if_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3817 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression ':' block elif_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3818 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3819 | { // 'if' named_expression ':' block else_block? |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3820 | if (p->error_indicator) { |
| 3821 | D(p->level--); |
| 3822 | return NULL; |
| 3823 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3824 | D(fprintf(stderr, "%*c> if_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block else_block?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3825 | Token * _keyword; |
| 3826 | Token * _literal; |
| 3827 | expr_ty a; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3828 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3829 | void *c; |
| 3830 | if ( |
| 3831 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
| 3832 | && |
| 3833 | (a = named_expression_rule(p)) // named_expression |
| 3834 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3835 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3836 | && |
| 3837 | (b = block_rule(p)) // block |
| 3838 | && |
| 3839 | (c = else_block_rule(p), 1) // else_block? |
| 3840 | ) |
| 3841 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3842 | D(fprintf(stderr, "%*c+ if_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block else_block?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3843 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3844 | if (_token == NULL) { |
| 3845 | D(p->level--); |
| 3846 | return NULL; |
| 3847 | } |
| 3848 | int _end_lineno = _token->end_lineno; |
| 3849 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3850 | int _end_col_offset = _token->end_col_offset; |
| 3851 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 3852 | _res = _PyAST_If ( a , b , c , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3853 | if (_res == NULL && PyErr_Occurred()) { |
| 3854 | p->error_indicator = 1; |
| 3855 | D(p->level--); |
| 3856 | return NULL; |
| 3857 | } |
| 3858 | goto done; |
| 3859 | } |
| 3860 | p->mark = _mark; |
| 3861 | D(fprintf(stderr, "%*c%s if_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3862 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression ':' block else_block?")); |
| 3863 | } |
| 3864 | if (p->call_invalid_rules) { // invalid_if_stmt |
| 3865 | if (p->error_indicator) { |
| 3866 | D(p->level--); |
| 3867 | return NULL; |
| 3868 | } |
| 3869 | D(fprintf(stderr, "%*c> if_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_if_stmt")); |
| 3870 | void *invalid_if_stmt_var; |
| 3871 | if ( |
| 3872 | (invalid_if_stmt_var = invalid_if_stmt_rule(p)) // invalid_if_stmt |
| 3873 | ) |
| 3874 | { |
| 3875 | D(fprintf(stderr, "%*c+ if_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_if_stmt")); |
| 3876 | _res = invalid_if_stmt_var; |
| 3877 | goto done; |
| 3878 | } |
| 3879 | p->mark = _mark; |
| 3880 | D(fprintf(stderr, "%*c%s if_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 3881 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_if_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3882 | } |
| 3883 | _res = NULL; |
| 3884 | done: |
| 3885 | D(p->level--); |
| 3886 | return _res; |
| 3887 | } |
| 3888 | |
| 3889 | // elif_stmt: |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3890 | // | 'elif' named_expression ':' block elif_stmt |
| 3891 | // | 'elif' named_expression ':' block else_block? |
| 3892 | // | invalid_elif_stmt |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3893 | static stmt_ty |
| 3894 | elif_stmt_rule(Parser *p) |
| 3895 | { |
| 3896 | D(p->level++); |
| 3897 | if (p->error_indicator) { |
| 3898 | D(p->level--); |
| 3899 | return NULL; |
| 3900 | } |
| 3901 | stmt_ty _res = NULL; |
| 3902 | int _mark = p->mark; |
| 3903 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3904 | p->error_indicator = 1; |
| 3905 | D(p->level--); |
| 3906 | return NULL; |
| 3907 | } |
| 3908 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3909 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3910 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3911 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3912 | { // 'elif' named_expression ':' block elif_stmt |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3913 | if (p->error_indicator) { |
| 3914 | D(p->level--); |
| 3915 | return NULL; |
| 3916 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3917 | D(fprintf(stderr, "%*c> elif_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block elif_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3918 | Token * _keyword; |
| 3919 | Token * _literal; |
| 3920 | expr_ty a; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3921 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3922 | stmt_ty c; |
| 3923 | if ( |
| 3924 | (_keyword = _PyPegen_expect_token(p, 515)) // token='elif' |
| 3925 | && |
| 3926 | (a = named_expression_rule(p)) // named_expression |
| 3927 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3928 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3929 | && |
| 3930 | (b = block_rule(p)) // block |
| 3931 | && |
| 3932 | (c = elif_stmt_rule(p)) // elif_stmt |
| 3933 | ) |
| 3934 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3935 | D(fprintf(stderr, "%*c+ elif_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block elif_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3936 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3937 | if (_token == NULL) { |
| 3938 | D(p->level--); |
| 3939 | return NULL; |
| 3940 | } |
| 3941 | int _end_lineno = _token->end_lineno; |
| 3942 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3943 | int _end_col_offset = _token->end_col_offset; |
| 3944 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 3945 | _res = _PyAST_If ( a , b , CHECK ( asdl_stmt_seq * , _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3946 | if (_res == NULL && PyErr_Occurred()) { |
| 3947 | p->error_indicator = 1; |
| 3948 | D(p->level--); |
| 3949 | return NULL; |
| 3950 | } |
| 3951 | goto done; |
| 3952 | } |
| 3953 | p->mark = _mark; |
| 3954 | D(fprintf(stderr, "%*c%s elif_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3955 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'elif' named_expression ':' block elif_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3956 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3957 | { // 'elif' named_expression ':' block else_block? |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3958 | if (p->error_indicator) { |
| 3959 | D(p->level--); |
| 3960 | return NULL; |
| 3961 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3962 | D(fprintf(stderr, "%*c> elif_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block else_block?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3963 | Token * _keyword; |
| 3964 | Token * _literal; |
| 3965 | expr_ty a; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 3966 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3967 | void *c; |
| 3968 | if ( |
| 3969 | (_keyword = _PyPegen_expect_token(p, 515)) // token='elif' |
| 3970 | && |
| 3971 | (a = named_expression_rule(p)) // named_expression |
| 3972 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3973 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3974 | && |
| 3975 | (b = block_rule(p)) // block |
| 3976 | && |
| 3977 | (c = else_block_rule(p), 1) // else_block? |
| 3978 | ) |
| 3979 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 3980 | D(fprintf(stderr, "%*c+ elif_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block else_block?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3981 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3982 | if (_token == NULL) { |
| 3983 | D(p->level--); |
| 3984 | return NULL; |
| 3985 | } |
| 3986 | int _end_lineno = _token->end_lineno; |
| 3987 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3988 | int _end_col_offset = _token->end_col_offset; |
| 3989 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 3990 | _res = _PyAST_If ( a , b , c , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 3991 | if (_res == NULL && PyErr_Occurred()) { |
| 3992 | p->error_indicator = 1; |
| 3993 | D(p->level--); |
| 3994 | return NULL; |
| 3995 | } |
| 3996 | goto done; |
| 3997 | } |
| 3998 | p->mark = _mark; |
| 3999 | D(fprintf(stderr, "%*c%s elif_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 4000 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'elif' named_expression ':' block else_block?")); |
| 4001 | } |
| 4002 | if (p->call_invalid_rules) { // invalid_elif_stmt |
| 4003 | if (p->error_indicator) { |
| 4004 | D(p->level--); |
| 4005 | return NULL; |
| 4006 | } |
| 4007 | D(fprintf(stderr, "%*c> elif_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_elif_stmt")); |
| 4008 | void *invalid_elif_stmt_var; |
| 4009 | if ( |
| 4010 | (invalid_elif_stmt_var = invalid_elif_stmt_rule(p)) // invalid_elif_stmt |
| 4011 | ) |
| 4012 | { |
| 4013 | D(fprintf(stderr, "%*c+ elif_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_elif_stmt")); |
| 4014 | _res = invalid_elif_stmt_var; |
| 4015 | goto done; |
| 4016 | } |
| 4017 | p->mark = _mark; |
| 4018 | D(fprintf(stderr, "%*c%s elif_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4019 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_elif_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4020 | } |
| 4021 | _res = NULL; |
| 4022 | done: |
| 4023 | D(p->level--); |
| 4024 | return _res; |
| 4025 | } |
| 4026 | |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4027 | // else_block: 'else' &&':' block |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4028 | static asdl_stmt_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4029 | else_block_rule(Parser *p) |
| 4030 | { |
| 4031 | D(p->level++); |
| 4032 | if (p->error_indicator) { |
| 4033 | D(p->level--); |
| 4034 | return NULL; |
| 4035 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4036 | asdl_stmt_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4037 | int _mark = p->mark; |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4038 | { // 'else' &&':' block |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4039 | if (p->error_indicator) { |
| 4040 | D(p->level--); |
| 4041 | return NULL; |
| 4042 | } |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4043 | D(fprintf(stderr, "%*c> else_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else' &&':' block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4044 | Token * _keyword; |
| 4045 | Token * _literal; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4046 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4047 | if ( |
| 4048 | (_keyword = _PyPegen_expect_token(p, 516)) // token='else' |
| 4049 | && |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4050 | (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4051 | && |
| 4052 | (b = block_rule(p)) // block |
| 4053 | ) |
| 4054 | { |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4055 | D(fprintf(stderr, "%*c+ else_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else' &&':' block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4056 | _res = b; |
| 4057 | if (_res == NULL && PyErr_Occurred()) { |
| 4058 | p->error_indicator = 1; |
| 4059 | D(p->level--); |
| 4060 | return NULL; |
| 4061 | } |
| 4062 | goto done; |
| 4063 | } |
| 4064 | p->mark = _mark; |
| 4065 | D(fprintf(stderr, "%*c%s else_block[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4066 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'else' &&':' block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4067 | } |
| 4068 | _res = NULL; |
| 4069 | done: |
| 4070 | D(p->level--); |
| 4071 | return _res; |
| 4072 | } |
| 4073 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 4074 | // while_stmt: 'while' named_expression ':' block else_block? | invalid_while_stmt |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4075 | static stmt_ty |
| 4076 | while_stmt_rule(Parser *p) |
| 4077 | { |
| 4078 | D(p->level++); |
| 4079 | if (p->error_indicator) { |
| 4080 | D(p->level--); |
| 4081 | return NULL; |
| 4082 | } |
| 4083 | stmt_ty _res = NULL; |
| 4084 | int _mark = p->mark; |
| 4085 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4086 | p->error_indicator = 1; |
| 4087 | D(p->level--); |
| 4088 | return NULL; |
| 4089 | } |
| 4090 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4091 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4092 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4093 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 4094 | { // 'while' named_expression ':' block else_block? |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4095 | if (p->error_indicator) { |
| 4096 | D(p->level--); |
| 4097 | return NULL; |
| 4098 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 4099 | D(fprintf(stderr, "%*c> while_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'while' named_expression ':' block else_block?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4100 | Token * _keyword; |
| 4101 | Token * _literal; |
| 4102 | expr_ty a; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4103 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4104 | void *c; |
| 4105 | if ( |
| 4106 | (_keyword = _PyPegen_expect_token(p, 512)) // token='while' |
| 4107 | && |
| 4108 | (a = named_expression_rule(p)) // named_expression |
| 4109 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 4110 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4111 | && |
| 4112 | (b = block_rule(p)) // block |
| 4113 | && |
| 4114 | (c = else_block_rule(p), 1) // else_block? |
| 4115 | ) |
| 4116 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 4117 | D(fprintf(stderr, "%*c+ while_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'while' named_expression ':' block else_block?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4118 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4119 | if (_token == NULL) { |
| 4120 | D(p->level--); |
| 4121 | return NULL; |
| 4122 | } |
| 4123 | int _end_lineno = _token->end_lineno; |
| 4124 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4125 | int _end_col_offset = _token->end_col_offset; |
| 4126 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 4127 | _res = _PyAST_While ( a , b , c , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4128 | if (_res == NULL && PyErr_Occurred()) { |
| 4129 | p->error_indicator = 1; |
| 4130 | D(p->level--); |
| 4131 | return NULL; |
| 4132 | } |
| 4133 | goto done; |
| 4134 | } |
| 4135 | p->mark = _mark; |
| 4136 | D(fprintf(stderr, "%*c%s while_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 4137 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'while' named_expression ':' block else_block?")); |
| 4138 | } |
| 4139 | if (p->call_invalid_rules) { // invalid_while_stmt |
| 4140 | if (p->error_indicator) { |
| 4141 | D(p->level--); |
| 4142 | return NULL; |
| 4143 | } |
| 4144 | D(fprintf(stderr, "%*c> while_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_while_stmt")); |
| 4145 | void *invalid_while_stmt_var; |
| 4146 | if ( |
| 4147 | (invalid_while_stmt_var = invalid_while_stmt_rule(p)) // invalid_while_stmt |
| 4148 | ) |
| 4149 | { |
| 4150 | D(fprintf(stderr, "%*c+ while_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_while_stmt")); |
| 4151 | _res = invalid_while_stmt_var; |
| 4152 | goto done; |
| 4153 | } |
| 4154 | p->mark = _mark; |
| 4155 | D(fprintf(stderr, "%*c%s while_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4156 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_while_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4157 | } |
| 4158 | _res = NULL; |
| 4159 | done: |
| 4160 | D(p->level--); |
| 4161 | return _res; |
| 4162 | } |
| 4163 | |
| 4164 | // for_stmt: |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4165 | // | 'for' star_targets 'in' ~ star_expressions &&':' TYPE_COMMENT? block else_block? |
| 4166 | // | ASYNC 'for' star_targets 'in' ~ star_expressions &&':' TYPE_COMMENT? block else_block? |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4167 | // | invalid_for_target |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4168 | static stmt_ty |
| 4169 | for_stmt_rule(Parser *p) |
| 4170 | { |
| 4171 | D(p->level++); |
| 4172 | if (p->error_indicator) { |
| 4173 | D(p->level--); |
| 4174 | return NULL; |
| 4175 | } |
| 4176 | stmt_ty _res = NULL; |
| 4177 | int _mark = p->mark; |
| 4178 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4179 | p->error_indicator = 1; |
| 4180 | D(p->level--); |
| 4181 | return NULL; |
| 4182 | } |
| 4183 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4184 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4185 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4186 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4187 | { // 'for' star_targets 'in' ~ star_expressions &&':' TYPE_COMMENT? block else_block? |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4188 | if (p->error_indicator) { |
| 4189 | D(p->level--); |
| 4190 | return NULL; |
| 4191 | } |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4192 | D(fprintf(stderr, "%*c> for_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' ~ star_expressions &&':' TYPE_COMMENT? block else_block?")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4193 | int _cut_var = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4194 | Token * _keyword; |
| 4195 | Token * _keyword_1; |
| 4196 | Token * _literal; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4197 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4198 | void *el; |
| 4199 | expr_ty ex; |
| 4200 | expr_ty t; |
| 4201 | void *tc; |
| 4202 | if ( |
| 4203 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
| 4204 | && |
| 4205 | (t = star_targets_rule(p)) // star_targets |
| 4206 | && |
| 4207 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
| 4208 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4209 | (_cut_var = 1) |
| 4210 | && |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4211 | (ex = star_expressions_rule(p)) // star_expressions |
| 4212 | && |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4213 | (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4214 | && |
| 4215 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
| 4216 | && |
| 4217 | (b = block_rule(p)) // block |
| 4218 | && |
| 4219 | (el = else_block_rule(p), 1) // else_block? |
| 4220 | ) |
| 4221 | { |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4222 | D(fprintf(stderr, "%*c+ for_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' ~ star_expressions &&':' TYPE_COMMENT? block else_block?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4223 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4224 | if (_token == NULL) { |
| 4225 | D(p->level--); |
| 4226 | return NULL; |
| 4227 | } |
| 4228 | int _end_lineno = _token->end_lineno; |
| 4229 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4230 | int _end_col_offset = _token->end_col_offset; |
| 4231 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 4232 | _res = _PyAST_For ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4233 | if (_res == NULL && PyErr_Occurred()) { |
| 4234 | p->error_indicator = 1; |
| 4235 | D(p->level--); |
| 4236 | return NULL; |
| 4237 | } |
| 4238 | goto done; |
| 4239 | } |
| 4240 | p->mark = _mark; |
| 4241 | D(fprintf(stderr, "%*c%s for_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4242 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for' star_targets 'in' ~ star_expressions &&':' TYPE_COMMENT? block else_block?")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4243 | if (_cut_var) { |
| 4244 | D(p->level--); |
| 4245 | return NULL; |
| 4246 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4247 | } |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4248 | { // ASYNC 'for' star_targets 'in' ~ star_expressions &&':' TYPE_COMMENT? block else_block? |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4249 | if (p->error_indicator) { |
| 4250 | D(p->level--); |
| 4251 | return NULL; |
| 4252 | } |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4253 | D(fprintf(stderr, "%*c> for_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' ~ star_expressions &&':' TYPE_COMMENT? block else_block?")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4254 | int _cut_var = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4255 | Token * _keyword; |
| 4256 | Token * _keyword_1; |
| 4257 | Token * _literal; |
| 4258 | Token * async_var; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4259 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4260 | void *el; |
| 4261 | expr_ty ex; |
| 4262 | expr_ty t; |
| 4263 | void *tc; |
| 4264 | if ( |
| 4265 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
| 4266 | && |
| 4267 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
| 4268 | && |
| 4269 | (t = star_targets_rule(p)) // star_targets |
| 4270 | && |
| 4271 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
| 4272 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4273 | (_cut_var = 1) |
| 4274 | && |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4275 | (ex = star_expressions_rule(p)) // star_expressions |
| 4276 | && |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4277 | (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4278 | && |
| 4279 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
| 4280 | && |
| 4281 | (b = block_rule(p)) // block |
| 4282 | && |
| 4283 | (el = else_block_rule(p), 1) // else_block? |
| 4284 | ) |
| 4285 | { |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4286 | D(fprintf(stderr, "%*c+ for_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' ~ star_expressions &&':' TYPE_COMMENT? block else_block?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4287 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4288 | if (_token == NULL) { |
| 4289 | D(p->level--); |
| 4290 | return NULL; |
| 4291 | } |
| 4292 | int _end_lineno = _token->end_lineno; |
| 4293 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4294 | int _end_col_offset = _token->end_col_offset; |
| 4295 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 4296 | _res = CHECK_VERSION ( stmt_ty , 5 , "Async for loops are" , _PyAST_AsyncFor ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4297 | if (_res == NULL && PyErr_Occurred()) { |
| 4298 | p->error_indicator = 1; |
| 4299 | D(p->level--); |
| 4300 | return NULL; |
| 4301 | } |
| 4302 | goto done; |
| 4303 | } |
| 4304 | p->mark = _mark; |
| 4305 | D(fprintf(stderr, "%*c%s for_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4306 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'for' star_targets 'in' ~ star_expressions &&':' TYPE_COMMENT? block else_block?")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4307 | if (_cut_var) { |
| 4308 | D(p->level--); |
| 4309 | return NULL; |
| 4310 | } |
| 4311 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 4312 | if (p->call_invalid_rules) { // invalid_for_target |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4313 | if (p->error_indicator) { |
| 4314 | D(p->level--); |
| 4315 | return NULL; |
| 4316 | } |
| 4317 | D(fprintf(stderr, "%*c> for_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_for_target")); |
| 4318 | void *invalid_for_target_var; |
| 4319 | if ( |
| 4320 | (invalid_for_target_var = invalid_for_target_rule(p)) // invalid_for_target |
| 4321 | ) |
| 4322 | { |
| 4323 | D(fprintf(stderr, "%*c+ for_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_for_target")); |
| 4324 | _res = invalid_for_target_var; |
| 4325 | goto done; |
| 4326 | } |
| 4327 | p->mark = _mark; |
| 4328 | D(fprintf(stderr, "%*c%s for_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4329 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_for_target")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4330 | } |
| 4331 | _res = NULL; |
| 4332 | done: |
| 4333 | D(p->level--); |
| 4334 | return _res; |
| 4335 | } |
| 4336 | |
| 4337 | // with_stmt: |
| 4338 | // | 'with' '(' ','.with_item+ ','? ')' ':' block |
| 4339 | // | 'with' ','.with_item+ ':' TYPE_COMMENT? block |
| 4340 | // | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block |
| 4341 | // | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4342 | // | invalid_with_stmt |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4343 | static stmt_ty |
| 4344 | with_stmt_rule(Parser *p) |
| 4345 | { |
| 4346 | D(p->level++); |
| 4347 | if (p->error_indicator) { |
| 4348 | D(p->level--); |
| 4349 | return NULL; |
| 4350 | } |
| 4351 | stmt_ty _res = NULL; |
| 4352 | int _mark = p->mark; |
| 4353 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4354 | p->error_indicator = 1; |
| 4355 | D(p->level--); |
| 4356 | return NULL; |
| 4357 | } |
| 4358 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4359 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4360 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4361 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 4362 | { // 'with' '(' ','.with_item+ ','? ')' ':' block |
| 4363 | if (p->error_indicator) { |
| 4364 | D(p->level--); |
| 4365 | return NULL; |
| 4366 | } |
| 4367 | D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with' '(' ','.with_item+ ','? ')' ':' block")); |
| 4368 | Token * _keyword; |
| 4369 | Token * _literal; |
| 4370 | Token * _literal_1; |
| 4371 | Token * _literal_2; |
| 4372 | void *_opt_var; |
| 4373 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4374 | asdl_withitem_seq* a; |
| 4375 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4376 | if ( |
| 4377 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
| 4378 | && |
| 4379 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 4380 | && |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4381 | (a = (asdl_withitem_seq*)_gather_39_rule(p)) // ','.with_item+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4382 | && |
| 4383 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 4384 | && |
| 4385 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 4386 | && |
| 4387 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
| 4388 | && |
| 4389 | (b = block_rule(p)) // block |
| 4390 | ) |
| 4391 | { |
| 4392 | D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with' '(' ','.with_item+ ','? ')' ':' block")); |
| 4393 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4394 | if (_token == NULL) { |
| 4395 | D(p->level--); |
| 4396 | return NULL; |
| 4397 | } |
| 4398 | int _end_lineno = _token->end_lineno; |
| 4399 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4400 | int _end_col_offset = _token->end_col_offset; |
| 4401 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 4402 | _res = _PyAST_With ( a , b , NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4403 | if (_res == NULL && PyErr_Occurred()) { |
| 4404 | p->error_indicator = 1; |
| 4405 | D(p->level--); |
| 4406 | return NULL; |
| 4407 | } |
| 4408 | goto done; |
| 4409 | } |
| 4410 | p->mark = _mark; |
| 4411 | D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4412 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with' '(' ','.with_item+ ','? ')' ':' block")); |
| 4413 | } |
| 4414 | { // 'with' ','.with_item+ ':' TYPE_COMMENT? block |
| 4415 | if (p->error_indicator) { |
| 4416 | D(p->level--); |
| 4417 | return NULL; |
| 4418 | } |
| 4419 | D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with' ','.with_item+ ':' TYPE_COMMENT? block")); |
| 4420 | Token * _keyword; |
| 4421 | Token * _literal; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4422 | asdl_withitem_seq* a; |
| 4423 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4424 | void *tc; |
| 4425 | if ( |
| 4426 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
| 4427 | && |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4428 | (a = (asdl_withitem_seq*)_gather_41_rule(p)) // ','.with_item+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4429 | && |
| 4430 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 4431 | && |
| 4432 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
| 4433 | && |
| 4434 | (b = block_rule(p)) // block |
| 4435 | ) |
| 4436 | { |
| 4437 | D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with' ','.with_item+ ':' TYPE_COMMENT? block")); |
| 4438 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4439 | if (_token == NULL) { |
| 4440 | D(p->level--); |
| 4441 | return NULL; |
| 4442 | } |
| 4443 | int _end_lineno = _token->end_lineno; |
| 4444 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4445 | int _end_col_offset = _token->end_col_offset; |
| 4446 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 4447 | _res = _PyAST_With ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4448 | if (_res == NULL && PyErr_Occurred()) { |
| 4449 | p->error_indicator = 1; |
| 4450 | D(p->level--); |
| 4451 | return NULL; |
| 4452 | } |
| 4453 | goto done; |
| 4454 | } |
| 4455 | p->mark = _mark; |
| 4456 | D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4457 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with' ','.with_item+ ':' TYPE_COMMENT? block")); |
| 4458 | } |
| 4459 | { // ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block |
| 4460 | if (p->error_indicator) { |
| 4461 | D(p->level--); |
| 4462 | return NULL; |
| 4463 | } |
| 4464 | D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block")); |
| 4465 | Token * _keyword; |
| 4466 | Token * _literal; |
| 4467 | Token * _literal_1; |
| 4468 | Token * _literal_2; |
| 4469 | void *_opt_var; |
| 4470 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4471 | asdl_withitem_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4472 | Token * async_var; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4473 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4474 | if ( |
| 4475 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
| 4476 | && |
| 4477 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
| 4478 | && |
| 4479 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 4480 | && |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4481 | (a = (asdl_withitem_seq*)_gather_43_rule(p)) // ','.with_item+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4482 | && |
| 4483 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 4484 | && |
| 4485 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 4486 | && |
| 4487 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
| 4488 | && |
| 4489 | (b = block_rule(p)) // block |
| 4490 | ) |
| 4491 | { |
| 4492 | D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block")); |
| 4493 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4494 | if (_token == NULL) { |
| 4495 | D(p->level--); |
| 4496 | return NULL; |
| 4497 | } |
| 4498 | int _end_lineno = _token->end_lineno; |
| 4499 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4500 | int _end_col_offset = _token->end_col_offset; |
| 4501 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 4502 | _res = CHECK_VERSION ( stmt_ty , 5 , "Async with statements are" , _PyAST_AsyncWith ( a , b , NULL , EXTRA ) ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4503 | if (_res == NULL && PyErr_Occurred()) { |
| 4504 | p->error_indicator = 1; |
| 4505 | D(p->level--); |
| 4506 | return NULL; |
| 4507 | } |
| 4508 | goto done; |
| 4509 | } |
| 4510 | p->mark = _mark; |
| 4511 | D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4512 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block")); |
| 4513 | } |
| 4514 | { // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
| 4515 | if (p->error_indicator) { |
| 4516 | D(p->level--); |
| 4517 | return NULL; |
| 4518 | } |
| 4519 | D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block")); |
| 4520 | Token * _keyword; |
| 4521 | Token * _literal; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4522 | asdl_withitem_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4523 | Token * async_var; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4524 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4525 | void *tc; |
| 4526 | if ( |
| 4527 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
| 4528 | && |
| 4529 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
| 4530 | && |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4531 | (a = (asdl_withitem_seq*)_gather_45_rule(p)) // ','.with_item+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4532 | && |
| 4533 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 4534 | && |
| 4535 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
| 4536 | && |
| 4537 | (b = block_rule(p)) // block |
| 4538 | ) |
| 4539 | { |
| 4540 | D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block")); |
| 4541 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4542 | if (_token == NULL) { |
| 4543 | D(p->level--); |
| 4544 | return NULL; |
| 4545 | } |
| 4546 | int _end_lineno = _token->end_lineno; |
| 4547 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4548 | int _end_col_offset = _token->end_col_offset; |
| 4549 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 4550 | _res = CHECK_VERSION ( stmt_ty , 5 , "Async with statements are" , _PyAST_AsyncWith ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4551 | if (_res == NULL && PyErr_Occurred()) { |
| 4552 | p->error_indicator = 1; |
| 4553 | D(p->level--); |
| 4554 | return NULL; |
| 4555 | } |
| 4556 | goto done; |
| 4557 | } |
| 4558 | p->mark = _mark; |
| 4559 | D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4560 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block")); |
| 4561 | } |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4562 | if (p->call_invalid_rules) { // invalid_with_stmt |
| 4563 | if (p->error_indicator) { |
| 4564 | D(p->level--); |
| 4565 | return NULL; |
| 4566 | } |
| 4567 | D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_with_stmt")); |
| 4568 | void *invalid_with_stmt_var; |
| 4569 | if ( |
| 4570 | (invalid_with_stmt_var = invalid_with_stmt_rule(p)) // invalid_with_stmt |
| 4571 | ) |
| 4572 | { |
| 4573 | D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_with_stmt")); |
| 4574 | _res = invalid_with_stmt_var; |
| 4575 | goto done; |
| 4576 | } |
| 4577 | p->mark = _mark; |
| 4578 | D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4579 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_with_stmt")); |
| 4580 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4581 | _res = NULL; |
| 4582 | done: |
| 4583 | D(p->level--); |
| 4584 | return _res; |
| 4585 | } |
| 4586 | |
Batuhan Taskaya | 48f305f | 2020-10-09 12:56:48 +0300 | [diff] [blame] | 4587 | // with_item: |
| 4588 | // | expression 'as' star_target &(',' | ')' | ':') |
| 4589 | // | invalid_with_item |
| 4590 | // | expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4591 | static withitem_ty |
| 4592 | with_item_rule(Parser *p) |
| 4593 | { |
| 4594 | D(p->level++); |
| 4595 | if (p->error_indicator) { |
| 4596 | D(p->level--); |
| 4597 | return NULL; |
| 4598 | } |
| 4599 | withitem_ty _res = NULL; |
| 4600 | int _mark = p->mark; |
Batuhan Taskaya | 48f305f | 2020-10-09 12:56:48 +0300 | [diff] [blame] | 4601 | { // expression 'as' star_target &(',' | ')' | ':') |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4602 | if (p->error_indicator) { |
| 4603 | D(p->level--); |
| 4604 | return NULL; |
| 4605 | } |
Batuhan Taskaya | 48f305f | 2020-10-09 12:56:48 +0300 | [diff] [blame] | 4606 | D(fprintf(stderr, "%*c> with_item[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression 'as' star_target &(',' | ')' | ':')")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4607 | Token * _keyword; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4608 | expr_ty e; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4609 | expr_ty t; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4610 | if ( |
| 4611 | (e = expression_rule(p)) // expression |
| 4612 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4613 | (_keyword = _PyPegen_expect_token(p, 520)) // token='as' |
| 4614 | && |
Batuhan Taskaya | 48f305f | 2020-10-09 12:56:48 +0300 | [diff] [blame] | 4615 | (t = star_target_rule(p)) // star_target |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4616 | && |
| 4617 | _PyPegen_lookahead(1, _tmp_47_rule, p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4618 | ) |
| 4619 | { |
Batuhan Taskaya | 48f305f | 2020-10-09 12:56:48 +0300 | [diff] [blame] | 4620 | D(fprintf(stderr, "%*c+ with_item[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression 'as' star_target &(',' | ')' | ':')")); |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 4621 | _res = _PyAST_withitem ( e , t , p -> arena ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4622 | if (_res == NULL && PyErr_Occurred()) { |
| 4623 | p->error_indicator = 1; |
| 4624 | D(p->level--); |
| 4625 | return NULL; |
| 4626 | } |
| 4627 | goto done; |
| 4628 | } |
| 4629 | p->mark = _mark; |
| 4630 | D(fprintf(stderr, "%*c%s with_item[%d-%d]: %s failed!\n", p->level, ' ', |
Batuhan Taskaya | 48f305f | 2020-10-09 12:56:48 +0300 | [diff] [blame] | 4631 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression 'as' star_target &(',' | ')' | ':')")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4632 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 4633 | if (p->call_invalid_rules) { // invalid_with_item |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4634 | if (p->error_indicator) { |
| 4635 | D(p->level--); |
| 4636 | return NULL; |
| 4637 | } |
| 4638 | D(fprintf(stderr, "%*c> with_item[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_with_item")); |
| 4639 | void *invalid_with_item_var; |
| 4640 | if ( |
| 4641 | (invalid_with_item_var = invalid_with_item_rule(p)) // invalid_with_item |
| 4642 | ) |
| 4643 | { |
| 4644 | D(fprintf(stderr, "%*c+ with_item[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_with_item")); |
| 4645 | _res = invalid_with_item_var; |
| 4646 | goto done; |
| 4647 | } |
| 4648 | p->mark = _mark; |
| 4649 | D(fprintf(stderr, "%*c%s with_item[%d-%d]: %s failed!\n", p->level, ' ', |
| 4650 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_with_item")); |
| 4651 | } |
| 4652 | { // expression |
| 4653 | if (p->error_indicator) { |
| 4654 | D(p->level--); |
| 4655 | return NULL; |
| 4656 | } |
| 4657 | D(fprintf(stderr, "%*c> with_item[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression")); |
| 4658 | expr_ty e; |
| 4659 | if ( |
| 4660 | (e = expression_rule(p)) // expression |
| 4661 | ) |
| 4662 | { |
| 4663 | D(fprintf(stderr, "%*c+ with_item[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression")); |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 4664 | _res = _PyAST_withitem ( e , NULL , p -> arena ); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4665 | if (_res == NULL && PyErr_Occurred()) { |
| 4666 | p->error_indicator = 1; |
| 4667 | D(p->level--); |
| 4668 | return NULL; |
| 4669 | } |
| 4670 | goto done; |
| 4671 | } |
| 4672 | p->mark = _mark; |
| 4673 | D(fprintf(stderr, "%*c%s with_item[%d-%d]: %s failed!\n", p->level, ' ', |
| 4674 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4675 | } |
| 4676 | _res = NULL; |
| 4677 | done: |
| 4678 | D(p->level--); |
| 4679 | return _res; |
| 4680 | } |
| 4681 | |
| 4682 | // try_stmt: |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4683 | // | 'try' &&':' block finally_block |
| 4684 | // | 'try' &&':' block except_block+ else_block? finally_block? |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4685 | static stmt_ty |
| 4686 | try_stmt_rule(Parser *p) |
| 4687 | { |
| 4688 | D(p->level++); |
| 4689 | if (p->error_indicator) { |
| 4690 | D(p->level--); |
| 4691 | return NULL; |
| 4692 | } |
| 4693 | stmt_ty _res = NULL; |
| 4694 | int _mark = p->mark; |
| 4695 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4696 | p->error_indicator = 1; |
| 4697 | D(p->level--); |
| 4698 | return NULL; |
| 4699 | } |
| 4700 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4701 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4702 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4703 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4704 | { // 'try' &&':' block finally_block |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4705 | if (p->error_indicator) { |
| 4706 | D(p->level--); |
| 4707 | return NULL; |
| 4708 | } |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4709 | D(fprintf(stderr, "%*c> try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' &&':' block finally_block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4710 | Token * _keyword; |
| 4711 | Token * _literal; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4712 | asdl_stmt_seq* b; |
| 4713 | asdl_stmt_seq* f; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4714 | if ( |
| 4715 | (_keyword = _PyPegen_expect_token(p, 511)) // token='try' |
| 4716 | && |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4717 | (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4718 | && |
| 4719 | (b = block_rule(p)) // block |
| 4720 | && |
| 4721 | (f = finally_block_rule(p)) // finally_block |
| 4722 | ) |
| 4723 | { |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4724 | D(fprintf(stderr, "%*c+ try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' &&':' block finally_block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4725 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4726 | if (_token == NULL) { |
| 4727 | D(p->level--); |
| 4728 | return NULL; |
| 4729 | } |
| 4730 | int _end_lineno = _token->end_lineno; |
| 4731 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4732 | int _end_col_offset = _token->end_col_offset; |
| 4733 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 4734 | _res = _PyAST_Try ( b , NULL , NULL , f , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4735 | if (_res == NULL && PyErr_Occurred()) { |
| 4736 | p->error_indicator = 1; |
| 4737 | D(p->level--); |
| 4738 | return NULL; |
| 4739 | } |
| 4740 | goto done; |
| 4741 | } |
| 4742 | p->mark = _mark; |
| 4743 | D(fprintf(stderr, "%*c%s try_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4744 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' &&':' block finally_block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4745 | } |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4746 | { // 'try' &&':' block except_block+ else_block? finally_block? |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4747 | if (p->error_indicator) { |
| 4748 | D(p->level--); |
| 4749 | return NULL; |
| 4750 | } |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4751 | D(fprintf(stderr, "%*c> try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' &&':' block except_block+ else_block? finally_block?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4752 | Token * _keyword; |
| 4753 | Token * _literal; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4754 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4755 | void *el; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4756 | asdl_excepthandler_seq* ex; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4757 | void *f; |
| 4758 | if ( |
| 4759 | (_keyword = _PyPegen_expect_token(p, 511)) // token='try' |
| 4760 | && |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4761 | (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4762 | && |
| 4763 | (b = block_rule(p)) // block |
| 4764 | && |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4765 | (ex = (asdl_excepthandler_seq*)_loop1_48_rule(p)) // except_block+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4766 | && |
| 4767 | (el = else_block_rule(p), 1) // else_block? |
| 4768 | && |
| 4769 | (f = finally_block_rule(p), 1) // finally_block? |
| 4770 | ) |
| 4771 | { |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4772 | D(fprintf(stderr, "%*c+ try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' &&':' block except_block+ else_block? finally_block?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4773 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4774 | if (_token == NULL) { |
| 4775 | D(p->level--); |
| 4776 | return NULL; |
| 4777 | } |
| 4778 | int _end_lineno = _token->end_lineno; |
| 4779 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4780 | int _end_col_offset = _token->end_col_offset; |
| 4781 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 4782 | _res = _PyAST_Try ( b , ex , el , f , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4783 | if (_res == NULL && PyErr_Occurred()) { |
| 4784 | p->error_indicator = 1; |
| 4785 | D(p->level--); |
| 4786 | return NULL; |
| 4787 | } |
| 4788 | goto done; |
| 4789 | } |
| 4790 | p->mark = _mark; |
| 4791 | D(fprintf(stderr, "%*c%s try_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 4792 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' &&':' block except_block+ else_block? finally_block?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4793 | } |
| 4794 | _res = NULL; |
| 4795 | done: |
| 4796 | D(p->level--); |
| 4797 | return _res; |
| 4798 | } |
| 4799 | |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 4800 | // except_block: |
| 4801 | // | 'except' expression ['as' NAME] ':' block |
| 4802 | // | 'except' ':' block |
| 4803 | // | invalid_except_block |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4804 | static excepthandler_ty |
| 4805 | except_block_rule(Parser *p) |
| 4806 | { |
| 4807 | D(p->level++); |
| 4808 | if (p->error_indicator) { |
| 4809 | D(p->level--); |
| 4810 | return NULL; |
| 4811 | } |
| 4812 | excepthandler_ty _res = NULL; |
| 4813 | int _mark = p->mark; |
| 4814 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4815 | p->error_indicator = 1; |
| 4816 | D(p->level--); |
| 4817 | return NULL; |
| 4818 | } |
| 4819 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4820 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4821 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4822 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 4823 | { // 'except' expression ['as' NAME] ':' block |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4824 | if (p->error_indicator) { |
| 4825 | D(p->level--); |
| 4826 | return NULL; |
| 4827 | } |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 4828 | D(fprintf(stderr, "%*c> except_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] ':' block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4829 | Token * _keyword; |
| 4830 | Token * _literal; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4831 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4832 | expr_ty e; |
| 4833 | void *t; |
| 4834 | if ( |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4835 | (_keyword = _PyPegen_expect_token(p, 521)) // token='except' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4836 | && |
| 4837 | (e = expression_rule(p)) // expression |
| 4838 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4839 | (t = _tmp_49_rule(p), 1) // ['as' NAME] |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4840 | && |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 4841 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4842 | && |
| 4843 | (b = block_rule(p)) // block |
| 4844 | ) |
| 4845 | { |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 4846 | D(fprintf(stderr, "%*c+ except_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] ':' block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4847 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4848 | if (_token == NULL) { |
| 4849 | D(p->level--); |
| 4850 | return NULL; |
| 4851 | } |
| 4852 | int _end_lineno = _token->end_lineno; |
| 4853 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4854 | int _end_col_offset = _token->end_col_offset; |
| 4855 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 4856 | _res = _PyAST_ExceptHandler ( e , ( t ) ? ( ( expr_ty ) t ) -> v . Name . id : NULL , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4857 | if (_res == NULL && PyErr_Occurred()) { |
| 4858 | p->error_indicator = 1; |
| 4859 | D(p->level--); |
| 4860 | return NULL; |
| 4861 | } |
| 4862 | goto done; |
| 4863 | } |
| 4864 | p->mark = _mark; |
| 4865 | D(fprintf(stderr, "%*c%s except_block[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 4866 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' expression ['as' NAME] ':' block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4867 | } |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 4868 | { // 'except' ':' block |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4869 | if (p->error_indicator) { |
| 4870 | D(p->level--); |
| 4871 | return NULL; |
| 4872 | } |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 4873 | D(fprintf(stderr, "%*c> except_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' ':' block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4874 | Token * _keyword; |
| 4875 | Token * _literal; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4876 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4877 | if ( |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4878 | (_keyword = _PyPegen_expect_token(p, 521)) // token='except' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4879 | && |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 4880 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4881 | && |
| 4882 | (b = block_rule(p)) // block |
| 4883 | ) |
| 4884 | { |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 4885 | D(fprintf(stderr, "%*c+ except_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' ':' block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4886 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4887 | if (_token == NULL) { |
| 4888 | D(p->level--); |
| 4889 | return NULL; |
| 4890 | } |
| 4891 | int _end_lineno = _token->end_lineno; |
| 4892 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4893 | int _end_col_offset = _token->end_col_offset; |
| 4894 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 4895 | _res = _PyAST_ExceptHandler ( NULL , NULL , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4896 | if (_res == NULL && PyErr_Occurred()) { |
| 4897 | p->error_indicator = 1; |
| 4898 | D(p->level--); |
| 4899 | return NULL; |
| 4900 | } |
| 4901 | goto done; |
| 4902 | } |
| 4903 | p->mark = _mark; |
| 4904 | D(fprintf(stderr, "%*c%s except_block[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 4905 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' ':' block")); |
| 4906 | } |
| 4907 | if (p->call_invalid_rules) { // invalid_except_block |
| 4908 | if (p->error_indicator) { |
| 4909 | D(p->level--); |
| 4910 | return NULL; |
| 4911 | } |
| 4912 | D(fprintf(stderr, "%*c> except_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_except_block")); |
| 4913 | void *invalid_except_block_var; |
| 4914 | if ( |
| 4915 | (invalid_except_block_var = invalid_except_block_rule(p)) // invalid_except_block |
| 4916 | ) |
| 4917 | { |
| 4918 | D(fprintf(stderr, "%*c+ except_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_except_block")); |
| 4919 | _res = invalid_except_block_var; |
| 4920 | goto done; |
| 4921 | } |
| 4922 | p->mark = _mark; |
| 4923 | D(fprintf(stderr, "%*c%s except_block[%d-%d]: %s failed!\n", p->level, ' ', |
| 4924 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_except_block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4925 | } |
| 4926 | _res = NULL; |
| 4927 | done: |
| 4928 | D(p->level--); |
| 4929 | return _res; |
| 4930 | } |
| 4931 | |
| 4932 | // finally_block: 'finally' ':' block |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4933 | static asdl_stmt_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4934 | finally_block_rule(Parser *p) |
| 4935 | { |
| 4936 | D(p->level++); |
| 4937 | if (p->error_indicator) { |
| 4938 | D(p->level--); |
| 4939 | return NULL; |
| 4940 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4941 | asdl_stmt_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4942 | int _mark = p->mark; |
| 4943 | { // 'finally' ':' block |
| 4944 | if (p->error_indicator) { |
| 4945 | D(p->level--); |
| 4946 | return NULL; |
| 4947 | } |
| 4948 | D(fprintf(stderr, "%*c> finally_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'finally' ':' block")); |
| 4949 | Token * _keyword; |
| 4950 | Token * _literal; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 4951 | asdl_stmt_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4952 | if ( |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 4953 | (_keyword = _PyPegen_expect_token(p, 522)) // token='finally' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 4954 | && |
| 4955 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 4956 | && |
| 4957 | (a = block_rule(p)) // block |
| 4958 | ) |
| 4959 | { |
| 4960 | D(fprintf(stderr, "%*c+ finally_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'finally' ':' block")); |
| 4961 | _res = a; |
| 4962 | if (_res == NULL && PyErr_Occurred()) { |
| 4963 | p->error_indicator = 1; |
| 4964 | D(p->level--); |
| 4965 | return NULL; |
| 4966 | } |
| 4967 | goto done; |
| 4968 | } |
| 4969 | p->mark = _mark; |
| 4970 | D(fprintf(stderr, "%*c%s finally_block[%d-%d]: %s failed!\n", p->level, ' ', |
| 4971 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'finally' ':' block")); |
| 4972 | } |
| 4973 | _res = NULL; |
| 4974 | done: |
| 4975 | D(p->level--); |
| 4976 | return _res; |
| 4977 | } |
| 4978 | |
Pablo Galindo | 08fb8ac | 2021-03-18 01:03:11 +0000 | [diff] [blame] | 4979 | // match_stmt: |
| 4980 | // | "match" subject_expr ':' NEWLINE INDENT case_block+ DEDENT |
| 4981 | // | invalid_match_stmt |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 4982 | static stmt_ty |
| 4983 | match_stmt_rule(Parser *p) |
| 4984 | { |
| 4985 | D(p->level++); |
| 4986 | if (p->error_indicator) { |
| 4987 | D(p->level--); |
| 4988 | return NULL; |
| 4989 | } |
| 4990 | stmt_ty _res = NULL; |
| 4991 | int _mark = p->mark; |
| 4992 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4993 | p->error_indicator = 1; |
| 4994 | D(p->level--); |
| 4995 | return NULL; |
| 4996 | } |
| 4997 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4998 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4999 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5000 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 5001 | { // "match" subject_expr ':' NEWLINE INDENT case_block+ DEDENT |
| 5002 | if (p->error_indicator) { |
| 5003 | D(p->level--); |
| 5004 | return NULL; |
| 5005 | } |
| 5006 | D(fprintf(stderr, "%*c> match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"match\" subject_expr ':' NEWLINE INDENT case_block+ DEDENT")); |
| 5007 | expr_ty _keyword; |
| 5008 | Token * _literal; |
| 5009 | asdl_match_case_seq* cases; |
| 5010 | Token * dedent_var; |
| 5011 | Token * indent_var; |
| 5012 | Token * newline_var; |
| 5013 | expr_ty subject; |
| 5014 | if ( |
| 5015 | (_keyword = _PyPegen_expect_soft_keyword(p, "match")) // soft_keyword='"match"' |
| 5016 | && |
| 5017 | (subject = subject_expr_rule(p)) // subject_expr |
| 5018 | && |
| 5019 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 5020 | && |
| 5021 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 5022 | && |
| 5023 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
| 5024 | && |
| 5025 | (cases = (asdl_match_case_seq*)_loop1_50_rule(p)) // case_block+ |
| 5026 | && |
| 5027 | (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' |
| 5028 | ) |
| 5029 | { |
| 5030 | D(fprintf(stderr, "%*c+ match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"match\" subject_expr ':' NEWLINE INDENT case_block+ DEDENT")); |
| 5031 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5032 | if (_token == NULL) { |
| 5033 | D(p->level--); |
| 5034 | return NULL; |
| 5035 | } |
| 5036 | int _end_lineno = _token->end_lineno; |
| 5037 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5038 | int _end_col_offset = _token->end_col_offset; |
| 5039 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 5040 | _res = CHECK_VERSION ( stmt_ty , 10 , "Pattern matching is" , _PyAST_Match ( subject , cases , EXTRA ) ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 5041 | if (_res == NULL && PyErr_Occurred()) { |
| 5042 | p->error_indicator = 1; |
| 5043 | D(p->level--); |
| 5044 | return NULL; |
| 5045 | } |
| 5046 | goto done; |
| 5047 | } |
| 5048 | p->mark = _mark; |
| 5049 | D(fprintf(stderr, "%*c%s match_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 5050 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"match\" subject_expr ':' NEWLINE INDENT case_block+ DEDENT")); |
| 5051 | } |
Pablo Galindo | 08fb8ac | 2021-03-18 01:03:11 +0000 | [diff] [blame] | 5052 | if (p->call_invalid_rules) { // invalid_match_stmt |
| 5053 | if (p->error_indicator) { |
| 5054 | D(p->level--); |
| 5055 | return NULL; |
| 5056 | } |
| 5057 | D(fprintf(stderr, "%*c> match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_match_stmt")); |
| 5058 | void *invalid_match_stmt_var; |
| 5059 | if ( |
| 5060 | (invalid_match_stmt_var = invalid_match_stmt_rule(p)) // invalid_match_stmt |
| 5061 | ) |
| 5062 | { |
| 5063 | D(fprintf(stderr, "%*c+ match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_match_stmt")); |
| 5064 | _res = invalid_match_stmt_var; |
| 5065 | goto done; |
| 5066 | } |
| 5067 | p->mark = _mark; |
| 5068 | D(fprintf(stderr, "%*c%s match_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 5069 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_match_stmt")); |
| 5070 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 5071 | _res = NULL; |
| 5072 | done: |
| 5073 | D(p->level--); |
| 5074 | return _res; |
| 5075 | } |
| 5076 | |
| 5077 | // subject_expr: star_named_expression ',' star_named_expressions? | named_expression |
| 5078 | static expr_ty |
| 5079 | subject_expr_rule(Parser *p) |
| 5080 | { |
| 5081 | D(p->level++); |
| 5082 | if (p->error_indicator) { |
| 5083 | D(p->level--); |
| 5084 | return NULL; |
| 5085 | } |
| 5086 | expr_ty _res = NULL; |
| 5087 | int _mark = p->mark; |
| 5088 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5089 | p->error_indicator = 1; |
| 5090 | D(p->level--); |
| 5091 | return NULL; |
| 5092 | } |
| 5093 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5094 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5095 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5096 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 5097 | { // star_named_expression ',' star_named_expressions? |
| 5098 | if (p->error_indicator) { |
| 5099 | D(p->level--); |
| 5100 | return NULL; |
| 5101 | } |
| 5102 | D(fprintf(stderr, "%*c> subject_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); |
| 5103 | Token * _literal; |
| 5104 | expr_ty value; |
| 5105 | void *values; |
| 5106 | if ( |
| 5107 | (value = star_named_expression_rule(p)) // star_named_expression |
| 5108 | && |
| 5109 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 5110 | && |
| 5111 | (values = star_named_expressions_rule(p), 1) // star_named_expressions? |
| 5112 | ) |
| 5113 | { |
| 5114 | D(fprintf(stderr, "%*c+ subject_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); |
| 5115 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5116 | if (_token == NULL) { |
| 5117 | D(p->level--); |
| 5118 | return NULL; |
| 5119 | } |
| 5120 | int _end_lineno = _token->end_lineno; |
| 5121 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5122 | int _end_col_offset = _token->end_col_offset; |
| 5123 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 5124 | _res = _PyAST_Tuple ( CHECK ( asdl_expr_seq * , _PyPegen_seq_insert_in_front ( p , value , values ) ) , Load , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 5125 | if (_res == NULL && PyErr_Occurred()) { |
| 5126 | p->error_indicator = 1; |
| 5127 | D(p->level--); |
| 5128 | return NULL; |
| 5129 | } |
| 5130 | goto done; |
| 5131 | } |
| 5132 | p->mark = _mark; |
| 5133 | D(fprintf(stderr, "%*c%s subject_expr[%d-%d]: %s failed!\n", p->level, ' ', |
| 5134 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); |
| 5135 | } |
| 5136 | { // named_expression |
| 5137 | if (p->error_indicator) { |
| 5138 | D(p->level--); |
| 5139 | return NULL; |
| 5140 | } |
| 5141 | D(fprintf(stderr, "%*c> subject_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); |
| 5142 | expr_ty named_expression_var; |
| 5143 | if ( |
| 5144 | (named_expression_var = named_expression_rule(p)) // named_expression |
| 5145 | ) |
| 5146 | { |
| 5147 | D(fprintf(stderr, "%*c+ subject_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); |
| 5148 | _res = named_expression_var; |
| 5149 | goto done; |
| 5150 | } |
| 5151 | p->mark = _mark; |
| 5152 | D(fprintf(stderr, "%*c%s subject_expr[%d-%d]: %s failed!\n", p->level, ' ', |
| 5153 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); |
| 5154 | } |
| 5155 | _res = NULL; |
| 5156 | done: |
| 5157 | D(p->level--); |
| 5158 | return _res; |
| 5159 | } |
| 5160 | |
Pablo Galindo | 08fb8ac | 2021-03-18 01:03:11 +0000 | [diff] [blame] | 5161 | // case_block: "case" patterns guard? ':' block | invalid_case_block |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 5162 | static match_case_ty |
| 5163 | case_block_rule(Parser *p) |
| 5164 | { |
| 5165 | D(p->level++); |
| 5166 | if (p->error_indicator) { |
| 5167 | D(p->level--); |
| 5168 | return NULL; |
| 5169 | } |
| 5170 | match_case_ty _res = NULL; |
| 5171 | int _mark = p->mark; |
| 5172 | { // "case" patterns guard? ':' block |
| 5173 | if (p->error_indicator) { |
| 5174 | D(p->level--); |
| 5175 | return NULL; |
| 5176 | } |
| 5177 | D(fprintf(stderr, "%*c> case_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? ':' block")); |
| 5178 | expr_ty _keyword; |
| 5179 | Token * _literal; |
| 5180 | asdl_stmt_seq* body; |
| 5181 | void *guard; |
| 5182 | expr_ty pattern; |
| 5183 | if ( |
| 5184 | (_keyword = _PyPegen_expect_soft_keyword(p, "case")) // soft_keyword='"case"' |
| 5185 | && |
| 5186 | (pattern = patterns_rule(p)) // patterns |
| 5187 | && |
| 5188 | (guard = guard_rule(p), 1) // guard? |
| 5189 | && |
| 5190 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 5191 | && |
| 5192 | (body = block_rule(p)) // block |
| 5193 | ) |
| 5194 | { |
| 5195 | D(fprintf(stderr, "%*c+ case_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? ':' block")); |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 5196 | _res = _PyAST_match_case ( pattern , guard , body , p -> arena ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 5197 | if (_res == NULL && PyErr_Occurred()) { |
| 5198 | p->error_indicator = 1; |
| 5199 | D(p->level--); |
| 5200 | return NULL; |
| 5201 | } |
| 5202 | goto done; |
| 5203 | } |
| 5204 | p->mark = _mark; |
| 5205 | D(fprintf(stderr, "%*c%s case_block[%d-%d]: %s failed!\n", p->level, ' ', |
| 5206 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" patterns guard? ':' block")); |
| 5207 | } |
Pablo Galindo | 08fb8ac | 2021-03-18 01:03:11 +0000 | [diff] [blame] | 5208 | if (p->call_invalid_rules) { // invalid_case_block |
| 5209 | if (p->error_indicator) { |
| 5210 | D(p->level--); |
| 5211 | return NULL; |
| 5212 | } |
| 5213 | D(fprintf(stderr, "%*c> case_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_case_block")); |
| 5214 | void *invalid_case_block_var; |
| 5215 | if ( |
| 5216 | (invalid_case_block_var = invalid_case_block_rule(p)) // invalid_case_block |
| 5217 | ) |
| 5218 | { |
| 5219 | D(fprintf(stderr, "%*c+ case_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_case_block")); |
| 5220 | _res = invalid_case_block_var; |
| 5221 | goto done; |
| 5222 | } |
| 5223 | p->mark = _mark; |
| 5224 | D(fprintf(stderr, "%*c%s case_block[%d-%d]: %s failed!\n", p->level, ' ', |
| 5225 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_case_block")); |
| 5226 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 5227 | _res = NULL; |
| 5228 | done: |
| 5229 | D(p->level--); |
| 5230 | return _res; |
| 5231 | } |
| 5232 | |
| 5233 | // guard: 'if' named_expression |
| 5234 | static expr_ty |
| 5235 | guard_rule(Parser *p) |
| 5236 | { |
| 5237 | D(p->level++); |
| 5238 | if (p->error_indicator) { |
| 5239 | D(p->level--); |
| 5240 | return NULL; |
| 5241 | } |
| 5242 | expr_ty _res = NULL; |
| 5243 | int _mark = p->mark; |
| 5244 | { // 'if' named_expression |
| 5245 | if (p->error_indicator) { |
| 5246 | D(p->level--); |
| 5247 | return NULL; |
| 5248 | } |
| 5249 | D(fprintf(stderr, "%*c> guard[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression")); |
| 5250 | Token * _keyword; |
| 5251 | expr_ty guard; |
| 5252 | if ( |
| 5253 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
| 5254 | && |
| 5255 | (guard = named_expression_rule(p)) // named_expression |
| 5256 | ) |
| 5257 | { |
| 5258 | D(fprintf(stderr, "%*c+ guard[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression")); |
| 5259 | _res = guard; |
| 5260 | if (_res == NULL && PyErr_Occurred()) { |
| 5261 | p->error_indicator = 1; |
| 5262 | D(p->level--); |
| 5263 | return NULL; |
| 5264 | } |
| 5265 | goto done; |
| 5266 | } |
| 5267 | p->mark = _mark; |
| 5268 | D(fprintf(stderr, "%*c%s guard[%d-%d]: %s failed!\n", p->level, ' ', |
| 5269 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression")); |
| 5270 | } |
| 5271 | _res = NULL; |
| 5272 | done: |
| 5273 | D(p->level--); |
| 5274 | return _res; |
| 5275 | } |
| 5276 | |
| 5277 | // patterns: open_sequence_pattern | pattern |
| 5278 | static expr_ty |
| 5279 | patterns_rule(Parser *p) |
| 5280 | { |
| 5281 | D(p->level++); |
| 5282 | if (p->error_indicator) { |
| 5283 | D(p->level--); |
| 5284 | return NULL; |
| 5285 | } |
| 5286 | expr_ty _res = NULL; |
| 5287 | int _mark = p->mark; |
| 5288 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5289 | p->error_indicator = 1; |
| 5290 | D(p->level--); |
| 5291 | return NULL; |
| 5292 | } |
| 5293 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5294 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5295 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5296 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 5297 | { // open_sequence_pattern |
| 5298 | if (p->error_indicator) { |
| 5299 | D(p->level--); |
| 5300 | return NULL; |
| 5301 | } |
| 5302 | D(fprintf(stderr, "%*c> patterns[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "open_sequence_pattern")); |
| 5303 | asdl_expr_seq* values; |
| 5304 | if ( |
| 5305 | (values = (asdl_expr_seq*)open_sequence_pattern_rule(p)) // open_sequence_pattern |
| 5306 | ) |
| 5307 | { |
| 5308 | D(fprintf(stderr, "%*c+ patterns[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "open_sequence_pattern")); |
| 5309 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5310 | if (_token == NULL) { |
| 5311 | D(p->level--); |
| 5312 | return NULL; |
| 5313 | } |
| 5314 | int _end_lineno = _token->end_lineno; |
| 5315 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5316 | int _end_col_offset = _token->end_col_offset; |
| 5317 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 5318 | _res = _PyAST_Tuple ( values , Load , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 5319 | if (_res == NULL && PyErr_Occurred()) { |
| 5320 | p->error_indicator = 1; |
| 5321 | D(p->level--); |
| 5322 | return NULL; |
| 5323 | } |
| 5324 | goto done; |
| 5325 | } |
| 5326 | p->mark = _mark; |
| 5327 | D(fprintf(stderr, "%*c%s patterns[%d-%d]: %s failed!\n", p->level, ' ', |
| 5328 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "open_sequence_pattern")); |
| 5329 | } |
| 5330 | { // pattern |
| 5331 | if (p->error_indicator) { |
| 5332 | D(p->level--); |
| 5333 | return NULL; |
| 5334 | } |
| 5335 | D(fprintf(stderr, "%*c> patterns[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); |
| 5336 | expr_ty pattern_var; |
| 5337 | if ( |
| 5338 | (pattern_var = pattern_rule(p)) // pattern |
| 5339 | ) |
| 5340 | { |
| 5341 | D(fprintf(stderr, "%*c+ patterns[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); |
| 5342 | _res = pattern_var; |
| 5343 | goto done; |
| 5344 | } |
| 5345 | p->mark = _mark; |
| 5346 | D(fprintf(stderr, "%*c%s patterns[%d-%d]: %s failed!\n", p->level, ' ', |
| 5347 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); |
| 5348 | } |
| 5349 | _res = NULL; |
| 5350 | done: |
| 5351 | D(p->level--); |
| 5352 | return _res; |
| 5353 | } |
| 5354 | |
| 5355 | // pattern: as_pattern | or_pattern |
| 5356 | static expr_ty |
| 5357 | pattern_rule(Parser *p) |
| 5358 | { |
| 5359 | D(p->level++); |
| 5360 | if (p->error_indicator) { |
| 5361 | D(p->level--); |
| 5362 | return NULL; |
| 5363 | } |
| 5364 | expr_ty _res = NULL; |
| 5365 | int _mark = p->mark; |
| 5366 | { // as_pattern |
| 5367 | if (p->error_indicator) { |
| 5368 | D(p->level--); |
| 5369 | return NULL; |
| 5370 | } |
| 5371 | D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "as_pattern")); |
| 5372 | expr_ty as_pattern_var; |
| 5373 | if ( |
| 5374 | (as_pattern_var = as_pattern_rule(p)) // as_pattern |
| 5375 | ) |
| 5376 | { |
| 5377 | D(fprintf(stderr, "%*c+ pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "as_pattern")); |
| 5378 | _res = as_pattern_var; |
| 5379 | goto done; |
| 5380 | } |
| 5381 | p->mark = _mark; |
| 5382 | D(fprintf(stderr, "%*c%s pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5383 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "as_pattern")); |
| 5384 | } |
| 5385 | { // or_pattern |
| 5386 | if (p->error_indicator) { |
| 5387 | D(p->level--); |
| 5388 | return NULL; |
| 5389 | } |
| 5390 | D(fprintf(stderr, "%*c> pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "or_pattern")); |
| 5391 | expr_ty or_pattern_var; |
| 5392 | if ( |
| 5393 | (or_pattern_var = or_pattern_rule(p)) // or_pattern |
| 5394 | ) |
| 5395 | { |
| 5396 | D(fprintf(stderr, "%*c+ pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "or_pattern")); |
| 5397 | _res = or_pattern_var; |
| 5398 | goto done; |
| 5399 | } |
| 5400 | p->mark = _mark; |
| 5401 | D(fprintf(stderr, "%*c%s pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5402 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "or_pattern")); |
| 5403 | } |
| 5404 | _res = NULL; |
| 5405 | done: |
| 5406 | D(p->level--); |
| 5407 | return _res; |
| 5408 | } |
| 5409 | |
| 5410 | // as_pattern: or_pattern 'as' capture_pattern |
| 5411 | static expr_ty |
| 5412 | as_pattern_rule(Parser *p) |
| 5413 | { |
| 5414 | D(p->level++); |
| 5415 | if (p->error_indicator) { |
| 5416 | D(p->level--); |
| 5417 | return NULL; |
| 5418 | } |
| 5419 | expr_ty _res = NULL; |
| 5420 | int _mark = p->mark; |
| 5421 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5422 | p->error_indicator = 1; |
| 5423 | D(p->level--); |
| 5424 | return NULL; |
| 5425 | } |
| 5426 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5427 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5428 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5429 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 5430 | { // or_pattern 'as' capture_pattern |
| 5431 | if (p->error_indicator) { |
| 5432 | D(p->level--); |
| 5433 | return NULL; |
| 5434 | } |
| 5435 | D(fprintf(stderr, "%*c> as_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' capture_pattern")); |
| 5436 | Token * _keyword; |
| 5437 | expr_ty pattern; |
| 5438 | expr_ty target; |
| 5439 | if ( |
| 5440 | (pattern = or_pattern_rule(p)) // or_pattern |
| 5441 | && |
| 5442 | (_keyword = _PyPegen_expect_token(p, 520)) // token='as' |
| 5443 | && |
| 5444 | (target = capture_pattern_rule(p)) // capture_pattern |
| 5445 | ) |
| 5446 | { |
| 5447 | D(fprintf(stderr, "%*c+ as_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "or_pattern 'as' capture_pattern")); |
| 5448 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5449 | if (_token == NULL) { |
| 5450 | D(p->level--); |
| 5451 | return NULL; |
| 5452 | } |
| 5453 | int _end_lineno = _token->end_lineno; |
| 5454 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5455 | int _end_col_offset = _token->end_col_offset; |
| 5456 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 5457 | _res = _PyAST_MatchAs ( pattern , target -> v . Name . id , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 5458 | if (_res == NULL && PyErr_Occurred()) { |
| 5459 | p->error_indicator = 1; |
| 5460 | D(p->level--); |
| 5461 | return NULL; |
| 5462 | } |
| 5463 | goto done; |
| 5464 | } |
| 5465 | p->mark = _mark; |
| 5466 | D(fprintf(stderr, "%*c%s as_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5467 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "or_pattern 'as' capture_pattern")); |
| 5468 | } |
| 5469 | _res = NULL; |
| 5470 | done: |
| 5471 | D(p->level--); |
| 5472 | return _res; |
| 5473 | } |
| 5474 | |
| 5475 | // or_pattern: '|'.closed_pattern+ |
| 5476 | static expr_ty |
| 5477 | or_pattern_rule(Parser *p) |
| 5478 | { |
| 5479 | D(p->level++); |
| 5480 | if (p->error_indicator) { |
| 5481 | D(p->level--); |
| 5482 | return NULL; |
| 5483 | } |
| 5484 | expr_ty _res = NULL; |
| 5485 | int _mark = p->mark; |
| 5486 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5487 | p->error_indicator = 1; |
| 5488 | D(p->level--); |
| 5489 | return NULL; |
| 5490 | } |
| 5491 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5492 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5493 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5494 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 5495 | { // '|'.closed_pattern+ |
| 5496 | if (p->error_indicator) { |
| 5497 | D(p->level--); |
| 5498 | return NULL; |
| 5499 | } |
| 5500 | D(fprintf(stderr, "%*c> or_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|'.closed_pattern+")); |
| 5501 | asdl_expr_seq* patterns; |
| 5502 | if ( |
| 5503 | (patterns = (asdl_expr_seq*)_gather_51_rule(p)) // '|'.closed_pattern+ |
| 5504 | ) |
| 5505 | { |
| 5506 | D(fprintf(stderr, "%*c+ or_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'|'.closed_pattern+")); |
| 5507 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5508 | if (_token == NULL) { |
| 5509 | D(p->level--); |
| 5510 | return NULL; |
| 5511 | } |
| 5512 | int _end_lineno = _token->end_lineno; |
| 5513 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5514 | int _end_col_offset = _token->end_col_offset; |
| 5515 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 5516 | _res = asdl_seq_LEN ( patterns ) == 1 ? asdl_seq_GET ( patterns , 0 ) : _PyAST_MatchOr ( patterns , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 5517 | if (_res == NULL && PyErr_Occurred()) { |
| 5518 | p->error_indicator = 1; |
| 5519 | D(p->level--); |
| 5520 | return NULL; |
| 5521 | } |
| 5522 | goto done; |
| 5523 | } |
| 5524 | p->mark = _mark; |
| 5525 | D(fprintf(stderr, "%*c%s or_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5526 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|'.closed_pattern+")); |
| 5527 | } |
| 5528 | _res = NULL; |
| 5529 | done: |
| 5530 | D(p->level--); |
| 5531 | return _res; |
| 5532 | } |
| 5533 | |
| 5534 | // closed_pattern: |
| 5535 | // | literal_pattern |
| 5536 | // | capture_pattern |
| 5537 | // | wildcard_pattern |
| 5538 | // | value_pattern |
| 5539 | // | group_pattern |
| 5540 | // | sequence_pattern |
| 5541 | // | mapping_pattern |
| 5542 | // | class_pattern |
| 5543 | static expr_ty |
| 5544 | closed_pattern_rule(Parser *p) |
| 5545 | { |
| 5546 | D(p->level++); |
| 5547 | if (p->error_indicator) { |
| 5548 | D(p->level--); |
| 5549 | return NULL; |
| 5550 | } |
| 5551 | expr_ty _res = NULL; |
| 5552 | int _mark = p->mark; |
| 5553 | { // literal_pattern |
| 5554 | if (p->error_indicator) { |
| 5555 | D(p->level--); |
| 5556 | return NULL; |
| 5557 | } |
| 5558 | D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); |
| 5559 | expr_ty literal_pattern_var; |
| 5560 | if ( |
| 5561 | (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern |
| 5562 | ) |
| 5563 | { |
| 5564 | D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); |
| 5565 | _res = literal_pattern_var; |
| 5566 | goto done; |
| 5567 | } |
| 5568 | p->mark = _mark; |
| 5569 | D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5570 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern")); |
| 5571 | } |
| 5572 | { // capture_pattern |
| 5573 | if (p->error_indicator) { |
| 5574 | D(p->level--); |
| 5575 | return NULL; |
| 5576 | } |
| 5577 | D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "capture_pattern")); |
| 5578 | expr_ty capture_pattern_var; |
| 5579 | if ( |
| 5580 | (capture_pattern_var = capture_pattern_rule(p)) // capture_pattern |
| 5581 | ) |
| 5582 | { |
| 5583 | D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "capture_pattern")); |
| 5584 | _res = capture_pattern_var; |
| 5585 | goto done; |
| 5586 | } |
| 5587 | p->mark = _mark; |
| 5588 | D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5589 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "capture_pattern")); |
| 5590 | } |
| 5591 | { // wildcard_pattern |
| 5592 | if (p->error_indicator) { |
| 5593 | D(p->level--); |
| 5594 | return NULL; |
| 5595 | } |
| 5596 | D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "wildcard_pattern")); |
| 5597 | expr_ty wildcard_pattern_var; |
| 5598 | if ( |
| 5599 | (wildcard_pattern_var = wildcard_pattern_rule(p)) // wildcard_pattern |
| 5600 | ) |
| 5601 | { |
| 5602 | D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "wildcard_pattern")); |
| 5603 | _res = wildcard_pattern_var; |
| 5604 | goto done; |
| 5605 | } |
| 5606 | p->mark = _mark; |
| 5607 | D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5608 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "wildcard_pattern")); |
| 5609 | } |
| 5610 | { // value_pattern |
| 5611 | if (p->error_indicator) { |
| 5612 | D(p->level--); |
| 5613 | return NULL; |
| 5614 | } |
| 5615 | D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern")); |
| 5616 | expr_ty value_pattern_var; |
| 5617 | if ( |
| 5618 | (value_pattern_var = value_pattern_rule(p)) // value_pattern |
| 5619 | ) |
| 5620 | { |
| 5621 | D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern")); |
| 5622 | _res = value_pattern_var; |
| 5623 | goto done; |
| 5624 | } |
| 5625 | p->mark = _mark; |
| 5626 | D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5627 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern")); |
| 5628 | } |
| 5629 | { // group_pattern |
| 5630 | if (p->error_indicator) { |
| 5631 | D(p->level--); |
| 5632 | return NULL; |
| 5633 | } |
| 5634 | D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group_pattern")); |
| 5635 | expr_ty group_pattern_var; |
| 5636 | if ( |
| 5637 | (group_pattern_var = group_pattern_rule(p)) // group_pattern |
| 5638 | ) |
| 5639 | { |
| 5640 | D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group_pattern")); |
| 5641 | _res = group_pattern_var; |
| 5642 | goto done; |
| 5643 | } |
| 5644 | p->mark = _mark; |
| 5645 | D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5646 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group_pattern")); |
| 5647 | } |
| 5648 | { // sequence_pattern |
| 5649 | if (p->error_indicator) { |
| 5650 | D(p->level--); |
| 5651 | return NULL; |
| 5652 | } |
| 5653 | D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sequence_pattern")); |
| 5654 | expr_ty sequence_pattern_var; |
| 5655 | if ( |
| 5656 | (sequence_pattern_var = sequence_pattern_rule(p)) // sequence_pattern |
| 5657 | ) |
| 5658 | { |
| 5659 | D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sequence_pattern")); |
| 5660 | _res = sequence_pattern_var; |
| 5661 | goto done; |
| 5662 | } |
| 5663 | p->mark = _mark; |
| 5664 | D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5665 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sequence_pattern")); |
| 5666 | } |
| 5667 | { // mapping_pattern |
| 5668 | if (p->error_indicator) { |
| 5669 | D(p->level--); |
| 5670 | return NULL; |
| 5671 | } |
| 5672 | D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "mapping_pattern")); |
| 5673 | expr_ty mapping_pattern_var; |
| 5674 | if ( |
| 5675 | (mapping_pattern_var = mapping_pattern_rule(p)) // mapping_pattern |
| 5676 | ) |
| 5677 | { |
| 5678 | D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "mapping_pattern")); |
| 5679 | _res = mapping_pattern_var; |
| 5680 | goto done; |
| 5681 | } |
| 5682 | p->mark = _mark; |
| 5683 | D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5684 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "mapping_pattern")); |
| 5685 | } |
| 5686 | { // class_pattern |
| 5687 | if (p->error_indicator) { |
| 5688 | D(p->level--); |
| 5689 | return NULL; |
| 5690 | } |
| 5691 | D(fprintf(stderr, "%*c> closed_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "class_pattern")); |
| 5692 | expr_ty class_pattern_var; |
| 5693 | if ( |
| 5694 | (class_pattern_var = class_pattern_rule(p)) // class_pattern |
| 5695 | ) |
| 5696 | { |
| 5697 | D(fprintf(stderr, "%*c+ closed_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "class_pattern")); |
| 5698 | _res = class_pattern_var; |
| 5699 | goto done; |
| 5700 | } |
| 5701 | p->mark = _mark; |
| 5702 | D(fprintf(stderr, "%*c%s closed_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5703 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "class_pattern")); |
| 5704 | } |
| 5705 | _res = NULL; |
| 5706 | done: |
| 5707 | D(p->level--); |
| 5708 | return _res; |
| 5709 | } |
| 5710 | |
| 5711 | // literal_pattern: |
| 5712 | // | signed_number !('+' | '-') |
| 5713 | // | signed_number '+' NUMBER |
| 5714 | // | signed_number '-' NUMBER |
| 5715 | // | strings |
| 5716 | // | 'None' |
| 5717 | // | 'True' |
| 5718 | // | 'False' |
| 5719 | static expr_ty |
| 5720 | literal_pattern_rule(Parser *p) |
| 5721 | { |
| 5722 | D(p->level++); |
| 5723 | if (p->error_indicator) { |
| 5724 | D(p->level--); |
| 5725 | return NULL; |
| 5726 | } |
| 5727 | expr_ty _res = NULL; |
| 5728 | int _mark = p->mark; |
| 5729 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5730 | p->error_indicator = 1; |
| 5731 | D(p->level--); |
| 5732 | return NULL; |
| 5733 | } |
| 5734 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5735 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5736 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5737 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 5738 | { // signed_number !('+' | '-') |
| 5739 | if (p->error_indicator) { |
| 5740 | D(p->level--); |
| 5741 | return NULL; |
| 5742 | } |
| 5743 | D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "signed_number !('+' | '-')")); |
| 5744 | expr_ty signed_number_var; |
| 5745 | if ( |
| 5746 | (signed_number_var = signed_number_rule(p)) // signed_number |
| 5747 | && |
| 5748 | _PyPegen_lookahead(0, _tmp_53_rule, p) |
| 5749 | ) |
| 5750 | { |
| 5751 | D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "signed_number !('+' | '-')")); |
| 5752 | _res = signed_number_var; |
| 5753 | goto done; |
| 5754 | } |
| 5755 | p->mark = _mark; |
| 5756 | D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5757 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "signed_number !('+' | '-')")); |
| 5758 | } |
| 5759 | { // signed_number '+' NUMBER |
| 5760 | if (p->error_indicator) { |
| 5761 | D(p->level--); |
| 5762 | return NULL; |
| 5763 | } |
| 5764 | D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "signed_number '+' NUMBER")); |
| 5765 | Token * _literal; |
| 5766 | expr_ty imag; |
| 5767 | expr_ty real; |
| 5768 | if ( |
| 5769 | (real = signed_number_rule(p)) // signed_number |
| 5770 | && |
| 5771 | (_literal = _PyPegen_expect_token(p, 14)) // token='+' |
| 5772 | && |
| 5773 | (imag = _PyPegen_number_token(p)) // NUMBER |
| 5774 | ) |
| 5775 | { |
| 5776 | D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "signed_number '+' NUMBER")); |
| 5777 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5778 | if (_token == NULL) { |
| 5779 | D(p->level--); |
| 5780 | return NULL; |
| 5781 | } |
| 5782 | int _end_lineno = _token->end_lineno; |
| 5783 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5784 | int _end_col_offset = _token->end_col_offset; |
| 5785 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 5786 | _res = _PyAST_BinOp ( real , Add , imag , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 5787 | if (_res == NULL && PyErr_Occurred()) { |
| 5788 | p->error_indicator = 1; |
| 5789 | D(p->level--); |
| 5790 | return NULL; |
| 5791 | } |
| 5792 | goto done; |
| 5793 | } |
| 5794 | p->mark = _mark; |
| 5795 | D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5796 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "signed_number '+' NUMBER")); |
| 5797 | } |
| 5798 | { // signed_number '-' NUMBER |
| 5799 | if (p->error_indicator) { |
| 5800 | D(p->level--); |
| 5801 | return NULL; |
| 5802 | } |
| 5803 | D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "signed_number '-' NUMBER")); |
| 5804 | Token * _literal; |
| 5805 | expr_ty imag; |
| 5806 | expr_ty real; |
| 5807 | if ( |
| 5808 | (real = signed_number_rule(p)) // signed_number |
| 5809 | && |
| 5810 | (_literal = _PyPegen_expect_token(p, 15)) // token='-' |
| 5811 | && |
| 5812 | (imag = _PyPegen_number_token(p)) // NUMBER |
| 5813 | ) |
| 5814 | { |
| 5815 | D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "signed_number '-' NUMBER")); |
| 5816 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5817 | if (_token == NULL) { |
| 5818 | D(p->level--); |
| 5819 | return NULL; |
| 5820 | } |
| 5821 | int _end_lineno = _token->end_lineno; |
| 5822 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5823 | int _end_col_offset = _token->end_col_offset; |
| 5824 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 5825 | _res = _PyAST_BinOp ( real , Sub , imag , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 5826 | if (_res == NULL && PyErr_Occurred()) { |
| 5827 | p->error_indicator = 1; |
| 5828 | D(p->level--); |
| 5829 | return NULL; |
| 5830 | } |
| 5831 | goto done; |
| 5832 | } |
| 5833 | p->mark = _mark; |
| 5834 | D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5835 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "signed_number '-' NUMBER")); |
| 5836 | } |
| 5837 | { // strings |
| 5838 | if (p->error_indicator) { |
| 5839 | D(p->level--); |
| 5840 | return NULL; |
| 5841 | } |
| 5842 | D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "strings")); |
| 5843 | expr_ty strings_var; |
| 5844 | if ( |
| 5845 | (strings_var = strings_rule(p)) // strings |
| 5846 | ) |
| 5847 | { |
| 5848 | D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "strings")); |
| 5849 | _res = strings_var; |
| 5850 | goto done; |
| 5851 | } |
| 5852 | p->mark = _mark; |
| 5853 | D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5854 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "strings")); |
| 5855 | } |
| 5856 | { // 'None' |
| 5857 | if (p->error_indicator) { |
| 5858 | D(p->level--); |
| 5859 | return NULL; |
| 5860 | } |
| 5861 | D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); |
| 5862 | Token * _keyword; |
| 5863 | if ( |
| 5864 | (_keyword = _PyPegen_expect_token(p, 523)) // token='None' |
| 5865 | ) |
| 5866 | { |
| 5867 | D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); |
| 5868 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5869 | if (_token == NULL) { |
| 5870 | D(p->level--); |
| 5871 | return NULL; |
| 5872 | } |
| 5873 | int _end_lineno = _token->end_lineno; |
| 5874 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5875 | int _end_col_offset = _token->end_col_offset; |
| 5876 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 5877 | _res = _PyAST_Constant ( Py_None , NULL , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 5878 | if (_res == NULL && PyErr_Occurred()) { |
| 5879 | p->error_indicator = 1; |
| 5880 | D(p->level--); |
| 5881 | return NULL; |
| 5882 | } |
| 5883 | goto done; |
| 5884 | } |
| 5885 | p->mark = _mark; |
| 5886 | D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5887 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); |
| 5888 | } |
| 5889 | { // 'True' |
| 5890 | if (p->error_indicator) { |
| 5891 | D(p->level--); |
| 5892 | return NULL; |
| 5893 | } |
| 5894 | D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); |
| 5895 | Token * _keyword; |
| 5896 | if ( |
| 5897 | (_keyword = _PyPegen_expect_token(p, 524)) // token='True' |
| 5898 | ) |
| 5899 | { |
| 5900 | D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); |
| 5901 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5902 | if (_token == NULL) { |
| 5903 | D(p->level--); |
| 5904 | return NULL; |
| 5905 | } |
| 5906 | int _end_lineno = _token->end_lineno; |
| 5907 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5908 | int _end_col_offset = _token->end_col_offset; |
| 5909 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 5910 | _res = _PyAST_Constant ( Py_True , NULL , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 5911 | if (_res == NULL && PyErr_Occurred()) { |
| 5912 | p->error_indicator = 1; |
| 5913 | D(p->level--); |
| 5914 | return NULL; |
| 5915 | } |
| 5916 | goto done; |
| 5917 | } |
| 5918 | p->mark = _mark; |
| 5919 | D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5920 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); |
| 5921 | } |
| 5922 | { // 'False' |
| 5923 | if (p->error_indicator) { |
| 5924 | D(p->level--); |
| 5925 | return NULL; |
| 5926 | } |
| 5927 | D(fprintf(stderr, "%*c> literal_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); |
| 5928 | Token * _keyword; |
| 5929 | if ( |
| 5930 | (_keyword = _PyPegen_expect_token(p, 525)) // token='False' |
| 5931 | ) |
| 5932 | { |
| 5933 | D(fprintf(stderr, "%*c+ literal_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); |
| 5934 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5935 | if (_token == NULL) { |
| 5936 | D(p->level--); |
| 5937 | return NULL; |
| 5938 | } |
| 5939 | int _end_lineno = _token->end_lineno; |
| 5940 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5941 | int _end_col_offset = _token->end_col_offset; |
| 5942 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 5943 | _res = _PyAST_Constant ( Py_False , NULL , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 5944 | if (_res == NULL && PyErr_Occurred()) { |
| 5945 | p->error_indicator = 1; |
| 5946 | D(p->level--); |
| 5947 | return NULL; |
| 5948 | } |
| 5949 | goto done; |
| 5950 | } |
| 5951 | p->mark = _mark; |
| 5952 | D(fprintf(stderr, "%*c%s literal_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 5953 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); |
| 5954 | } |
| 5955 | _res = NULL; |
| 5956 | done: |
| 5957 | D(p->level--); |
| 5958 | return _res; |
| 5959 | } |
| 5960 | |
| 5961 | // signed_number: NUMBER | '-' NUMBER |
| 5962 | static expr_ty |
| 5963 | signed_number_rule(Parser *p) |
| 5964 | { |
| 5965 | D(p->level++); |
| 5966 | if (p->error_indicator) { |
| 5967 | D(p->level--); |
| 5968 | return NULL; |
| 5969 | } |
| 5970 | expr_ty _res = NULL; |
| 5971 | int _mark = p->mark; |
| 5972 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5973 | p->error_indicator = 1; |
| 5974 | D(p->level--); |
| 5975 | return NULL; |
| 5976 | } |
| 5977 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5978 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5979 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5980 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 5981 | { // NUMBER |
| 5982 | if (p->error_indicator) { |
| 5983 | D(p->level--); |
| 5984 | return NULL; |
| 5985 | } |
| 5986 | D(fprintf(stderr, "%*c> signed_number[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NUMBER")); |
| 5987 | expr_ty number_var; |
| 5988 | if ( |
| 5989 | (number_var = _PyPegen_number_token(p)) // NUMBER |
| 5990 | ) |
| 5991 | { |
| 5992 | D(fprintf(stderr, "%*c+ signed_number[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NUMBER")); |
| 5993 | _res = number_var; |
| 5994 | goto done; |
| 5995 | } |
| 5996 | p->mark = _mark; |
| 5997 | D(fprintf(stderr, "%*c%s signed_number[%d-%d]: %s failed!\n", p->level, ' ', |
| 5998 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER")); |
| 5999 | } |
| 6000 | { // '-' NUMBER |
| 6001 | if (p->error_indicator) { |
| 6002 | D(p->level--); |
| 6003 | return NULL; |
| 6004 | } |
| 6005 | D(fprintf(stderr, "%*c> signed_number[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-' NUMBER")); |
| 6006 | Token * _literal; |
| 6007 | expr_ty number; |
| 6008 | if ( |
| 6009 | (_literal = _PyPegen_expect_token(p, 15)) // token='-' |
| 6010 | && |
| 6011 | (number = _PyPegen_number_token(p)) // NUMBER |
| 6012 | ) |
| 6013 | { |
| 6014 | D(fprintf(stderr, "%*c+ signed_number[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-' NUMBER")); |
| 6015 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6016 | if (_token == NULL) { |
| 6017 | D(p->level--); |
| 6018 | return NULL; |
| 6019 | } |
| 6020 | int _end_lineno = _token->end_lineno; |
| 6021 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6022 | int _end_col_offset = _token->end_col_offset; |
| 6023 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 6024 | _res = _PyAST_UnaryOp ( USub , number , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 6025 | if (_res == NULL && PyErr_Occurred()) { |
| 6026 | p->error_indicator = 1; |
| 6027 | D(p->level--); |
| 6028 | return NULL; |
| 6029 | } |
| 6030 | goto done; |
| 6031 | } |
| 6032 | p->mark = _mark; |
| 6033 | D(fprintf(stderr, "%*c%s signed_number[%d-%d]: %s failed!\n", p->level, ' ', |
| 6034 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-' NUMBER")); |
| 6035 | } |
| 6036 | _res = NULL; |
| 6037 | done: |
| 6038 | D(p->level--); |
| 6039 | return _res; |
| 6040 | } |
| 6041 | |
| 6042 | // capture_pattern: !"_" NAME !('.' | '(' | '=') |
| 6043 | static expr_ty |
| 6044 | capture_pattern_rule(Parser *p) |
| 6045 | { |
| 6046 | D(p->level++); |
| 6047 | if (p->error_indicator) { |
| 6048 | D(p->level--); |
| 6049 | return NULL; |
| 6050 | } |
| 6051 | expr_ty _res = NULL; |
| 6052 | int _mark = p->mark; |
| 6053 | { // !"_" NAME !('.' | '(' | '=') |
| 6054 | if (p->error_indicator) { |
| 6055 | D(p->level--); |
| 6056 | return NULL; |
| 6057 | } |
| 6058 | D(fprintf(stderr, "%*c> capture_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!\"_\" NAME !('.' | '(' | '=')")); |
| 6059 | expr_ty name; |
| 6060 | if ( |
| 6061 | _PyPegen_lookahead_with_string(0, _PyPegen_expect_soft_keyword, p, "_") |
| 6062 | && |
| 6063 | (name = _PyPegen_name_token(p)) // NAME |
| 6064 | && |
| 6065 | _PyPegen_lookahead(0, _tmp_54_rule, p) |
| 6066 | ) |
| 6067 | { |
| 6068 | D(fprintf(stderr, "%*c+ capture_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!\"_\" NAME !('.' | '(' | '=')")); |
| 6069 | _res = _PyPegen_set_expr_context ( p , name , Store ); |
| 6070 | if (_res == NULL && PyErr_Occurred()) { |
| 6071 | p->error_indicator = 1; |
| 6072 | D(p->level--); |
| 6073 | return NULL; |
| 6074 | } |
| 6075 | goto done; |
| 6076 | } |
| 6077 | p->mark = _mark; |
| 6078 | D(fprintf(stderr, "%*c%s capture_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6079 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!\"_\" NAME !('.' | '(' | '=')")); |
| 6080 | } |
| 6081 | _res = NULL; |
| 6082 | done: |
| 6083 | D(p->level--); |
| 6084 | return _res; |
| 6085 | } |
| 6086 | |
| 6087 | // wildcard_pattern: "_" |
| 6088 | static expr_ty |
| 6089 | wildcard_pattern_rule(Parser *p) |
| 6090 | { |
| 6091 | D(p->level++); |
| 6092 | if (p->error_indicator) { |
| 6093 | D(p->level--); |
| 6094 | return NULL; |
| 6095 | } |
| 6096 | expr_ty _res = NULL; |
| 6097 | int _mark = p->mark; |
| 6098 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6099 | p->error_indicator = 1; |
| 6100 | D(p->level--); |
| 6101 | return NULL; |
| 6102 | } |
| 6103 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6104 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6105 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6106 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 6107 | { // "_" |
| 6108 | if (p->error_indicator) { |
| 6109 | D(p->level--); |
| 6110 | return NULL; |
| 6111 | } |
| 6112 | D(fprintf(stderr, "%*c> wildcard_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"_\"")); |
| 6113 | expr_ty _keyword; |
| 6114 | if ( |
| 6115 | (_keyword = _PyPegen_expect_soft_keyword(p, "_")) // soft_keyword='"_"' |
| 6116 | ) |
| 6117 | { |
| 6118 | D(fprintf(stderr, "%*c+ wildcard_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"_\"")); |
| 6119 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6120 | if (_token == NULL) { |
| 6121 | D(p->level--); |
| 6122 | return NULL; |
| 6123 | } |
| 6124 | int _end_lineno = _token->end_lineno; |
| 6125 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6126 | int _end_col_offset = _token->end_col_offset; |
| 6127 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 6128 | _res = _PyAST_Name ( CHECK ( PyObject * , _PyPegen_new_identifier ( p , "_" ) ) , Store , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 6129 | if (_res == NULL && PyErr_Occurred()) { |
| 6130 | p->error_indicator = 1; |
| 6131 | D(p->level--); |
| 6132 | return NULL; |
| 6133 | } |
| 6134 | goto done; |
| 6135 | } |
| 6136 | p->mark = _mark; |
| 6137 | D(fprintf(stderr, "%*c%s wildcard_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6138 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"_\"")); |
| 6139 | } |
| 6140 | _res = NULL; |
| 6141 | done: |
| 6142 | D(p->level--); |
| 6143 | return _res; |
| 6144 | } |
| 6145 | |
| 6146 | // value_pattern: attr !('.' | '(' | '=') |
| 6147 | static expr_ty |
| 6148 | value_pattern_rule(Parser *p) |
| 6149 | { |
| 6150 | D(p->level++); |
| 6151 | if (p->error_indicator) { |
| 6152 | D(p->level--); |
| 6153 | return NULL; |
| 6154 | } |
| 6155 | expr_ty _res = NULL; |
| 6156 | int _mark = p->mark; |
| 6157 | { // attr !('.' | '(' | '=') |
| 6158 | if (p->error_indicator) { |
| 6159 | D(p->level--); |
| 6160 | return NULL; |
| 6161 | } |
| 6162 | D(fprintf(stderr, "%*c> value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "attr !('.' | '(' | '=')")); |
| 6163 | expr_ty attr; |
| 6164 | if ( |
| 6165 | (attr = attr_rule(p)) // attr |
| 6166 | && |
| 6167 | _PyPegen_lookahead(0, _tmp_55_rule, p) |
| 6168 | ) |
| 6169 | { |
| 6170 | D(fprintf(stderr, "%*c+ value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "attr !('.' | '(' | '=')")); |
| 6171 | _res = attr; |
| 6172 | if (_res == NULL && PyErr_Occurred()) { |
| 6173 | p->error_indicator = 1; |
| 6174 | D(p->level--); |
| 6175 | return NULL; |
| 6176 | } |
| 6177 | goto done; |
| 6178 | } |
| 6179 | p->mark = _mark; |
| 6180 | D(fprintf(stderr, "%*c%s value_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6181 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "attr !('.' | '(' | '=')")); |
| 6182 | } |
| 6183 | _res = NULL; |
| 6184 | done: |
| 6185 | D(p->level--); |
| 6186 | return _res; |
| 6187 | } |
| 6188 | |
| 6189 | // Left-recursive |
| 6190 | // attr: name_or_attr '.' NAME |
| 6191 | static expr_ty attr_raw(Parser *); |
| 6192 | static expr_ty |
| 6193 | attr_rule(Parser *p) |
| 6194 | { |
| 6195 | D(p->level++); |
| 6196 | expr_ty _res = NULL; |
| 6197 | if (_PyPegen_is_memoized(p, attr_type, &_res)) { |
| 6198 | D(p->level--); |
| 6199 | return _res; |
| 6200 | } |
| 6201 | int _mark = p->mark; |
| 6202 | int _resmark = p->mark; |
| 6203 | while (1) { |
| 6204 | int tmpvar_1 = _PyPegen_update_memo(p, _mark, attr_type, _res); |
| 6205 | if (tmpvar_1) { |
| 6206 | D(p->level--); |
| 6207 | return _res; |
| 6208 | } |
| 6209 | p->mark = _mark; |
| 6210 | void *_raw = attr_raw(p); |
| 6211 | if (p->error_indicator) |
| 6212 | return NULL; |
| 6213 | if (_raw == NULL || p->mark <= _resmark) |
| 6214 | break; |
| 6215 | _resmark = p->mark; |
| 6216 | _res = _raw; |
| 6217 | } |
| 6218 | p->mark = _resmark; |
| 6219 | D(p->level--); |
| 6220 | return _res; |
| 6221 | } |
| 6222 | static expr_ty |
| 6223 | attr_raw(Parser *p) |
| 6224 | { |
| 6225 | D(p->level++); |
| 6226 | if (p->error_indicator) { |
| 6227 | D(p->level--); |
| 6228 | return NULL; |
| 6229 | } |
| 6230 | expr_ty _res = NULL; |
| 6231 | int _mark = p->mark; |
| 6232 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6233 | p->error_indicator = 1; |
| 6234 | D(p->level--); |
| 6235 | return NULL; |
| 6236 | } |
| 6237 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6238 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6239 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6240 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 6241 | { // name_or_attr '.' NAME |
| 6242 | if (p->error_indicator) { |
| 6243 | D(p->level--); |
| 6244 | return NULL; |
| 6245 | } |
| 6246 | D(fprintf(stderr, "%*c> attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME")); |
| 6247 | Token * _literal; |
| 6248 | expr_ty attr; |
| 6249 | expr_ty value; |
| 6250 | if ( |
| 6251 | (value = name_or_attr_rule(p)) // name_or_attr |
| 6252 | && |
| 6253 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 6254 | && |
| 6255 | (attr = _PyPegen_name_token(p)) // NAME |
| 6256 | ) |
| 6257 | { |
| 6258 | D(fprintf(stderr, "%*c+ attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '.' NAME")); |
| 6259 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6260 | if (_token == NULL) { |
| 6261 | D(p->level--); |
| 6262 | return NULL; |
| 6263 | } |
| 6264 | int _end_lineno = _token->end_lineno; |
| 6265 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6266 | int _end_col_offset = _token->end_col_offset; |
| 6267 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 6268 | _res = _PyAST_Attribute ( value , attr -> v . Name . id , Load , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 6269 | if (_res == NULL && PyErr_Occurred()) { |
| 6270 | p->error_indicator = 1; |
| 6271 | D(p->level--); |
| 6272 | return NULL; |
| 6273 | } |
| 6274 | goto done; |
| 6275 | } |
| 6276 | p->mark = _mark; |
| 6277 | D(fprintf(stderr, "%*c%s attr[%d-%d]: %s failed!\n", p->level, ' ', |
| 6278 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '.' NAME")); |
| 6279 | } |
| 6280 | _res = NULL; |
| 6281 | done: |
| 6282 | D(p->level--); |
| 6283 | return _res; |
| 6284 | } |
| 6285 | |
| 6286 | // Left-recursive |
| 6287 | // name_or_attr: attr | NAME |
| 6288 | static expr_ty |
| 6289 | name_or_attr_rule(Parser *p) |
| 6290 | { |
| 6291 | D(p->level++); |
| 6292 | if (p->error_indicator) { |
| 6293 | D(p->level--); |
| 6294 | return NULL; |
| 6295 | } |
| 6296 | expr_ty _res = NULL; |
| 6297 | int _mark = p->mark; |
| 6298 | { // attr |
| 6299 | if (p->error_indicator) { |
| 6300 | D(p->level--); |
| 6301 | return NULL; |
| 6302 | } |
| 6303 | D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "attr")); |
| 6304 | expr_ty attr_var; |
| 6305 | if ( |
| 6306 | (attr_var = attr_rule(p)) // attr |
| 6307 | ) |
| 6308 | { |
| 6309 | D(fprintf(stderr, "%*c+ name_or_attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "attr")); |
| 6310 | _res = attr_var; |
| 6311 | goto done; |
| 6312 | } |
| 6313 | p->mark = _mark; |
| 6314 | D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', |
| 6315 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "attr")); |
| 6316 | } |
| 6317 | { // NAME |
| 6318 | if (p->error_indicator) { |
| 6319 | D(p->level--); |
| 6320 | return NULL; |
| 6321 | } |
| 6322 | D(fprintf(stderr, "%*c> name_or_attr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); |
| 6323 | expr_ty name_var; |
| 6324 | if ( |
| 6325 | (name_var = _PyPegen_name_token(p)) // NAME |
| 6326 | ) |
| 6327 | { |
| 6328 | D(fprintf(stderr, "%*c+ name_or_attr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); |
| 6329 | _res = name_var; |
| 6330 | goto done; |
| 6331 | } |
| 6332 | p->mark = _mark; |
| 6333 | D(fprintf(stderr, "%*c%s name_or_attr[%d-%d]: %s failed!\n", p->level, ' ', |
| 6334 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); |
| 6335 | } |
| 6336 | _res = NULL; |
| 6337 | done: |
| 6338 | D(p->level--); |
| 6339 | return _res; |
| 6340 | } |
| 6341 | |
| 6342 | // group_pattern: '(' pattern ')' |
| 6343 | static expr_ty |
| 6344 | group_pattern_rule(Parser *p) |
| 6345 | { |
| 6346 | D(p->level++); |
| 6347 | if (p->error_indicator) { |
| 6348 | D(p->level--); |
| 6349 | return NULL; |
| 6350 | } |
| 6351 | expr_ty _res = NULL; |
| 6352 | int _mark = p->mark; |
| 6353 | { // '(' pattern ')' |
| 6354 | if (p->error_indicator) { |
| 6355 | D(p->level--); |
| 6356 | return NULL; |
| 6357 | } |
| 6358 | D(fprintf(stderr, "%*c> group_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' pattern ')'")); |
| 6359 | Token * _literal; |
| 6360 | Token * _literal_1; |
| 6361 | expr_ty pattern; |
| 6362 | if ( |
| 6363 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 6364 | && |
| 6365 | (pattern = pattern_rule(p)) // pattern |
| 6366 | && |
| 6367 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 6368 | ) |
| 6369 | { |
| 6370 | D(fprintf(stderr, "%*c+ group_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' pattern ')'")); |
| 6371 | _res = pattern; |
| 6372 | if (_res == NULL && PyErr_Occurred()) { |
| 6373 | p->error_indicator = 1; |
| 6374 | D(p->level--); |
| 6375 | return NULL; |
| 6376 | } |
| 6377 | goto done; |
| 6378 | } |
| 6379 | p->mark = _mark; |
| 6380 | D(fprintf(stderr, "%*c%s group_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6381 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' pattern ')'")); |
| 6382 | } |
| 6383 | _res = NULL; |
| 6384 | done: |
| 6385 | D(p->level--); |
| 6386 | return _res; |
| 6387 | } |
| 6388 | |
| 6389 | // sequence_pattern: '[' maybe_sequence_pattern? ']' | '(' open_sequence_pattern? ')' |
| 6390 | static expr_ty |
| 6391 | sequence_pattern_rule(Parser *p) |
| 6392 | { |
| 6393 | D(p->level++); |
| 6394 | if (p->error_indicator) { |
| 6395 | D(p->level--); |
| 6396 | return NULL; |
| 6397 | } |
| 6398 | expr_ty _res = NULL; |
| 6399 | int _mark = p->mark; |
| 6400 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6401 | p->error_indicator = 1; |
| 6402 | D(p->level--); |
| 6403 | return NULL; |
| 6404 | } |
| 6405 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6406 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6407 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6408 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 6409 | { // '[' maybe_sequence_pattern? ']' |
| 6410 | if (p->error_indicator) { |
| 6411 | D(p->level--); |
| 6412 | return NULL; |
| 6413 | } |
| 6414 | D(fprintf(stderr, "%*c> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' maybe_sequence_pattern? ']'")); |
| 6415 | Token * _literal; |
| 6416 | Token * _literal_1; |
| 6417 | void *values; |
| 6418 | if ( |
| 6419 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 6420 | && |
| 6421 | (values = maybe_sequence_pattern_rule(p), 1) // maybe_sequence_pattern? |
| 6422 | && |
| 6423 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
| 6424 | ) |
| 6425 | { |
| 6426 | D(fprintf(stderr, "%*c+ sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' maybe_sequence_pattern? ']'")); |
| 6427 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6428 | if (_token == NULL) { |
| 6429 | D(p->level--); |
| 6430 | return NULL; |
| 6431 | } |
| 6432 | int _end_lineno = _token->end_lineno; |
| 6433 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6434 | int _end_col_offset = _token->end_col_offset; |
| 6435 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 6436 | _res = _PyAST_List ( values , Load , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 6437 | if (_res == NULL && PyErr_Occurred()) { |
| 6438 | p->error_indicator = 1; |
| 6439 | D(p->level--); |
| 6440 | return NULL; |
| 6441 | } |
| 6442 | goto done; |
| 6443 | } |
| 6444 | p->mark = _mark; |
| 6445 | D(fprintf(stderr, "%*c%s sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6446 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' maybe_sequence_pattern? ']'")); |
| 6447 | } |
| 6448 | { // '(' open_sequence_pattern? ')' |
| 6449 | if (p->error_indicator) { |
| 6450 | D(p->level--); |
| 6451 | return NULL; |
| 6452 | } |
| 6453 | D(fprintf(stderr, "%*c> sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' open_sequence_pattern? ')'")); |
| 6454 | Token * _literal; |
| 6455 | Token * _literal_1; |
| 6456 | void *values; |
| 6457 | if ( |
| 6458 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 6459 | && |
| 6460 | (values = open_sequence_pattern_rule(p), 1) // open_sequence_pattern? |
| 6461 | && |
| 6462 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 6463 | ) |
| 6464 | { |
| 6465 | D(fprintf(stderr, "%*c+ sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' open_sequence_pattern? ')'")); |
| 6466 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6467 | if (_token == NULL) { |
| 6468 | D(p->level--); |
| 6469 | return NULL; |
| 6470 | } |
| 6471 | int _end_lineno = _token->end_lineno; |
| 6472 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6473 | int _end_col_offset = _token->end_col_offset; |
| 6474 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 6475 | _res = _PyAST_Tuple ( values , Load , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 6476 | if (_res == NULL && PyErr_Occurred()) { |
| 6477 | p->error_indicator = 1; |
| 6478 | D(p->level--); |
| 6479 | return NULL; |
| 6480 | } |
| 6481 | goto done; |
| 6482 | } |
| 6483 | p->mark = _mark; |
| 6484 | D(fprintf(stderr, "%*c%s sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6485 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' open_sequence_pattern? ')'")); |
| 6486 | } |
| 6487 | _res = NULL; |
| 6488 | done: |
| 6489 | D(p->level--); |
| 6490 | return _res; |
| 6491 | } |
| 6492 | |
| 6493 | // open_sequence_pattern: maybe_star_pattern ',' maybe_sequence_pattern? |
| 6494 | static asdl_seq* |
| 6495 | open_sequence_pattern_rule(Parser *p) |
| 6496 | { |
| 6497 | D(p->level++); |
| 6498 | if (p->error_indicator) { |
| 6499 | D(p->level--); |
| 6500 | return NULL; |
| 6501 | } |
| 6502 | asdl_seq* _res = NULL; |
| 6503 | int _mark = p->mark; |
| 6504 | { // maybe_star_pattern ',' maybe_sequence_pattern? |
| 6505 | if (p->error_indicator) { |
| 6506 | D(p->level--); |
| 6507 | return NULL; |
| 6508 | } |
| 6509 | D(fprintf(stderr, "%*c> open_sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern ',' maybe_sequence_pattern?")); |
| 6510 | Token * _literal; |
| 6511 | expr_ty value; |
| 6512 | void *values; |
| 6513 | if ( |
| 6514 | (value = maybe_star_pattern_rule(p)) // maybe_star_pattern |
| 6515 | && |
| 6516 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 6517 | && |
| 6518 | (values = maybe_sequence_pattern_rule(p), 1) // maybe_sequence_pattern? |
| 6519 | ) |
| 6520 | { |
| 6521 | D(fprintf(stderr, "%*c+ open_sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern ',' maybe_sequence_pattern?")); |
| 6522 | _res = _PyPegen_seq_insert_in_front ( p , value , values ); |
| 6523 | if (_res == NULL && PyErr_Occurred()) { |
| 6524 | p->error_indicator = 1; |
| 6525 | D(p->level--); |
| 6526 | return NULL; |
| 6527 | } |
| 6528 | goto done; |
| 6529 | } |
| 6530 | p->mark = _mark; |
| 6531 | D(fprintf(stderr, "%*c%s open_sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6532 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "maybe_star_pattern ',' maybe_sequence_pattern?")); |
| 6533 | } |
| 6534 | _res = NULL; |
| 6535 | done: |
| 6536 | D(p->level--); |
| 6537 | return _res; |
| 6538 | } |
| 6539 | |
| 6540 | // maybe_sequence_pattern: ','.maybe_star_pattern+ ','? |
| 6541 | static asdl_seq* |
| 6542 | maybe_sequence_pattern_rule(Parser *p) |
| 6543 | { |
| 6544 | D(p->level++); |
| 6545 | if (p->error_indicator) { |
| 6546 | D(p->level--); |
| 6547 | return NULL; |
| 6548 | } |
| 6549 | asdl_seq* _res = NULL; |
| 6550 | int _mark = p->mark; |
| 6551 | { // ','.maybe_star_pattern+ ','? |
| 6552 | if (p->error_indicator) { |
| 6553 | D(p->level--); |
| 6554 | return NULL; |
| 6555 | } |
| 6556 | D(fprintf(stderr, "%*c> maybe_sequence_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.maybe_star_pattern+ ','?")); |
| 6557 | void *_opt_var; |
| 6558 | UNUSED(_opt_var); // Silence compiler warnings |
| 6559 | asdl_seq * values; |
| 6560 | if ( |
| 6561 | (values = _gather_56_rule(p)) // ','.maybe_star_pattern+ |
| 6562 | && |
| 6563 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 6564 | ) |
| 6565 | { |
| 6566 | D(fprintf(stderr, "%*c+ maybe_sequence_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.maybe_star_pattern+ ','?")); |
| 6567 | _res = values; |
| 6568 | if (_res == NULL && PyErr_Occurred()) { |
| 6569 | p->error_indicator = 1; |
| 6570 | D(p->level--); |
| 6571 | return NULL; |
| 6572 | } |
| 6573 | goto done; |
| 6574 | } |
| 6575 | p->mark = _mark; |
| 6576 | D(fprintf(stderr, "%*c%s maybe_sequence_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6577 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.maybe_star_pattern+ ','?")); |
| 6578 | } |
| 6579 | _res = NULL; |
| 6580 | done: |
| 6581 | D(p->level--); |
| 6582 | return _res; |
| 6583 | } |
| 6584 | |
| 6585 | // maybe_star_pattern: star_pattern | pattern |
| 6586 | static expr_ty |
| 6587 | maybe_star_pattern_rule(Parser *p) |
| 6588 | { |
| 6589 | D(p->level++); |
| 6590 | if (p->error_indicator) { |
| 6591 | D(p->level--); |
| 6592 | return NULL; |
| 6593 | } |
| 6594 | expr_ty _res = NULL; |
| 6595 | int _mark = p->mark; |
| 6596 | { // star_pattern |
| 6597 | if (p->error_indicator) { |
| 6598 | D(p->level--); |
| 6599 | return NULL; |
| 6600 | } |
| 6601 | D(fprintf(stderr, "%*c> maybe_star_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_pattern")); |
| 6602 | expr_ty star_pattern_var; |
| 6603 | if ( |
| 6604 | (star_pattern_var = star_pattern_rule(p)) // star_pattern |
| 6605 | ) |
| 6606 | { |
| 6607 | D(fprintf(stderr, "%*c+ maybe_star_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_pattern")); |
| 6608 | _res = star_pattern_var; |
| 6609 | goto done; |
| 6610 | } |
| 6611 | p->mark = _mark; |
| 6612 | D(fprintf(stderr, "%*c%s maybe_star_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6613 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_pattern")); |
| 6614 | } |
| 6615 | { // pattern |
| 6616 | if (p->error_indicator) { |
| 6617 | D(p->level--); |
| 6618 | return NULL; |
| 6619 | } |
| 6620 | D(fprintf(stderr, "%*c> maybe_star_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern")); |
| 6621 | expr_ty pattern_var; |
| 6622 | if ( |
| 6623 | (pattern_var = pattern_rule(p)) // pattern |
| 6624 | ) |
| 6625 | { |
| 6626 | D(fprintf(stderr, "%*c+ maybe_star_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern")); |
| 6627 | _res = pattern_var; |
| 6628 | goto done; |
| 6629 | } |
| 6630 | p->mark = _mark; |
| 6631 | D(fprintf(stderr, "%*c%s maybe_star_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6632 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern")); |
| 6633 | } |
| 6634 | _res = NULL; |
| 6635 | done: |
| 6636 | D(p->level--); |
| 6637 | return _res; |
| 6638 | } |
| 6639 | |
| 6640 | // star_pattern: '*' (capture_pattern | wildcard_pattern) |
| 6641 | static expr_ty |
| 6642 | star_pattern_rule(Parser *p) |
| 6643 | { |
| 6644 | D(p->level++); |
| 6645 | if (p->error_indicator) { |
| 6646 | D(p->level--); |
| 6647 | return NULL; |
| 6648 | } |
| 6649 | expr_ty _res = NULL; |
| 6650 | int _mark = p->mark; |
| 6651 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6652 | p->error_indicator = 1; |
| 6653 | D(p->level--); |
| 6654 | return NULL; |
| 6655 | } |
| 6656 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6657 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6658 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6659 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 6660 | { // '*' (capture_pattern | wildcard_pattern) |
| 6661 | if (p->error_indicator) { |
| 6662 | D(p->level--); |
| 6663 | return NULL; |
| 6664 | } |
| 6665 | D(fprintf(stderr, "%*c> star_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (capture_pattern | wildcard_pattern)")); |
| 6666 | Token * _literal; |
| 6667 | void *value; |
| 6668 | if ( |
| 6669 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 6670 | && |
| 6671 | (value = _tmp_58_rule(p)) // capture_pattern | wildcard_pattern |
| 6672 | ) |
| 6673 | { |
| 6674 | D(fprintf(stderr, "%*c+ star_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (capture_pattern | wildcard_pattern)")); |
| 6675 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6676 | if (_token == NULL) { |
| 6677 | D(p->level--); |
| 6678 | return NULL; |
| 6679 | } |
| 6680 | int _end_lineno = _token->end_lineno; |
| 6681 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6682 | int _end_col_offset = _token->end_col_offset; |
| 6683 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 6684 | _res = _PyAST_Starred ( value , Store , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 6685 | if (_res == NULL && PyErr_Occurred()) { |
| 6686 | p->error_indicator = 1; |
| 6687 | D(p->level--); |
| 6688 | return NULL; |
| 6689 | } |
| 6690 | goto done; |
| 6691 | } |
| 6692 | p->mark = _mark; |
| 6693 | D(fprintf(stderr, "%*c%s star_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6694 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (capture_pattern | wildcard_pattern)")); |
| 6695 | } |
| 6696 | _res = NULL; |
| 6697 | done: |
| 6698 | D(p->level--); |
| 6699 | return _res; |
| 6700 | } |
| 6701 | |
| 6702 | // mapping_pattern: '{' items_pattern? '}' |
| 6703 | static expr_ty |
| 6704 | mapping_pattern_rule(Parser *p) |
| 6705 | { |
| 6706 | D(p->level++); |
| 6707 | if (p->error_indicator) { |
| 6708 | D(p->level--); |
| 6709 | return NULL; |
| 6710 | } |
| 6711 | expr_ty _res = NULL; |
| 6712 | int _mark = p->mark; |
| 6713 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6714 | p->error_indicator = 1; |
| 6715 | D(p->level--); |
| 6716 | return NULL; |
| 6717 | } |
| 6718 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6719 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6720 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6721 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 6722 | { // '{' items_pattern? '}' |
| 6723 | if (p->error_indicator) { |
| 6724 | D(p->level--); |
| 6725 | return NULL; |
| 6726 | } |
| 6727 | D(fprintf(stderr, "%*c> mapping_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' items_pattern? '}'")); |
| 6728 | Token * _literal; |
| 6729 | Token * _literal_1; |
| 6730 | void *items; |
| 6731 | if ( |
| 6732 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
| 6733 | && |
| 6734 | (items = items_pattern_rule(p), 1) // items_pattern? |
| 6735 | && |
| 6736 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
| 6737 | ) |
| 6738 | { |
| 6739 | D(fprintf(stderr, "%*c+ mapping_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' items_pattern? '}'")); |
| 6740 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6741 | if (_token == NULL) { |
| 6742 | D(p->level--); |
| 6743 | return NULL; |
| 6744 | } |
| 6745 | int _end_lineno = _token->end_lineno; |
| 6746 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6747 | int _end_col_offset = _token->end_col_offset; |
| 6748 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 6749 | _res = _PyAST_Dict ( CHECK ( asdl_expr_seq * , _PyPegen_get_keys ( p , items ) ) , CHECK ( asdl_expr_seq * , _PyPegen_get_values ( p , items ) ) , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 6750 | if (_res == NULL && PyErr_Occurred()) { |
| 6751 | p->error_indicator = 1; |
| 6752 | D(p->level--); |
| 6753 | return NULL; |
| 6754 | } |
| 6755 | goto done; |
| 6756 | } |
| 6757 | p->mark = _mark; |
| 6758 | D(fprintf(stderr, "%*c%s mapping_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6759 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' items_pattern? '}'")); |
| 6760 | } |
| 6761 | _res = NULL; |
| 6762 | done: |
| 6763 | D(p->level--); |
| 6764 | return _res; |
| 6765 | } |
| 6766 | |
| 6767 | // items_pattern: ','.key_value_pattern+ ','? |
| 6768 | static asdl_seq* |
| 6769 | items_pattern_rule(Parser *p) |
| 6770 | { |
| 6771 | D(p->level++); |
| 6772 | if (p->error_indicator) { |
| 6773 | D(p->level--); |
| 6774 | return NULL; |
| 6775 | } |
| 6776 | asdl_seq* _res = NULL; |
| 6777 | int _mark = p->mark; |
| 6778 | { // ','.key_value_pattern+ ','? |
| 6779 | if (p->error_indicator) { |
| 6780 | D(p->level--); |
| 6781 | return NULL; |
| 6782 | } |
| 6783 | D(fprintf(stderr, "%*c> items_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.key_value_pattern+ ','?")); |
| 6784 | void *_opt_var; |
| 6785 | UNUSED(_opt_var); // Silence compiler warnings |
| 6786 | asdl_seq * items; |
| 6787 | if ( |
| 6788 | (items = _gather_59_rule(p)) // ','.key_value_pattern+ |
| 6789 | && |
| 6790 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 6791 | ) |
| 6792 | { |
| 6793 | D(fprintf(stderr, "%*c+ items_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.key_value_pattern+ ','?")); |
| 6794 | _res = items; |
| 6795 | if (_res == NULL && PyErr_Occurred()) { |
| 6796 | p->error_indicator = 1; |
| 6797 | D(p->level--); |
| 6798 | return NULL; |
| 6799 | } |
| 6800 | goto done; |
| 6801 | } |
| 6802 | p->mark = _mark; |
| 6803 | D(fprintf(stderr, "%*c%s items_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6804 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.key_value_pattern+ ','?")); |
| 6805 | } |
| 6806 | _res = NULL; |
| 6807 | done: |
| 6808 | D(p->level--); |
| 6809 | return _res; |
| 6810 | } |
| 6811 | |
| 6812 | // key_value_pattern: (literal_pattern | value_pattern) ':' pattern | double_star_pattern |
| 6813 | static KeyValuePair* |
| 6814 | key_value_pattern_rule(Parser *p) |
| 6815 | { |
| 6816 | D(p->level++); |
| 6817 | if (p->error_indicator) { |
| 6818 | D(p->level--); |
| 6819 | return NULL; |
| 6820 | } |
| 6821 | KeyValuePair* _res = NULL; |
| 6822 | int _mark = p->mark; |
| 6823 | { // (literal_pattern | value_pattern) ':' pattern |
| 6824 | if (p->error_indicator) { |
| 6825 | D(p->level--); |
| 6826 | return NULL; |
| 6827 | } |
| 6828 | D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(literal_pattern | value_pattern) ':' pattern")); |
| 6829 | Token * _literal; |
| 6830 | void *key; |
| 6831 | expr_ty value; |
| 6832 | if ( |
| 6833 | (key = _tmp_61_rule(p)) // literal_pattern | value_pattern |
| 6834 | && |
| 6835 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 6836 | && |
| 6837 | (value = pattern_rule(p)) // pattern |
| 6838 | ) |
| 6839 | { |
| 6840 | D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(literal_pattern | value_pattern) ':' pattern")); |
| 6841 | _res = _PyPegen_key_value_pair ( p , key , value ); |
| 6842 | if (_res == NULL && PyErr_Occurred()) { |
| 6843 | p->error_indicator = 1; |
| 6844 | D(p->level--); |
| 6845 | return NULL; |
| 6846 | } |
| 6847 | goto done; |
| 6848 | } |
| 6849 | p->mark = _mark; |
| 6850 | D(fprintf(stderr, "%*c%s key_value_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6851 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(literal_pattern | value_pattern) ':' pattern")); |
| 6852 | } |
| 6853 | { // double_star_pattern |
| 6854 | if (p->error_indicator) { |
| 6855 | D(p->level--); |
| 6856 | return NULL; |
| 6857 | } |
| 6858 | D(fprintf(stderr, "%*c> key_value_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_star_pattern")); |
| 6859 | KeyValuePair* double_star_pattern_var; |
| 6860 | if ( |
| 6861 | (double_star_pattern_var = double_star_pattern_rule(p)) // double_star_pattern |
| 6862 | ) |
| 6863 | { |
| 6864 | D(fprintf(stderr, "%*c+ key_value_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_star_pattern")); |
| 6865 | _res = double_star_pattern_var; |
| 6866 | goto done; |
| 6867 | } |
| 6868 | p->mark = _mark; |
| 6869 | D(fprintf(stderr, "%*c%s key_value_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6870 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_star_pattern")); |
| 6871 | } |
| 6872 | _res = NULL; |
| 6873 | done: |
| 6874 | D(p->level--); |
| 6875 | return _res; |
| 6876 | } |
| 6877 | |
| 6878 | // double_star_pattern: '**' capture_pattern |
| 6879 | static KeyValuePair* |
| 6880 | double_star_pattern_rule(Parser *p) |
| 6881 | { |
| 6882 | D(p->level++); |
| 6883 | if (p->error_indicator) { |
| 6884 | D(p->level--); |
| 6885 | return NULL; |
| 6886 | } |
| 6887 | KeyValuePair* _res = NULL; |
| 6888 | int _mark = p->mark; |
| 6889 | { // '**' capture_pattern |
| 6890 | if (p->error_indicator) { |
| 6891 | D(p->level--); |
| 6892 | return NULL; |
| 6893 | } |
| 6894 | D(fprintf(stderr, "%*c> double_star_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' capture_pattern")); |
| 6895 | Token * _literal; |
| 6896 | expr_ty value; |
| 6897 | if ( |
| 6898 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
| 6899 | && |
| 6900 | (value = capture_pattern_rule(p)) // capture_pattern |
| 6901 | ) |
| 6902 | { |
| 6903 | D(fprintf(stderr, "%*c+ double_star_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' capture_pattern")); |
| 6904 | _res = _PyPegen_key_value_pair ( p , NULL , value ); |
| 6905 | if (_res == NULL && PyErr_Occurred()) { |
| 6906 | p->error_indicator = 1; |
| 6907 | D(p->level--); |
| 6908 | return NULL; |
| 6909 | } |
| 6910 | goto done; |
| 6911 | } |
| 6912 | p->mark = _mark; |
| 6913 | D(fprintf(stderr, "%*c%s double_star_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6914 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' capture_pattern")); |
| 6915 | } |
| 6916 | _res = NULL; |
| 6917 | done: |
| 6918 | D(p->level--); |
| 6919 | return _res; |
| 6920 | } |
| 6921 | |
| 6922 | // class_pattern: |
| 6923 | // | name_or_attr '(' ')' |
| 6924 | // | name_or_attr '(' positional_patterns ','? ')' |
| 6925 | // | name_or_attr '(' keyword_patterns ','? ')' |
| 6926 | // | name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')' |
| 6927 | static expr_ty |
| 6928 | class_pattern_rule(Parser *p) |
| 6929 | { |
| 6930 | D(p->level++); |
| 6931 | if (p->error_indicator) { |
| 6932 | D(p->level--); |
| 6933 | return NULL; |
| 6934 | } |
| 6935 | expr_ty _res = NULL; |
| 6936 | int _mark = p->mark; |
| 6937 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6938 | p->error_indicator = 1; |
| 6939 | D(p->level--); |
| 6940 | return NULL; |
| 6941 | } |
| 6942 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6943 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6944 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6945 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 6946 | { // name_or_attr '(' ')' |
| 6947 | if (p->error_indicator) { |
| 6948 | D(p->level--); |
| 6949 | return NULL; |
| 6950 | } |
| 6951 | D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ')'")); |
| 6952 | Token * _literal; |
| 6953 | Token * _literal_1; |
| 6954 | expr_ty func; |
| 6955 | if ( |
| 6956 | (func = name_or_attr_rule(p)) // name_or_attr |
| 6957 | && |
| 6958 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 6959 | && |
| 6960 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 6961 | ) |
| 6962 | { |
| 6963 | D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' ')'")); |
| 6964 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6965 | if (_token == NULL) { |
| 6966 | D(p->level--); |
| 6967 | return NULL; |
| 6968 | } |
| 6969 | int _end_lineno = _token->end_lineno; |
| 6970 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6971 | int _end_col_offset = _token->end_col_offset; |
| 6972 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 6973 | _res = _PyAST_Call ( func , NULL , NULL , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 6974 | if (_res == NULL && PyErr_Occurred()) { |
| 6975 | p->error_indicator = 1; |
| 6976 | D(p->level--); |
| 6977 | return NULL; |
| 6978 | } |
| 6979 | goto done; |
| 6980 | } |
| 6981 | p->mark = _mark; |
| 6982 | D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 6983 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' ')'")); |
| 6984 | } |
| 6985 | { // name_or_attr '(' positional_patterns ','? ')' |
| 6986 | if (p->error_indicator) { |
| 6987 | D(p->level--); |
| 6988 | return NULL; |
| 6989 | } |
| 6990 | D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' positional_patterns ','? ')'")); |
| 6991 | Token * _literal; |
| 6992 | Token * _literal_1; |
| 6993 | void *_opt_var; |
| 6994 | UNUSED(_opt_var); // Silence compiler warnings |
| 6995 | asdl_expr_seq* args; |
| 6996 | expr_ty func; |
| 6997 | if ( |
| 6998 | (func = name_or_attr_rule(p)) // name_or_attr |
| 6999 | && |
| 7000 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 7001 | && |
| 7002 | (args = positional_patterns_rule(p)) // positional_patterns |
| 7003 | && |
| 7004 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 7005 | && |
| 7006 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 7007 | ) |
| 7008 | { |
| 7009 | D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' positional_patterns ','? ')'")); |
| 7010 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7011 | if (_token == NULL) { |
| 7012 | D(p->level--); |
| 7013 | return NULL; |
| 7014 | } |
| 7015 | int _end_lineno = _token->end_lineno; |
| 7016 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7017 | int _end_col_offset = _token->end_col_offset; |
| 7018 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 7019 | _res = _PyAST_Call ( func , args , NULL , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7020 | if (_res == NULL && PyErr_Occurred()) { |
| 7021 | p->error_indicator = 1; |
| 7022 | D(p->level--); |
| 7023 | return NULL; |
| 7024 | } |
| 7025 | goto done; |
| 7026 | } |
| 7027 | p->mark = _mark; |
| 7028 | D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 7029 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' positional_patterns ','? ')'")); |
| 7030 | } |
| 7031 | { // name_or_attr '(' keyword_patterns ','? ')' |
| 7032 | if (p->error_indicator) { |
| 7033 | D(p->level--); |
| 7034 | return NULL; |
| 7035 | } |
| 7036 | D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' keyword_patterns ','? ')'")); |
| 7037 | Token * _literal; |
| 7038 | Token * _literal_1; |
| 7039 | void *_opt_var; |
| 7040 | UNUSED(_opt_var); // Silence compiler warnings |
| 7041 | expr_ty func; |
| 7042 | asdl_keyword_seq* keywords; |
| 7043 | if ( |
| 7044 | (func = name_or_attr_rule(p)) // name_or_attr |
| 7045 | && |
| 7046 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 7047 | && |
| 7048 | (keywords = keyword_patterns_rule(p)) // keyword_patterns |
| 7049 | && |
| 7050 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 7051 | && |
| 7052 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 7053 | ) |
| 7054 | { |
| 7055 | D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' keyword_patterns ','? ')'")); |
| 7056 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7057 | if (_token == NULL) { |
| 7058 | D(p->level--); |
| 7059 | return NULL; |
| 7060 | } |
| 7061 | int _end_lineno = _token->end_lineno; |
| 7062 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7063 | int _end_col_offset = _token->end_col_offset; |
| 7064 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 7065 | _res = _PyAST_Call ( func , NULL , keywords , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7066 | if (_res == NULL && PyErr_Occurred()) { |
| 7067 | p->error_indicator = 1; |
| 7068 | D(p->level--); |
| 7069 | return NULL; |
| 7070 | } |
| 7071 | goto done; |
| 7072 | } |
| 7073 | p->mark = _mark; |
| 7074 | D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 7075 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' keyword_patterns ','? ')'")); |
| 7076 | } |
| 7077 | { // name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')' |
| 7078 | if (p->error_indicator) { |
| 7079 | D(p->level--); |
| 7080 | return NULL; |
| 7081 | } |
| 7082 | D(fprintf(stderr, "%*c> class_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')'")); |
| 7083 | Token * _literal; |
| 7084 | Token * _literal_1; |
| 7085 | Token * _literal_2; |
| 7086 | void *_opt_var; |
| 7087 | UNUSED(_opt_var); // Silence compiler warnings |
| 7088 | asdl_expr_seq* args; |
| 7089 | expr_ty func; |
| 7090 | asdl_keyword_seq* keywords; |
| 7091 | if ( |
| 7092 | (func = name_or_attr_rule(p)) // name_or_attr |
| 7093 | && |
| 7094 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 7095 | && |
| 7096 | (args = positional_patterns_rule(p)) // positional_patterns |
| 7097 | && |
| 7098 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
| 7099 | && |
| 7100 | (keywords = keyword_patterns_rule(p)) // keyword_patterns |
| 7101 | && |
| 7102 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 7103 | && |
| 7104 | (_literal_2 = _PyPegen_expect_token(p, 8)) // token=')' |
| 7105 | ) |
| 7106 | { |
| 7107 | D(fprintf(stderr, "%*c+ class_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')'")); |
| 7108 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7109 | if (_token == NULL) { |
| 7110 | D(p->level--); |
| 7111 | return NULL; |
| 7112 | } |
| 7113 | int _end_lineno = _token->end_lineno; |
| 7114 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7115 | int _end_col_offset = _token->end_col_offset; |
| 7116 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 7117 | _res = _PyAST_Call ( func , args , keywords , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7118 | if (_res == NULL && PyErr_Occurred()) { |
| 7119 | p->error_indicator = 1; |
| 7120 | D(p->level--); |
| 7121 | return NULL; |
| 7122 | } |
| 7123 | goto done; |
| 7124 | } |
| 7125 | p->mark = _mark; |
| 7126 | D(fprintf(stderr, "%*c%s class_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 7127 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "name_or_attr '(' positional_patterns ',' keyword_patterns ','? ')'")); |
| 7128 | } |
| 7129 | _res = NULL; |
| 7130 | done: |
| 7131 | D(p->level--); |
| 7132 | return _res; |
| 7133 | } |
| 7134 | |
| 7135 | // positional_patterns: ','.pattern+ |
| 7136 | static asdl_expr_seq* |
| 7137 | positional_patterns_rule(Parser *p) |
| 7138 | { |
| 7139 | D(p->level++); |
| 7140 | if (p->error_indicator) { |
| 7141 | D(p->level--); |
| 7142 | return NULL; |
| 7143 | } |
| 7144 | asdl_expr_seq* _res = NULL; |
| 7145 | int _mark = p->mark; |
| 7146 | { // ','.pattern+ |
| 7147 | if (p->error_indicator) { |
| 7148 | D(p->level--); |
| 7149 | return NULL; |
| 7150 | } |
| 7151 | D(fprintf(stderr, "%*c> positional_patterns[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.pattern+")); |
| 7152 | asdl_expr_seq* args; |
| 7153 | if ( |
| 7154 | (args = (asdl_expr_seq*)_gather_62_rule(p)) // ','.pattern+ |
| 7155 | ) |
| 7156 | { |
| 7157 | D(fprintf(stderr, "%*c+ positional_patterns[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.pattern+")); |
| 7158 | _res = args; |
| 7159 | if (_res == NULL && PyErr_Occurred()) { |
| 7160 | p->error_indicator = 1; |
| 7161 | D(p->level--); |
| 7162 | return NULL; |
| 7163 | } |
| 7164 | goto done; |
| 7165 | } |
| 7166 | p->mark = _mark; |
| 7167 | D(fprintf(stderr, "%*c%s positional_patterns[%d-%d]: %s failed!\n", p->level, ' ', |
| 7168 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.pattern+")); |
| 7169 | } |
| 7170 | _res = NULL; |
| 7171 | done: |
| 7172 | D(p->level--); |
| 7173 | return _res; |
| 7174 | } |
| 7175 | |
| 7176 | // keyword_patterns: ','.keyword_pattern+ |
| 7177 | static asdl_keyword_seq* |
| 7178 | keyword_patterns_rule(Parser *p) |
| 7179 | { |
| 7180 | D(p->level++); |
| 7181 | if (p->error_indicator) { |
| 7182 | D(p->level--); |
| 7183 | return NULL; |
| 7184 | } |
| 7185 | asdl_keyword_seq* _res = NULL; |
| 7186 | int _mark = p->mark; |
| 7187 | { // ','.keyword_pattern+ |
| 7188 | if (p->error_indicator) { |
| 7189 | D(p->level--); |
| 7190 | return NULL; |
| 7191 | } |
| 7192 | D(fprintf(stderr, "%*c> keyword_patterns[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.keyword_pattern+")); |
| 7193 | asdl_keyword_seq* keywords; |
| 7194 | if ( |
| 7195 | (keywords = (asdl_keyword_seq*)_gather_64_rule(p)) // ','.keyword_pattern+ |
| 7196 | ) |
| 7197 | { |
| 7198 | D(fprintf(stderr, "%*c+ keyword_patterns[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.keyword_pattern+")); |
| 7199 | _res = keywords; |
| 7200 | if (_res == NULL && PyErr_Occurred()) { |
| 7201 | p->error_indicator = 1; |
| 7202 | D(p->level--); |
| 7203 | return NULL; |
| 7204 | } |
| 7205 | goto done; |
| 7206 | } |
| 7207 | p->mark = _mark; |
| 7208 | D(fprintf(stderr, "%*c%s keyword_patterns[%d-%d]: %s failed!\n", p->level, ' ', |
| 7209 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.keyword_pattern+")); |
| 7210 | } |
| 7211 | _res = NULL; |
| 7212 | done: |
| 7213 | D(p->level--); |
| 7214 | return _res; |
| 7215 | } |
| 7216 | |
| 7217 | // keyword_pattern: NAME '=' pattern |
| 7218 | static keyword_ty |
| 7219 | keyword_pattern_rule(Parser *p) |
| 7220 | { |
| 7221 | D(p->level++); |
| 7222 | if (p->error_indicator) { |
| 7223 | D(p->level--); |
| 7224 | return NULL; |
| 7225 | } |
| 7226 | keyword_ty _res = NULL; |
| 7227 | int _mark = p->mark; |
| 7228 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7229 | p->error_indicator = 1; |
| 7230 | D(p->level--); |
| 7231 | return NULL; |
| 7232 | } |
| 7233 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7234 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7235 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7236 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 7237 | { // NAME '=' pattern |
| 7238 | if (p->error_indicator) { |
| 7239 | D(p->level--); |
| 7240 | return NULL; |
| 7241 | } |
| 7242 | D(fprintf(stderr, "%*c> keyword_pattern[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' pattern")); |
| 7243 | Token * _literal; |
| 7244 | expr_ty arg; |
| 7245 | expr_ty value; |
| 7246 | if ( |
| 7247 | (arg = _PyPegen_name_token(p)) // NAME |
| 7248 | && |
| 7249 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 7250 | && |
| 7251 | (value = pattern_rule(p)) // pattern |
| 7252 | ) |
| 7253 | { |
| 7254 | D(fprintf(stderr, "%*c+ keyword_pattern[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' pattern")); |
| 7255 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7256 | if (_token == NULL) { |
| 7257 | D(p->level--); |
| 7258 | return NULL; |
| 7259 | } |
| 7260 | int _end_lineno = _token->end_lineno; |
| 7261 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7262 | int _end_col_offset = _token->end_col_offset; |
| 7263 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 7264 | _res = _PyAST_keyword ( arg -> v . Name . id , value , EXTRA ); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7265 | if (_res == NULL && PyErr_Occurred()) { |
| 7266 | p->error_indicator = 1; |
| 7267 | D(p->level--); |
| 7268 | return NULL; |
| 7269 | } |
| 7270 | goto done; |
| 7271 | } |
| 7272 | p->mark = _mark; |
| 7273 | D(fprintf(stderr, "%*c%s keyword_pattern[%d-%d]: %s failed!\n", p->level, ' ', |
| 7274 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' pattern")); |
| 7275 | } |
| 7276 | _res = NULL; |
| 7277 | done: |
| 7278 | D(p->level--); |
| 7279 | return _res; |
| 7280 | } |
| 7281 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7282 | // return_stmt: 'return' star_expressions? |
| 7283 | static stmt_ty |
| 7284 | return_stmt_rule(Parser *p) |
| 7285 | { |
| 7286 | D(p->level++); |
| 7287 | if (p->error_indicator) { |
| 7288 | D(p->level--); |
| 7289 | return NULL; |
| 7290 | } |
| 7291 | stmt_ty _res = NULL; |
| 7292 | int _mark = p->mark; |
| 7293 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7294 | p->error_indicator = 1; |
| 7295 | D(p->level--); |
| 7296 | return NULL; |
| 7297 | } |
| 7298 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7299 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7300 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7301 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 7302 | { // 'return' star_expressions? |
| 7303 | if (p->error_indicator) { |
| 7304 | D(p->level--); |
| 7305 | return NULL; |
| 7306 | } |
| 7307 | D(fprintf(stderr, "%*c> return_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?")); |
| 7308 | Token * _keyword; |
| 7309 | void *a; |
| 7310 | if ( |
| 7311 | (_keyword = _PyPegen_expect_token(p, 500)) // token='return' |
| 7312 | && |
| 7313 | (a = star_expressions_rule(p), 1) // star_expressions? |
| 7314 | ) |
| 7315 | { |
| 7316 | D(fprintf(stderr, "%*c+ return_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?")); |
| 7317 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7318 | if (_token == NULL) { |
| 7319 | D(p->level--); |
| 7320 | return NULL; |
| 7321 | } |
| 7322 | int _end_lineno = _token->end_lineno; |
| 7323 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7324 | int _end_col_offset = _token->end_col_offset; |
| 7325 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 7326 | _res = _PyAST_Return ( a , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7327 | if (_res == NULL && PyErr_Occurred()) { |
| 7328 | p->error_indicator = 1; |
| 7329 | D(p->level--); |
| 7330 | return NULL; |
| 7331 | } |
| 7332 | goto done; |
| 7333 | } |
| 7334 | p->mark = _mark; |
| 7335 | D(fprintf(stderr, "%*c%s return_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 7336 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'return' star_expressions?")); |
| 7337 | } |
| 7338 | _res = NULL; |
| 7339 | done: |
| 7340 | D(p->level--); |
| 7341 | return _res; |
| 7342 | } |
| 7343 | |
| 7344 | // raise_stmt: 'raise' expression ['from' expression] | 'raise' |
| 7345 | static stmt_ty |
| 7346 | raise_stmt_rule(Parser *p) |
| 7347 | { |
| 7348 | D(p->level++); |
| 7349 | if (p->error_indicator) { |
| 7350 | D(p->level--); |
| 7351 | return NULL; |
| 7352 | } |
| 7353 | stmt_ty _res = NULL; |
| 7354 | int _mark = p->mark; |
| 7355 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7356 | p->error_indicator = 1; |
| 7357 | D(p->level--); |
| 7358 | return NULL; |
| 7359 | } |
| 7360 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7361 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7362 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7363 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 7364 | { // 'raise' expression ['from' expression] |
| 7365 | if (p->error_indicator) { |
| 7366 | D(p->level--); |
| 7367 | return NULL; |
| 7368 | } |
| 7369 | D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); |
| 7370 | Token * _keyword; |
| 7371 | expr_ty a; |
| 7372 | void *b; |
| 7373 | if ( |
| 7374 | (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' |
| 7375 | && |
| 7376 | (a = expression_rule(p)) // expression |
| 7377 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7378 | (b = _tmp_66_rule(p), 1) // ['from' expression] |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7379 | ) |
| 7380 | { |
| 7381 | D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); |
| 7382 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7383 | if (_token == NULL) { |
| 7384 | D(p->level--); |
| 7385 | return NULL; |
| 7386 | } |
| 7387 | int _end_lineno = _token->end_lineno; |
| 7388 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7389 | int _end_col_offset = _token->end_col_offset; |
| 7390 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 7391 | _res = _PyAST_Raise ( a , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7392 | if (_res == NULL && PyErr_Occurred()) { |
| 7393 | p->error_indicator = 1; |
| 7394 | D(p->level--); |
| 7395 | return NULL; |
| 7396 | } |
| 7397 | goto done; |
| 7398 | } |
| 7399 | p->mark = _mark; |
| 7400 | D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 7401 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise' expression ['from' expression]")); |
| 7402 | } |
| 7403 | { // 'raise' |
| 7404 | if (p->error_indicator) { |
| 7405 | D(p->level--); |
| 7406 | return NULL; |
| 7407 | } |
| 7408 | D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise'")); |
| 7409 | Token * _keyword; |
| 7410 | if ( |
| 7411 | (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' |
| 7412 | ) |
| 7413 | { |
| 7414 | D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise'")); |
| 7415 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7416 | if (_token == NULL) { |
| 7417 | D(p->level--); |
| 7418 | return NULL; |
| 7419 | } |
| 7420 | int _end_lineno = _token->end_lineno; |
| 7421 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7422 | int _end_col_offset = _token->end_col_offset; |
| 7423 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 7424 | _res = _PyAST_Raise ( NULL , NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7425 | if (_res == NULL && PyErr_Occurred()) { |
| 7426 | p->error_indicator = 1; |
| 7427 | D(p->level--); |
| 7428 | return NULL; |
| 7429 | } |
| 7430 | goto done; |
| 7431 | } |
| 7432 | p->mark = _mark; |
| 7433 | D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 7434 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise'")); |
| 7435 | } |
| 7436 | _res = NULL; |
| 7437 | done: |
| 7438 | D(p->level--); |
| 7439 | return _res; |
| 7440 | } |
| 7441 | |
| 7442 | // function_def: decorators function_def_raw | function_def_raw |
| 7443 | static stmt_ty |
| 7444 | function_def_rule(Parser *p) |
| 7445 | { |
| 7446 | D(p->level++); |
| 7447 | if (p->error_indicator) { |
| 7448 | D(p->level--); |
| 7449 | return NULL; |
| 7450 | } |
| 7451 | stmt_ty _res = NULL; |
| 7452 | int _mark = p->mark; |
| 7453 | { // decorators function_def_raw |
| 7454 | if (p->error_indicator) { |
| 7455 | D(p->level--); |
| 7456 | return NULL; |
| 7457 | } |
| 7458 | D(fprintf(stderr, "%*c> function_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "decorators function_def_raw")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 7459 | asdl_expr_seq* d; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7460 | stmt_ty f; |
| 7461 | if ( |
| 7462 | (d = decorators_rule(p)) // decorators |
| 7463 | && |
| 7464 | (f = function_def_raw_rule(p)) // function_def_raw |
| 7465 | ) |
| 7466 | { |
| 7467 | D(fprintf(stderr, "%*c+ function_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "decorators function_def_raw")); |
| 7468 | _res = _PyPegen_function_def_decorators ( p , d , f ); |
| 7469 | if (_res == NULL && PyErr_Occurred()) { |
| 7470 | p->error_indicator = 1; |
| 7471 | D(p->level--); |
| 7472 | return NULL; |
| 7473 | } |
| 7474 | goto done; |
| 7475 | } |
| 7476 | p->mark = _mark; |
| 7477 | D(fprintf(stderr, "%*c%s function_def[%d-%d]: %s failed!\n", p->level, ' ', |
| 7478 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "decorators function_def_raw")); |
| 7479 | } |
| 7480 | { // function_def_raw |
| 7481 | if (p->error_indicator) { |
| 7482 | D(p->level--); |
| 7483 | return NULL; |
| 7484 | } |
| 7485 | D(fprintf(stderr, "%*c> function_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "function_def_raw")); |
| 7486 | stmt_ty function_def_raw_var; |
| 7487 | if ( |
| 7488 | (function_def_raw_var = function_def_raw_rule(p)) // function_def_raw |
| 7489 | ) |
| 7490 | { |
| 7491 | D(fprintf(stderr, "%*c+ function_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "function_def_raw")); |
| 7492 | _res = function_def_raw_var; |
| 7493 | goto done; |
| 7494 | } |
| 7495 | p->mark = _mark; |
| 7496 | D(fprintf(stderr, "%*c%s function_def[%d-%d]: %s failed!\n", p->level, ' ', |
| 7497 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "function_def_raw")); |
| 7498 | } |
| 7499 | _res = NULL; |
| 7500 | done: |
| 7501 | D(p->level--); |
| 7502 | return _res; |
| 7503 | } |
| 7504 | |
| 7505 | // function_def_raw: |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 7506 | // | 'def' NAME '(' params? ')' ['->' expression] &&':' func_type_comment? block |
| 7507 | // | ASYNC 'def' NAME '(' params? ')' ['->' expression] &&':' func_type_comment? block |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7508 | static stmt_ty |
| 7509 | function_def_raw_rule(Parser *p) |
| 7510 | { |
| 7511 | D(p->level++); |
| 7512 | if (p->error_indicator) { |
| 7513 | D(p->level--); |
| 7514 | return NULL; |
| 7515 | } |
| 7516 | stmt_ty _res = NULL; |
| 7517 | int _mark = p->mark; |
| 7518 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7519 | p->error_indicator = 1; |
| 7520 | D(p->level--); |
| 7521 | return NULL; |
| 7522 | } |
| 7523 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7524 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7525 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7526 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 7527 | { // 'def' NAME '(' params? ')' ['->' expression] &&':' func_type_comment? block |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7528 | if (p->error_indicator) { |
| 7529 | D(p->level--); |
| 7530 | return NULL; |
| 7531 | } |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 7532 | D(fprintf(stderr, "%*c> function_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] &&':' func_type_comment? block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7533 | Token * _keyword; |
| 7534 | Token * _literal; |
| 7535 | Token * _literal_1; |
| 7536 | Token * _literal_2; |
| 7537 | void *a; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 7538 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7539 | expr_ty n; |
| 7540 | void *params; |
| 7541 | void *tc; |
| 7542 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7543 | (_keyword = _PyPegen_expect_token(p, 526)) // token='def' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7544 | && |
| 7545 | (n = _PyPegen_name_token(p)) // NAME |
| 7546 | && |
| 7547 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 7548 | && |
| 7549 | (params = params_rule(p), 1) // params? |
| 7550 | && |
| 7551 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 7552 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7553 | (a = _tmp_67_rule(p), 1) // ['->' expression] |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7554 | && |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 7555 | (_literal_2 = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7556 | && |
| 7557 | (tc = func_type_comment_rule(p), 1) // func_type_comment? |
| 7558 | && |
| 7559 | (b = block_rule(p)) // block |
| 7560 | ) |
| 7561 | { |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 7562 | D(fprintf(stderr, "%*c+ function_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] &&':' func_type_comment? block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7563 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7564 | if (_token == NULL) { |
| 7565 | D(p->level--); |
| 7566 | return NULL; |
| 7567 | } |
| 7568 | int _end_lineno = _token->end_lineno; |
| 7569 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7570 | int _end_col_offset = _token->end_col_offset; |
| 7571 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 7572 | _res = _PyAST_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( arguments_ty , _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7573 | if (_res == NULL && PyErr_Occurred()) { |
| 7574 | p->error_indicator = 1; |
| 7575 | D(p->level--); |
| 7576 | return NULL; |
| 7577 | } |
| 7578 | goto done; |
| 7579 | } |
| 7580 | p->mark = _mark; |
| 7581 | D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 7582 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] &&':' func_type_comment? block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7583 | } |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 7584 | { // ASYNC 'def' NAME '(' params? ')' ['->' expression] &&':' func_type_comment? block |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7585 | if (p->error_indicator) { |
| 7586 | D(p->level--); |
| 7587 | return NULL; |
| 7588 | } |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 7589 | D(fprintf(stderr, "%*c> function_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] &&':' func_type_comment? block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7590 | Token * _keyword; |
| 7591 | Token * _literal; |
| 7592 | Token * _literal_1; |
| 7593 | Token * _literal_2; |
| 7594 | void *a; |
| 7595 | Token * async_var; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 7596 | asdl_stmt_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7597 | expr_ty n; |
| 7598 | void *params; |
| 7599 | void *tc; |
| 7600 | if ( |
| 7601 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
| 7602 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7603 | (_keyword = _PyPegen_expect_token(p, 526)) // token='def' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7604 | && |
| 7605 | (n = _PyPegen_name_token(p)) // NAME |
| 7606 | && |
| 7607 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 7608 | && |
| 7609 | (params = params_rule(p), 1) // params? |
| 7610 | && |
| 7611 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 7612 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7613 | (a = _tmp_68_rule(p), 1) // ['->' expression] |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7614 | && |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 7615 | (_literal_2 = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7616 | && |
| 7617 | (tc = func_type_comment_rule(p), 1) // func_type_comment? |
| 7618 | && |
| 7619 | (b = block_rule(p)) // block |
| 7620 | ) |
| 7621 | { |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 7622 | D(fprintf(stderr, "%*c+ function_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] &&':' func_type_comment? block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7623 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7624 | if (_token == NULL) { |
| 7625 | D(p->level--); |
| 7626 | return NULL; |
| 7627 | } |
| 7628 | int _end_lineno = _token->end_lineno; |
| 7629 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7630 | int _end_col_offset = _token->end_col_offset; |
| 7631 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 7632 | _res = CHECK_VERSION ( stmt_ty , 5 , "Async functions are" , _PyAST_AsyncFunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( arguments_ty , _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7633 | if (_res == NULL && PyErr_Occurred()) { |
| 7634 | p->error_indicator = 1; |
| 7635 | D(p->level--); |
| 7636 | return NULL; |
| 7637 | } |
| 7638 | goto done; |
| 7639 | } |
| 7640 | p->mark = _mark; |
| 7641 | D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 7642 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] &&':' func_type_comment? block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7643 | } |
| 7644 | _res = NULL; |
| 7645 | done: |
| 7646 | D(p->level--); |
| 7647 | return _res; |
| 7648 | } |
| 7649 | |
| 7650 | // func_type_comment: |
| 7651 | // | NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
| 7652 | // | invalid_double_type_comments |
| 7653 | // | TYPE_COMMENT |
| 7654 | static Token* |
| 7655 | func_type_comment_rule(Parser *p) |
| 7656 | { |
| 7657 | D(p->level++); |
| 7658 | if (p->error_indicator) { |
| 7659 | D(p->level--); |
| 7660 | return NULL; |
| 7661 | } |
| 7662 | Token* _res = NULL; |
| 7663 | int _mark = p->mark; |
| 7664 | { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
| 7665 | if (p->error_indicator) { |
| 7666 | D(p->level--); |
| 7667 | return NULL; |
| 7668 | } |
| 7669 | D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); |
| 7670 | Token * newline_var; |
| 7671 | Token * t; |
| 7672 | if ( |
| 7673 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 7674 | && |
| 7675 | (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
| 7676 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7677 | _PyPegen_lookahead(1, _tmp_69_rule, p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7678 | ) |
| 7679 | { |
| 7680 | D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); |
| 7681 | _res = t; |
| 7682 | if (_res == NULL && PyErr_Occurred()) { |
| 7683 | p->error_indicator = 1; |
| 7684 | D(p->level--); |
| 7685 | return NULL; |
| 7686 | } |
| 7687 | goto done; |
| 7688 | } |
| 7689 | p->mark = _mark; |
| 7690 | D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', |
| 7691 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); |
| 7692 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 7693 | if (p->call_invalid_rules) { // invalid_double_type_comments |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7694 | if (p->error_indicator) { |
| 7695 | D(p->level--); |
| 7696 | return NULL; |
| 7697 | } |
| 7698 | D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments")); |
| 7699 | void *invalid_double_type_comments_var; |
| 7700 | if ( |
| 7701 | (invalid_double_type_comments_var = invalid_double_type_comments_rule(p)) // invalid_double_type_comments |
| 7702 | ) |
| 7703 | { |
| 7704 | D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments")); |
| 7705 | _res = invalid_double_type_comments_var; |
| 7706 | goto done; |
| 7707 | } |
| 7708 | p->mark = _mark; |
| 7709 | D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', |
| 7710 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_double_type_comments")); |
| 7711 | } |
| 7712 | { // TYPE_COMMENT |
| 7713 | if (p->error_indicator) { |
| 7714 | D(p->level--); |
| 7715 | return NULL; |
| 7716 | } |
| 7717 | D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT")); |
| 7718 | Token * type_comment_var; |
| 7719 | if ( |
| 7720 | (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
| 7721 | ) |
| 7722 | { |
| 7723 | D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT")); |
| 7724 | _res = type_comment_var; |
| 7725 | goto done; |
| 7726 | } |
| 7727 | p->mark = _mark; |
| 7728 | D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', |
| 7729 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT")); |
| 7730 | } |
| 7731 | _res = NULL; |
| 7732 | done: |
| 7733 | D(p->level--); |
| 7734 | return _res; |
| 7735 | } |
| 7736 | |
| 7737 | // params: invalid_parameters | parameters |
| 7738 | static arguments_ty |
| 7739 | params_rule(Parser *p) |
| 7740 | { |
| 7741 | D(p->level++); |
| 7742 | if (p->error_indicator) { |
| 7743 | D(p->level--); |
| 7744 | return NULL; |
| 7745 | } |
| 7746 | arguments_ty _res = NULL; |
| 7747 | int _mark = p->mark; |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 7748 | if (p->call_invalid_rules) { // invalid_parameters |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7749 | if (p->error_indicator) { |
| 7750 | D(p->level--); |
| 7751 | return NULL; |
| 7752 | } |
| 7753 | D(fprintf(stderr, "%*c> params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_parameters")); |
| 7754 | void *invalid_parameters_var; |
| 7755 | if ( |
| 7756 | (invalid_parameters_var = invalid_parameters_rule(p)) // invalid_parameters |
| 7757 | ) |
| 7758 | { |
| 7759 | D(fprintf(stderr, "%*c+ params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_parameters")); |
| 7760 | _res = invalid_parameters_var; |
| 7761 | goto done; |
| 7762 | } |
| 7763 | p->mark = _mark; |
| 7764 | D(fprintf(stderr, "%*c%s params[%d-%d]: %s failed!\n", p->level, ' ', |
| 7765 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_parameters")); |
| 7766 | } |
| 7767 | { // parameters |
| 7768 | if (p->error_indicator) { |
| 7769 | D(p->level--); |
| 7770 | return NULL; |
| 7771 | } |
| 7772 | D(fprintf(stderr, "%*c> params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "parameters")); |
| 7773 | arguments_ty parameters_var; |
| 7774 | if ( |
| 7775 | (parameters_var = parameters_rule(p)) // parameters |
| 7776 | ) |
| 7777 | { |
| 7778 | D(fprintf(stderr, "%*c+ params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "parameters")); |
| 7779 | _res = parameters_var; |
| 7780 | goto done; |
| 7781 | } |
| 7782 | p->mark = _mark; |
| 7783 | D(fprintf(stderr, "%*c%s params[%d-%d]: %s failed!\n", p->level, ' ', |
| 7784 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "parameters")); |
| 7785 | } |
| 7786 | _res = NULL; |
| 7787 | done: |
| 7788 | D(p->level--); |
| 7789 | return _res; |
| 7790 | } |
| 7791 | |
| 7792 | // parameters: |
| 7793 | // | slash_no_default param_no_default* param_with_default* star_etc? |
| 7794 | // | slash_with_default param_with_default* star_etc? |
| 7795 | // | param_no_default+ param_with_default* star_etc? |
| 7796 | // | param_with_default+ star_etc? |
| 7797 | // | star_etc |
| 7798 | static arguments_ty |
| 7799 | parameters_rule(Parser *p) |
| 7800 | { |
| 7801 | D(p->level++); |
| 7802 | if (p->error_indicator) { |
| 7803 | D(p->level--); |
| 7804 | return NULL; |
| 7805 | } |
| 7806 | arguments_ty _res = NULL; |
| 7807 | int _mark = p->mark; |
| 7808 | { // slash_no_default param_no_default* param_with_default* star_etc? |
| 7809 | if (p->error_indicator) { |
| 7810 | D(p->level--); |
| 7811 | return NULL; |
| 7812 | } |
| 7813 | D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 7814 | asdl_arg_seq* a; |
| 7815 | asdl_arg_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7816 | asdl_seq * c; |
| 7817 | void *d; |
| 7818 | if ( |
| 7819 | (a = slash_no_default_rule(p)) // slash_no_default |
| 7820 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7821 | (b = (asdl_arg_seq*)_loop0_70_rule(p)) // param_no_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7822 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7823 | (c = _loop0_71_rule(p)) // param_with_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7824 | && |
| 7825 | (d = star_etc_rule(p), 1) // star_etc? |
| 7826 | ) |
| 7827 | { |
| 7828 | D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?")); |
| 7829 | _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 7830 | if (_res == NULL && PyErr_Occurred()) { |
| 7831 | p->error_indicator = 1; |
| 7832 | D(p->level--); |
| 7833 | return NULL; |
| 7834 | } |
| 7835 | goto done; |
| 7836 | } |
| 7837 | p->mark = _mark; |
| 7838 | D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 7839 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?")); |
| 7840 | } |
| 7841 | { // slash_with_default param_with_default* star_etc? |
| 7842 | if (p->error_indicator) { |
| 7843 | D(p->level--); |
| 7844 | return NULL; |
| 7845 | } |
| 7846 | D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default param_with_default* star_etc?")); |
| 7847 | SlashWithDefault* a; |
| 7848 | asdl_seq * b; |
| 7849 | void *c; |
| 7850 | if ( |
| 7851 | (a = slash_with_default_rule(p)) // slash_with_default |
| 7852 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7853 | (b = _loop0_72_rule(p)) // param_with_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7854 | && |
| 7855 | (c = star_etc_rule(p), 1) // star_etc? |
| 7856 | ) |
| 7857 | { |
| 7858 | D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default param_with_default* star_etc?")); |
| 7859 | _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 7860 | if (_res == NULL && PyErr_Occurred()) { |
| 7861 | p->error_indicator = 1; |
| 7862 | D(p->level--); |
| 7863 | return NULL; |
| 7864 | } |
| 7865 | goto done; |
| 7866 | } |
| 7867 | p->mark = _mark; |
| 7868 | D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 7869 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default param_with_default* star_etc?")); |
| 7870 | } |
| 7871 | { // param_no_default+ param_with_default* star_etc? |
| 7872 | if (p->error_indicator) { |
| 7873 | D(p->level--); |
| 7874 | return NULL; |
| 7875 | } |
| 7876 | D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ param_with_default* star_etc?")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 7877 | asdl_arg_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7878 | asdl_seq * b; |
| 7879 | void *c; |
| 7880 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7881 | (a = (asdl_arg_seq*)_loop1_73_rule(p)) // param_no_default+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7882 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7883 | (b = _loop0_74_rule(p)) // param_with_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7884 | && |
| 7885 | (c = star_etc_rule(p), 1) // star_etc? |
| 7886 | ) |
| 7887 | { |
| 7888 | D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ param_with_default* star_etc?")); |
| 7889 | _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 7890 | if (_res == NULL && PyErr_Occurred()) { |
| 7891 | p->error_indicator = 1; |
| 7892 | D(p->level--); |
| 7893 | return NULL; |
| 7894 | } |
| 7895 | goto done; |
| 7896 | } |
| 7897 | p->mark = _mark; |
| 7898 | D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 7899 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ param_with_default* star_etc?")); |
| 7900 | } |
| 7901 | { // param_with_default+ star_etc? |
| 7902 | if (p->error_indicator) { |
| 7903 | D(p->level--); |
| 7904 | return NULL; |
| 7905 | } |
| 7906 | D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+ star_etc?")); |
| 7907 | asdl_seq * a; |
| 7908 | void *b; |
| 7909 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7910 | (a = _loop1_75_rule(p)) // param_with_default+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7911 | && |
| 7912 | (b = star_etc_rule(p), 1) // star_etc? |
| 7913 | ) |
| 7914 | { |
| 7915 | D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+ star_etc?")); |
| 7916 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 7917 | if (_res == NULL && PyErr_Occurred()) { |
| 7918 | p->error_indicator = 1; |
| 7919 | D(p->level--); |
| 7920 | return NULL; |
| 7921 | } |
| 7922 | goto done; |
| 7923 | } |
| 7924 | p->mark = _mark; |
| 7925 | D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 7926 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+ star_etc?")); |
| 7927 | } |
| 7928 | { // star_etc |
| 7929 | if (p->error_indicator) { |
| 7930 | D(p->level--); |
| 7931 | return NULL; |
| 7932 | } |
| 7933 | D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_etc")); |
| 7934 | StarEtc* a; |
| 7935 | if ( |
| 7936 | (a = star_etc_rule(p)) // star_etc |
| 7937 | ) |
| 7938 | { |
| 7939 | D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_etc")); |
| 7940 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 7941 | if (_res == NULL && PyErr_Occurred()) { |
| 7942 | p->error_indicator = 1; |
| 7943 | D(p->level--); |
| 7944 | return NULL; |
| 7945 | } |
| 7946 | goto done; |
| 7947 | } |
| 7948 | p->mark = _mark; |
| 7949 | D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 7950 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_etc")); |
| 7951 | } |
| 7952 | _res = NULL; |
| 7953 | done: |
| 7954 | D(p->level--); |
| 7955 | return _res; |
| 7956 | } |
| 7957 | |
| 7958 | // slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')' |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 7959 | static asdl_arg_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7960 | slash_no_default_rule(Parser *p) |
| 7961 | { |
| 7962 | D(p->level++); |
| 7963 | if (p->error_indicator) { |
| 7964 | D(p->level--); |
| 7965 | return NULL; |
| 7966 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 7967 | asdl_arg_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7968 | int _mark = p->mark; |
| 7969 | { // param_no_default+ '/' ',' |
| 7970 | if (p->error_indicator) { |
| 7971 | D(p->level--); |
| 7972 | return NULL; |
| 7973 | } |
| 7974 | D(fprintf(stderr, "%*c> slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' ','")); |
| 7975 | Token * _literal; |
| 7976 | Token * _literal_1; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 7977 | asdl_arg_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7978 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 7979 | (a = (asdl_arg_seq*)_loop1_76_rule(p)) // param_no_default+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 7980 | && |
| 7981 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
| 7982 | && |
| 7983 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
| 7984 | ) |
| 7985 | { |
| 7986 | D(fprintf(stderr, "%*c+ slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' ','")); |
| 7987 | _res = a; |
| 7988 | if (_res == NULL && PyErr_Occurred()) { |
| 7989 | p->error_indicator = 1; |
| 7990 | D(p->level--); |
| 7991 | return NULL; |
| 7992 | } |
| 7993 | goto done; |
| 7994 | } |
| 7995 | p->mark = _mark; |
| 7996 | D(fprintf(stderr, "%*c%s slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 7997 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ '/' ','")); |
| 7998 | } |
| 7999 | { // param_no_default+ '/' &')' |
| 8000 | if (p->error_indicator) { |
| 8001 | D(p->level--); |
| 8002 | return NULL; |
| 8003 | } |
| 8004 | D(fprintf(stderr, "%*c> slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' &')'")); |
| 8005 | Token * _literal; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 8006 | asdl_arg_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8007 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 8008 | (a = (asdl_arg_seq*)_loop1_77_rule(p)) // param_no_default+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8009 | && |
| 8010 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
| 8011 | && |
| 8012 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
| 8013 | ) |
| 8014 | { |
| 8015 | D(fprintf(stderr, "%*c+ slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' &')'")); |
| 8016 | _res = a; |
| 8017 | if (_res == NULL && PyErr_Occurred()) { |
| 8018 | p->error_indicator = 1; |
| 8019 | D(p->level--); |
| 8020 | return NULL; |
| 8021 | } |
| 8022 | goto done; |
| 8023 | } |
| 8024 | p->mark = _mark; |
| 8025 | D(fprintf(stderr, "%*c%s slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 8026 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ '/' &')'")); |
| 8027 | } |
| 8028 | _res = NULL; |
| 8029 | done: |
| 8030 | D(p->level--); |
| 8031 | return _res; |
| 8032 | } |
| 8033 | |
| 8034 | // slash_with_default: |
| 8035 | // | param_no_default* param_with_default+ '/' ',' |
| 8036 | // | param_no_default* param_with_default+ '/' &')' |
| 8037 | static SlashWithDefault* |
| 8038 | slash_with_default_rule(Parser *p) |
| 8039 | { |
| 8040 | D(p->level++); |
| 8041 | if (p->error_indicator) { |
| 8042 | D(p->level--); |
| 8043 | return NULL; |
| 8044 | } |
| 8045 | SlashWithDefault* _res = NULL; |
| 8046 | int _mark = p->mark; |
| 8047 | { // param_no_default* param_with_default+ '/' ',' |
| 8048 | if (p->error_indicator) { |
| 8049 | D(p->level--); |
| 8050 | return NULL; |
| 8051 | } |
| 8052 | D(fprintf(stderr, "%*c> slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' ','")); |
| 8053 | Token * _literal; |
| 8054 | Token * _literal_1; |
| 8055 | asdl_seq * a; |
| 8056 | asdl_seq * b; |
| 8057 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 8058 | (a = _loop0_78_rule(p)) // param_no_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8059 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 8060 | (b = _loop1_79_rule(p)) // param_with_default+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8061 | && |
| 8062 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
| 8063 | && |
| 8064 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
| 8065 | ) |
| 8066 | { |
| 8067 | D(fprintf(stderr, "%*c+ slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' ','")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 8068 | _res = _PyPegen_slash_with_default ( p , ( asdl_arg_seq * ) a , b ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8069 | if (_res == NULL && PyErr_Occurred()) { |
| 8070 | p->error_indicator = 1; |
| 8071 | D(p->level--); |
| 8072 | return NULL; |
| 8073 | } |
| 8074 | goto done; |
| 8075 | } |
| 8076 | p->mark = _mark; |
| 8077 | D(fprintf(stderr, "%*c%s slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 8078 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* param_with_default+ '/' ','")); |
| 8079 | } |
| 8080 | { // param_no_default* param_with_default+ '/' &')' |
| 8081 | if (p->error_indicator) { |
| 8082 | D(p->level--); |
| 8083 | return NULL; |
| 8084 | } |
| 8085 | D(fprintf(stderr, "%*c> slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' &')'")); |
| 8086 | Token * _literal; |
| 8087 | asdl_seq * a; |
| 8088 | asdl_seq * b; |
| 8089 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 8090 | (a = _loop0_80_rule(p)) // param_no_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8091 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 8092 | (b = _loop1_81_rule(p)) // param_with_default+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8093 | && |
| 8094 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
| 8095 | && |
| 8096 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
| 8097 | ) |
| 8098 | { |
| 8099 | D(fprintf(stderr, "%*c+ slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' &')'")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 8100 | _res = _PyPegen_slash_with_default ( p , ( asdl_arg_seq * ) a , b ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8101 | if (_res == NULL && PyErr_Occurred()) { |
| 8102 | p->error_indicator = 1; |
| 8103 | D(p->level--); |
| 8104 | return NULL; |
| 8105 | } |
| 8106 | goto done; |
| 8107 | } |
| 8108 | p->mark = _mark; |
| 8109 | D(fprintf(stderr, "%*c%s slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 8110 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* param_with_default+ '/' &')'")); |
| 8111 | } |
| 8112 | _res = NULL; |
| 8113 | done: |
| 8114 | D(p->level--); |
| 8115 | return _res; |
| 8116 | } |
| 8117 | |
| 8118 | // star_etc: |
| 8119 | // | '*' param_no_default param_maybe_default* kwds? |
| 8120 | // | '*' ',' param_maybe_default+ kwds? |
| 8121 | // | kwds |
| 8122 | // | invalid_star_etc |
| 8123 | static StarEtc* |
| 8124 | star_etc_rule(Parser *p) |
| 8125 | { |
| 8126 | D(p->level++); |
| 8127 | if (p->error_indicator) { |
| 8128 | D(p->level--); |
| 8129 | return NULL; |
| 8130 | } |
| 8131 | StarEtc* _res = NULL; |
| 8132 | int _mark = p->mark; |
| 8133 | { // '*' param_no_default param_maybe_default* kwds? |
| 8134 | if (p->error_indicator) { |
| 8135 | D(p->level--); |
| 8136 | return NULL; |
| 8137 | } |
| 8138 | D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?")); |
| 8139 | Token * _literal; |
| 8140 | arg_ty a; |
| 8141 | asdl_seq * b; |
| 8142 | void *c; |
| 8143 | if ( |
| 8144 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 8145 | && |
| 8146 | (a = param_no_default_rule(p)) // param_no_default |
| 8147 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 8148 | (b = _loop0_82_rule(p)) // param_maybe_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8149 | && |
| 8150 | (c = kwds_rule(p), 1) // kwds? |
| 8151 | ) |
| 8152 | { |
| 8153 | D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?")); |
| 8154 | _res = _PyPegen_star_etc ( p , a , b , c ); |
| 8155 | if (_res == NULL && PyErr_Occurred()) { |
| 8156 | p->error_indicator = 1; |
| 8157 | D(p->level--); |
| 8158 | return NULL; |
| 8159 | } |
| 8160 | goto done; |
| 8161 | } |
| 8162 | p->mark = _mark; |
| 8163 | D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 8164 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?")); |
| 8165 | } |
| 8166 | { // '*' ',' param_maybe_default+ kwds? |
| 8167 | if (p->error_indicator) { |
| 8168 | D(p->level--); |
| 8169 | return NULL; |
| 8170 | } |
| 8171 | D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' param_maybe_default+ kwds?")); |
| 8172 | Token * _literal; |
| 8173 | Token * _literal_1; |
| 8174 | asdl_seq * b; |
| 8175 | void *c; |
| 8176 | if ( |
| 8177 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 8178 | && |
| 8179 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
| 8180 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 8181 | (b = _loop1_83_rule(p)) // param_maybe_default+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8182 | && |
| 8183 | (c = kwds_rule(p), 1) // kwds? |
| 8184 | ) |
| 8185 | { |
| 8186 | D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' param_maybe_default+ kwds?")); |
| 8187 | _res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 8188 | if (_res == NULL && PyErr_Occurred()) { |
| 8189 | p->error_indicator = 1; |
| 8190 | D(p->level--); |
| 8191 | return NULL; |
| 8192 | } |
| 8193 | goto done; |
| 8194 | } |
| 8195 | p->mark = _mark; |
| 8196 | D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 8197 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' param_maybe_default+ kwds?")); |
| 8198 | } |
| 8199 | { // kwds |
| 8200 | if (p->error_indicator) { |
| 8201 | D(p->level--); |
| 8202 | return NULL; |
| 8203 | } |
| 8204 | D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwds")); |
| 8205 | arg_ty a; |
| 8206 | if ( |
| 8207 | (a = kwds_rule(p)) // kwds |
| 8208 | ) |
| 8209 | { |
| 8210 | D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwds")); |
| 8211 | _res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 8212 | if (_res == NULL && PyErr_Occurred()) { |
| 8213 | p->error_indicator = 1; |
| 8214 | D(p->level--); |
| 8215 | return NULL; |
| 8216 | } |
| 8217 | goto done; |
| 8218 | } |
| 8219 | p->mark = _mark; |
| 8220 | D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 8221 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwds")); |
| 8222 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 8223 | if (p->call_invalid_rules) { // invalid_star_etc |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8224 | if (p->error_indicator) { |
| 8225 | D(p->level--); |
| 8226 | return NULL; |
| 8227 | } |
| 8228 | D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_star_etc")); |
| 8229 | void *invalid_star_etc_var; |
| 8230 | if ( |
| 8231 | (invalid_star_etc_var = invalid_star_etc_rule(p)) // invalid_star_etc |
| 8232 | ) |
| 8233 | { |
| 8234 | D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_star_etc")); |
| 8235 | _res = invalid_star_etc_var; |
| 8236 | goto done; |
| 8237 | } |
| 8238 | p->mark = _mark; |
| 8239 | D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 8240 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_star_etc")); |
| 8241 | } |
| 8242 | _res = NULL; |
| 8243 | done: |
| 8244 | D(p->level--); |
| 8245 | return _res; |
| 8246 | } |
| 8247 | |
| 8248 | // kwds: '**' param_no_default |
| 8249 | static arg_ty |
| 8250 | kwds_rule(Parser *p) |
| 8251 | { |
| 8252 | D(p->level++); |
| 8253 | if (p->error_indicator) { |
| 8254 | D(p->level--); |
| 8255 | return NULL; |
| 8256 | } |
| 8257 | arg_ty _res = NULL; |
| 8258 | int _mark = p->mark; |
| 8259 | { // '**' param_no_default |
| 8260 | if (p->error_indicator) { |
| 8261 | D(p->level--); |
| 8262 | return NULL; |
| 8263 | } |
| 8264 | D(fprintf(stderr, "%*c> kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' param_no_default")); |
| 8265 | Token * _literal; |
| 8266 | arg_ty a; |
| 8267 | if ( |
| 8268 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
| 8269 | && |
| 8270 | (a = param_no_default_rule(p)) // param_no_default |
| 8271 | ) |
| 8272 | { |
| 8273 | D(fprintf(stderr, "%*c+ kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' param_no_default")); |
| 8274 | _res = a; |
| 8275 | if (_res == NULL && PyErr_Occurred()) { |
| 8276 | p->error_indicator = 1; |
| 8277 | D(p->level--); |
| 8278 | return NULL; |
| 8279 | } |
| 8280 | goto done; |
| 8281 | } |
| 8282 | p->mark = _mark; |
| 8283 | D(fprintf(stderr, "%*c%s kwds[%d-%d]: %s failed!\n", p->level, ' ', |
| 8284 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' param_no_default")); |
| 8285 | } |
| 8286 | _res = NULL; |
| 8287 | done: |
| 8288 | D(p->level--); |
| 8289 | return _res; |
| 8290 | } |
| 8291 | |
| 8292 | // param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')' |
| 8293 | static arg_ty |
| 8294 | param_no_default_rule(Parser *p) |
| 8295 | { |
| 8296 | D(p->level++); |
| 8297 | if (p->error_indicator) { |
| 8298 | D(p->level--); |
| 8299 | return NULL; |
| 8300 | } |
| 8301 | arg_ty _res = NULL; |
| 8302 | int _mark = p->mark; |
| 8303 | { // param ',' TYPE_COMMENT? |
| 8304 | if (p->error_indicator) { |
| 8305 | D(p->level--); |
| 8306 | return NULL; |
| 8307 | } |
| 8308 | D(fprintf(stderr, "%*c> param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param ',' TYPE_COMMENT?")); |
| 8309 | Token * _literal; |
| 8310 | arg_ty a; |
| 8311 | void *tc; |
| 8312 | if ( |
| 8313 | (a = param_rule(p)) // param |
| 8314 | && |
| 8315 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 8316 | && |
| 8317 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
| 8318 | ) |
| 8319 | { |
| 8320 | D(fprintf(stderr, "%*c+ param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param ',' TYPE_COMMENT?")); |
| 8321 | _res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
| 8322 | if (_res == NULL && PyErr_Occurred()) { |
| 8323 | p->error_indicator = 1; |
| 8324 | D(p->level--); |
| 8325 | return NULL; |
| 8326 | } |
| 8327 | goto done; |
| 8328 | } |
| 8329 | p->mark = _mark; |
| 8330 | D(fprintf(stderr, "%*c%s param_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 8331 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param ',' TYPE_COMMENT?")); |
| 8332 | } |
| 8333 | { // param TYPE_COMMENT? &')' |
| 8334 | if (p->error_indicator) { |
| 8335 | D(p->level--); |
| 8336 | return NULL; |
| 8337 | } |
| 8338 | D(fprintf(stderr, "%*c> param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param TYPE_COMMENT? &')'")); |
| 8339 | arg_ty a; |
| 8340 | void *tc; |
| 8341 | if ( |
| 8342 | (a = param_rule(p)) // param |
| 8343 | && |
| 8344 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
| 8345 | && |
| 8346 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
| 8347 | ) |
| 8348 | { |
| 8349 | D(fprintf(stderr, "%*c+ param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param TYPE_COMMENT? &')'")); |
| 8350 | _res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
| 8351 | if (_res == NULL && PyErr_Occurred()) { |
| 8352 | p->error_indicator = 1; |
| 8353 | D(p->level--); |
| 8354 | return NULL; |
| 8355 | } |
| 8356 | goto done; |
| 8357 | } |
| 8358 | p->mark = _mark; |
| 8359 | D(fprintf(stderr, "%*c%s param_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 8360 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param TYPE_COMMENT? &')'")); |
| 8361 | } |
| 8362 | _res = NULL; |
| 8363 | done: |
| 8364 | D(p->level--); |
| 8365 | return _res; |
| 8366 | } |
| 8367 | |
| 8368 | // param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')' |
| 8369 | static NameDefaultPair* |
| 8370 | param_with_default_rule(Parser *p) |
| 8371 | { |
| 8372 | D(p->level++); |
| 8373 | if (p->error_indicator) { |
| 8374 | D(p->level--); |
| 8375 | return NULL; |
| 8376 | } |
| 8377 | NameDefaultPair* _res = NULL; |
| 8378 | int _mark = p->mark; |
| 8379 | { // param default ',' TYPE_COMMENT? |
| 8380 | if (p->error_indicator) { |
| 8381 | D(p->level--); |
| 8382 | return NULL; |
| 8383 | } |
| 8384 | D(fprintf(stderr, "%*c> param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default ',' TYPE_COMMENT?")); |
| 8385 | Token * _literal; |
| 8386 | arg_ty a; |
| 8387 | expr_ty c; |
| 8388 | void *tc; |
| 8389 | if ( |
| 8390 | (a = param_rule(p)) // param |
| 8391 | && |
| 8392 | (c = default_rule(p)) // default |
| 8393 | && |
| 8394 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 8395 | && |
| 8396 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
| 8397 | ) |
| 8398 | { |
| 8399 | D(fprintf(stderr, "%*c+ param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default ',' TYPE_COMMENT?")); |
| 8400 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 8401 | if (_res == NULL && PyErr_Occurred()) { |
| 8402 | p->error_indicator = 1; |
| 8403 | D(p->level--); |
| 8404 | return NULL; |
| 8405 | } |
| 8406 | goto done; |
| 8407 | } |
| 8408 | p->mark = _mark; |
| 8409 | D(fprintf(stderr, "%*c%s param_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 8410 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default ',' TYPE_COMMENT?")); |
| 8411 | } |
| 8412 | { // param default TYPE_COMMENT? &')' |
| 8413 | if (p->error_indicator) { |
| 8414 | D(p->level--); |
| 8415 | return NULL; |
| 8416 | } |
| 8417 | D(fprintf(stderr, "%*c> param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default TYPE_COMMENT? &')'")); |
| 8418 | arg_ty a; |
| 8419 | expr_ty c; |
| 8420 | void *tc; |
| 8421 | if ( |
| 8422 | (a = param_rule(p)) // param |
| 8423 | && |
| 8424 | (c = default_rule(p)) // default |
| 8425 | && |
| 8426 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
| 8427 | && |
| 8428 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
| 8429 | ) |
| 8430 | { |
| 8431 | D(fprintf(stderr, "%*c+ param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default TYPE_COMMENT? &')'")); |
| 8432 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 8433 | if (_res == NULL && PyErr_Occurred()) { |
| 8434 | p->error_indicator = 1; |
| 8435 | D(p->level--); |
| 8436 | return NULL; |
| 8437 | } |
| 8438 | goto done; |
| 8439 | } |
| 8440 | p->mark = _mark; |
| 8441 | D(fprintf(stderr, "%*c%s param_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 8442 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default TYPE_COMMENT? &')'")); |
| 8443 | } |
| 8444 | _res = NULL; |
| 8445 | done: |
| 8446 | D(p->level--); |
| 8447 | return _res; |
| 8448 | } |
| 8449 | |
| 8450 | // param_maybe_default: |
| 8451 | // | param default? ',' TYPE_COMMENT? |
| 8452 | // | param default? TYPE_COMMENT? &')' |
| 8453 | static NameDefaultPair* |
| 8454 | param_maybe_default_rule(Parser *p) |
| 8455 | { |
| 8456 | D(p->level++); |
| 8457 | if (p->error_indicator) { |
| 8458 | D(p->level--); |
| 8459 | return NULL; |
| 8460 | } |
| 8461 | NameDefaultPair* _res = NULL; |
| 8462 | int _mark = p->mark; |
| 8463 | { // param default? ',' TYPE_COMMENT? |
| 8464 | if (p->error_indicator) { |
| 8465 | D(p->level--); |
| 8466 | return NULL; |
| 8467 | } |
| 8468 | D(fprintf(stderr, "%*c> param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default? ',' TYPE_COMMENT?")); |
| 8469 | Token * _literal; |
| 8470 | arg_ty a; |
| 8471 | void *c; |
| 8472 | void *tc; |
| 8473 | if ( |
| 8474 | (a = param_rule(p)) // param |
| 8475 | && |
| 8476 | (c = default_rule(p), 1) // default? |
| 8477 | && |
| 8478 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 8479 | && |
| 8480 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
| 8481 | ) |
| 8482 | { |
| 8483 | D(fprintf(stderr, "%*c+ param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default? ',' TYPE_COMMENT?")); |
| 8484 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 8485 | if (_res == NULL && PyErr_Occurred()) { |
| 8486 | p->error_indicator = 1; |
| 8487 | D(p->level--); |
| 8488 | return NULL; |
| 8489 | } |
| 8490 | goto done; |
| 8491 | } |
| 8492 | p->mark = _mark; |
| 8493 | D(fprintf(stderr, "%*c%s param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 8494 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default? ',' TYPE_COMMENT?")); |
| 8495 | } |
| 8496 | { // param default? TYPE_COMMENT? &')' |
| 8497 | if (p->error_indicator) { |
| 8498 | D(p->level--); |
| 8499 | return NULL; |
| 8500 | } |
| 8501 | D(fprintf(stderr, "%*c> param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default? TYPE_COMMENT? &')'")); |
| 8502 | arg_ty a; |
| 8503 | void *c; |
| 8504 | void *tc; |
| 8505 | if ( |
| 8506 | (a = param_rule(p)) // param |
| 8507 | && |
| 8508 | (c = default_rule(p), 1) // default? |
| 8509 | && |
| 8510 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
| 8511 | && |
| 8512 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
| 8513 | ) |
| 8514 | { |
| 8515 | D(fprintf(stderr, "%*c+ param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default? TYPE_COMMENT? &')'")); |
| 8516 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 8517 | if (_res == NULL && PyErr_Occurred()) { |
| 8518 | p->error_indicator = 1; |
| 8519 | D(p->level--); |
| 8520 | return NULL; |
| 8521 | } |
| 8522 | goto done; |
| 8523 | } |
| 8524 | p->mark = _mark; |
| 8525 | D(fprintf(stderr, "%*c%s param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 8526 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default? TYPE_COMMENT? &')'")); |
| 8527 | } |
| 8528 | _res = NULL; |
| 8529 | done: |
| 8530 | D(p->level--); |
| 8531 | return _res; |
| 8532 | } |
| 8533 | |
| 8534 | // param: NAME annotation? |
| 8535 | static arg_ty |
| 8536 | param_rule(Parser *p) |
| 8537 | { |
| 8538 | D(p->level++); |
| 8539 | if (p->error_indicator) { |
| 8540 | D(p->level--); |
| 8541 | return NULL; |
| 8542 | } |
| 8543 | arg_ty _res = NULL; |
| 8544 | int _mark = p->mark; |
| 8545 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8546 | p->error_indicator = 1; |
| 8547 | D(p->level--); |
| 8548 | return NULL; |
| 8549 | } |
| 8550 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8551 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8552 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8553 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 8554 | { // NAME annotation? |
| 8555 | if (p->error_indicator) { |
| 8556 | D(p->level--); |
| 8557 | return NULL; |
| 8558 | } |
| 8559 | D(fprintf(stderr, "%*c> param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME annotation?")); |
| 8560 | expr_ty a; |
| 8561 | void *b; |
| 8562 | if ( |
| 8563 | (a = _PyPegen_name_token(p)) // NAME |
| 8564 | && |
| 8565 | (b = annotation_rule(p), 1) // annotation? |
| 8566 | ) |
| 8567 | { |
| 8568 | D(fprintf(stderr, "%*c+ param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME annotation?")); |
| 8569 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8570 | if (_token == NULL) { |
| 8571 | D(p->level--); |
| 8572 | return NULL; |
| 8573 | } |
| 8574 | int _end_lineno = _token->end_lineno; |
| 8575 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8576 | int _end_col_offset = _token->end_col_offset; |
| 8577 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 8578 | _res = _PyAST_arg ( a -> v . Name . id , b , NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8579 | if (_res == NULL && PyErr_Occurred()) { |
| 8580 | p->error_indicator = 1; |
| 8581 | D(p->level--); |
| 8582 | return NULL; |
| 8583 | } |
| 8584 | goto done; |
| 8585 | } |
| 8586 | p->mark = _mark; |
| 8587 | D(fprintf(stderr, "%*c%s param[%d-%d]: %s failed!\n", p->level, ' ', |
| 8588 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME annotation?")); |
| 8589 | } |
| 8590 | _res = NULL; |
| 8591 | done: |
| 8592 | D(p->level--); |
| 8593 | return _res; |
| 8594 | } |
| 8595 | |
| 8596 | // annotation: ':' expression |
| 8597 | static expr_ty |
| 8598 | annotation_rule(Parser *p) |
| 8599 | { |
| 8600 | D(p->level++); |
| 8601 | if (p->error_indicator) { |
| 8602 | D(p->level--); |
| 8603 | return NULL; |
| 8604 | } |
| 8605 | expr_ty _res = NULL; |
| 8606 | int _mark = p->mark; |
| 8607 | { // ':' expression |
| 8608 | if (p->error_indicator) { |
| 8609 | D(p->level--); |
| 8610 | return NULL; |
| 8611 | } |
| 8612 | D(fprintf(stderr, "%*c> annotation[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression")); |
| 8613 | Token * _literal; |
| 8614 | expr_ty a; |
| 8615 | if ( |
| 8616 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 8617 | && |
| 8618 | (a = expression_rule(p)) // expression |
| 8619 | ) |
| 8620 | { |
| 8621 | D(fprintf(stderr, "%*c+ annotation[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression")); |
| 8622 | _res = a; |
| 8623 | if (_res == NULL && PyErr_Occurred()) { |
| 8624 | p->error_indicator = 1; |
| 8625 | D(p->level--); |
| 8626 | return NULL; |
| 8627 | } |
| 8628 | goto done; |
| 8629 | } |
| 8630 | p->mark = _mark; |
| 8631 | D(fprintf(stderr, "%*c%s annotation[%d-%d]: %s failed!\n", p->level, ' ', |
| 8632 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression")); |
| 8633 | } |
| 8634 | _res = NULL; |
| 8635 | done: |
| 8636 | D(p->level--); |
| 8637 | return _res; |
| 8638 | } |
| 8639 | |
| 8640 | // default: '=' expression |
| 8641 | static expr_ty |
| 8642 | default_rule(Parser *p) |
| 8643 | { |
| 8644 | D(p->level++); |
| 8645 | if (p->error_indicator) { |
| 8646 | D(p->level--); |
| 8647 | return NULL; |
| 8648 | } |
| 8649 | expr_ty _res = NULL; |
| 8650 | int _mark = p->mark; |
| 8651 | { // '=' expression |
| 8652 | if (p->error_indicator) { |
| 8653 | D(p->level--); |
| 8654 | return NULL; |
| 8655 | } |
| 8656 | D(fprintf(stderr, "%*c> default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' expression")); |
| 8657 | Token * _literal; |
| 8658 | expr_ty a; |
| 8659 | if ( |
| 8660 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 8661 | && |
| 8662 | (a = expression_rule(p)) // expression |
| 8663 | ) |
| 8664 | { |
| 8665 | D(fprintf(stderr, "%*c+ default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' expression")); |
| 8666 | _res = a; |
| 8667 | if (_res == NULL && PyErr_Occurred()) { |
| 8668 | p->error_indicator = 1; |
| 8669 | D(p->level--); |
| 8670 | return NULL; |
| 8671 | } |
| 8672 | goto done; |
| 8673 | } |
| 8674 | p->mark = _mark; |
| 8675 | D(fprintf(stderr, "%*c%s default[%d-%d]: %s failed!\n", p->level, ' ', |
| 8676 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' expression")); |
| 8677 | } |
| 8678 | _res = NULL; |
| 8679 | done: |
| 8680 | D(p->level--); |
| 8681 | return _res; |
| 8682 | } |
| 8683 | |
| 8684 | // decorators: (('@' named_expression NEWLINE))+ |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 8685 | static asdl_expr_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8686 | decorators_rule(Parser *p) |
| 8687 | { |
| 8688 | D(p->level++); |
| 8689 | if (p->error_indicator) { |
| 8690 | D(p->level--); |
| 8691 | return NULL; |
| 8692 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 8693 | asdl_expr_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8694 | int _mark = p->mark; |
| 8695 | { // (('@' named_expression NEWLINE))+ |
| 8696 | if (p->error_indicator) { |
| 8697 | D(p->level--); |
| 8698 | return NULL; |
| 8699 | } |
| 8700 | D(fprintf(stderr, "%*c> decorators[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 8701 | asdl_expr_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8702 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 8703 | (a = (asdl_expr_seq*)_loop1_84_rule(p)) // (('@' named_expression NEWLINE))+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8704 | ) |
| 8705 | { |
| 8706 | D(fprintf(stderr, "%*c+ decorators[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); |
| 8707 | _res = a; |
| 8708 | if (_res == NULL && PyErr_Occurred()) { |
| 8709 | p->error_indicator = 1; |
| 8710 | D(p->level--); |
| 8711 | return NULL; |
| 8712 | } |
| 8713 | goto done; |
| 8714 | } |
| 8715 | p->mark = _mark; |
| 8716 | D(fprintf(stderr, "%*c%s decorators[%d-%d]: %s failed!\n", p->level, ' ', |
| 8717 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(('@' named_expression NEWLINE))+")); |
| 8718 | } |
| 8719 | _res = NULL; |
| 8720 | done: |
| 8721 | D(p->level--); |
| 8722 | return _res; |
| 8723 | } |
| 8724 | |
| 8725 | // class_def: decorators class_def_raw | class_def_raw |
| 8726 | static stmt_ty |
| 8727 | class_def_rule(Parser *p) |
| 8728 | { |
| 8729 | D(p->level++); |
| 8730 | if (p->error_indicator) { |
| 8731 | D(p->level--); |
| 8732 | return NULL; |
| 8733 | } |
| 8734 | stmt_ty _res = NULL; |
| 8735 | int _mark = p->mark; |
| 8736 | { // decorators class_def_raw |
| 8737 | if (p->error_indicator) { |
| 8738 | D(p->level--); |
| 8739 | return NULL; |
| 8740 | } |
| 8741 | D(fprintf(stderr, "%*c> class_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "decorators class_def_raw")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 8742 | asdl_expr_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8743 | stmt_ty b; |
| 8744 | if ( |
| 8745 | (a = decorators_rule(p)) // decorators |
| 8746 | && |
| 8747 | (b = class_def_raw_rule(p)) // class_def_raw |
| 8748 | ) |
| 8749 | { |
| 8750 | D(fprintf(stderr, "%*c+ class_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "decorators class_def_raw")); |
| 8751 | _res = _PyPegen_class_def_decorators ( p , a , b ); |
| 8752 | if (_res == NULL && PyErr_Occurred()) { |
| 8753 | p->error_indicator = 1; |
| 8754 | D(p->level--); |
| 8755 | return NULL; |
| 8756 | } |
| 8757 | goto done; |
| 8758 | } |
| 8759 | p->mark = _mark; |
| 8760 | D(fprintf(stderr, "%*c%s class_def[%d-%d]: %s failed!\n", p->level, ' ', |
| 8761 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "decorators class_def_raw")); |
| 8762 | } |
| 8763 | { // class_def_raw |
| 8764 | if (p->error_indicator) { |
| 8765 | D(p->level--); |
| 8766 | return NULL; |
| 8767 | } |
| 8768 | D(fprintf(stderr, "%*c> class_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "class_def_raw")); |
| 8769 | stmt_ty class_def_raw_var; |
| 8770 | if ( |
| 8771 | (class_def_raw_var = class_def_raw_rule(p)) // class_def_raw |
| 8772 | ) |
| 8773 | { |
| 8774 | D(fprintf(stderr, "%*c+ class_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "class_def_raw")); |
| 8775 | _res = class_def_raw_var; |
| 8776 | goto done; |
| 8777 | } |
| 8778 | p->mark = _mark; |
| 8779 | D(fprintf(stderr, "%*c%s class_def[%d-%d]: %s failed!\n", p->level, ' ', |
| 8780 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "class_def_raw")); |
| 8781 | } |
| 8782 | _res = NULL; |
| 8783 | done: |
| 8784 | D(p->level--); |
| 8785 | return _res; |
| 8786 | } |
| 8787 | |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 8788 | // class_def_raw: 'class' NAME ['(' arguments? ')'] &&':' block |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8789 | static stmt_ty |
| 8790 | class_def_raw_rule(Parser *p) |
| 8791 | { |
| 8792 | D(p->level++); |
| 8793 | if (p->error_indicator) { |
| 8794 | D(p->level--); |
| 8795 | return NULL; |
| 8796 | } |
| 8797 | stmt_ty _res = NULL; |
| 8798 | int _mark = p->mark; |
| 8799 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8800 | p->error_indicator = 1; |
| 8801 | D(p->level--); |
| 8802 | return NULL; |
| 8803 | } |
| 8804 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8805 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8806 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8807 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 8808 | { // 'class' NAME ['(' arguments? ')'] &&':' block |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8809 | if (p->error_indicator) { |
| 8810 | D(p->level--); |
| 8811 | return NULL; |
| 8812 | } |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 8813 | D(fprintf(stderr, "%*c> class_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class' NAME ['(' arguments? ')'] &&':' block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8814 | Token * _keyword; |
| 8815 | Token * _literal; |
| 8816 | expr_ty a; |
| 8817 | void *b; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 8818 | asdl_stmt_seq* c; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8819 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 8820 | (_keyword = _PyPegen_expect_token(p, 527)) // token='class' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8821 | && |
| 8822 | (a = _PyPegen_name_token(p)) // NAME |
| 8823 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 8824 | (b = _tmp_85_rule(p), 1) // ['(' arguments? ')'] |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8825 | && |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 8826 | (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8827 | && |
| 8828 | (c = block_rule(p)) // block |
| 8829 | ) |
| 8830 | { |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 8831 | D(fprintf(stderr, "%*c+ class_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class' NAME ['(' arguments? ')'] &&':' block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8832 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8833 | if (_token == NULL) { |
| 8834 | D(p->level--); |
| 8835 | return NULL; |
| 8836 | } |
| 8837 | int _end_lineno = _token->end_lineno; |
| 8838 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8839 | int _end_col_offset = _token->end_col_offset; |
| 8840 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 8841 | _res = _PyAST_ClassDef ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , c , NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8842 | if (_res == NULL && PyErr_Occurred()) { |
| 8843 | p->error_indicator = 1; |
| 8844 | D(p->level--); |
| 8845 | return NULL; |
| 8846 | } |
| 8847 | goto done; |
| 8848 | } |
| 8849 | p->mark = _mark; |
| 8850 | D(fprintf(stderr, "%*c%s class_def_raw[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 8851 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class' NAME ['(' arguments? ')'] &&':' block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8852 | } |
| 8853 | _res = NULL; |
| 8854 | done: |
| 8855 | D(p->level--); |
| 8856 | return _res; |
| 8857 | } |
| 8858 | |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 8859 | // block: NEWLINE INDENT statements DEDENT | simple_stmts | invalid_block |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 8860 | static asdl_stmt_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8861 | block_rule(Parser *p) |
| 8862 | { |
| 8863 | D(p->level++); |
| 8864 | if (p->error_indicator) { |
| 8865 | D(p->level--); |
| 8866 | return NULL; |
| 8867 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 8868 | asdl_stmt_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8869 | if (_PyPegen_is_memoized(p, block_type, &_res)) { |
| 8870 | D(p->level--); |
| 8871 | return _res; |
| 8872 | } |
| 8873 | int _mark = p->mark; |
| 8874 | { // NEWLINE INDENT statements DEDENT |
| 8875 | if (p->error_indicator) { |
| 8876 | D(p->level--); |
| 8877 | return NULL; |
| 8878 | } |
| 8879 | D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT statements DEDENT")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 8880 | asdl_stmt_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8881 | Token * dedent_var; |
| 8882 | Token * indent_var; |
| 8883 | Token * newline_var; |
| 8884 | if ( |
| 8885 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 8886 | && |
| 8887 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
| 8888 | && |
| 8889 | (a = statements_rule(p)) // statements |
| 8890 | && |
| 8891 | (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' |
| 8892 | ) |
| 8893 | { |
| 8894 | D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT statements DEDENT")); |
| 8895 | _res = a; |
| 8896 | if (_res == NULL && PyErr_Occurred()) { |
| 8897 | p->error_indicator = 1; |
| 8898 | D(p->level--); |
| 8899 | return NULL; |
| 8900 | } |
| 8901 | goto done; |
| 8902 | } |
| 8903 | p->mark = _mark; |
| 8904 | D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ', |
| 8905 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT statements DEDENT")); |
| 8906 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 8907 | { // simple_stmts |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8908 | if (p->error_indicator) { |
| 8909 | D(p->level--); |
| 8910 | return NULL; |
| 8911 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 8912 | D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmts")); |
| 8913 | asdl_stmt_seq* simple_stmts_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8914 | if ( |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 8915 | (simple_stmts_var = simple_stmts_rule(p)) // simple_stmts |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8916 | ) |
| 8917 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 8918 | D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmts")); |
| 8919 | _res = simple_stmts_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8920 | goto done; |
| 8921 | } |
| 8922 | p->mark = _mark; |
| 8923 | D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 8924 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmts")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8925 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 8926 | if (p->call_invalid_rules) { // invalid_block |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8927 | if (p->error_indicator) { |
| 8928 | D(p->level--); |
| 8929 | return NULL; |
| 8930 | } |
| 8931 | D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_block")); |
| 8932 | void *invalid_block_var; |
| 8933 | if ( |
| 8934 | (invalid_block_var = invalid_block_rule(p)) // invalid_block |
| 8935 | ) |
| 8936 | { |
| 8937 | D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_block")); |
| 8938 | _res = invalid_block_var; |
| 8939 | goto done; |
| 8940 | } |
| 8941 | p->mark = _mark; |
| 8942 | D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ', |
| 8943 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_block")); |
| 8944 | } |
| 8945 | _res = NULL; |
| 8946 | done: |
| 8947 | _PyPegen_insert_memo(p, _mark, block_type, _res); |
| 8948 | D(p->level--); |
| 8949 | return _res; |
| 8950 | } |
| 8951 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8952 | // star_expressions: |
| 8953 | // | star_expression ((',' star_expression))+ ','? |
| 8954 | // | star_expression ',' |
| 8955 | // | star_expression |
| 8956 | static expr_ty |
| 8957 | star_expressions_rule(Parser *p) |
| 8958 | { |
| 8959 | D(p->level++); |
| 8960 | if (p->error_indicator) { |
| 8961 | D(p->level--); |
| 8962 | return NULL; |
| 8963 | } |
| 8964 | expr_ty _res = NULL; |
| 8965 | int _mark = p->mark; |
| 8966 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8967 | p->error_indicator = 1; |
| 8968 | D(p->level--); |
| 8969 | return NULL; |
| 8970 | } |
| 8971 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8972 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8973 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8974 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 8975 | { // star_expression ((',' star_expression))+ ','? |
| 8976 | if (p->error_indicator) { |
| 8977 | D(p->level--); |
| 8978 | return NULL; |
| 8979 | } |
| 8980 | D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression ((',' star_expression))+ ','?")); |
| 8981 | void *_opt_var; |
| 8982 | UNUSED(_opt_var); // Silence compiler warnings |
| 8983 | expr_ty a; |
| 8984 | asdl_seq * b; |
| 8985 | if ( |
| 8986 | (a = star_expression_rule(p)) // star_expression |
| 8987 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 8988 | (b = _loop1_86_rule(p)) // ((',' star_expression))+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 8989 | && |
| 8990 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 8991 | ) |
| 8992 | { |
| 8993 | D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression ((',' star_expression))+ ','?")); |
| 8994 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8995 | if (_token == NULL) { |
| 8996 | D(p->level--); |
| 8997 | return NULL; |
| 8998 | } |
| 8999 | int _end_lineno = _token->end_lineno; |
| 9000 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9001 | int _end_col_offset = _token->end_col_offset; |
| 9002 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 9003 | _res = _PyAST_Tuple ( CHECK ( asdl_expr_seq * , _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9004 | if (_res == NULL && PyErr_Occurred()) { |
| 9005 | p->error_indicator = 1; |
| 9006 | D(p->level--); |
| 9007 | return NULL; |
| 9008 | } |
| 9009 | goto done; |
| 9010 | } |
| 9011 | p->mark = _mark; |
| 9012 | D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 9013 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression ((',' star_expression))+ ','?")); |
| 9014 | } |
| 9015 | { // star_expression ',' |
| 9016 | if (p->error_indicator) { |
| 9017 | D(p->level--); |
| 9018 | return NULL; |
| 9019 | } |
| 9020 | D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression ','")); |
| 9021 | Token * _literal; |
| 9022 | expr_ty a; |
| 9023 | if ( |
| 9024 | (a = star_expression_rule(p)) // star_expression |
| 9025 | && |
| 9026 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 9027 | ) |
| 9028 | { |
| 9029 | D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression ','")); |
| 9030 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9031 | if (_token == NULL) { |
| 9032 | D(p->level--); |
| 9033 | return NULL; |
| 9034 | } |
| 9035 | int _end_lineno = _token->end_lineno; |
| 9036 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9037 | int _end_col_offset = _token->end_col_offset; |
| 9038 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 9039 | _res = _PyAST_Tuple ( CHECK ( asdl_expr_seq * , _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9040 | if (_res == NULL && PyErr_Occurred()) { |
| 9041 | p->error_indicator = 1; |
| 9042 | D(p->level--); |
| 9043 | return NULL; |
| 9044 | } |
| 9045 | goto done; |
| 9046 | } |
| 9047 | p->mark = _mark; |
| 9048 | D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 9049 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression ','")); |
| 9050 | } |
| 9051 | { // star_expression |
| 9052 | if (p->error_indicator) { |
| 9053 | D(p->level--); |
| 9054 | return NULL; |
| 9055 | } |
| 9056 | D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression")); |
| 9057 | expr_ty star_expression_var; |
| 9058 | if ( |
| 9059 | (star_expression_var = star_expression_rule(p)) // star_expression |
| 9060 | ) |
| 9061 | { |
| 9062 | D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression")); |
| 9063 | _res = star_expression_var; |
| 9064 | goto done; |
| 9065 | } |
| 9066 | p->mark = _mark; |
| 9067 | D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 9068 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression")); |
| 9069 | } |
| 9070 | _res = NULL; |
| 9071 | done: |
| 9072 | D(p->level--); |
| 9073 | return _res; |
| 9074 | } |
| 9075 | |
| 9076 | // star_expression: '*' bitwise_or | expression |
| 9077 | static expr_ty |
| 9078 | star_expression_rule(Parser *p) |
| 9079 | { |
| 9080 | D(p->level++); |
| 9081 | if (p->error_indicator) { |
| 9082 | D(p->level--); |
| 9083 | return NULL; |
| 9084 | } |
| 9085 | expr_ty _res = NULL; |
| 9086 | if (_PyPegen_is_memoized(p, star_expression_type, &_res)) { |
| 9087 | D(p->level--); |
| 9088 | return _res; |
| 9089 | } |
| 9090 | int _mark = p->mark; |
| 9091 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9092 | p->error_indicator = 1; |
| 9093 | D(p->level--); |
| 9094 | return NULL; |
| 9095 | } |
| 9096 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9097 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9098 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9099 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 9100 | { // '*' bitwise_or |
| 9101 | if (p->error_indicator) { |
| 9102 | D(p->level--); |
| 9103 | return NULL; |
| 9104 | } |
| 9105 | D(fprintf(stderr, "%*c> star_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); |
| 9106 | Token * _literal; |
| 9107 | expr_ty a; |
| 9108 | if ( |
| 9109 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 9110 | && |
| 9111 | (a = bitwise_or_rule(p)) // bitwise_or |
| 9112 | ) |
| 9113 | { |
| 9114 | D(fprintf(stderr, "%*c+ star_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); |
| 9115 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9116 | if (_token == NULL) { |
| 9117 | D(p->level--); |
| 9118 | return NULL; |
| 9119 | } |
| 9120 | int _end_lineno = _token->end_lineno; |
| 9121 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9122 | int _end_col_offset = _token->end_col_offset; |
| 9123 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 9124 | _res = _PyAST_Starred ( a , Load , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9125 | if (_res == NULL && PyErr_Occurred()) { |
| 9126 | p->error_indicator = 1; |
| 9127 | D(p->level--); |
| 9128 | return NULL; |
| 9129 | } |
| 9130 | goto done; |
| 9131 | } |
| 9132 | p->mark = _mark; |
| 9133 | D(fprintf(stderr, "%*c%s star_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 9134 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' bitwise_or")); |
| 9135 | } |
| 9136 | { // expression |
| 9137 | if (p->error_indicator) { |
| 9138 | D(p->level--); |
| 9139 | return NULL; |
| 9140 | } |
| 9141 | D(fprintf(stderr, "%*c> star_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression")); |
| 9142 | expr_ty expression_var; |
| 9143 | if ( |
| 9144 | (expression_var = expression_rule(p)) // expression |
| 9145 | ) |
| 9146 | { |
| 9147 | D(fprintf(stderr, "%*c+ star_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression")); |
| 9148 | _res = expression_var; |
| 9149 | goto done; |
| 9150 | } |
| 9151 | p->mark = _mark; |
| 9152 | D(fprintf(stderr, "%*c%s star_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 9153 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression")); |
| 9154 | } |
| 9155 | _res = NULL; |
| 9156 | done: |
| 9157 | _PyPegen_insert_memo(p, _mark, star_expression_type, _res); |
| 9158 | D(p->level--); |
| 9159 | return _res; |
| 9160 | } |
| 9161 | |
| 9162 | // star_named_expressions: ','.star_named_expression+ ','? |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 9163 | static asdl_expr_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9164 | star_named_expressions_rule(Parser *p) |
| 9165 | { |
| 9166 | D(p->level++); |
| 9167 | if (p->error_indicator) { |
| 9168 | D(p->level--); |
| 9169 | return NULL; |
| 9170 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 9171 | asdl_expr_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9172 | int _mark = p->mark; |
| 9173 | { // ','.star_named_expression+ ','? |
| 9174 | if (p->error_indicator) { |
| 9175 | D(p->level--); |
| 9176 | return NULL; |
| 9177 | } |
| 9178 | D(fprintf(stderr, "%*c> star_named_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_named_expression+ ','?")); |
| 9179 | void *_opt_var; |
| 9180 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 9181 | asdl_expr_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9182 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 9183 | (a = (asdl_expr_seq*)_gather_87_rule(p)) // ','.star_named_expression+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9184 | && |
| 9185 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 9186 | ) |
| 9187 | { |
| 9188 | D(fprintf(stderr, "%*c+ star_named_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_named_expression+ ','?")); |
| 9189 | _res = a; |
| 9190 | if (_res == NULL && PyErr_Occurred()) { |
| 9191 | p->error_indicator = 1; |
| 9192 | D(p->level--); |
| 9193 | return NULL; |
| 9194 | } |
| 9195 | goto done; |
| 9196 | } |
| 9197 | p->mark = _mark; |
| 9198 | D(fprintf(stderr, "%*c%s star_named_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 9199 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_named_expression+ ','?")); |
| 9200 | } |
| 9201 | _res = NULL; |
| 9202 | done: |
| 9203 | D(p->level--); |
| 9204 | return _res; |
| 9205 | } |
| 9206 | |
| 9207 | // star_named_expression: '*' bitwise_or | named_expression |
| 9208 | static expr_ty |
| 9209 | star_named_expression_rule(Parser *p) |
| 9210 | { |
| 9211 | D(p->level++); |
| 9212 | if (p->error_indicator) { |
| 9213 | D(p->level--); |
| 9214 | return NULL; |
| 9215 | } |
| 9216 | expr_ty _res = NULL; |
| 9217 | int _mark = p->mark; |
| 9218 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9219 | p->error_indicator = 1; |
| 9220 | D(p->level--); |
| 9221 | return NULL; |
| 9222 | } |
| 9223 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9224 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9225 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9226 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 9227 | { // '*' bitwise_or |
| 9228 | if (p->error_indicator) { |
| 9229 | D(p->level--); |
| 9230 | return NULL; |
| 9231 | } |
| 9232 | D(fprintf(stderr, "%*c> star_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); |
| 9233 | Token * _literal; |
| 9234 | expr_ty a; |
| 9235 | if ( |
| 9236 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 9237 | && |
| 9238 | (a = bitwise_or_rule(p)) // bitwise_or |
| 9239 | ) |
| 9240 | { |
| 9241 | D(fprintf(stderr, "%*c+ star_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); |
| 9242 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9243 | if (_token == NULL) { |
| 9244 | D(p->level--); |
| 9245 | return NULL; |
| 9246 | } |
| 9247 | int _end_lineno = _token->end_lineno; |
| 9248 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9249 | int _end_col_offset = _token->end_col_offset; |
| 9250 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 9251 | _res = _PyAST_Starred ( a , Load , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9252 | if (_res == NULL && PyErr_Occurred()) { |
| 9253 | p->error_indicator = 1; |
| 9254 | D(p->level--); |
| 9255 | return NULL; |
| 9256 | } |
| 9257 | goto done; |
| 9258 | } |
| 9259 | p->mark = _mark; |
| 9260 | D(fprintf(stderr, "%*c%s star_named_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 9261 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' bitwise_or")); |
| 9262 | } |
| 9263 | { // named_expression |
| 9264 | if (p->error_indicator) { |
| 9265 | D(p->level--); |
| 9266 | return NULL; |
| 9267 | } |
| 9268 | D(fprintf(stderr, "%*c> star_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); |
| 9269 | expr_ty named_expression_var; |
| 9270 | if ( |
| 9271 | (named_expression_var = named_expression_rule(p)) // named_expression |
| 9272 | ) |
| 9273 | { |
| 9274 | D(fprintf(stderr, "%*c+ star_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); |
| 9275 | _res = named_expression_var; |
| 9276 | goto done; |
| 9277 | } |
| 9278 | p->mark = _mark; |
| 9279 | D(fprintf(stderr, "%*c%s star_named_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 9280 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); |
| 9281 | } |
| 9282 | _res = NULL; |
| 9283 | done: |
| 9284 | D(p->level--); |
| 9285 | return _res; |
| 9286 | } |
| 9287 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 9288 | // named_expression: NAME ':=' ~ expression | invalid_named_expression | expression !':=' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9289 | static expr_ty |
| 9290 | named_expression_rule(Parser *p) |
| 9291 | { |
| 9292 | D(p->level++); |
| 9293 | if (p->error_indicator) { |
| 9294 | D(p->level--); |
| 9295 | return NULL; |
| 9296 | } |
| 9297 | expr_ty _res = NULL; |
| 9298 | int _mark = p->mark; |
| 9299 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9300 | p->error_indicator = 1; |
| 9301 | D(p->level--); |
| 9302 | return NULL; |
| 9303 | } |
| 9304 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9305 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9306 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9307 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 9308 | { // NAME ':=' ~ expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9309 | if (p->error_indicator) { |
| 9310 | D(p->level--); |
| 9311 | return NULL; |
| 9312 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 9313 | D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':=' ~ expression")); |
| 9314 | int _cut_var = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9315 | Token * _literal; |
| 9316 | expr_ty a; |
| 9317 | expr_ty b; |
| 9318 | if ( |
| 9319 | (a = _PyPegen_name_token(p)) // NAME |
| 9320 | && |
| 9321 | (_literal = _PyPegen_expect_token(p, 53)) // token=':=' |
| 9322 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 9323 | (_cut_var = 1) |
| 9324 | && |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9325 | (b = expression_rule(p)) // expression |
| 9326 | ) |
| 9327 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 9328 | D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ':=' ~ expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9329 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9330 | if (_token == NULL) { |
| 9331 | D(p->level--); |
| 9332 | return NULL; |
| 9333 | } |
| 9334 | int _end_lineno = _token->end_lineno; |
| 9335 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9336 | int _end_col_offset = _token->end_col_offset; |
| 9337 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 9338 | _res = _PyAST_NamedExpr ( CHECK ( expr_ty , _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9339 | if (_res == NULL && PyErr_Occurred()) { |
| 9340 | p->error_indicator = 1; |
| 9341 | D(p->level--); |
| 9342 | return NULL; |
| 9343 | } |
| 9344 | goto done; |
| 9345 | } |
| 9346 | p->mark = _mark; |
| 9347 | D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 9348 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':=' ~ expression")); |
| 9349 | if (_cut_var) { |
| 9350 | D(p->level--); |
| 9351 | return NULL; |
| 9352 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9353 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 9354 | if (p->call_invalid_rules) { // invalid_named_expression |
| 9355 | if (p->error_indicator) { |
| 9356 | D(p->level--); |
| 9357 | return NULL; |
| 9358 | } |
| 9359 | D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_named_expression")); |
| 9360 | void *invalid_named_expression_var; |
| 9361 | if ( |
| 9362 | (invalid_named_expression_var = invalid_named_expression_rule(p)) // invalid_named_expression |
| 9363 | ) |
| 9364 | { |
| 9365 | D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_named_expression")); |
| 9366 | _res = invalid_named_expression_var; |
| 9367 | goto done; |
| 9368 | } |
| 9369 | p->mark = _mark; |
| 9370 | D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 9371 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_named_expression")); |
| 9372 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9373 | { // expression !':=' |
| 9374 | if (p->error_indicator) { |
| 9375 | D(p->level--); |
| 9376 | return NULL; |
| 9377 | } |
| 9378 | D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); |
| 9379 | expr_ty expression_var; |
| 9380 | if ( |
| 9381 | (expression_var = expression_rule(p)) // expression |
| 9382 | && |
| 9383 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' |
| 9384 | ) |
| 9385 | { |
| 9386 | D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); |
| 9387 | _res = expression_var; |
| 9388 | goto done; |
| 9389 | } |
| 9390 | p->mark = _mark; |
| 9391 | D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 9392 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); |
| 9393 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9394 | _res = NULL; |
| 9395 | done: |
| 9396 | D(p->level--); |
| 9397 | return _res; |
| 9398 | } |
| 9399 | |
| 9400 | // annotated_rhs: yield_expr | star_expressions |
| 9401 | static expr_ty |
| 9402 | annotated_rhs_rule(Parser *p) |
| 9403 | { |
| 9404 | D(p->level++); |
| 9405 | if (p->error_indicator) { |
| 9406 | D(p->level--); |
| 9407 | return NULL; |
| 9408 | } |
| 9409 | expr_ty _res = NULL; |
| 9410 | int _mark = p->mark; |
| 9411 | { // yield_expr |
| 9412 | if (p->error_indicator) { |
| 9413 | D(p->level--); |
| 9414 | return NULL; |
| 9415 | } |
| 9416 | D(fprintf(stderr, "%*c> annotated_rhs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
| 9417 | expr_ty yield_expr_var; |
| 9418 | if ( |
| 9419 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
| 9420 | ) |
| 9421 | { |
| 9422 | D(fprintf(stderr, "%*c+ annotated_rhs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
| 9423 | _res = yield_expr_var; |
| 9424 | goto done; |
| 9425 | } |
| 9426 | p->mark = _mark; |
| 9427 | D(fprintf(stderr, "%*c%s annotated_rhs[%d-%d]: %s failed!\n", p->level, ' ', |
| 9428 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); |
| 9429 | } |
| 9430 | { // star_expressions |
| 9431 | if (p->error_indicator) { |
| 9432 | D(p->level--); |
| 9433 | return NULL; |
| 9434 | } |
| 9435 | D(fprintf(stderr, "%*c> annotated_rhs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
| 9436 | expr_ty star_expressions_var; |
| 9437 | if ( |
| 9438 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
| 9439 | ) |
| 9440 | { |
| 9441 | D(fprintf(stderr, "%*c+ annotated_rhs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
| 9442 | _res = star_expressions_var; |
| 9443 | goto done; |
| 9444 | } |
| 9445 | p->mark = _mark; |
| 9446 | D(fprintf(stderr, "%*c%s annotated_rhs[%d-%d]: %s failed!\n", p->level, ' ', |
| 9447 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); |
| 9448 | } |
| 9449 | _res = NULL; |
| 9450 | done: |
| 9451 | D(p->level--); |
| 9452 | return _res; |
| 9453 | } |
| 9454 | |
| 9455 | // expressions: expression ((',' expression))+ ','? | expression ',' | expression |
| 9456 | static expr_ty |
| 9457 | expressions_rule(Parser *p) |
| 9458 | { |
| 9459 | D(p->level++); |
| 9460 | if (p->error_indicator) { |
| 9461 | D(p->level--); |
| 9462 | return NULL; |
| 9463 | } |
| 9464 | expr_ty _res = NULL; |
| 9465 | int _mark = p->mark; |
| 9466 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9467 | p->error_indicator = 1; |
| 9468 | D(p->level--); |
| 9469 | return NULL; |
| 9470 | } |
| 9471 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9472 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9473 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9474 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 9475 | { // expression ((',' expression))+ ','? |
| 9476 | if (p->error_indicator) { |
| 9477 | D(p->level--); |
| 9478 | return NULL; |
| 9479 | } |
| 9480 | D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ((',' expression))+ ','?")); |
| 9481 | void *_opt_var; |
| 9482 | UNUSED(_opt_var); // Silence compiler warnings |
| 9483 | expr_ty a; |
| 9484 | asdl_seq * b; |
| 9485 | if ( |
| 9486 | (a = expression_rule(p)) // expression |
| 9487 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 9488 | (b = _loop1_89_rule(p)) // ((',' expression))+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9489 | && |
| 9490 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 9491 | ) |
| 9492 | { |
| 9493 | D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ((',' expression))+ ','?")); |
| 9494 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9495 | if (_token == NULL) { |
| 9496 | D(p->level--); |
| 9497 | return NULL; |
| 9498 | } |
| 9499 | int _end_lineno = _token->end_lineno; |
| 9500 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9501 | int _end_col_offset = _token->end_col_offset; |
| 9502 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 9503 | _res = _PyAST_Tuple ( CHECK ( asdl_expr_seq * , _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9504 | if (_res == NULL && PyErr_Occurred()) { |
| 9505 | p->error_indicator = 1; |
| 9506 | D(p->level--); |
| 9507 | return NULL; |
| 9508 | } |
| 9509 | goto done; |
| 9510 | } |
| 9511 | p->mark = _mark; |
| 9512 | D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 9513 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ((',' expression))+ ','?")); |
| 9514 | } |
| 9515 | { // expression ',' |
| 9516 | if (p->error_indicator) { |
| 9517 | D(p->level--); |
| 9518 | return NULL; |
| 9519 | } |
| 9520 | D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ','")); |
| 9521 | Token * _literal; |
| 9522 | expr_ty a; |
| 9523 | if ( |
| 9524 | (a = expression_rule(p)) // expression |
| 9525 | && |
| 9526 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 9527 | ) |
| 9528 | { |
| 9529 | D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ','")); |
| 9530 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9531 | if (_token == NULL) { |
| 9532 | D(p->level--); |
| 9533 | return NULL; |
| 9534 | } |
| 9535 | int _end_lineno = _token->end_lineno; |
| 9536 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9537 | int _end_col_offset = _token->end_col_offset; |
| 9538 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 9539 | _res = _PyAST_Tuple ( CHECK ( asdl_expr_seq * , _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9540 | if (_res == NULL && PyErr_Occurred()) { |
| 9541 | p->error_indicator = 1; |
| 9542 | D(p->level--); |
| 9543 | return NULL; |
| 9544 | } |
| 9545 | goto done; |
| 9546 | } |
| 9547 | p->mark = _mark; |
| 9548 | D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 9549 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ','")); |
| 9550 | } |
| 9551 | { // expression |
| 9552 | if (p->error_indicator) { |
| 9553 | D(p->level--); |
| 9554 | return NULL; |
| 9555 | } |
| 9556 | D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression")); |
| 9557 | expr_ty expression_var; |
| 9558 | if ( |
| 9559 | (expression_var = expression_rule(p)) // expression |
| 9560 | ) |
| 9561 | { |
| 9562 | D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression")); |
| 9563 | _res = expression_var; |
| 9564 | goto done; |
| 9565 | } |
| 9566 | p->mark = _mark; |
| 9567 | D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 9568 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression")); |
| 9569 | } |
| 9570 | _res = NULL; |
| 9571 | done: |
| 9572 | D(p->level--); |
| 9573 | return _res; |
| 9574 | } |
| 9575 | |
| 9576 | // expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef |
| 9577 | static expr_ty |
| 9578 | expression_rule(Parser *p) |
| 9579 | { |
| 9580 | D(p->level++); |
| 9581 | if (p->error_indicator) { |
| 9582 | D(p->level--); |
| 9583 | return NULL; |
| 9584 | } |
| 9585 | expr_ty _res = NULL; |
| 9586 | if (_PyPegen_is_memoized(p, expression_type, &_res)) { |
| 9587 | D(p->level--); |
| 9588 | return _res; |
| 9589 | } |
| 9590 | int _mark = p->mark; |
| 9591 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9592 | p->error_indicator = 1; |
| 9593 | D(p->level--); |
| 9594 | return NULL; |
| 9595 | } |
| 9596 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9597 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9598 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9599 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 9600 | { // disjunction 'if' disjunction 'else' expression |
| 9601 | if (p->error_indicator) { |
| 9602 | D(p->level--); |
| 9603 | return NULL; |
| 9604 | } |
| 9605 | D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); |
| 9606 | Token * _keyword; |
| 9607 | Token * _keyword_1; |
| 9608 | expr_ty a; |
| 9609 | expr_ty b; |
| 9610 | expr_ty c; |
| 9611 | if ( |
| 9612 | (a = disjunction_rule(p)) // disjunction |
| 9613 | && |
| 9614 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
| 9615 | && |
| 9616 | (b = disjunction_rule(p)) // disjunction |
| 9617 | && |
| 9618 | (_keyword_1 = _PyPegen_expect_token(p, 516)) // token='else' |
| 9619 | && |
| 9620 | (c = expression_rule(p)) // expression |
| 9621 | ) |
| 9622 | { |
| 9623 | D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); |
| 9624 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9625 | if (_token == NULL) { |
| 9626 | D(p->level--); |
| 9627 | return NULL; |
| 9628 | } |
| 9629 | int _end_lineno = _token->end_lineno; |
| 9630 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9631 | int _end_col_offset = _token->end_col_offset; |
| 9632 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 9633 | _res = _PyAST_IfExp ( b , a , c , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9634 | if (_res == NULL && PyErr_Occurred()) { |
| 9635 | p->error_indicator = 1; |
| 9636 | D(p->level--); |
| 9637 | return NULL; |
| 9638 | } |
| 9639 | goto done; |
| 9640 | } |
| 9641 | p->mark = _mark; |
| 9642 | D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 9643 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); |
| 9644 | } |
| 9645 | { // disjunction |
| 9646 | if (p->error_indicator) { |
| 9647 | D(p->level--); |
| 9648 | return NULL; |
| 9649 | } |
| 9650 | D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction")); |
| 9651 | expr_ty disjunction_var; |
| 9652 | if ( |
| 9653 | (disjunction_var = disjunction_rule(p)) // disjunction |
| 9654 | ) |
| 9655 | { |
| 9656 | D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction")); |
| 9657 | _res = disjunction_var; |
| 9658 | goto done; |
| 9659 | } |
| 9660 | p->mark = _mark; |
| 9661 | D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 9662 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction")); |
| 9663 | } |
| 9664 | { // lambdef |
| 9665 | if (p->error_indicator) { |
| 9666 | D(p->level--); |
| 9667 | return NULL; |
| 9668 | } |
| 9669 | D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambdef")); |
| 9670 | expr_ty lambdef_var; |
| 9671 | if ( |
| 9672 | (lambdef_var = lambdef_rule(p)) // lambdef |
| 9673 | ) |
| 9674 | { |
| 9675 | D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambdef")); |
| 9676 | _res = lambdef_var; |
| 9677 | goto done; |
| 9678 | } |
| 9679 | p->mark = _mark; |
| 9680 | D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 9681 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambdef")); |
| 9682 | } |
| 9683 | _res = NULL; |
| 9684 | done: |
| 9685 | _PyPegen_insert_memo(p, _mark, expression_type, _res); |
| 9686 | D(p->level--); |
| 9687 | return _res; |
| 9688 | } |
| 9689 | |
| 9690 | // lambdef: 'lambda' lambda_params? ':' expression |
| 9691 | static expr_ty |
| 9692 | lambdef_rule(Parser *p) |
| 9693 | { |
| 9694 | D(p->level++); |
| 9695 | if (p->error_indicator) { |
| 9696 | D(p->level--); |
| 9697 | return NULL; |
| 9698 | } |
| 9699 | expr_ty _res = NULL; |
| 9700 | int _mark = p->mark; |
| 9701 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9702 | p->error_indicator = 1; |
| 9703 | D(p->level--); |
| 9704 | return NULL; |
| 9705 | } |
| 9706 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9707 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9708 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9709 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 9710 | { // 'lambda' lambda_params? ':' expression |
| 9711 | if (p->error_indicator) { |
| 9712 | D(p->level--); |
| 9713 | return NULL; |
| 9714 | } |
| 9715 | D(fprintf(stderr, "%*c> lambdef[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' expression")); |
| 9716 | Token * _keyword; |
| 9717 | Token * _literal; |
| 9718 | void *a; |
| 9719 | expr_ty b; |
| 9720 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 9721 | (_keyword = _PyPegen_expect_token(p, 528)) // token='lambda' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9722 | && |
| 9723 | (a = lambda_params_rule(p), 1) // lambda_params? |
| 9724 | && |
| 9725 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 9726 | && |
| 9727 | (b = expression_rule(p)) // expression |
| 9728 | ) |
| 9729 | { |
| 9730 | D(fprintf(stderr, "%*c+ lambdef[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' expression")); |
| 9731 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9732 | if (_token == NULL) { |
| 9733 | D(p->level--); |
| 9734 | return NULL; |
| 9735 | } |
| 9736 | int _end_lineno = _token->end_lineno; |
| 9737 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9738 | int _end_col_offset = _token->end_col_offset; |
| 9739 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 9740 | _res = _PyAST_Lambda ( ( a ) ? a : CHECK ( arguments_ty , _PyPegen_empty_arguments ( p ) ) , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9741 | if (_res == NULL && PyErr_Occurred()) { |
| 9742 | p->error_indicator = 1; |
| 9743 | D(p->level--); |
| 9744 | return NULL; |
| 9745 | } |
| 9746 | goto done; |
| 9747 | } |
| 9748 | p->mark = _mark; |
| 9749 | D(fprintf(stderr, "%*c%s lambdef[%d-%d]: %s failed!\n", p->level, ' ', |
| 9750 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'lambda' lambda_params? ':' expression")); |
| 9751 | } |
| 9752 | _res = NULL; |
| 9753 | done: |
| 9754 | D(p->level--); |
| 9755 | return _res; |
| 9756 | } |
| 9757 | |
| 9758 | // lambda_params: invalid_lambda_parameters | lambda_parameters |
| 9759 | static arguments_ty |
| 9760 | lambda_params_rule(Parser *p) |
| 9761 | { |
| 9762 | D(p->level++); |
| 9763 | if (p->error_indicator) { |
| 9764 | D(p->level--); |
| 9765 | return NULL; |
| 9766 | } |
| 9767 | arguments_ty _res = NULL; |
| 9768 | int _mark = p->mark; |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 9769 | if (p->call_invalid_rules) { // invalid_lambda_parameters |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9770 | if (p->error_indicator) { |
| 9771 | D(p->level--); |
| 9772 | return NULL; |
| 9773 | } |
| 9774 | D(fprintf(stderr, "%*c> lambda_params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_lambda_parameters")); |
| 9775 | void *invalid_lambda_parameters_var; |
| 9776 | if ( |
| 9777 | (invalid_lambda_parameters_var = invalid_lambda_parameters_rule(p)) // invalid_lambda_parameters |
| 9778 | ) |
| 9779 | { |
| 9780 | D(fprintf(stderr, "%*c+ lambda_params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_lambda_parameters")); |
| 9781 | _res = invalid_lambda_parameters_var; |
| 9782 | goto done; |
| 9783 | } |
| 9784 | p->mark = _mark; |
| 9785 | D(fprintf(stderr, "%*c%s lambda_params[%d-%d]: %s failed!\n", p->level, ' ', |
| 9786 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_lambda_parameters")); |
| 9787 | } |
| 9788 | { // lambda_parameters |
| 9789 | if (p->error_indicator) { |
| 9790 | D(p->level--); |
| 9791 | return NULL; |
| 9792 | } |
| 9793 | D(fprintf(stderr, "%*c> lambda_params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_parameters")); |
| 9794 | arguments_ty lambda_parameters_var; |
| 9795 | if ( |
| 9796 | (lambda_parameters_var = lambda_parameters_rule(p)) // lambda_parameters |
| 9797 | ) |
| 9798 | { |
| 9799 | D(fprintf(stderr, "%*c+ lambda_params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_parameters")); |
| 9800 | _res = lambda_parameters_var; |
| 9801 | goto done; |
| 9802 | } |
| 9803 | p->mark = _mark; |
| 9804 | D(fprintf(stderr, "%*c%s lambda_params[%d-%d]: %s failed!\n", p->level, ' ', |
| 9805 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_parameters")); |
| 9806 | } |
| 9807 | _res = NULL; |
| 9808 | done: |
| 9809 | D(p->level--); |
| 9810 | return _res; |
| 9811 | } |
| 9812 | |
| 9813 | // lambda_parameters: |
| 9814 | // | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? |
| 9815 | // | lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
| 9816 | // | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
| 9817 | // | lambda_param_with_default+ lambda_star_etc? |
| 9818 | // | lambda_star_etc |
| 9819 | static arguments_ty |
| 9820 | lambda_parameters_rule(Parser *p) |
| 9821 | { |
| 9822 | D(p->level++); |
| 9823 | if (p->error_indicator) { |
| 9824 | D(p->level--); |
| 9825 | return NULL; |
| 9826 | } |
| 9827 | arguments_ty _res = NULL; |
| 9828 | int _mark = p->mark; |
| 9829 | { // lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? |
| 9830 | if (p->error_indicator) { |
| 9831 | D(p->level--); |
| 9832 | return NULL; |
| 9833 | } |
| 9834 | D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 9835 | asdl_arg_seq* a; |
| 9836 | asdl_arg_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9837 | asdl_seq * c; |
| 9838 | void *d; |
| 9839 | if ( |
| 9840 | (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default |
| 9841 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 9842 | (b = (asdl_arg_seq*)_loop0_90_rule(p)) // lambda_param_no_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9843 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 9844 | (c = _loop0_91_rule(p)) // lambda_param_with_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9845 | && |
| 9846 | (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
| 9847 | ) |
| 9848 | { |
| 9849 | D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?")); |
| 9850 | _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 9851 | if (_res == NULL && PyErr_Occurred()) { |
| 9852 | p->error_indicator = 1; |
| 9853 | D(p->level--); |
| 9854 | return NULL; |
| 9855 | } |
| 9856 | goto done; |
| 9857 | } |
| 9858 | p->mark = _mark; |
| 9859 | D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 9860 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?")); |
| 9861 | } |
| 9862 | { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
| 9863 | if (p->error_indicator) { |
| 9864 | D(p->level--); |
| 9865 | return NULL; |
| 9866 | } |
| 9867 | D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?")); |
| 9868 | SlashWithDefault* a; |
| 9869 | asdl_seq * b; |
| 9870 | void *c; |
| 9871 | if ( |
| 9872 | (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default |
| 9873 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 9874 | (b = _loop0_92_rule(p)) // lambda_param_with_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9875 | && |
| 9876 | (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
| 9877 | ) |
| 9878 | { |
| 9879 | D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?")); |
| 9880 | _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 9881 | if (_res == NULL && PyErr_Occurred()) { |
| 9882 | p->error_indicator = 1; |
| 9883 | D(p->level--); |
| 9884 | return NULL; |
| 9885 | } |
| 9886 | goto done; |
| 9887 | } |
| 9888 | p->mark = _mark; |
| 9889 | D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 9890 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?")); |
| 9891 | } |
| 9892 | { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
| 9893 | if (p->error_indicator) { |
| 9894 | D(p->level--); |
| 9895 | return NULL; |
| 9896 | } |
| 9897 | D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 9898 | asdl_arg_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9899 | asdl_seq * b; |
| 9900 | void *c; |
| 9901 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 9902 | (a = (asdl_arg_seq*)_loop1_93_rule(p)) // lambda_param_no_default+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9903 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 9904 | (b = _loop0_94_rule(p)) // lambda_param_with_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9905 | && |
| 9906 | (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
| 9907 | ) |
| 9908 | { |
| 9909 | D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?")); |
| 9910 | _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 9911 | if (_res == NULL && PyErr_Occurred()) { |
| 9912 | p->error_indicator = 1; |
| 9913 | D(p->level--); |
| 9914 | return NULL; |
| 9915 | } |
| 9916 | goto done; |
| 9917 | } |
| 9918 | p->mark = _mark; |
| 9919 | D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 9920 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?")); |
| 9921 | } |
| 9922 | { // lambda_param_with_default+ lambda_star_etc? |
| 9923 | if (p->error_indicator) { |
| 9924 | D(p->level--); |
| 9925 | return NULL; |
| 9926 | } |
| 9927 | D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?")); |
| 9928 | asdl_seq * a; |
| 9929 | void *b; |
| 9930 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 9931 | (a = _loop1_95_rule(p)) // lambda_param_with_default+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9932 | && |
| 9933 | (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
| 9934 | ) |
| 9935 | { |
| 9936 | D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?")); |
| 9937 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 9938 | if (_res == NULL && PyErr_Occurred()) { |
| 9939 | p->error_indicator = 1; |
| 9940 | D(p->level--); |
| 9941 | return NULL; |
| 9942 | } |
| 9943 | goto done; |
| 9944 | } |
| 9945 | p->mark = _mark; |
| 9946 | D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 9947 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?")); |
| 9948 | } |
| 9949 | { // lambda_star_etc |
| 9950 | if (p->error_indicator) { |
| 9951 | D(p->level--); |
| 9952 | return NULL; |
| 9953 | } |
| 9954 | D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_star_etc")); |
| 9955 | StarEtc* a; |
| 9956 | if ( |
| 9957 | (a = lambda_star_etc_rule(p)) // lambda_star_etc |
| 9958 | ) |
| 9959 | { |
| 9960 | D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_star_etc")); |
| 9961 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 9962 | if (_res == NULL && PyErr_Occurred()) { |
| 9963 | p->error_indicator = 1; |
| 9964 | D(p->level--); |
| 9965 | return NULL; |
| 9966 | } |
| 9967 | goto done; |
| 9968 | } |
| 9969 | p->mark = _mark; |
| 9970 | D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 9971 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_star_etc")); |
| 9972 | } |
| 9973 | _res = NULL; |
| 9974 | done: |
| 9975 | D(p->level--); |
| 9976 | return _res; |
| 9977 | } |
| 9978 | |
| 9979 | // lambda_slash_no_default: |
| 9980 | // | lambda_param_no_default+ '/' ',' |
| 9981 | // | lambda_param_no_default+ '/' &':' |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 9982 | static asdl_arg_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9983 | lambda_slash_no_default_rule(Parser *p) |
| 9984 | { |
| 9985 | D(p->level++); |
| 9986 | if (p->error_indicator) { |
| 9987 | D(p->level--); |
| 9988 | return NULL; |
| 9989 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 9990 | asdl_arg_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 9991 | int _mark = p->mark; |
| 9992 | { // lambda_param_no_default+ '/' ',' |
| 9993 | if (p->error_indicator) { |
| 9994 | D(p->level--); |
| 9995 | return NULL; |
| 9996 | } |
| 9997 | D(fprintf(stderr, "%*c> lambda_slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' ','")); |
| 9998 | Token * _literal; |
| 9999 | Token * _literal_1; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 10000 | asdl_arg_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10001 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 10002 | (a = (asdl_arg_seq*)_loop1_96_rule(p)) // lambda_param_no_default+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10003 | && |
| 10004 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
| 10005 | && |
| 10006 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
| 10007 | ) |
| 10008 | { |
| 10009 | D(fprintf(stderr, "%*c+ lambda_slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' ','")); |
| 10010 | _res = a; |
| 10011 | if (_res == NULL && PyErr_Occurred()) { |
| 10012 | p->error_indicator = 1; |
| 10013 | D(p->level--); |
| 10014 | return NULL; |
| 10015 | } |
| 10016 | goto done; |
| 10017 | } |
| 10018 | p->mark = _mark; |
| 10019 | D(fprintf(stderr, "%*c%s lambda_slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 10020 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ '/' ','")); |
| 10021 | } |
| 10022 | { // lambda_param_no_default+ '/' &':' |
| 10023 | if (p->error_indicator) { |
| 10024 | D(p->level--); |
| 10025 | return NULL; |
| 10026 | } |
| 10027 | D(fprintf(stderr, "%*c> lambda_slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' &':'")); |
| 10028 | Token * _literal; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 10029 | asdl_arg_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10030 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 10031 | (a = (asdl_arg_seq*)_loop1_97_rule(p)) // lambda_param_no_default+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10032 | && |
| 10033 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
| 10034 | && |
| 10035 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
| 10036 | ) |
| 10037 | { |
| 10038 | D(fprintf(stderr, "%*c+ lambda_slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' &':'")); |
| 10039 | _res = a; |
| 10040 | if (_res == NULL && PyErr_Occurred()) { |
| 10041 | p->error_indicator = 1; |
| 10042 | D(p->level--); |
| 10043 | return NULL; |
| 10044 | } |
| 10045 | goto done; |
| 10046 | } |
| 10047 | p->mark = _mark; |
| 10048 | D(fprintf(stderr, "%*c%s lambda_slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 10049 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ '/' &':'")); |
| 10050 | } |
| 10051 | _res = NULL; |
| 10052 | done: |
| 10053 | D(p->level--); |
| 10054 | return _res; |
| 10055 | } |
| 10056 | |
| 10057 | // lambda_slash_with_default: |
| 10058 | // | lambda_param_no_default* lambda_param_with_default+ '/' ',' |
| 10059 | // | lambda_param_no_default* lambda_param_with_default+ '/' &':' |
| 10060 | static SlashWithDefault* |
| 10061 | lambda_slash_with_default_rule(Parser *p) |
| 10062 | { |
| 10063 | D(p->level++); |
| 10064 | if (p->error_indicator) { |
| 10065 | D(p->level--); |
| 10066 | return NULL; |
| 10067 | } |
| 10068 | SlashWithDefault* _res = NULL; |
| 10069 | int _mark = p->mark; |
| 10070 | { // lambda_param_no_default* lambda_param_with_default+ '/' ',' |
| 10071 | if (p->error_indicator) { |
| 10072 | D(p->level--); |
| 10073 | return NULL; |
| 10074 | } |
| 10075 | D(fprintf(stderr, "%*c> lambda_slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','")); |
| 10076 | Token * _literal; |
| 10077 | Token * _literal_1; |
| 10078 | asdl_seq * a; |
| 10079 | asdl_seq * b; |
| 10080 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 10081 | (a = _loop0_98_rule(p)) // lambda_param_no_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10082 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 10083 | (b = _loop1_99_rule(p)) // lambda_param_with_default+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10084 | && |
| 10085 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
| 10086 | && |
| 10087 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
| 10088 | ) |
| 10089 | { |
| 10090 | D(fprintf(stderr, "%*c+ lambda_slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 10091 | _res = _PyPegen_slash_with_default ( p , ( asdl_arg_seq * ) a , b ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10092 | if (_res == NULL && PyErr_Occurred()) { |
| 10093 | p->error_indicator = 1; |
| 10094 | D(p->level--); |
| 10095 | return NULL; |
| 10096 | } |
| 10097 | goto done; |
| 10098 | } |
| 10099 | p->mark = _mark; |
| 10100 | D(fprintf(stderr, "%*c%s lambda_slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 10101 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','")); |
| 10102 | } |
| 10103 | { // lambda_param_no_default* lambda_param_with_default+ '/' &':' |
| 10104 | if (p->error_indicator) { |
| 10105 | D(p->level--); |
| 10106 | return NULL; |
| 10107 | } |
| 10108 | D(fprintf(stderr, "%*c> lambda_slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'")); |
| 10109 | Token * _literal; |
| 10110 | asdl_seq * a; |
| 10111 | asdl_seq * b; |
| 10112 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 10113 | (a = _loop0_100_rule(p)) // lambda_param_no_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10114 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 10115 | (b = _loop1_101_rule(p)) // lambda_param_with_default+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10116 | && |
| 10117 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
| 10118 | && |
| 10119 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
| 10120 | ) |
| 10121 | { |
| 10122 | D(fprintf(stderr, "%*c+ lambda_slash_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 10123 | _res = _PyPegen_slash_with_default ( p , ( asdl_arg_seq * ) a , b ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10124 | if (_res == NULL && PyErr_Occurred()) { |
| 10125 | p->error_indicator = 1; |
| 10126 | D(p->level--); |
| 10127 | return NULL; |
| 10128 | } |
| 10129 | goto done; |
| 10130 | } |
| 10131 | p->mark = _mark; |
| 10132 | D(fprintf(stderr, "%*c%s lambda_slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 10133 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'")); |
| 10134 | } |
| 10135 | _res = NULL; |
| 10136 | done: |
| 10137 | D(p->level--); |
| 10138 | return _res; |
| 10139 | } |
| 10140 | |
| 10141 | // lambda_star_etc: |
| 10142 | // | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
| 10143 | // | '*' ',' lambda_param_maybe_default+ lambda_kwds? |
| 10144 | // | lambda_kwds |
| 10145 | // | invalid_lambda_star_etc |
| 10146 | static StarEtc* |
| 10147 | lambda_star_etc_rule(Parser *p) |
| 10148 | { |
| 10149 | D(p->level++); |
| 10150 | if (p->error_indicator) { |
| 10151 | D(p->level--); |
| 10152 | return NULL; |
| 10153 | } |
| 10154 | StarEtc* _res = NULL; |
| 10155 | int _mark = p->mark; |
| 10156 | { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
| 10157 | if (p->error_indicator) { |
| 10158 | D(p->level--); |
| 10159 | return NULL; |
| 10160 | } |
| 10161 | D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?")); |
| 10162 | Token * _literal; |
| 10163 | arg_ty a; |
| 10164 | asdl_seq * b; |
| 10165 | void *c; |
| 10166 | if ( |
| 10167 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 10168 | && |
| 10169 | (a = lambda_param_no_default_rule(p)) // lambda_param_no_default |
| 10170 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 10171 | (b = _loop0_102_rule(p)) // lambda_param_maybe_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10172 | && |
| 10173 | (c = lambda_kwds_rule(p), 1) // lambda_kwds? |
| 10174 | ) |
| 10175 | { |
| 10176 | D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?")); |
| 10177 | _res = _PyPegen_star_etc ( p , a , b , c ); |
| 10178 | if (_res == NULL && PyErr_Occurred()) { |
| 10179 | p->error_indicator = 1; |
| 10180 | D(p->level--); |
| 10181 | return NULL; |
| 10182 | } |
| 10183 | goto done; |
| 10184 | } |
| 10185 | p->mark = _mark; |
| 10186 | D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 10187 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?")); |
| 10188 | } |
| 10189 | { // '*' ',' lambda_param_maybe_default+ lambda_kwds? |
| 10190 | if (p->error_indicator) { |
| 10191 | D(p->level--); |
| 10192 | return NULL; |
| 10193 | } |
| 10194 | D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?")); |
| 10195 | Token * _literal; |
| 10196 | Token * _literal_1; |
| 10197 | asdl_seq * b; |
| 10198 | void *c; |
| 10199 | if ( |
| 10200 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 10201 | && |
| 10202 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
| 10203 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 10204 | (b = _loop1_103_rule(p)) // lambda_param_maybe_default+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10205 | && |
| 10206 | (c = lambda_kwds_rule(p), 1) // lambda_kwds? |
| 10207 | ) |
| 10208 | { |
| 10209 | D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?")); |
| 10210 | _res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 10211 | if (_res == NULL && PyErr_Occurred()) { |
| 10212 | p->error_indicator = 1; |
| 10213 | D(p->level--); |
| 10214 | return NULL; |
| 10215 | } |
| 10216 | goto done; |
| 10217 | } |
| 10218 | p->mark = _mark; |
| 10219 | D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 10220 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?")); |
| 10221 | } |
| 10222 | { // lambda_kwds |
| 10223 | if (p->error_indicator) { |
| 10224 | D(p->level--); |
| 10225 | return NULL; |
| 10226 | } |
| 10227 | D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_kwds")); |
| 10228 | arg_ty a; |
| 10229 | if ( |
| 10230 | (a = lambda_kwds_rule(p)) // lambda_kwds |
| 10231 | ) |
| 10232 | { |
| 10233 | D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_kwds")); |
| 10234 | _res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 10235 | if (_res == NULL && PyErr_Occurred()) { |
| 10236 | p->error_indicator = 1; |
| 10237 | D(p->level--); |
| 10238 | return NULL; |
| 10239 | } |
| 10240 | goto done; |
| 10241 | } |
| 10242 | p->mark = _mark; |
| 10243 | D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 10244 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_kwds")); |
| 10245 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 10246 | if (p->call_invalid_rules) { // invalid_lambda_star_etc |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10247 | if (p->error_indicator) { |
| 10248 | D(p->level--); |
| 10249 | return NULL; |
| 10250 | } |
| 10251 | D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_lambda_star_etc")); |
| 10252 | void *invalid_lambda_star_etc_var; |
| 10253 | if ( |
| 10254 | (invalid_lambda_star_etc_var = invalid_lambda_star_etc_rule(p)) // invalid_lambda_star_etc |
| 10255 | ) |
| 10256 | { |
| 10257 | D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_lambda_star_etc")); |
| 10258 | _res = invalid_lambda_star_etc_var; |
| 10259 | goto done; |
| 10260 | } |
| 10261 | p->mark = _mark; |
| 10262 | D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 10263 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_lambda_star_etc")); |
| 10264 | } |
| 10265 | _res = NULL; |
| 10266 | done: |
| 10267 | D(p->level--); |
| 10268 | return _res; |
| 10269 | } |
| 10270 | |
| 10271 | // lambda_kwds: '**' lambda_param_no_default |
| 10272 | static arg_ty |
| 10273 | lambda_kwds_rule(Parser *p) |
| 10274 | { |
| 10275 | D(p->level++); |
| 10276 | if (p->error_indicator) { |
| 10277 | D(p->level--); |
| 10278 | return NULL; |
| 10279 | } |
| 10280 | arg_ty _res = NULL; |
| 10281 | int _mark = p->mark; |
| 10282 | { // '**' lambda_param_no_default |
| 10283 | if (p->error_indicator) { |
| 10284 | D(p->level--); |
| 10285 | return NULL; |
| 10286 | } |
| 10287 | D(fprintf(stderr, "%*c> lambda_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' lambda_param_no_default")); |
| 10288 | Token * _literal; |
| 10289 | arg_ty a; |
| 10290 | if ( |
| 10291 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
| 10292 | && |
| 10293 | (a = lambda_param_no_default_rule(p)) // lambda_param_no_default |
| 10294 | ) |
| 10295 | { |
| 10296 | D(fprintf(stderr, "%*c+ lambda_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' lambda_param_no_default")); |
| 10297 | _res = a; |
| 10298 | if (_res == NULL && PyErr_Occurred()) { |
| 10299 | p->error_indicator = 1; |
| 10300 | D(p->level--); |
| 10301 | return NULL; |
| 10302 | } |
| 10303 | goto done; |
| 10304 | } |
| 10305 | p->mark = _mark; |
| 10306 | D(fprintf(stderr, "%*c%s lambda_kwds[%d-%d]: %s failed!\n", p->level, ' ', |
| 10307 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' lambda_param_no_default")); |
| 10308 | } |
| 10309 | _res = NULL; |
| 10310 | done: |
| 10311 | D(p->level--); |
| 10312 | return _res; |
| 10313 | } |
| 10314 | |
| 10315 | // lambda_param_no_default: lambda_param ',' | lambda_param &':' |
| 10316 | static arg_ty |
| 10317 | lambda_param_no_default_rule(Parser *p) |
| 10318 | { |
| 10319 | D(p->level++); |
| 10320 | if (p->error_indicator) { |
| 10321 | D(p->level--); |
| 10322 | return NULL; |
| 10323 | } |
| 10324 | arg_ty _res = NULL; |
| 10325 | int _mark = p->mark; |
| 10326 | { // lambda_param ',' |
| 10327 | if (p->error_indicator) { |
| 10328 | D(p->level--); |
| 10329 | return NULL; |
| 10330 | } |
| 10331 | D(fprintf(stderr, "%*c> lambda_param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param ','")); |
| 10332 | Token * _literal; |
| 10333 | arg_ty a; |
| 10334 | if ( |
| 10335 | (a = lambda_param_rule(p)) // lambda_param |
| 10336 | && |
| 10337 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 10338 | ) |
| 10339 | { |
| 10340 | D(fprintf(stderr, "%*c+ lambda_param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param ','")); |
| 10341 | _res = a; |
| 10342 | if (_res == NULL && PyErr_Occurred()) { |
| 10343 | p->error_indicator = 1; |
| 10344 | D(p->level--); |
| 10345 | return NULL; |
| 10346 | } |
| 10347 | goto done; |
| 10348 | } |
| 10349 | p->mark = _mark; |
| 10350 | D(fprintf(stderr, "%*c%s lambda_param_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 10351 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param ','")); |
| 10352 | } |
| 10353 | { // lambda_param &':' |
| 10354 | if (p->error_indicator) { |
| 10355 | D(p->level--); |
| 10356 | return NULL; |
| 10357 | } |
| 10358 | D(fprintf(stderr, "%*c> lambda_param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param &':'")); |
| 10359 | arg_ty a; |
| 10360 | if ( |
| 10361 | (a = lambda_param_rule(p)) // lambda_param |
| 10362 | && |
| 10363 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
| 10364 | ) |
| 10365 | { |
| 10366 | D(fprintf(stderr, "%*c+ lambda_param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param &':'")); |
| 10367 | _res = a; |
| 10368 | if (_res == NULL && PyErr_Occurred()) { |
| 10369 | p->error_indicator = 1; |
| 10370 | D(p->level--); |
| 10371 | return NULL; |
| 10372 | } |
| 10373 | goto done; |
| 10374 | } |
| 10375 | p->mark = _mark; |
| 10376 | D(fprintf(stderr, "%*c%s lambda_param_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 10377 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param &':'")); |
| 10378 | } |
| 10379 | _res = NULL; |
| 10380 | done: |
| 10381 | D(p->level--); |
| 10382 | return _res; |
| 10383 | } |
| 10384 | |
| 10385 | // lambda_param_with_default: lambda_param default ',' | lambda_param default &':' |
| 10386 | static NameDefaultPair* |
| 10387 | lambda_param_with_default_rule(Parser *p) |
| 10388 | { |
| 10389 | D(p->level++); |
| 10390 | if (p->error_indicator) { |
| 10391 | D(p->level--); |
| 10392 | return NULL; |
| 10393 | } |
| 10394 | NameDefaultPair* _res = NULL; |
| 10395 | int _mark = p->mark; |
| 10396 | { // lambda_param default ',' |
| 10397 | if (p->error_indicator) { |
| 10398 | D(p->level--); |
| 10399 | return NULL; |
| 10400 | } |
| 10401 | D(fprintf(stderr, "%*c> lambda_param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default ','")); |
| 10402 | Token * _literal; |
| 10403 | arg_ty a; |
| 10404 | expr_ty c; |
| 10405 | if ( |
| 10406 | (a = lambda_param_rule(p)) // lambda_param |
| 10407 | && |
| 10408 | (c = default_rule(p)) // default |
| 10409 | && |
| 10410 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 10411 | ) |
| 10412 | { |
| 10413 | D(fprintf(stderr, "%*c+ lambda_param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default ','")); |
| 10414 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 10415 | if (_res == NULL && PyErr_Occurred()) { |
| 10416 | p->error_indicator = 1; |
| 10417 | D(p->level--); |
| 10418 | return NULL; |
| 10419 | } |
| 10420 | goto done; |
| 10421 | } |
| 10422 | p->mark = _mark; |
| 10423 | D(fprintf(stderr, "%*c%s lambda_param_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 10424 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default ','")); |
| 10425 | } |
| 10426 | { // lambda_param default &':' |
| 10427 | if (p->error_indicator) { |
| 10428 | D(p->level--); |
| 10429 | return NULL; |
| 10430 | } |
| 10431 | D(fprintf(stderr, "%*c> lambda_param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default &':'")); |
| 10432 | arg_ty a; |
| 10433 | expr_ty c; |
| 10434 | if ( |
| 10435 | (a = lambda_param_rule(p)) // lambda_param |
| 10436 | && |
| 10437 | (c = default_rule(p)) // default |
| 10438 | && |
| 10439 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
| 10440 | ) |
| 10441 | { |
| 10442 | D(fprintf(stderr, "%*c+ lambda_param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default &':'")); |
| 10443 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 10444 | if (_res == NULL && PyErr_Occurred()) { |
| 10445 | p->error_indicator = 1; |
| 10446 | D(p->level--); |
| 10447 | return NULL; |
| 10448 | } |
| 10449 | goto done; |
| 10450 | } |
| 10451 | p->mark = _mark; |
| 10452 | D(fprintf(stderr, "%*c%s lambda_param_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 10453 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default &':'")); |
| 10454 | } |
| 10455 | _res = NULL; |
| 10456 | done: |
| 10457 | D(p->level--); |
| 10458 | return _res; |
| 10459 | } |
| 10460 | |
| 10461 | // lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':' |
| 10462 | static NameDefaultPair* |
| 10463 | lambda_param_maybe_default_rule(Parser *p) |
| 10464 | { |
| 10465 | D(p->level++); |
| 10466 | if (p->error_indicator) { |
| 10467 | D(p->level--); |
| 10468 | return NULL; |
| 10469 | } |
| 10470 | NameDefaultPair* _res = NULL; |
| 10471 | int _mark = p->mark; |
| 10472 | { // lambda_param default? ',' |
| 10473 | if (p->error_indicator) { |
| 10474 | D(p->level--); |
| 10475 | return NULL; |
| 10476 | } |
| 10477 | D(fprintf(stderr, "%*c> lambda_param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default? ','")); |
| 10478 | Token * _literal; |
| 10479 | arg_ty a; |
| 10480 | void *c; |
| 10481 | if ( |
| 10482 | (a = lambda_param_rule(p)) // lambda_param |
| 10483 | && |
| 10484 | (c = default_rule(p), 1) // default? |
| 10485 | && |
| 10486 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 10487 | ) |
| 10488 | { |
| 10489 | D(fprintf(stderr, "%*c+ lambda_param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default? ','")); |
| 10490 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 10491 | if (_res == NULL && PyErr_Occurred()) { |
| 10492 | p->error_indicator = 1; |
| 10493 | D(p->level--); |
| 10494 | return NULL; |
| 10495 | } |
| 10496 | goto done; |
| 10497 | } |
| 10498 | p->mark = _mark; |
| 10499 | D(fprintf(stderr, "%*c%s lambda_param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 10500 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default? ','")); |
| 10501 | } |
| 10502 | { // lambda_param default? &':' |
| 10503 | if (p->error_indicator) { |
| 10504 | D(p->level--); |
| 10505 | return NULL; |
| 10506 | } |
| 10507 | D(fprintf(stderr, "%*c> lambda_param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default? &':'")); |
| 10508 | arg_ty a; |
| 10509 | void *c; |
| 10510 | if ( |
| 10511 | (a = lambda_param_rule(p)) // lambda_param |
| 10512 | && |
| 10513 | (c = default_rule(p), 1) // default? |
| 10514 | && |
| 10515 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
| 10516 | ) |
| 10517 | { |
| 10518 | D(fprintf(stderr, "%*c+ lambda_param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default? &':'")); |
| 10519 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 10520 | if (_res == NULL && PyErr_Occurred()) { |
| 10521 | p->error_indicator = 1; |
| 10522 | D(p->level--); |
| 10523 | return NULL; |
| 10524 | } |
| 10525 | goto done; |
| 10526 | } |
| 10527 | p->mark = _mark; |
| 10528 | D(fprintf(stderr, "%*c%s lambda_param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 10529 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default? &':'")); |
| 10530 | } |
| 10531 | _res = NULL; |
| 10532 | done: |
| 10533 | D(p->level--); |
| 10534 | return _res; |
| 10535 | } |
| 10536 | |
| 10537 | // lambda_param: NAME |
| 10538 | static arg_ty |
| 10539 | lambda_param_rule(Parser *p) |
| 10540 | { |
| 10541 | D(p->level++); |
| 10542 | if (p->error_indicator) { |
| 10543 | D(p->level--); |
| 10544 | return NULL; |
| 10545 | } |
| 10546 | arg_ty _res = NULL; |
| 10547 | int _mark = p->mark; |
| 10548 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10549 | p->error_indicator = 1; |
| 10550 | D(p->level--); |
| 10551 | return NULL; |
| 10552 | } |
| 10553 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10554 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10555 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10556 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 10557 | { // NAME |
| 10558 | if (p->error_indicator) { |
| 10559 | D(p->level--); |
| 10560 | return NULL; |
| 10561 | } |
| 10562 | D(fprintf(stderr, "%*c> lambda_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); |
| 10563 | expr_ty a; |
| 10564 | if ( |
| 10565 | (a = _PyPegen_name_token(p)) // NAME |
| 10566 | ) |
| 10567 | { |
| 10568 | D(fprintf(stderr, "%*c+ lambda_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); |
| 10569 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10570 | if (_token == NULL) { |
| 10571 | D(p->level--); |
| 10572 | return NULL; |
| 10573 | } |
| 10574 | int _end_lineno = _token->end_lineno; |
| 10575 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10576 | int _end_col_offset = _token->end_col_offset; |
| 10577 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 10578 | _res = _PyAST_arg ( a -> v . Name . id , NULL , NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10579 | if (_res == NULL && PyErr_Occurred()) { |
| 10580 | p->error_indicator = 1; |
| 10581 | D(p->level--); |
| 10582 | return NULL; |
| 10583 | } |
| 10584 | goto done; |
| 10585 | } |
| 10586 | p->mark = _mark; |
| 10587 | D(fprintf(stderr, "%*c%s lambda_param[%d-%d]: %s failed!\n", p->level, ' ', |
| 10588 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); |
| 10589 | } |
| 10590 | _res = NULL; |
| 10591 | done: |
| 10592 | D(p->level--); |
| 10593 | return _res; |
| 10594 | } |
| 10595 | |
| 10596 | // disjunction: conjunction (('or' conjunction))+ | conjunction |
| 10597 | static expr_ty |
| 10598 | disjunction_rule(Parser *p) |
| 10599 | { |
| 10600 | D(p->level++); |
| 10601 | if (p->error_indicator) { |
| 10602 | D(p->level--); |
| 10603 | return NULL; |
| 10604 | } |
| 10605 | expr_ty _res = NULL; |
| 10606 | if (_PyPegen_is_memoized(p, disjunction_type, &_res)) { |
| 10607 | D(p->level--); |
| 10608 | return _res; |
| 10609 | } |
| 10610 | int _mark = p->mark; |
| 10611 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10612 | p->error_indicator = 1; |
| 10613 | D(p->level--); |
| 10614 | return NULL; |
| 10615 | } |
| 10616 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10617 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10618 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10619 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 10620 | { // conjunction (('or' conjunction))+ |
| 10621 | if (p->error_indicator) { |
| 10622 | D(p->level--); |
| 10623 | return NULL; |
| 10624 | } |
| 10625 | D(fprintf(stderr, "%*c> disjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); |
| 10626 | expr_ty a; |
| 10627 | asdl_seq * b; |
| 10628 | if ( |
| 10629 | (a = conjunction_rule(p)) // conjunction |
| 10630 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 10631 | (b = _loop1_104_rule(p)) // (('or' conjunction))+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10632 | ) |
| 10633 | { |
| 10634 | D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); |
| 10635 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10636 | if (_token == NULL) { |
| 10637 | D(p->level--); |
| 10638 | return NULL; |
| 10639 | } |
| 10640 | int _end_lineno = _token->end_lineno; |
| 10641 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10642 | int _end_col_offset = _token->end_col_offset; |
| 10643 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 10644 | _res = _PyAST_BoolOp ( Or , CHECK ( asdl_expr_seq * , _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10645 | if (_res == NULL && PyErr_Occurred()) { |
| 10646 | p->error_indicator = 1; |
| 10647 | D(p->level--); |
| 10648 | return NULL; |
| 10649 | } |
| 10650 | goto done; |
| 10651 | } |
| 10652 | p->mark = _mark; |
| 10653 | D(fprintf(stderr, "%*c%s disjunction[%d-%d]: %s failed!\n", p->level, ' ', |
| 10654 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "conjunction (('or' conjunction))+")); |
| 10655 | } |
| 10656 | { // conjunction |
| 10657 | if (p->error_indicator) { |
| 10658 | D(p->level--); |
| 10659 | return NULL; |
| 10660 | } |
| 10661 | D(fprintf(stderr, "%*c> disjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "conjunction")); |
| 10662 | expr_ty conjunction_var; |
| 10663 | if ( |
| 10664 | (conjunction_var = conjunction_rule(p)) // conjunction |
| 10665 | ) |
| 10666 | { |
| 10667 | D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction")); |
| 10668 | _res = conjunction_var; |
| 10669 | goto done; |
| 10670 | } |
| 10671 | p->mark = _mark; |
| 10672 | D(fprintf(stderr, "%*c%s disjunction[%d-%d]: %s failed!\n", p->level, ' ', |
| 10673 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "conjunction")); |
| 10674 | } |
| 10675 | _res = NULL; |
| 10676 | done: |
| 10677 | _PyPegen_insert_memo(p, _mark, disjunction_type, _res); |
| 10678 | D(p->level--); |
| 10679 | return _res; |
| 10680 | } |
| 10681 | |
| 10682 | // conjunction: inversion (('and' inversion))+ | inversion |
| 10683 | static expr_ty |
| 10684 | conjunction_rule(Parser *p) |
| 10685 | { |
| 10686 | D(p->level++); |
| 10687 | if (p->error_indicator) { |
| 10688 | D(p->level--); |
| 10689 | return NULL; |
| 10690 | } |
| 10691 | expr_ty _res = NULL; |
| 10692 | if (_PyPegen_is_memoized(p, conjunction_type, &_res)) { |
| 10693 | D(p->level--); |
| 10694 | return _res; |
| 10695 | } |
| 10696 | int _mark = p->mark; |
| 10697 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10698 | p->error_indicator = 1; |
| 10699 | D(p->level--); |
| 10700 | return NULL; |
| 10701 | } |
| 10702 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10703 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10704 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10705 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 10706 | { // inversion (('and' inversion))+ |
| 10707 | if (p->error_indicator) { |
| 10708 | D(p->level--); |
| 10709 | return NULL; |
| 10710 | } |
| 10711 | D(fprintf(stderr, "%*c> conjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); |
| 10712 | expr_ty a; |
| 10713 | asdl_seq * b; |
| 10714 | if ( |
| 10715 | (a = inversion_rule(p)) // inversion |
| 10716 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 10717 | (b = _loop1_105_rule(p)) // (('and' inversion))+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10718 | ) |
| 10719 | { |
| 10720 | D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); |
| 10721 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10722 | if (_token == NULL) { |
| 10723 | D(p->level--); |
| 10724 | return NULL; |
| 10725 | } |
| 10726 | int _end_lineno = _token->end_lineno; |
| 10727 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10728 | int _end_col_offset = _token->end_col_offset; |
| 10729 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 10730 | _res = _PyAST_BoolOp ( And , CHECK ( asdl_expr_seq * , _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10731 | if (_res == NULL && PyErr_Occurred()) { |
| 10732 | p->error_indicator = 1; |
| 10733 | D(p->level--); |
| 10734 | return NULL; |
| 10735 | } |
| 10736 | goto done; |
| 10737 | } |
| 10738 | p->mark = _mark; |
| 10739 | D(fprintf(stderr, "%*c%s conjunction[%d-%d]: %s failed!\n", p->level, ' ', |
| 10740 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "inversion (('and' inversion))+")); |
| 10741 | } |
| 10742 | { // inversion |
| 10743 | if (p->error_indicator) { |
| 10744 | D(p->level--); |
| 10745 | return NULL; |
| 10746 | } |
| 10747 | D(fprintf(stderr, "%*c> conjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "inversion")); |
| 10748 | expr_ty inversion_var; |
| 10749 | if ( |
| 10750 | (inversion_var = inversion_rule(p)) // inversion |
| 10751 | ) |
| 10752 | { |
| 10753 | D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion")); |
| 10754 | _res = inversion_var; |
| 10755 | goto done; |
| 10756 | } |
| 10757 | p->mark = _mark; |
| 10758 | D(fprintf(stderr, "%*c%s conjunction[%d-%d]: %s failed!\n", p->level, ' ', |
| 10759 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "inversion")); |
| 10760 | } |
| 10761 | _res = NULL; |
| 10762 | done: |
| 10763 | _PyPegen_insert_memo(p, _mark, conjunction_type, _res); |
| 10764 | D(p->level--); |
| 10765 | return _res; |
| 10766 | } |
| 10767 | |
| 10768 | // inversion: 'not' inversion | comparison |
| 10769 | static expr_ty |
| 10770 | inversion_rule(Parser *p) |
| 10771 | { |
| 10772 | D(p->level++); |
| 10773 | if (p->error_indicator) { |
| 10774 | D(p->level--); |
| 10775 | return NULL; |
| 10776 | } |
| 10777 | expr_ty _res = NULL; |
| 10778 | if (_PyPegen_is_memoized(p, inversion_type, &_res)) { |
| 10779 | D(p->level--); |
| 10780 | return _res; |
| 10781 | } |
| 10782 | int _mark = p->mark; |
| 10783 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10784 | p->error_indicator = 1; |
| 10785 | D(p->level--); |
| 10786 | return NULL; |
| 10787 | } |
| 10788 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10789 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10790 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10791 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 10792 | { // 'not' inversion |
| 10793 | if (p->error_indicator) { |
| 10794 | D(p->level--); |
| 10795 | return NULL; |
| 10796 | } |
| 10797 | D(fprintf(stderr, "%*c> inversion[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'not' inversion")); |
| 10798 | Token * _keyword; |
| 10799 | expr_ty a; |
| 10800 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 10801 | (_keyword = _PyPegen_expect_token(p, 529)) // token='not' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10802 | && |
| 10803 | (a = inversion_rule(p)) // inversion |
| 10804 | ) |
| 10805 | { |
| 10806 | D(fprintf(stderr, "%*c+ inversion[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'not' inversion")); |
| 10807 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10808 | if (_token == NULL) { |
| 10809 | D(p->level--); |
| 10810 | return NULL; |
| 10811 | } |
| 10812 | int _end_lineno = _token->end_lineno; |
| 10813 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10814 | int _end_col_offset = _token->end_col_offset; |
| 10815 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 10816 | _res = _PyAST_UnaryOp ( Not , a , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10817 | if (_res == NULL && PyErr_Occurred()) { |
| 10818 | p->error_indicator = 1; |
| 10819 | D(p->level--); |
| 10820 | return NULL; |
| 10821 | } |
| 10822 | goto done; |
| 10823 | } |
| 10824 | p->mark = _mark; |
| 10825 | D(fprintf(stderr, "%*c%s inversion[%d-%d]: %s failed!\n", p->level, ' ', |
| 10826 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'not' inversion")); |
| 10827 | } |
| 10828 | { // comparison |
| 10829 | if (p->error_indicator) { |
| 10830 | D(p->level--); |
| 10831 | return NULL; |
| 10832 | } |
| 10833 | D(fprintf(stderr, "%*c> inversion[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "comparison")); |
| 10834 | expr_ty comparison_var; |
| 10835 | if ( |
| 10836 | (comparison_var = comparison_rule(p)) // comparison |
| 10837 | ) |
| 10838 | { |
| 10839 | D(fprintf(stderr, "%*c+ inversion[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "comparison")); |
| 10840 | _res = comparison_var; |
| 10841 | goto done; |
| 10842 | } |
| 10843 | p->mark = _mark; |
| 10844 | D(fprintf(stderr, "%*c%s inversion[%d-%d]: %s failed!\n", p->level, ' ', |
| 10845 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "comparison")); |
| 10846 | } |
| 10847 | _res = NULL; |
| 10848 | done: |
| 10849 | _PyPegen_insert_memo(p, _mark, inversion_type, _res); |
| 10850 | D(p->level--); |
| 10851 | return _res; |
| 10852 | } |
| 10853 | |
| 10854 | // comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or |
| 10855 | static expr_ty |
| 10856 | comparison_rule(Parser *p) |
| 10857 | { |
| 10858 | D(p->level++); |
| 10859 | if (p->error_indicator) { |
| 10860 | D(p->level--); |
| 10861 | return NULL; |
| 10862 | } |
| 10863 | expr_ty _res = NULL; |
| 10864 | int _mark = p->mark; |
| 10865 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10866 | p->error_indicator = 1; |
| 10867 | D(p->level--); |
| 10868 | return NULL; |
| 10869 | } |
| 10870 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10871 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10872 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10873 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 10874 | { // bitwise_or compare_op_bitwise_or_pair+ |
| 10875 | if (p->error_indicator) { |
| 10876 | D(p->level--); |
| 10877 | return NULL; |
| 10878 | } |
| 10879 | D(fprintf(stderr, "%*c> comparison[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); |
| 10880 | expr_ty a; |
| 10881 | asdl_seq * b; |
| 10882 | if ( |
| 10883 | (a = bitwise_or_rule(p)) // bitwise_or |
| 10884 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 10885 | (b = _loop1_106_rule(p)) // compare_op_bitwise_or_pair+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10886 | ) |
| 10887 | { |
| 10888 | D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); |
| 10889 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10890 | if (_token == NULL) { |
| 10891 | D(p->level--); |
| 10892 | return NULL; |
| 10893 | } |
| 10894 | int _end_lineno = _token->end_lineno; |
| 10895 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10896 | int _end_col_offset = _token->end_col_offset; |
| 10897 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 10898 | _res = _PyAST_Compare ( a , CHECK ( asdl_int_seq * , _PyPegen_get_cmpops ( p , b ) ) , CHECK ( asdl_expr_seq * , _PyPegen_get_exprs ( p , b ) ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 10899 | if (_res == NULL && PyErr_Occurred()) { |
| 10900 | p->error_indicator = 1; |
| 10901 | D(p->level--); |
| 10902 | return NULL; |
| 10903 | } |
| 10904 | goto done; |
| 10905 | } |
| 10906 | p->mark = _mark; |
| 10907 | D(fprintf(stderr, "%*c%s comparison[%d-%d]: %s failed!\n", p->level, ' ', |
| 10908 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); |
| 10909 | } |
| 10910 | { // bitwise_or |
| 10911 | if (p->error_indicator) { |
| 10912 | D(p->level--); |
| 10913 | return NULL; |
| 10914 | } |
| 10915 | D(fprintf(stderr, "%*c> comparison[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or")); |
| 10916 | expr_ty bitwise_or_var; |
| 10917 | if ( |
| 10918 | (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or |
| 10919 | ) |
| 10920 | { |
| 10921 | D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or")); |
| 10922 | _res = bitwise_or_var; |
| 10923 | goto done; |
| 10924 | } |
| 10925 | p->mark = _mark; |
| 10926 | D(fprintf(stderr, "%*c%s comparison[%d-%d]: %s failed!\n", p->level, ' ', |
| 10927 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or")); |
| 10928 | } |
| 10929 | _res = NULL; |
| 10930 | done: |
| 10931 | D(p->level--); |
| 10932 | return _res; |
| 10933 | } |
| 10934 | |
| 10935 | // compare_op_bitwise_or_pair: |
| 10936 | // | eq_bitwise_or |
| 10937 | // | noteq_bitwise_or |
| 10938 | // | lte_bitwise_or |
| 10939 | // | lt_bitwise_or |
| 10940 | // | gte_bitwise_or |
| 10941 | // | gt_bitwise_or |
| 10942 | // | notin_bitwise_or |
| 10943 | // | in_bitwise_or |
| 10944 | // | isnot_bitwise_or |
| 10945 | // | is_bitwise_or |
| 10946 | static CmpopExprPair* |
| 10947 | compare_op_bitwise_or_pair_rule(Parser *p) |
| 10948 | { |
| 10949 | D(p->level++); |
| 10950 | if (p->error_indicator) { |
| 10951 | D(p->level--); |
| 10952 | return NULL; |
| 10953 | } |
| 10954 | CmpopExprPair* _res = NULL; |
| 10955 | int _mark = p->mark; |
| 10956 | { // eq_bitwise_or |
| 10957 | if (p->error_indicator) { |
| 10958 | D(p->level--); |
| 10959 | return NULL; |
| 10960 | } |
| 10961 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "eq_bitwise_or")); |
| 10962 | CmpopExprPair* eq_bitwise_or_var; |
| 10963 | if ( |
| 10964 | (eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or |
| 10965 | ) |
| 10966 | { |
| 10967 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "eq_bitwise_or")); |
| 10968 | _res = eq_bitwise_or_var; |
| 10969 | goto done; |
| 10970 | } |
| 10971 | p->mark = _mark; |
| 10972 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 10973 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "eq_bitwise_or")); |
| 10974 | } |
| 10975 | { // noteq_bitwise_or |
| 10976 | if (p->error_indicator) { |
| 10977 | D(p->level--); |
| 10978 | return NULL; |
| 10979 | } |
| 10980 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "noteq_bitwise_or")); |
| 10981 | CmpopExprPair* noteq_bitwise_or_var; |
| 10982 | if ( |
| 10983 | (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or |
| 10984 | ) |
| 10985 | { |
| 10986 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "noteq_bitwise_or")); |
| 10987 | _res = noteq_bitwise_or_var; |
| 10988 | goto done; |
| 10989 | } |
| 10990 | p->mark = _mark; |
| 10991 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 10992 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "noteq_bitwise_or")); |
| 10993 | } |
| 10994 | { // lte_bitwise_or |
| 10995 | if (p->error_indicator) { |
| 10996 | D(p->level--); |
| 10997 | return NULL; |
| 10998 | } |
| 10999 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lte_bitwise_or")); |
| 11000 | CmpopExprPair* lte_bitwise_or_var; |
| 11001 | if ( |
| 11002 | (lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or |
| 11003 | ) |
| 11004 | { |
| 11005 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lte_bitwise_or")); |
| 11006 | _res = lte_bitwise_or_var; |
| 11007 | goto done; |
| 11008 | } |
| 11009 | p->mark = _mark; |
| 11010 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 11011 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lte_bitwise_or")); |
| 11012 | } |
| 11013 | { // lt_bitwise_or |
| 11014 | if (p->error_indicator) { |
| 11015 | D(p->level--); |
| 11016 | return NULL; |
| 11017 | } |
| 11018 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lt_bitwise_or")); |
| 11019 | CmpopExprPair* lt_bitwise_or_var; |
| 11020 | if ( |
| 11021 | (lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or |
| 11022 | ) |
| 11023 | { |
| 11024 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lt_bitwise_or")); |
| 11025 | _res = lt_bitwise_or_var; |
| 11026 | goto done; |
| 11027 | } |
| 11028 | p->mark = _mark; |
| 11029 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 11030 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lt_bitwise_or")); |
| 11031 | } |
| 11032 | { // gte_bitwise_or |
| 11033 | if (p->error_indicator) { |
| 11034 | D(p->level--); |
| 11035 | return NULL; |
| 11036 | } |
| 11037 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "gte_bitwise_or")); |
| 11038 | CmpopExprPair* gte_bitwise_or_var; |
| 11039 | if ( |
| 11040 | (gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or |
| 11041 | ) |
| 11042 | { |
| 11043 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "gte_bitwise_or")); |
| 11044 | _res = gte_bitwise_or_var; |
| 11045 | goto done; |
| 11046 | } |
| 11047 | p->mark = _mark; |
| 11048 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 11049 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "gte_bitwise_or")); |
| 11050 | } |
| 11051 | { // gt_bitwise_or |
| 11052 | if (p->error_indicator) { |
| 11053 | D(p->level--); |
| 11054 | return NULL; |
| 11055 | } |
| 11056 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "gt_bitwise_or")); |
| 11057 | CmpopExprPair* gt_bitwise_or_var; |
| 11058 | if ( |
| 11059 | (gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or |
| 11060 | ) |
| 11061 | { |
| 11062 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "gt_bitwise_or")); |
| 11063 | _res = gt_bitwise_or_var; |
| 11064 | goto done; |
| 11065 | } |
| 11066 | p->mark = _mark; |
| 11067 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 11068 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "gt_bitwise_or")); |
| 11069 | } |
| 11070 | { // notin_bitwise_or |
| 11071 | if (p->error_indicator) { |
| 11072 | D(p->level--); |
| 11073 | return NULL; |
| 11074 | } |
| 11075 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "notin_bitwise_or")); |
| 11076 | CmpopExprPair* notin_bitwise_or_var; |
| 11077 | if ( |
| 11078 | (notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or |
| 11079 | ) |
| 11080 | { |
| 11081 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "notin_bitwise_or")); |
| 11082 | _res = notin_bitwise_or_var; |
| 11083 | goto done; |
| 11084 | } |
| 11085 | p->mark = _mark; |
| 11086 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 11087 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "notin_bitwise_or")); |
| 11088 | } |
| 11089 | { // in_bitwise_or |
| 11090 | if (p->error_indicator) { |
| 11091 | D(p->level--); |
| 11092 | return NULL; |
| 11093 | } |
| 11094 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "in_bitwise_or")); |
| 11095 | CmpopExprPair* in_bitwise_or_var; |
| 11096 | if ( |
| 11097 | (in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or |
| 11098 | ) |
| 11099 | { |
| 11100 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "in_bitwise_or")); |
| 11101 | _res = in_bitwise_or_var; |
| 11102 | goto done; |
| 11103 | } |
| 11104 | p->mark = _mark; |
| 11105 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 11106 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "in_bitwise_or")); |
| 11107 | } |
| 11108 | { // isnot_bitwise_or |
| 11109 | if (p->error_indicator) { |
| 11110 | D(p->level--); |
| 11111 | return NULL; |
| 11112 | } |
| 11113 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "isnot_bitwise_or")); |
| 11114 | CmpopExprPair* isnot_bitwise_or_var; |
| 11115 | if ( |
| 11116 | (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or |
| 11117 | ) |
| 11118 | { |
| 11119 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "isnot_bitwise_or")); |
| 11120 | _res = isnot_bitwise_or_var; |
| 11121 | goto done; |
| 11122 | } |
| 11123 | p->mark = _mark; |
| 11124 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 11125 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "isnot_bitwise_or")); |
| 11126 | } |
| 11127 | { // is_bitwise_or |
| 11128 | if (p->error_indicator) { |
| 11129 | D(p->level--); |
| 11130 | return NULL; |
| 11131 | } |
| 11132 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "is_bitwise_or")); |
| 11133 | CmpopExprPair* is_bitwise_or_var; |
| 11134 | if ( |
| 11135 | (is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or |
| 11136 | ) |
| 11137 | { |
| 11138 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "is_bitwise_or")); |
| 11139 | _res = is_bitwise_or_var; |
| 11140 | goto done; |
| 11141 | } |
| 11142 | p->mark = _mark; |
| 11143 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 11144 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "is_bitwise_or")); |
| 11145 | } |
| 11146 | _res = NULL; |
| 11147 | done: |
| 11148 | D(p->level--); |
| 11149 | return _res; |
| 11150 | } |
| 11151 | |
| 11152 | // eq_bitwise_or: '==' bitwise_or |
| 11153 | static CmpopExprPair* |
| 11154 | eq_bitwise_or_rule(Parser *p) |
| 11155 | { |
| 11156 | D(p->level++); |
| 11157 | if (p->error_indicator) { |
| 11158 | D(p->level--); |
| 11159 | return NULL; |
| 11160 | } |
| 11161 | CmpopExprPair* _res = NULL; |
| 11162 | int _mark = p->mark; |
| 11163 | { // '==' bitwise_or |
| 11164 | if (p->error_indicator) { |
| 11165 | D(p->level--); |
| 11166 | return NULL; |
| 11167 | } |
| 11168 | D(fprintf(stderr, "%*c> eq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or")); |
| 11169 | Token * _literal; |
| 11170 | expr_ty a; |
| 11171 | if ( |
| 11172 | (_literal = _PyPegen_expect_token(p, 27)) // token='==' |
| 11173 | && |
| 11174 | (a = bitwise_or_rule(p)) // bitwise_or |
| 11175 | ) |
| 11176 | { |
| 11177 | D(fprintf(stderr, "%*c+ eq_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or")); |
| 11178 | _res = _PyPegen_cmpop_expr_pair ( p , Eq , a ); |
| 11179 | if (_res == NULL && PyErr_Occurred()) { |
| 11180 | p->error_indicator = 1; |
| 11181 | D(p->level--); |
| 11182 | return NULL; |
| 11183 | } |
| 11184 | goto done; |
| 11185 | } |
| 11186 | p->mark = _mark; |
| 11187 | D(fprintf(stderr, "%*c%s eq_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 11188 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'==' bitwise_or")); |
| 11189 | } |
| 11190 | _res = NULL; |
| 11191 | done: |
| 11192 | D(p->level--); |
| 11193 | return _res; |
| 11194 | } |
| 11195 | |
| 11196 | // noteq_bitwise_or: ('!=') bitwise_or |
| 11197 | static CmpopExprPair* |
| 11198 | noteq_bitwise_or_rule(Parser *p) |
| 11199 | { |
| 11200 | D(p->level++); |
| 11201 | if (p->error_indicator) { |
| 11202 | D(p->level--); |
| 11203 | return NULL; |
| 11204 | } |
| 11205 | CmpopExprPair* _res = NULL; |
| 11206 | int _mark = p->mark; |
| 11207 | { // ('!=') bitwise_or |
| 11208 | if (p->error_indicator) { |
| 11209 | D(p->level--); |
| 11210 | return NULL; |
| 11211 | } |
| 11212 | D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 11213 | void *_tmp_107_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11214 | expr_ty a; |
| 11215 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 11216 | (_tmp_107_var = _tmp_107_rule(p)) // '!=' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11217 | && |
| 11218 | (a = bitwise_or_rule(p)) // bitwise_or |
| 11219 | ) |
| 11220 | { |
| 11221 | D(fprintf(stderr, "%*c+ noteq_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); |
| 11222 | _res = _PyPegen_cmpop_expr_pair ( p , NotEq , a ); |
| 11223 | if (_res == NULL && PyErr_Occurred()) { |
| 11224 | p->error_indicator = 1; |
| 11225 | D(p->level--); |
| 11226 | return NULL; |
| 11227 | } |
| 11228 | goto done; |
| 11229 | } |
| 11230 | p->mark = _mark; |
| 11231 | D(fprintf(stderr, "%*c%s noteq_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 11232 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('!=') bitwise_or")); |
| 11233 | } |
| 11234 | _res = NULL; |
| 11235 | done: |
| 11236 | D(p->level--); |
| 11237 | return _res; |
| 11238 | } |
| 11239 | |
| 11240 | // lte_bitwise_or: '<=' bitwise_or |
| 11241 | static CmpopExprPair* |
| 11242 | lte_bitwise_or_rule(Parser *p) |
| 11243 | { |
| 11244 | D(p->level++); |
| 11245 | if (p->error_indicator) { |
| 11246 | D(p->level--); |
| 11247 | return NULL; |
| 11248 | } |
| 11249 | CmpopExprPair* _res = NULL; |
| 11250 | int _mark = p->mark; |
| 11251 | { // '<=' bitwise_or |
| 11252 | if (p->error_indicator) { |
| 11253 | D(p->level--); |
| 11254 | return NULL; |
| 11255 | } |
| 11256 | D(fprintf(stderr, "%*c> lte_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or")); |
| 11257 | Token * _literal; |
| 11258 | expr_ty a; |
| 11259 | if ( |
| 11260 | (_literal = _PyPegen_expect_token(p, 29)) // token='<=' |
| 11261 | && |
| 11262 | (a = bitwise_or_rule(p)) // bitwise_or |
| 11263 | ) |
| 11264 | { |
| 11265 | D(fprintf(stderr, "%*c+ lte_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or")); |
| 11266 | _res = _PyPegen_cmpop_expr_pair ( p , LtE , a ); |
| 11267 | if (_res == NULL && PyErr_Occurred()) { |
| 11268 | p->error_indicator = 1; |
| 11269 | D(p->level--); |
| 11270 | return NULL; |
| 11271 | } |
| 11272 | goto done; |
| 11273 | } |
| 11274 | p->mark = _mark; |
| 11275 | D(fprintf(stderr, "%*c%s lte_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 11276 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<=' bitwise_or")); |
| 11277 | } |
| 11278 | _res = NULL; |
| 11279 | done: |
| 11280 | D(p->level--); |
| 11281 | return _res; |
| 11282 | } |
| 11283 | |
| 11284 | // lt_bitwise_or: '<' bitwise_or |
| 11285 | static CmpopExprPair* |
| 11286 | lt_bitwise_or_rule(Parser *p) |
| 11287 | { |
| 11288 | D(p->level++); |
| 11289 | if (p->error_indicator) { |
| 11290 | D(p->level--); |
| 11291 | return NULL; |
| 11292 | } |
| 11293 | CmpopExprPair* _res = NULL; |
| 11294 | int _mark = p->mark; |
| 11295 | { // '<' bitwise_or |
| 11296 | if (p->error_indicator) { |
| 11297 | D(p->level--); |
| 11298 | return NULL; |
| 11299 | } |
| 11300 | D(fprintf(stderr, "%*c> lt_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or")); |
| 11301 | Token * _literal; |
| 11302 | expr_ty a; |
| 11303 | if ( |
| 11304 | (_literal = _PyPegen_expect_token(p, 20)) // token='<' |
| 11305 | && |
| 11306 | (a = bitwise_or_rule(p)) // bitwise_or |
| 11307 | ) |
| 11308 | { |
| 11309 | D(fprintf(stderr, "%*c+ lt_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or")); |
| 11310 | _res = _PyPegen_cmpop_expr_pair ( p , Lt , a ); |
| 11311 | if (_res == NULL && PyErr_Occurred()) { |
| 11312 | p->error_indicator = 1; |
| 11313 | D(p->level--); |
| 11314 | return NULL; |
| 11315 | } |
| 11316 | goto done; |
| 11317 | } |
| 11318 | p->mark = _mark; |
| 11319 | D(fprintf(stderr, "%*c%s lt_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 11320 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<' bitwise_or")); |
| 11321 | } |
| 11322 | _res = NULL; |
| 11323 | done: |
| 11324 | D(p->level--); |
| 11325 | return _res; |
| 11326 | } |
| 11327 | |
| 11328 | // gte_bitwise_or: '>=' bitwise_or |
| 11329 | static CmpopExprPair* |
| 11330 | gte_bitwise_or_rule(Parser *p) |
| 11331 | { |
| 11332 | D(p->level++); |
| 11333 | if (p->error_indicator) { |
| 11334 | D(p->level--); |
| 11335 | return NULL; |
| 11336 | } |
| 11337 | CmpopExprPair* _res = NULL; |
| 11338 | int _mark = p->mark; |
| 11339 | { // '>=' bitwise_or |
| 11340 | if (p->error_indicator) { |
| 11341 | D(p->level--); |
| 11342 | return NULL; |
| 11343 | } |
| 11344 | D(fprintf(stderr, "%*c> gte_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or")); |
| 11345 | Token * _literal; |
| 11346 | expr_ty a; |
| 11347 | if ( |
| 11348 | (_literal = _PyPegen_expect_token(p, 30)) // token='>=' |
| 11349 | && |
| 11350 | (a = bitwise_or_rule(p)) // bitwise_or |
| 11351 | ) |
| 11352 | { |
| 11353 | D(fprintf(stderr, "%*c+ gte_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or")); |
| 11354 | _res = _PyPegen_cmpop_expr_pair ( p , GtE , a ); |
| 11355 | if (_res == NULL && PyErr_Occurred()) { |
| 11356 | p->error_indicator = 1; |
| 11357 | D(p->level--); |
| 11358 | return NULL; |
| 11359 | } |
| 11360 | goto done; |
| 11361 | } |
| 11362 | p->mark = _mark; |
| 11363 | D(fprintf(stderr, "%*c%s gte_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 11364 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>=' bitwise_or")); |
| 11365 | } |
| 11366 | _res = NULL; |
| 11367 | done: |
| 11368 | D(p->level--); |
| 11369 | return _res; |
| 11370 | } |
| 11371 | |
| 11372 | // gt_bitwise_or: '>' bitwise_or |
| 11373 | static CmpopExprPair* |
| 11374 | gt_bitwise_or_rule(Parser *p) |
| 11375 | { |
| 11376 | D(p->level++); |
| 11377 | if (p->error_indicator) { |
| 11378 | D(p->level--); |
| 11379 | return NULL; |
| 11380 | } |
| 11381 | CmpopExprPair* _res = NULL; |
| 11382 | int _mark = p->mark; |
| 11383 | { // '>' bitwise_or |
| 11384 | if (p->error_indicator) { |
| 11385 | D(p->level--); |
| 11386 | return NULL; |
| 11387 | } |
| 11388 | D(fprintf(stderr, "%*c> gt_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or")); |
| 11389 | Token * _literal; |
| 11390 | expr_ty a; |
| 11391 | if ( |
| 11392 | (_literal = _PyPegen_expect_token(p, 21)) // token='>' |
| 11393 | && |
| 11394 | (a = bitwise_or_rule(p)) // bitwise_or |
| 11395 | ) |
| 11396 | { |
| 11397 | D(fprintf(stderr, "%*c+ gt_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or")); |
| 11398 | _res = _PyPegen_cmpop_expr_pair ( p , Gt , a ); |
| 11399 | if (_res == NULL && PyErr_Occurred()) { |
| 11400 | p->error_indicator = 1; |
| 11401 | D(p->level--); |
| 11402 | return NULL; |
| 11403 | } |
| 11404 | goto done; |
| 11405 | } |
| 11406 | p->mark = _mark; |
| 11407 | D(fprintf(stderr, "%*c%s gt_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 11408 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>' bitwise_or")); |
| 11409 | } |
| 11410 | _res = NULL; |
| 11411 | done: |
| 11412 | D(p->level--); |
| 11413 | return _res; |
| 11414 | } |
| 11415 | |
| 11416 | // notin_bitwise_or: 'not' 'in' bitwise_or |
| 11417 | static CmpopExprPair* |
| 11418 | notin_bitwise_or_rule(Parser *p) |
| 11419 | { |
| 11420 | D(p->level++); |
| 11421 | if (p->error_indicator) { |
| 11422 | D(p->level--); |
| 11423 | return NULL; |
| 11424 | } |
| 11425 | CmpopExprPair* _res = NULL; |
| 11426 | int _mark = p->mark; |
| 11427 | { // 'not' 'in' bitwise_or |
| 11428 | if (p->error_indicator) { |
| 11429 | D(p->level--); |
| 11430 | return NULL; |
| 11431 | } |
| 11432 | D(fprintf(stderr, "%*c> notin_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or")); |
| 11433 | Token * _keyword; |
| 11434 | Token * _keyword_1; |
| 11435 | expr_ty a; |
| 11436 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 11437 | (_keyword = _PyPegen_expect_token(p, 529)) // token='not' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11438 | && |
| 11439 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
| 11440 | && |
| 11441 | (a = bitwise_or_rule(p)) // bitwise_or |
| 11442 | ) |
| 11443 | { |
| 11444 | D(fprintf(stderr, "%*c+ notin_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or")); |
| 11445 | _res = _PyPegen_cmpop_expr_pair ( p , NotIn , a ); |
| 11446 | if (_res == NULL && PyErr_Occurred()) { |
| 11447 | p->error_indicator = 1; |
| 11448 | D(p->level--); |
| 11449 | return NULL; |
| 11450 | } |
| 11451 | goto done; |
| 11452 | } |
| 11453 | p->mark = _mark; |
| 11454 | D(fprintf(stderr, "%*c%s notin_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 11455 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'not' 'in' bitwise_or")); |
| 11456 | } |
| 11457 | _res = NULL; |
| 11458 | done: |
| 11459 | D(p->level--); |
| 11460 | return _res; |
| 11461 | } |
| 11462 | |
| 11463 | // in_bitwise_or: 'in' bitwise_or |
| 11464 | static CmpopExprPair* |
| 11465 | in_bitwise_or_rule(Parser *p) |
| 11466 | { |
| 11467 | D(p->level++); |
| 11468 | if (p->error_indicator) { |
| 11469 | D(p->level--); |
| 11470 | return NULL; |
| 11471 | } |
| 11472 | CmpopExprPair* _res = NULL; |
| 11473 | int _mark = p->mark; |
| 11474 | { // 'in' bitwise_or |
| 11475 | if (p->error_indicator) { |
| 11476 | D(p->level--); |
| 11477 | return NULL; |
| 11478 | } |
| 11479 | D(fprintf(stderr, "%*c> in_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or")); |
| 11480 | Token * _keyword; |
| 11481 | expr_ty a; |
| 11482 | if ( |
| 11483 | (_keyword = _PyPegen_expect_token(p, 518)) // token='in' |
| 11484 | && |
| 11485 | (a = bitwise_or_rule(p)) // bitwise_or |
| 11486 | ) |
| 11487 | { |
| 11488 | D(fprintf(stderr, "%*c+ in_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or")); |
| 11489 | _res = _PyPegen_cmpop_expr_pair ( p , In , a ); |
| 11490 | if (_res == NULL && PyErr_Occurred()) { |
| 11491 | p->error_indicator = 1; |
| 11492 | D(p->level--); |
| 11493 | return NULL; |
| 11494 | } |
| 11495 | goto done; |
| 11496 | } |
| 11497 | p->mark = _mark; |
| 11498 | D(fprintf(stderr, "%*c%s in_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 11499 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'in' bitwise_or")); |
| 11500 | } |
| 11501 | _res = NULL; |
| 11502 | done: |
| 11503 | D(p->level--); |
| 11504 | return _res; |
| 11505 | } |
| 11506 | |
| 11507 | // isnot_bitwise_or: 'is' 'not' bitwise_or |
| 11508 | static CmpopExprPair* |
| 11509 | isnot_bitwise_or_rule(Parser *p) |
| 11510 | { |
| 11511 | D(p->level++); |
| 11512 | if (p->error_indicator) { |
| 11513 | D(p->level--); |
| 11514 | return NULL; |
| 11515 | } |
| 11516 | CmpopExprPair* _res = NULL; |
| 11517 | int _mark = p->mark; |
| 11518 | { // 'is' 'not' bitwise_or |
| 11519 | if (p->error_indicator) { |
| 11520 | D(p->level--); |
| 11521 | return NULL; |
| 11522 | } |
| 11523 | D(fprintf(stderr, "%*c> isnot_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or")); |
| 11524 | Token * _keyword; |
| 11525 | Token * _keyword_1; |
| 11526 | expr_ty a; |
| 11527 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 11528 | (_keyword = _PyPegen_expect_token(p, 530)) // token='is' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11529 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 11530 | (_keyword_1 = _PyPegen_expect_token(p, 529)) // token='not' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11531 | && |
| 11532 | (a = bitwise_or_rule(p)) // bitwise_or |
| 11533 | ) |
| 11534 | { |
| 11535 | D(fprintf(stderr, "%*c+ isnot_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or")); |
| 11536 | _res = _PyPegen_cmpop_expr_pair ( p , IsNot , a ); |
| 11537 | if (_res == NULL && PyErr_Occurred()) { |
| 11538 | p->error_indicator = 1; |
| 11539 | D(p->level--); |
| 11540 | return NULL; |
| 11541 | } |
| 11542 | goto done; |
| 11543 | } |
| 11544 | p->mark = _mark; |
| 11545 | D(fprintf(stderr, "%*c%s isnot_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 11546 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' 'not' bitwise_or")); |
| 11547 | } |
| 11548 | _res = NULL; |
| 11549 | done: |
| 11550 | D(p->level--); |
| 11551 | return _res; |
| 11552 | } |
| 11553 | |
| 11554 | // is_bitwise_or: 'is' bitwise_or |
| 11555 | static CmpopExprPair* |
| 11556 | is_bitwise_or_rule(Parser *p) |
| 11557 | { |
| 11558 | D(p->level++); |
| 11559 | if (p->error_indicator) { |
| 11560 | D(p->level--); |
| 11561 | return NULL; |
| 11562 | } |
| 11563 | CmpopExprPair* _res = NULL; |
| 11564 | int _mark = p->mark; |
| 11565 | { // 'is' bitwise_or |
| 11566 | if (p->error_indicator) { |
| 11567 | D(p->level--); |
| 11568 | return NULL; |
| 11569 | } |
| 11570 | D(fprintf(stderr, "%*c> is_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or")); |
| 11571 | Token * _keyword; |
| 11572 | expr_ty a; |
| 11573 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 11574 | (_keyword = _PyPegen_expect_token(p, 530)) // token='is' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11575 | && |
| 11576 | (a = bitwise_or_rule(p)) // bitwise_or |
| 11577 | ) |
| 11578 | { |
| 11579 | D(fprintf(stderr, "%*c+ is_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or")); |
| 11580 | _res = _PyPegen_cmpop_expr_pair ( p , Is , a ); |
| 11581 | if (_res == NULL && PyErr_Occurred()) { |
| 11582 | p->error_indicator = 1; |
| 11583 | D(p->level--); |
| 11584 | return NULL; |
| 11585 | } |
| 11586 | goto done; |
| 11587 | } |
| 11588 | p->mark = _mark; |
| 11589 | D(fprintf(stderr, "%*c%s is_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 11590 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' bitwise_or")); |
| 11591 | } |
| 11592 | _res = NULL; |
| 11593 | done: |
| 11594 | D(p->level--); |
| 11595 | return _res; |
| 11596 | } |
| 11597 | |
| 11598 | // Left-recursive |
| 11599 | // bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor |
| 11600 | static expr_ty bitwise_or_raw(Parser *); |
| 11601 | static expr_ty |
| 11602 | bitwise_or_rule(Parser *p) |
| 11603 | { |
| 11604 | D(p->level++); |
| 11605 | expr_ty _res = NULL; |
| 11606 | if (_PyPegen_is_memoized(p, bitwise_or_type, &_res)) { |
| 11607 | D(p->level--); |
| 11608 | return _res; |
| 11609 | } |
| 11610 | int _mark = p->mark; |
| 11611 | int _resmark = p->mark; |
| 11612 | while (1) { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 11613 | int tmpvar_2 = _PyPegen_update_memo(p, _mark, bitwise_or_type, _res); |
| 11614 | if (tmpvar_2) { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11615 | D(p->level--); |
| 11616 | return _res; |
| 11617 | } |
| 11618 | p->mark = _mark; |
| 11619 | void *_raw = bitwise_or_raw(p); |
Lysandros Nikolaou | 02cdfc9 | 2020-10-31 20:31:41 +0200 | [diff] [blame] | 11620 | if (p->error_indicator) |
| 11621 | return NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11622 | if (_raw == NULL || p->mark <= _resmark) |
| 11623 | break; |
| 11624 | _resmark = p->mark; |
| 11625 | _res = _raw; |
| 11626 | } |
| 11627 | p->mark = _resmark; |
| 11628 | D(p->level--); |
| 11629 | return _res; |
| 11630 | } |
| 11631 | static expr_ty |
| 11632 | bitwise_or_raw(Parser *p) |
| 11633 | { |
| 11634 | D(p->level++); |
| 11635 | if (p->error_indicator) { |
| 11636 | D(p->level--); |
| 11637 | return NULL; |
| 11638 | } |
| 11639 | expr_ty _res = NULL; |
| 11640 | int _mark = p->mark; |
| 11641 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 11642 | p->error_indicator = 1; |
| 11643 | D(p->level--); |
| 11644 | return NULL; |
| 11645 | } |
| 11646 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11647 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11648 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11649 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 11650 | { // bitwise_or '|' bitwise_xor |
| 11651 | if (p->error_indicator) { |
| 11652 | D(p->level--); |
| 11653 | return NULL; |
| 11654 | } |
| 11655 | D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor")); |
| 11656 | Token * _literal; |
| 11657 | expr_ty a; |
| 11658 | expr_ty b; |
| 11659 | if ( |
| 11660 | (a = bitwise_or_rule(p)) // bitwise_or |
| 11661 | && |
| 11662 | (_literal = _PyPegen_expect_token(p, 18)) // token='|' |
| 11663 | && |
| 11664 | (b = bitwise_xor_rule(p)) // bitwise_xor |
| 11665 | ) |
| 11666 | { |
| 11667 | D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor")); |
| 11668 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11669 | if (_token == NULL) { |
| 11670 | D(p->level--); |
| 11671 | return NULL; |
| 11672 | } |
| 11673 | int _end_lineno = _token->end_lineno; |
| 11674 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11675 | int _end_col_offset = _token->end_col_offset; |
| 11676 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 11677 | _res = _PyAST_BinOp ( a , BitOr , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11678 | if (_res == NULL && PyErr_Occurred()) { |
| 11679 | p->error_indicator = 1; |
| 11680 | D(p->level--); |
| 11681 | return NULL; |
| 11682 | } |
| 11683 | goto done; |
| 11684 | } |
| 11685 | p->mark = _mark; |
| 11686 | D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 11687 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or '|' bitwise_xor")); |
| 11688 | } |
| 11689 | { // bitwise_xor |
| 11690 | if (p->error_indicator) { |
| 11691 | D(p->level--); |
| 11692 | return NULL; |
| 11693 | } |
| 11694 | D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor")); |
| 11695 | expr_ty bitwise_xor_var; |
| 11696 | if ( |
| 11697 | (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor |
| 11698 | ) |
| 11699 | { |
| 11700 | D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor")); |
| 11701 | _res = bitwise_xor_var; |
| 11702 | goto done; |
| 11703 | } |
| 11704 | p->mark = _mark; |
| 11705 | D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 11706 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor")); |
| 11707 | } |
| 11708 | _res = NULL; |
| 11709 | done: |
| 11710 | D(p->level--); |
| 11711 | return _res; |
| 11712 | } |
| 11713 | |
| 11714 | // Left-recursive |
| 11715 | // bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and |
| 11716 | static expr_ty bitwise_xor_raw(Parser *); |
| 11717 | static expr_ty |
| 11718 | bitwise_xor_rule(Parser *p) |
| 11719 | { |
| 11720 | D(p->level++); |
| 11721 | expr_ty _res = NULL; |
| 11722 | if (_PyPegen_is_memoized(p, bitwise_xor_type, &_res)) { |
| 11723 | D(p->level--); |
| 11724 | return _res; |
| 11725 | } |
| 11726 | int _mark = p->mark; |
| 11727 | int _resmark = p->mark; |
| 11728 | while (1) { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 11729 | int tmpvar_3 = _PyPegen_update_memo(p, _mark, bitwise_xor_type, _res); |
| 11730 | if (tmpvar_3) { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11731 | D(p->level--); |
| 11732 | return _res; |
| 11733 | } |
| 11734 | p->mark = _mark; |
| 11735 | void *_raw = bitwise_xor_raw(p); |
Lysandros Nikolaou | 02cdfc9 | 2020-10-31 20:31:41 +0200 | [diff] [blame] | 11736 | if (p->error_indicator) |
| 11737 | return NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11738 | if (_raw == NULL || p->mark <= _resmark) |
| 11739 | break; |
| 11740 | _resmark = p->mark; |
| 11741 | _res = _raw; |
| 11742 | } |
| 11743 | p->mark = _resmark; |
| 11744 | D(p->level--); |
| 11745 | return _res; |
| 11746 | } |
| 11747 | static expr_ty |
| 11748 | bitwise_xor_raw(Parser *p) |
| 11749 | { |
| 11750 | D(p->level++); |
| 11751 | if (p->error_indicator) { |
| 11752 | D(p->level--); |
| 11753 | return NULL; |
| 11754 | } |
| 11755 | expr_ty _res = NULL; |
| 11756 | int _mark = p->mark; |
| 11757 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 11758 | p->error_indicator = 1; |
| 11759 | D(p->level--); |
| 11760 | return NULL; |
| 11761 | } |
| 11762 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11763 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11764 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11765 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 11766 | { // bitwise_xor '^' bitwise_and |
| 11767 | if (p->error_indicator) { |
| 11768 | D(p->level--); |
| 11769 | return NULL; |
| 11770 | } |
| 11771 | D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and")); |
| 11772 | Token * _literal; |
| 11773 | expr_ty a; |
| 11774 | expr_ty b; |
| 11775 | if ( |
| 11776 | (a = bitwise_xor_rule(p)) // bitwise_xor |
| 11777 | && |
| 11778 | (_literal = _PyPegen_expect_token(p, 32)) // token='^' |
| 11779 | && |
| 11780 | (b = bitwise_and_rule(p)) // bitwise_and |
| 11781 | ) |
| 11782 | { |
| 11783 | D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and")); |
| 11784 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11785 | if (_token == NULL) { |
| 11786 | D(p->level--); |
| 11787 | return NULL; |
| 11788 | } |
| 11789 | int _end_lineno = _token->end_lineno; |
| 11790 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11791 | int _end_col_offset = _token->end_col_offset; |
| 11792 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 11793 | _res = _PyAST_BinOp ( a , BitXor , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11794 | if (_res == NULL && PyErr_Occurred()) { |
| 11795 | p->error_indicator = 1; |
| 11796 | D(p->level--); |
| 11797 | return NULL; |
| 11798 | } |
| 11799 | goto done; |
| 11800 | } |
| 11801 | p->mark = _mark; |
| 11802 | D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ', |
| 11803 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor '^' bitwise_and")); |
| 11804 | } |
| 11805 | { // bitwise_and |
| 11806 | if (p->error_indicator) { |
| 11807 | D(p->level--); |
| 11808 | return NULL; |
| 11809 | } |
| 11810 | D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and")); |
| 11811 | expr_ty bitwise_and_var; |
| 11812 | if ( |
| 11813 | (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and |
| 11814 | ) |
| 11815 | { |
| 11816 | D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and")); |
| 11817 | _res = bitwise_and_var; |
| 11818 | goto done; |
| 11819 | } |
| 11820 | p->mark = _mark; |
| 11821 | D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ', |
| 11822 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and")); |
| 11823 | } |
| 11824 | _res = NULL; |
| 11825 | done: |
| 11826 | D(p->level--); |
| 11827 | return _res; |
| 11828 | } |
| 11829 | |
| 11830 | // Left-recursive |
| 11831 | // bitwise_and: bitwise_and '&' shift_expr | shift_expr |
| 11832 | static expr_ty bitwise_and_raw(Parser *); |
| 11833 | static expr_ty |
| 11834 | bitwise_and_rule(Parser *p) |
| 11835 | { |
| 11836 | D(p->level++); |
| 11837 | expr_ty _res = NULL; |
| 11838 | if (_PyPegen_is_memoized(p, bitwise_and_type, &_res)) { |
| 11839 | D(p->level--); |
| 11840 | return _res; |
| 11841 | } |
| 11842 | int _mark = p->mark; |
| 11843 | int _resmark = p->mark; |
| 11844 | while (1) { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 11845 | int tmpvar_4 = _PyPegen_update_memo(p, _mark, bitwise_and_type, _res); |
| 11846 | if (tmpvar_4) { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11847 | D(p->level--); |
| 11848 | return _res; |
| 11849 | } |
| 11850 | p->mark = _mark; |
| 11851 | void *_raw = bitwise_and_raw(p); |
Lysandros Nikolaou | 02cdfc9 | 2020-10-31 20:31:41 +0200 | [diff] [blame] | 11852 | if (p->error_indicator) |
| 11853 | return NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11854 | if (_raw == NULL || p->mark <= _resmark) |
| 11855 | break; |
| 11856 | _resmark = p->mark; |
| 11857 | _res = _raw; |
| 11858 | } |
| 11859 | p->mark = _resmark; |
| 11860 | D(p->level--); |
| 11861 | return _res; |
| 11862 | } |
| 11863 | static expr_ty |
| 11864 | bitwise_and_raw(Parser *p) |
| 11865 | { |
| 11866 | D(p->level++); |
| 11867 | if (p->error_indicator) { |
| 11868 | D(p->level--); |
| 11869 | return NULL; |
| 11870 | } |
| 11871 | expr_ty _res = NULL; |
| 11872 | int _mark = p->mark; |
| 11873 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 11874 | p->error_indicator = 1; |
| 11875 | D(p->level--); |
| 11876 | return NULL; |
| 11877 | } |
| 11878 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11879 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11880 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11881 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 11882 | { // bitwise_and '&' shift_expr |
| 11883 | if (p->error_indicator) { |
| 11884 | D(p->level--); |
| 11885 | return NULL; |
| 11886 | } |
| 11887 | D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr")); |
| 11888 | Token * _literal; |
| 11889 | expr_ty a; |
| 11890 | expr_ty b; |
| 11891 | if ( |
| 11892 | (a = bitwise_and_rule(p)) // bitwise_and |
| 11893 | && |
| 11894 | (_literal = _PyPegen_expect_token(p, 19)) // token='&' |
| 11895 | && |
| 11896 | (b = shift_expr_rule(p)) // shift_expr |
| 11897 | ) |
| 11898 | { |
| 11899 | D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr")); |
| 11900 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11901 | if (_token == NULL) { |
| 11902 | D(p->level--); |
| 11903 | return NULL; |
| 11904 | } |
| 11905 | int _end_lineno = _token->end_lineno; |
| 11906 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11907 | int _end_col_offset = _token->end_col_offset; |
| 11908 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 11909 | _res = _PyAST_BinOp ( a , BitAnd , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11910 | if (_res == NULL && PyErr_Occurred()) { |
| 11911 | p->error_indicator = 1; |
| 11912 | D(p->level--); |
| 11913 | return NULL; |
| 11914 | } |
| 11915 | goto done; |
| 11916 | } |
| 11917 | p->mark = _mark; |
| 11918 | D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', |
| 11919 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and '&' shift_expr")); |
| 11920 | } |
| 11921 | { // shift_expr |
| 11922 | if (p->error_indicator) { |
| 11923 | D(p->level--); |
| 11924 | return NULL; |
| 11925 | } |
| 11926 | D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr")); |
| 11927 | expr_ty shift_expr_var; |
| 11928 | if ( |
| 11929 | (shift_expr_var = shift_expr_rule(p)) // shift_expr |
| 11930 | ) |
| 11931 | { |
| 11932 | D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr")); |
| 11933 | _res = shift_expr_var; |
| 11934 | goto done; |
| 11935 | } |
| 11936 | p->mark = _mark; |
| 11937 | D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', |
| 11938 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr")); |
| 11939 | } |
| 11940 | _res = NULL; |
| 11941 | done: |
| 11942 | D(p->level--); |
| 11943 | return _res; |
| 11944 | } |
| 11945 | |
| 11946 | // Left-recursive |
| 11947 | // shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum |
| 11948 | static expr_ty shift_expr_raw(Parser *); |
| 11949 | static expr_ty |
| 11950 | shift_expr_rule(Parser *p) |
| 11951 | { |
| 11952 | D(p->level++); |
| 11953 | expr_ty _res = NULL; |
| 11954 | if (_PyPegen_is_memoized(p, shift_expr_type, &_res)) { |
| 11955 | D(p->level--); |
| 11956 | return _res; |
| 11957 | } |
| 11958 | int _mark = p->mark; |
| 11959 | int _resmark = p->mark; |
| 11960 | while (1) { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 11961 | int tmpvar_5 = _PyPegen_update_memo(p, _mark, shift_expr_type, _res); |
| 11962 | if (tmpvar_5) { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11963 | D(p->level--); |
| 11964 | return _res; |
| 11965 | } |
| 11966 | p->mark = _mark; |
| 11967 | void *_raw = shift_expr_raw(p); |
Lysandros Nikolaou | 02cdfc9 | 2020-10-31 20:31:41 +0200 | [diff] [blame] | 11968 | if (p->error_indicator) |
| 11969 | return NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 11970 | if (_raw == NULL || p->mark <= _resmark) |
| 11971 | break; |
| 11972 | _resmark = p->mark; |
| 11973 | _res = _raw; |
| 11974 | } |
| 11975 | p->mark = _resmark; |
| 11976 | D(p->level--); |
| 11977 | return _res; |
| 11978 | } |
| 11979 | static expr_ty |
| 11980 | shift_expr_raw(Parser *p) |
| 11981 | { |
| 11982 | D(p->level++); |
| 11983 | if (p->error_indicator) { |
| 11984 | D(p->level--); |
| 11985 | return NULL; |
| 11986 | } |
| 11987 | expr_ty _res = NULL; |
| 11988 | int _mark = p->mark; |
| 11989 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 11990 | p->error_indicator = 1; |
| 11991 | D(p->level--); |
| 11992 | return NULL; |
| 11993 | } |
| 11994 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11995 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11996 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11997 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 11998 | { // shift_expr '<<' sum |
| 11999 | if (p->error_indicator) { |
| 12000 | D(p->level--); |
| 12001 | return NULL; |
| 12002 | } |
| 12003 | D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum")); |
| 12004 | Token * _literal; |
| 12005 | expr_ty a; |
| 12006 | expr_ty b; |
| 12007 | if ( |
| 12008 | (a = shift_expr_rule(p)) // shift_expr |
| 12009 | && |
| 12010 | (_literal = _PyPegen_expect_token(p, 33)) // token='<<' |
| 12011 | && |
| 12012 | (b = sum_rule(p)) // sum |
| 12013 | ) |
| 12014 | { |
| 12015 | D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum")); |
| 12016 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12017 | if (_token == NULL) { |
| 12018 | D(p->level--); |
| 12019 | return NULL; |
| 12020 | } |
| 12021 | int _end_lineno = _token->end_lineno; |
| 12022 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12023 | int _end_col_offset = _token->end_col_offset; |
| 12024 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12025 | _res = _PyAST_BinOp ( a , LShift , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12026 | if (_res == NULL && PyErr_Occurred()) { |
| 12027 | p->error_indicator = 1; |
| 12028 | D(p->level--); |
| 12029 | return NULL; |
| 12030 | } |
| 12031 | goto done; |
| 12032 | } |
| 12033 | p->mark = _mark; |
| 12034 | D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', |
| 12035 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '<<' sum")); |
| 12036 | } |
| 12037 | { // shift_expr '>>' sum |
| 12038 | if (p->error_indicator) { |
| 12039 | D(p->level--); |
| 12040 | return NULL; |
| 12041 | } |
| 12042 | D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum")); |
| 12043 | Token * _literal; |
| 12044 | expr_ty a; |
| 12045 | expr_ty b; |
| 12046 | if ( |
| 12047 | (a = shift_expr_rule(p)) // shift_expr |
| 12048 | && |
| 12049 | (_literal = _PyPegen_expect_token(p, 34)) // token='>>' |
| 12050 | && |
| 12051 | (b = sum_rule(p)) // sum |
| 12052 | ) |
| 12053 | { |
| 12054 | D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum")); |
| 12055 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12056 | if (_token == NULL) { |
| 12057 | D(p->level--); |
| 12058 | return NULL; |
| 12059 | } |
| 12060 | int _end_lineno = _token->end_lineno; |
| 12061 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12062 | int _end_col_offset = _token->end_col_offset; |
| 12063 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12064 | _res = _PyAST_BinOp ( a , RShift , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12065 | if (_res == NULL && PyErr_Occurred()) { |
| 12066 | p->error_indicator = 1; |
| 12067 | D(p->level--); |
| 12068 | return NULL; |
| 12069 | } |
| 12070 | goto done; |
| 12071 | } |
| 12072 | p->mark = _mark; |
| 12073 | D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', |
| 12074 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '>>' sum")); |
| 12075 | } |
| 12076 | { // sum |
| 12077 | if (p->error_indicator) { |
| 12078 | D(p->level--); |
| 12079 | return NULL; |
| 12080 | } |
| 12081 | D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum")); |
| 12082 | expr_ty sum_var; |
| 12083 | if ( |
| 12084 | (sum_var = sum_rule(p)) // sum |
| 12085 | ) |
| 12086 | { |
| 12087 | D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum")); |
| 12088 | _res = sum_var; |
| 12089 | goto done; |
| 12090 | } |
| 12091 | p->mark = _mark; |
| 12092 | D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', |
| 12093 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum")); |
| 12094 | } |
| 12095 | _res = NULL; |
| 12096 | done: |
| 12097 | D(p->level--); |
| 12098 | return _res; |
| 12099 | } |
| 12100 | |
| 12101 | // Left-recursive |
| 12102 | // sum: sum '+' term | sum '-' term | term |
| 12103 | static expr_ty sum_raw(Parser *); |
| 12104 | static expr_ty |
| 12105 | sum_rule(Parser *p) |
| 12106 | { |
| 12107 | D(p->level++); |
| 12108 | expr_ty _res = NULL; |
| 12109 | if (_PyPegen_is_memoized(p, sum_type, &_res)) { |
| 12110 | D(p->level--); |
| 12111 | return _res; |
| 12112 | } |
| 12113 | int _mark = p->mark; |
| 12114 | int _resmark = p->mark; |
| 12115 | while (1) { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 12116 | int tmpvar_6 = _PyPegen_update_memo(p, _mark, sum_type, _res); |
| 12117 | if (tmpvar_6) { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12118 | D(p->level--); |
| 12119 | return _res; |
| 12120 | } |
| 12121 | p->mark = _mark; |
| 12122 | void *_raw = sum_raw(p); |
Lysandros Nikolaou | 02cdfc9 | 2020-10-31 20:31:41 +0200 | [diff] [blame] | 12123 | if (p->error_indicator) |
| 12124 | return NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12125 | if (_raw == NULL || p->mark <= _resmark) |
| 12126 | break; |
| 12127 | _resmark = p->mark; |
| 12128 | _res = _raw; |
| 12129 | } |
| 12130 | p->mark = _resmark; |
| 12131 | D(p->level--); |
| 12132 | return _res; |
| 12133 | } |
| 12134 | static expr_ty |
| 12135 | sum_raw(Parser *p) |
| 12136 | { |
| 12137 | D(p->level++); |
| 12138 | if (p->error_indicator) { |
| 12139 | D(p->level--); |
| 12140 | return NULL; |
| 12141 | } |
| 12142 | expr_ty _res = NULL; |
| 12143 | int _mark = p->mark; |
| 12144 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 12145 | p->error_indicator = 1; |
| 12146 | D(p->level--); |
| 12147 | return NULL; |
| 12148 | } |
| 12149 | int _start_lineno = p->tokens[_mark]->lineno; |
| 12150 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 12151 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 12152 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 12153 | { // sum '+' term |
| 12154 | if (p->error_indicator) { |
| 12155 | D(p->level--); |
| 12156 | return NULL; |
| 12157 | } |
| 12158 | D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '+' term")); |
| 12159 | Token * _literal; |
| 12160 | expr_ty a; |
| 12161 | expr_ty b; |
| 12162 | if ( |
| 12163 | (a = sum_rule(p)) // sum |
| 12164 | && |
| 12165 | (_literal = _PyPegen_expect_token(p, 14)) // token='+' |
| 12166 | && |
| 12167 | (b = term_rule(p)) // term |
| 12168 | ) |
| 12169 | { |
| 12170 | D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '+' term")); |
| 12171 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12172 | if (_token == NULL) { |
| 12173 | D(p->level--); |
| 12174 | return NULL; |
| 12175 | } |
| 12176 | int _end_lineno = _token->end_lineno; |
| 12177 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12178 | int _end_col_offset = _token->end_col_offset; |
| 12179 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12180 | _res = _PyAST_BinOp ( a , Add , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12181 | if (_res == NULL && PyErr_Occurred()) { |
| 12182 | p->error_indicator = 1; |
| 12183 | D(p->level--); |
| 12184 | return NULL; |
| 12185 | } |
| 12186 | goto done; |
| 12187 | } |
| 12188 | p->mark = _mark; |
| 12189 | D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', |
| 12190 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '+' term")); |
| 12191 | } |
| 12192 | { // sum '-' term |
| 12193 | if (p->error_indicator) { |
| 12194 | D(p->level--); |
| 12195 | return NULL; |
| 12196 | } |
| 12197 | D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '-' term")); |
| 12198 | Token * _literal; |
| 12199 | expr_ty a; |
| 12200 | expr_ty b; |
| 12201 | if ( |
| 12202 | (a = sum_rule(p)) // sum |
| 12203 | && |
| 12204 | (_literal = _PyPegen_expect_token(p, 15)) // token='-' |
| 12205 | && |
| 12206 | (b = term_rule(p)) // term |
| 12207 | ) |
| 12208 | { |
| 12209 | D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '-' term")); |
| 12210 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12211 | if (_token == NULL) { |
| 12212 | D(p->level--); |
| 12213 | return NULL; |
| 12214 | } |
| 12215 | int _end_lineno = _token->end_lineno; |
| 12216 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12217 | int _end_col_offset = _token->end_col_offset; |
| 12218 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12219 | _res = _PyAST_BinOp ( a , Sub , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12220 | if (_res == NULL && PyErr_Occurred()) { |
| 12221 | p->error_indicator = 1; |
| 12222 | D(p->level--); |
| 12223 | return NULL; |
| 12224 | } |
| 12225 | goto done; |
| 12226 | } |
| 12227 | p->mark = _mark; |
| 12228 | D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', |
| 12229 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '-' term")); |
| 12230 | } |
| 12231 | { // term |
| 12232 | if (p->error_indicator) { |
| 12233 | D(p->level--); |
| 12234 | return NULL; |
| 12235 | } |
| 12236 | D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term")); |
| 12237 | expr_ty term_var; |
| 12238 | if ( |
| 12239 | (term_var = term_rule(p)) // term |
| 12240 | ) |
| 12241 | { |
| 12242 | D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term")); |
| 12243 | _res = term_var; |
| 12244 | goto done; |
| 12245 | } |
| 12246 | p->mark = _mark; |
| 12247 | D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', |
| 12248 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term")); |
| 12249 | } |
| 12250 | _res = NULL; |
| 12251 | done: |
| 12252 | D(p->level--); |
| 12253 | return _res; |
| 12254 | } |
| 12255 | |
| 12256 | // Left-recursive |
| 12257 | // term: |
| 12258 | // | term '*' factor |
| 12259 | // | term '/' factor |
| 12260 | // | term '//' factor |
| 12261 | // | term '%' factor |
| 12262 | // | term '@' factor |
| 12263 | // | factor |
| 12264 | static expr_ty term_raw(Parser *); |
| 12265 | static expr_ty |
| 12266 | term_rule(Parser *p) |
| 12267 | { |
| 12268 | D(p->level++); |
| 12269 | expr_ty _res = NULL; |
| 12270 | if (_PyPegen_is_memoized(p, term_type, &_res)) { |
| 12271 | D(p->level--); |
| 12272 | return _res; |
| 12273 | } |
| 12274 | int _mark = p->mark; |
| 12275 | int _resmark = p->mark; |
| 12276 | while (1) { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 12277 | int tmpvar_7 = _PyPegen_update_memo(p, _mark, term_type, _res); |
| 12278 | if (tmpvar_7) { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12279 | D(p->level--); |
| 12280 | return _res; |
| 12281 | } |
| 12282 | p->mark = _mark; |
| 12283 | void *_raw = term_raw(p); |
Lysandros Nikolaou | 02cdfc9 | 2020-10-31 20:31:41 +0200 | [diff] [blame] | 12284 | if (p->error_indicator) |
| 12285 | return NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12286 | if (_raw == NULL || p->mark <= _resmark) |
| 12287 | break; |
| 12288 | _resmark = p->mark; |
| 12289 | _res = _raw; |
| 12290 | } |
| 12291 | p->mark = _resmark; |
| 12292 | D(p->level--); |
| 12293 | return _res; |
| 12294 | } |
| 12295 | static expr_ty |
| 12296 | term_raw(Parser *p) |
| 12297 | { |
| 12298 | D(p->level++); |
| 12299 | if (p->error_indicator) { |
| 12300 | D(p->level--); |
| 12301 | return NULL; |
| 12302 | } |
| 12303 | expr_ty _res = NULL; |
| 12304 | int _mark = p->mark; |
| 12305 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 12306 | p->error_indicator = 1; |
| 12307 | D(p->level--); |
| 12308 | return NULL; |
| 12309 | } |
| 12310 | int _start_lineno = p->tokens[_mark]->lineno; |
| 12311 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 12312 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 12313 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 12314 | { // term '*' factor |
| 12315 | if (p->error_indicator) { |
| 12316 | D(p->level--); |
| 12317 | return NULL; |
| 12318 | } |
| 12319 | D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '*' factor")); |
| 12320 | Token * _literal; |
| 12321 | expr_ty a; |
| 12322 | expr_ty b; |
| 12323 | if ( |
| 12324 | (a = term_rule(p)) // term |
| 12325 | && |
| 12326 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 12327 | && |
| 12328 | (b = factor_rule(p)) // factor |
| 12329 | ) |
| 12330 | { |
| 12331 | D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '*' factor")); |
| 12332 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12333 | if (_token == NULL) { |
| 12334 | D(p->level--); |
| 12335 | return NULL; |
| 12336 | } |
| 12337 | int _end_lineno = _token->end_lineno; |
| 12338 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12339 | int _end_col_offset = _token->end_col_offset; |
| 12340 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12341 | _res = _PyAST_BinOp ( a , Mult , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12342 | if (_res == NULL && PyErr_Occurred()) { |
| 12343 | p->error_indicator = 1; |
| 12344 | D(p->level--); |
| 12345 | return NULL; |
| 12346 | } |
| 12347 | goto done; |
| 12348 | } |
| 12349 | p->mark = _mark; |
| 12350 | D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', |
| 12351 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '*' factor")); |
| 12352 | } |
| 12353 | { // term '/' factor |
| 12354 | if (p->error_indicator) { |
| 12355 | D(p->level--); |
| 12356 | return NULL; |
| 12357 | } |
| 12358 | D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '/' factor")); |
| 12359 | Token * _literal; |
| 12360 | expr_ty a; |
| 12361 | expr_ty b; |
| 12362 | if ( |
| 12363 | (a = term_rule(p)) // term |
| 12364 | && |
| 12365 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
| 12366 | && |
| 12367 | (b = factor_rule(p)) // factor |
| 12368 | ) |
| 12369 | { |
| 12370 | D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '/' factor")); |
| 12371 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12372 | if (_token == NULL) { |
| 12373 | D(p->level--); |
| 12374 | return NULL; |
| 12375 | } |
| 12376 | int _end_lineno = _token->end_lineno; |
| 12377 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12378 | int _end_col_offset = _token->end_col_offset; |
| 12379 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12380 | _res = _PyAST_BinOp ( a , Div , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12381 | if (_res == NULL && PyErr_Occurred()) { |
| 12382 | p->error_indicator = 1; |
| 12383 | D(p->level--); |
| 12384 | return NULL; |
| 12385 | } |
| 12386 | goto done; |
| 12387 | } |
| 12388 | p->mark = _mark; |
| 12389 | D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', |
| 12390 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '/' factor")); |
| 12391 | } |
| 12392 | { // term '//' factor |
| 12393 | if (p->error_indicator) { |
| 12394 | D(p->level--); |
| 12395 | return NULL; |
| 12396 | } |
| 12397 | D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '//' factor")); |
| 12398 | Token * _literal; |
| 12399 | expr_ty a; |
| 12400 | expr_ty b; |
| 12401 | if ( |
| 12402 | (a = term_rule(p)) // term |
| 12403 | && |
| 12404 | (_literal = _PyPegen_expect_token(p, 47)) // token='//' |
| 12405 | && |
| 12406 | (b = factor_rule(p)) // factor |
| 12407 | ) |
| 12408 | { |
| 12409 | D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '//' factor")); |
| 12410 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12411 | if (_token == NULL) { |
| 12412 | D(p->level--); |
| 12413 | return NULL; |
| 12414 | } |
| 12415 | int _end_lineno = _token->end_lineno; |
| 12416 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12417 | int _end_col_offset = _token->end_col_offset; |
| 12418 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12419 | _res = _PyAST_BinOp ( a , FloorDiv , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12420 | if (_res == NULL && PyErr_Occurred()) { |
| 12421 | p->error_indicator = 1; |
| 12422 | D(p->level--); |
| 12423 | return NULL; |
| 12424 | } |
| 12425 | goto done; |
| 12426 | } |
| 12427 | p->mark = _mark; |
| 12428 | D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', |
| 12429 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '//' factor")); |
| 12430 | } |
| 12431 | { // term '%' factor |
| 12432 | if (p->error_indicator) { |
| 12433 | D(p->level--); |
| 12434 | return NULL; |
| 12435 | } |
| 12436 | D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '%' factor")); |
| 12437 | Token * _literal; |
| 12438 | expr_ty a; |
| 12439 | expr_ty b; |
| 12440 | if ( |
| 12441 | (a = term_rule(p)) // term |
| 12442 | && |
| 12443 | (_literal = _PyPegen_expect_token(p, 24)) // token='%' |
| 12444 | && |
| 12445 | (b = factor_rule(p)) // factor |
| 12446 | ) |
| 12447 | { |
| 12448 | D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '%' factor")); |
| 12449 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12450 | if (_token == NULL) { |
| 12451 | D(p->level--); |
| 12452 | return NULL; |
| 12453 | } |
| 12454 | int _end_lineno = _token->end_lineno; |
| 12455 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12456 | int _end_col_offset = _token->end_col_offset; |
| 12457 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12458 | _res = _PyAST_BinOp ( a , Mod , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12459 | if (_res == NULL && PyErr_Occurred()) { |
| 12460 | p->error_indicator = 1; |
| 12461 | D(p->level--); |
| 12462 | return NULL; |
| 12463 | } |
| 12464 | goto done; |
| 12465 | } |
| 12466 | p->mark = _mark; |
| 12467 | D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', |
| 12468 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '%' factor")); |
| 12469 | } |
| 12470 | { // term '@' factor |
| 12471 | if (p->error_indicator) { |
| 12472 | D(p->level--); |
| 12473 | return NULL; |
| 12474 | } |
| 12475 | D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '@' factor")); |
| 12476 | Token * _literal; |
| 12477 | expr_ty a; |
| 12478 | expr_ty b; |
| 12479 | if ( |
| 12480 | (a = term_rule(p)) // term |
| 12481 | && |
| 12482 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
| 12483 | && |
| 12484 | (b = factor_rule(p)) // factor |
| 12485 | ) |
| 12486 | { |
| 12487 | D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '@' factor")); |
| 12488 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12489 | if (_token == NULL) { |
| 12490 | D(p->level--); |
| 12491 | return NULL; |
| 12492 | } |
| 12493 | int _end_lineno = _token->end_lineno; |
| 12494 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12495 | int _end_col_offset = _token->end_col_offset; |
| 12496 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12497 | _res = CHECK_VERSION ( expr_ty , 5 , "The '@' operator is" , _PyAST_BinOp ( a , MatMult , b , EXTRA ) ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12498 | if (_res == NULL && PyErr_Occurred()) { |
| 12499 | p->error_indicator = 1; |
| 12500 | D(p->level--); |
| 12501 | return NULL; |
| 12502 | } |
| 12503 | goto done; |
| 12504 | } |
| 12505 | p->mark = _mark; |
| 12506 | D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', |
| 12507 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '@' factor")); |
| 12508 | } |
| 12509 | { // factor |
| 12510 | if (p->error_indicator) { |
| 12511 | D(p->level--); |
| 12512 | return NULL; |
| 12513 | } |
| 12514 | D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "factor")); |
| 12515 | expr_ty factor_var; |
| 12516 | if ( |
| 12517 | (factor_var = factor_rule(p)) // factor |
| 12518 | ) |
| 12519 | { |
| 12520 | D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "factor")); |
| 12521 | _res = factor_var; |
| 12522 | goto done; |
| 12523 | } |
| 12524 | p->mark = _mark; |
| 12525 | D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', |
| 12526 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "factor")); |
| 12527 | } |
| 12528 | _res = NULL; |
| 12529 | done: |
| 12530 | D(p->level--); |
| 12531 | return _res; |
| 12532 | } |
| 12533 | |
| 12534 | // factor: '+' factor | '-' factor | '~' factor | power |
| 12535 | static expr_ty |
| 12536 | factor_rule(Parser *p) |
| 12537 | { |
| 12538 | D(p->level++); |
| 12539 | if (p->error_indicator) { |
| 12540 | D(p->level--); |
| 12541 | return NULL; |
| 12542 | } |
| 12543 | expr_ty _res = NULL; |
| 12544 | if (_PyPegen_is_memoized(p, factor_type, &_res)) { |
| 12545 | D(p->level--); |
| 12546 | return _res; |
| 12547 | } |
| 12548 | int _mark = p->mark; |
| 12549 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 12550 | p->error_indicator = 1; |
| 12551 | D(p->level--); |
| 12552 | return NULL; |
| 12553 | } |
| 12554 | int _start_lineno = p->tokens[_mark]->lineno; |
| 12555 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 12556 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 12557 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 12558 | { // '+' factor |
| 12559 | if (p->error_indicator) { |
| 12560 | D(p->level--); |
| 12561 | return NULL; |
| 12562 | } |
| 12563 | D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+' factor")); |
| 12564 | Token * _literal; |
| 12565 | expr_ty a; |
| 12566 | if ( |
| 12567 | (_literal = _PyPegen_expect_token(p, 14)) // token='+' |
| 12568 | && |
| 12569 | (a = factor_rule(p)) // factor |
| 12570 | ) |
| 12571 | { |
| 12572 | D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+' factor")); |
| 12573 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12574 | if (_token == NULL) { |
| 12575 | D(p->level--); |
| 12576 | return NULL; |
| 12577 | } |
| 12578 | int _end_lineno = _token->end_lineno; |
| 12579 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12580 | int _end_col_offset = _token->end_col_offset; |
| 12581 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12582 | _res = _PyAST_UnaryOp ( UAdd , a , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12583 | if (_res == NULL && PyErr_Occurred()) { |
| 12584 | p->error_indicator = 1; |
| 12585 | D(p->level--); |
| 12586 | return NULL; |
| 12587 | } |
| 12588 | goto done; |
| 12589 | } |
| 12590 | p->mark = _mark; |
| 12591 | D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', |
| 12592 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+' factor")); |
| 12593 | } |
| 12594 | { // '-' factor |
| 12595 | if (p->error_indicator) { |
| 12596 | D(p->level--); |
| 12597 | return NULL; |
| 12598 | } |
| 12599 | D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-' factor")); |
| 12600 | Token * _literal; |
| 12601 | expr_ty a; |
| 12602 | if ( |
| 12603 | (_literal = _PyPegen_expect_token(p, 15)) // token='-' |
| 12604 | && |
| 12605 | (a = factor_rule(p)) // factor |
| 12606 | ) |
| 12607 | { |
| 12608 | D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-' factor")); |
| 12609 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12610 | if (_token == NULL) { |
| 12611 | D(p->level--); |
| 12612 | return NULL; |
| 12613 | } |
| 12614 | int _end_lineno = _token->end_lineno; |
| 12615 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12616 | int _end_col_offset = _token->end_col_offset; |
| 12617 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12618 | _res = _PyAST_UnaryOp ( USub , a , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12619 | if (_res == NULL && PyErr_Occurred()) { |
| 12620 | p->error_indicator = 1; |
| 12621 | D(p->level--); |
| 12622 | return NULL; |
| 12623 | } |
| 12624 | goto done; |
| 12625 | } |
| 12626 | p->mark = _mark; |
| 12627 | D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', |
| 12628 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-' factor")); |
| 12629 | } |
| 12630 | { // '~' factor |
| 12631 | if (p->error_indicator) { |
| 12632 | D(p->level--); |
| 12633 | return NULL; |
| 12634 | } |
| 12635 | D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'~' factor")); |
| 12636 | Token * _literal; |
| 12637 | expr_ty a; |
| 12638 | if ( |
| 12639 | (_literal = _PyPegen_expect_token(p, 31)) // token='~' |
| 12640 | && |
| 12641 | (a = factor_rule(p)) // factor |
| 12642 | ) |
| 12643 | { |
| 12644 | D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'~' factor")); |
| 12645 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12646 | if (_token == NULL) { |
| 12647 | D(p->level--); |
| 12648 | return NULL; |
| 12649 | } |
| 12650 | int _end_lineno = _token->end_lineno; |
| 12651 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12652 | int _end_col_offset = _token->end_col_offset; |
| 12653 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12654 | _res = _PyAST_UnaryOp ( Invert , a , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12655 | if (_res == NULL && PyErr_Occurred()) { |
| 12656 | p->error_indicator = 1; |
| 12657 | D(p->level--); |
| 12658 | return NULL; |
| 12659 | } |
| 12660 | goto done; |
| 12661 | } |
| 12662 | p->mark = _mark; |
| 12663 | D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', |
| 12664 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'~' factor")); |
| 12665 | } |
| 12666 | { // power |
| 12667 | if (p->error_indicator) { |
| 12668 | D(p->level--); |
| 12669 | return NULL; |
| 12670 | } |
| 12671 | D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "power")); |
| 12672 | expr_ty power_var; |
| 12673 | if ( |
| 12674 | (power_var = power_rule(p)) // power |
| 12675 | ) |
| 12676 | { |
| 12677 | D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "power")); |
| 12678 | _res = power_var; |
| 12679 | goto done; |
| 12680 | } |
| 12681 | p->mark = _mark; |
| 12682 | D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', |
| 12683 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "power")); |
| 12684 | } |
| 12685 | _res = NULL; |
| 12686 | done: |
| 12687 | _PyPegen_insert_memo(p, _mark, factor_type, _res); |
| 12688 | D(p->level--); |
| 12689 | return _res; |
| 12690 | } |
| 12691 | |
| 12692 | // power: await_primary '**' factor | await_primary |
| 12693 | static expr_ty |
| 12694 | power_rule(Parser *p) |
| 12695 | { |
| 12696 | D(p->level++); |
| 12697 | if (p->error_indicator) { |
| 12698 | D(p->level--); |
| 12699 | return NULL; |
| 12700 | } |
| 12701 | expr_ty _res = NULL; |
| 12702 | int _mark = p->mark; |
| 12703 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 12704 | p->error_indicator = 1; |
| 12705 | D(p->level--); |
| 12706 | return NULL; |
| 12707 | } |
| 12708 | int _start_lineno = p->tokens[_mark]->lineno; |
| 12709 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 12710 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 12711 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 12712 | { // await_primary '**' factor |
| 12713 | if (p->error_indicator) { |
| 12714 | D(p->level--); |
| 12715 | return NULL; |
| 12716 | } |
| 12717 | D(fprintf(stderr, "%*c> power[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "await_primary '**' factor")); |
| 12718 | Token * _literal; |
| 12719 | expr_ty a; |
| 12720 | expr_ty b; |
| 12721 | if ( |
| 12722 | (a = await_primary_rule(p)) // await_primary |
| 12723 | && |
| 12724 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
| 12725 | && |
| 12726 | (b = factor_rule(p)) // factor |
| 12727 | ) |
| 12728 | { |
| 12729 | D(fprintf(stderr, "%*c+ power[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "await_primary '**' factor")); |
| 12730 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12731 | if (_token == NULL) { |
| 12732 | D(p->level--); |
| 12733 | return NULL; |
| 12734 | } |
| 12735 | int _end_lineno = _token->end_lineno; |
| 12736 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12737 | int _end_col_offset = _token->end_col_offset; |
| 12738 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12739 | _res = _PyAST_BinOp ( a , Pow , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12740 | if (_res == NULL && PyErr_Occurred()) { |
| 12741 | p->error_indicator = 1; |
| 12742 | D(p->level--); |
| 12743 | return NULL; |
| 12744 | } |
| 12745 | goto done; |
| 12746 | } |
| 12747 | p->mark = _mark; |
| 12748 | D(fprintf(stderr, "%*c%s power[%d-%d]: %s failed!\n", p->level, ' ', |
| 12749 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "await_primary '**' factor")); |
| 12750 | } |
| 12751 | { // await_primary |
| 12752 | if (p->error_indicator) { |
| 12753 | D(p->level--); |
| 12754 | return NULL; |
| 12755 | } |
| 12756 | D(fprintf(stderr, "%*c> power[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "await_primary")); |
| 12757 | expr_ty await_primary_var; |
| 12758 | if ( |
| 12759 | (await_primary_var = await_primary_rule(p)) // await_primary |
| 12760 | ) |
| 12761 | { |
| 12762 | D(fprintf(stderr, "%*c+ power[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "await_primary")); |
| 12763 | _res = await_primary_var; |
| 12764 | goto done; |
| 12765 | } |
| 12766 | p->mark = _mark; |
| 12767 | D(fprintf(stderr, "%*c%s power[%d-%d]: %s failed!\n", p->level, ' ', |
| 12768 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "await_primary")); |
| 12769 | } |
| 12770 | _res = NULL; |
| 12771 | done: |
| 12772 | D(p->level--); |
| 12773 | return _res; |
| 12774 | } |
| 12775 | |
| 12776 | // await_primary: AWAIT primary | primary |
| 12777 | static expr_ty |
| 12778 | await_primary_rule(Parser *p) |
| 12779 | { |
| 12780 | D(p->level++); |
| 12781 | if (p->error_indicator) { |
| 12782 | D(p->level--); |
| 12783 | return NULL; |
| 12784 | } |
| 12785 | expr_ty _res = NULL; |
| 12786 | if (_PyPegen_is_memoized(p, await_primary_type, &_res)) { |
| 12787 | D(p->level--); |
| 12788 | return _res; |
| 12789 | } |
| 12790 | int _mark = p->mark; |
| 12791 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 12792 | p->error_indicator = 1; |
| 12793 | D(p->level--); |
| 12794 | return NULL; |
| 12795 | } |
| 12796 | int _start_lineno = p->tokens[_mark]->lineno; |
| 12797 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 12798 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 12799 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 12800 | { // AWAIT primary |
| 12801 | if (p->error_indicator) { |
| 12802 | D(p->level--); |
| 12803 | return NULL; |
| 12804 | } |
| 12805 | D(fprintf(stderr, "%*c> await_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "AWAIT primary")); |
| 12806 | expr_ty a; |
| 12807 | Token * await_var; |
| 12808 | if ( |
| 12809 | (await_var = _PyPegen_expect_token(p, AWAIT)) // token='AWAIT' |
| 12810 | && |
| 12811 | (a = primary_rule(p)) // primary |
| 12812 | ) |
| 12813 | { |
| 12814 | D(fprintf(stderr, "%*c+ await_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "AWAIT primary")); |
| 12815 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12816 | if (_token == NULL) { |
| 12817 | D(p->level--); |
| 12818 | return NULL; |
| 12819 | } |
| 12820 | int _end_lineno = _token->end_lineno; |
| 12821 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12822 | int _end_col_offset = _token->end_col_offset; |
| 12823 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12824 | _res = CHECK_VERSION ( expr_ty , 5 , "Await expressions are" , _PyAST_Await ( a , EXTRA ) ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12825 | if (_res == NULL && PyErr_Occurred()) { |
| 12826 | p->error_indicator = 1; |
| 12827 | D(p->level--); |
| 12828 | return NULL; |
| 12829 | } |
| 12830 | goto done; |
| 12831 | } |
| 12832 | p->mark = _mark; |
| 12833 | D(fprintf(stderr, "%*c%s await_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 12834 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "AWAIT primary")); |
| 12835 | } |
| 12836 | { // primary |
| 12837 | if (p->error_indicator) { |
| 12838 | D(p->level--); |
| 12839 | return NULL; |
| 12840 | } |
| 12841 | D(fprintf(stderr, "%*c> await_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary")); |
| 12842 | expr_ty primary_var; |
| 12843 | if ( |
| 12844 | (primary_var = primary_rule(p)) // primary |
| 12845 | ) |
| 12846 | { |
| 12847 | D(fprintf(stderr, "%*c+ await_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary")); |
| 12848 | _res = primary_var; |
| 12849 | goto done; |
| 12850 | } |
| 12851 | p->mark = _mark; |
| 12852 | D(fprintf(stderr, "%*c%s await_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 12853 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary")); |
| 12854 | } |
| 12855 | _res = NULL; |
| 12856 | done: |
| 12857 | _PyPegen_insert_memo(p, _mark, await_primary_type, _res); |
| 12858 | D(p->level--); |
| 12859 | return _res; |
| 12860 | } |
| 12861 | |
| 12862 | // Left-recursive |
| 12863 | // primary: |
Lysandros Nikolaou | 15acc4e | 2020-10-27 20:54:20 +0200 | [diff] [blame] | 12864 | // | invalid_primary |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12865 | // | primary '.' NAME |
| 12866 | // | primary genexp |
| 12867 | // | primary '(' arguments? ')' |
| 12868 | // | primary '[' slices ']' |
| 12869 | // | atom |
| 12870 | static expr_ty primary_raw(Parser *); |
| 12871 | static expr_ty |
| 12872 | primary_rule(Parser *p) |
| 12873 | { |
| 12874 | D(p->level++); |
| 12875 | expr_ty _res = NULL; |
| 12876 | if (_PyPegen_is_memoized(p, primary_type, &_res)) { |
| 12877 | D(p->level--); |
| 12878 | return _res; |
| 12879 | } |
| 12880 | int _mark = p->mark; |
| 12881 | int _resmark = p->mark; |
| 12882 | while (1) { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 12883 | int tmpvar_8 = _PyPegen_update_memo(p, _mark, primary_type, _res); |
| 12884 | if (tmpvar_8) { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12885 | D(p->level--); |
| 12886 | return _res; |
| 12887 | } |
| 12888 | p->mark = _mark; |
| 12889 | void *_raw = primary_raw(p); |
Lysandros Nikolaou | 02cdfc9 | 2020-10-31 20:31:41 +0200 | [diff] [blame] | 12890 | if (p->error_indicator) |
| 12891 | return NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12892 | if (_raw == NULL || p->mark <= _resmark) |
| 12893 | break; |
| 12894 | _resmark = p->mark; |
| 12895 | _res = _raw; |
| 12896 | } |
| 12897 | p->mark = _resmark; |
| 12898 | D(p->level--); |
| 12899 | return _res; |
| 12900 | } |
| 12901 | static expr_ty |
| 12902 | primary_raw(Parser *p) |
| 12903 | { |
| 12904 | D(p->level++); |
| 12905 | if (p->error_indicator) { |
| 12906 | D(p->level--); |
| 12907 | return NULL; |
| 12908 | } |
| 12909 | expr_ty _res = NULL; |
| 12910 | int _mark = p->mark; |
| 12911 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 12912 | p->error_indicator = 1; |
| 12913 | D(p->level--); |
| 12914 | return NULL; |
| 12915 | } |
| 12916 | int _start_lineno = p->tokens[_mark]->lineno; |
| 12917 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 12918 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 12919 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 15acc4e | 2020-10-27 20:54:20 +0200 | [diff] [blame] | 12920 | if (p->call_invalid_rules) { // invalid_primary |
| 12921 | if (p->error_indicator) { |
| 12922 | D(p->level--); |
| 12923 | return NULL; |
| 12924 | } |
| 12925 | D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_primary")); |
| 12926 | void *invalid_primary_var; |
| 12927 | if ( |
| 12928 | (invalid_primary_var = invalid_primary_rule(p)) // invalid_primary |
| 12929 | ) |
| 12930 | { |
| 12931 | D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_primary")); |
| 12932 | _res = invalid_primary_var; |
| 12933 | goto done; |
| 12934 | } |
| 12935 | p->mark = _mark; |
| 12936 | D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 12937 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_primary")); |
| 12938 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12939 | { // primary '.' NAME |
| 12940 | if (p->error_indicator) { |
| 12941 | D(p->level--); |
| 12942 | return NULL; |
| 12943 | } |
| 12944 | D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '.' NAME")); |
| 12945 | Token * _literal; |
| 12946 | expr_ty a; |
| 12947 | expr_ty b; |
| 12948 | if ( |
| 12949 | (a = primary_rule(p)) // primary |
| 12950 | && |
| 12951 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 12952 | && |
| 12953 | (b = _PyPegen_name_token(p)) // NAME |
| 12954 | ) |
| 12955 | { |
| 12956 | D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '.' NAME")); |
| 12957 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12958 | if (_token == NULL) { |
| 12959 | D(p->level--); |
| 12960 | return NULL; |
| 12961 | } |
| 12962 | int _end_lineno = _token->end_lineno; |
| 12963 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12964 | int _end_col_offset = _token->end_col_offset; |
| 12965 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 12966 | _res = _PyAST_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 12967 | if (_res == NULL && PyErr_Occurred()) { |
| 12968 | p->error_indicator = 1; |
| 12969 | D(p->level--); |
| 12970 | return NULL; |
| 12971 | } |
| 12972 | goto done; |
| 12973 | } |
| 12974 | p->mark = _mark; |
| 12975 | D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 12976 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '.' NAME")); |
| 12977 | } |
| 12978 | { // primary genexp |
| 12979 | if (p->error_indicator) { |
| 12980 | D(p->level--); |
| 12981 | return NULL; |
| 12982 | } |
| 12983 | D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary genexp")); |
| 12984 | expr_ty a; |
| 12985 | expr_ty b; |
| 12986 | if ( |
| 12987 | (a = primary_rule(p)) // primary |
| 12988 | && |
| 12989 | (b = genexp_rule(p)) // genexp |
| 12990 | ) |
| 12991 | { |
| 12992 | D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary genexp")); |
| 12993 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12994 | if (_token == NULL) { |
| 12995 | D(p->level--); |
| 12996 | return NULL; |
| 12997 | } |
| 12998 | int _end_lineno = _token->end_lineno; |
| 12999 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13000 | int _end_col_offset = _token->end_col_offset; |
| 13001 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 13002 | _res = _PyAST_Call ( a , CHECK ( asdl_expr_seq * , ( asdl_expr_seq * ) _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13003 | if (_res == NULL && PyErr_Occurred()) { |
| 13004 | p->error_indicator = 1; |
| 13005 | D(p->level--); |
| 13006 | return NULL; |
| 13007 | } |
| 13008 | goto done; |
| 13009 | } |
| 13010 | p->mark = _mark; |
| 13011 | D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 13012 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary genexp")); |
| 13013 | } |
| 13014 | { // primary '(' arguments? ')' |
| 13015 | if (p->error_indicator) { |
| 13016 | D(p->level--); |
| 13017 | return NULL; |
| 13018 | } |
| 13019 | D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '(' arguments? ')'")); |
| 13020 | Token * _literal; |
| 13021 | Token * _literal_1; |
| 13022 | expr_ty a; |
| 13023 | void *b; |
| 13024 | if ( |
| 13025 | (a = primary_rule(p)) // primary |
| 13026 | && |
| 13027 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 13028 | && |
| 13029 | (b = arguments_rule(p), 1) // arguments? |
| 13030 | && |
| 13031 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 13032 | ) |
| 13033 | { |
| 13034 | D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '(' arguments? ')'")); |
| 13035 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13036 | if (_token == NULL) { |
| 13037 | D(p->level--); |
| 13038 | return NULL; |
| 13039 | } |
| 13040 | int _end_lineno = _token->end_lineno; |
| 13041 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13042 | int _end_col_offset = _token->end_col_offset; |
| 13043 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 13044 | _res = _PyAST_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13045 | if (_res == NULL && PyErr_Occurred()) { |
| 13046 | p->error_indicator = 1; |
| 13047 | D(p->level--); |
| 13048 | return NULL; |
| 13049 | } |
| 13050 | goto done; |
| 13051 | } |
| 13052 | p->mark = _mark; |
| 13053 | D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 13054 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '(' arguments? ')'")); |
| 13055 | } |
| 13056 | { // primary '[' slices ']' |
| 13057 | if (p->error_indicator) { |
| 13058 | D(p->level--); |
| 13059 | return NULL; |
| 13060 | } |
| 13061 | D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '[' slices ']'")); |
| 13062 | Token * _literal; |
| 13063 | Token * _literal_1; |
| 13064 | expr_ty a; |
| 13065 | expr_ty b; |
| 13066 | if ( |
| 13067 | (a = primary_rule(p)) // primary |
| 13068 | && |
| 13069 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 13070 | && |
| 13071 | (b = slices_rule(p)) // slices |
| 13072 | && |
| 13073 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
| 13074 | ) |
| 13075 | { |
| 13076 | D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '[' slices ']'")); |
| 13077 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13078 | if (_token == NULL) { |
| 13079 | D(p->level--); |
| 13080 | return NULL; |
| 13081 | } |
| 13082 | int _end_lineno = _token->end_lineno; |
| 13083 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13084 | int _end_col_offset = _token->end_col_offset; |
| 13085 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 13086 | _res = _PyAST_Subscript ( a , b , Load , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13087 | if (_res == NULL && PyErr_Occurred()) { |
| 13088 | p->error_indicator = 1; |
| 13089 | D(p->level--); |
| 13090 | return NULL; |
| 13091 | } |
| 13092 | goto done; |
| 13093 | } |
| 13094 | p->mark = _mark; |
| 13095 | D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 13096 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '[' slices ']'")); |
| 13097 | } |
| 13098 | { // atom |
| 13099 | if (p->error_indicator) { |
| 13100 | D(p->level--); |
| 13101 | return NULL; |
| 13102 | } |
| 13103 | D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "atom")); |
| 13104 | expr_ty atom_var; |
| 13105 | if ( |
| 13106 | (atom_var = atom_rule(p)) // atom |
| 13107 | ) |
| 13108 | { |
| 13109 | D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "atom")); |
| 13110 | _res = atom_var; |
| 13111 | goto done; |
| 13112 | } |
| 13113 | p->mark = _mark; |
| 13114 | D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 13115 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "atom")); |
| 13116 | } |
| 13117 | _res = NULL; |
| 13118 | done: |
| 13119 | D(p->level--); |
| 13120 | return _res; |
| 13121 | } |
| 13122 | |
| 13123 | // slices: slice !',' | ','.slice+ ','? |
| 13124 | static expr_ty |
| 13125 | slices_rule(Parser *p) |
| 13126 | { |
| 13127 | D(p->level++); |
| 13128 | if (p->error_indicator) { |
| 13129 | D(p->level--); |
| 13130 | return NULL; |
| 13131 | } |
| 13132 | expr_ty _res = NULL; |
| 13133 | int _mark = p->mark; |
| 13134 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 13135 | p->error_indicator = 1; |
| 13136 | D(p->level--); |
| 13137 | return NULL; |
| 13138 | } |
| 13139 | int _start_lineno = p->tokens[_mark]->lineno; |
| 13140 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 13141 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 13142 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 13143 | { // slice !',' |
| 13144 | if (p->error_indicator) { |
| 13145 | D(p->level--); |
| 13146 | return NULL; |
| 13147 | } |
| 13148 | D(fprintf(stderr, "%*c> slices[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice !','")); |
| 13149 | expr_ty a; |
| 13150 | if ( |
| 13151 | (a = slice_rule(p)) // slice |
| 13152 | && |
| 13153 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
| 13154 | ) |
| 13155 | { |
| 13156 | D(fprintf(stderr, "%*c+ slices[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice !','")); |
| 13157 | _res = a; |
| 13158 | if (_res == NULL && PyErr_Occurred()) { |
| 13159 | p->error_indicator = 1; |
| 13160 | D(p->level--); |
| 13161 | return NULL; |
| 13162 | } |
| 13163 | goto done; |
| 13164 | } |
| 13165 | p->mark = _mark; |
| 13166 | D(fprintf(stderr, "%*c%s slices[%d-%d]: %s failed!\n", p->level, ' ', |
| 13167 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice !','")); |
| 13168 | } |
| 13169 | { // ','.slice+ ','? |
| 13170 | if (p->error_indicator) { |
| 13171 | D(p->level--); |
| 13172 | return NULL; |
| 13173 | } |
| 13174 | D(fprintf(stderr, "%*c> slices[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.slice+ ','?")); |
| 13175 | void *_opt_var; |
| 13176 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 13177 | asdl_expr_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13178 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13179 | (a = (asdl_expr_seq*)_gather_108_rule(p)) // ','.slice+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13180 | && |
| 13181 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 13182 | ) |
| 13183 | { |
| 13184 | D(fprintf(stderr, "%*c+ slices[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.slice+ ','?")); |
| 13185 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13186 | if (_token == NULL) { |
| 13187 | D(p->level--); |
| 13188 | return NULL; |
| 13189 | } |
| 13190 | int _end_lineno = _token->end_lineno; |
| 13191 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13192 | int _end_col_offset = _token->end_col_offset; |
| 13193 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 13194 | _res = _PyAST_Tuple ( a , Load , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13195 | if (_res == NULL && PyErr_Occurred()) { |
| 13196 | p->error_indicator = 1; |
| 13197 | D(p->level--); |
| 13198 | return NULL; |
| 13199 | } |
| 13200 | goto done; |
| 13201 | } |
| 13202 | p->mark = _mark; |
| 13203 | D(fprintf(stderr, "%*c%s slices[%d-%d]: %s failed!\n", p->level, ' ', |
| 13204 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.slice+ ','?")); |
| 13205 | } |
| 13206 | _res = NULL; |
| 13207 | done: |
| 13208 | D(p->level--); |
| 13209 | return _res; |
| 13210 | } |
| 13211 | |
Lysandros Nikolaou | cae6018 | 2020-11-17 01:09:35 +0200 | [diff] [blame] | 13212 | // slice: expression? ':' expression? [':' expression?] | named_expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13213 | static expr_ty |
| 13214 | slice_rule(Parser *p) |
| 13215 | { |
| 13216 | D(p->level++); |
| 13217 | if (p->error_indicator) { |
| 13218 | D(p->level--); |
| 13219 | return NULL; |
| 13220 | } |
| 13221 | expr_ty _res = NULL; |
| 13222 | int _mark = p->mark; |
| 13223 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 13224 | p->error_indicator = 1; |
| 13225 | D(p->level--); |
| 13226 | return NULL; |
| 13227 | } |
| 13228 | int _start_lineno = p->tokens[_mark]->lineno; |
| 13229 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 13230 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 13231 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 13232 | { // expression? ':' expression? [':' expression?] |
| 13233 | if (p->error_indicator) { |
| 13234 | D(p->level--); |
| 13235 | return NULL; |
| 13236 | } |
| 13237 | D(fprintf(stderr, "%*c> slice[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); |
| 13238 | Token * _literal; |
| 13239 | void *a; |
| 13240 | void *b; |
| 13241 | void *c; |
| 13242 | if ( |
| 13243 | (a = expression_rule(p), 1) // expression? |
| 13244 | && |
| 13245 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 13246 | && |
| 13247 | (b = expression_rule(p), 1) // expression? |
| 13248 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13249 | (c = _tmp_110_rule(p), 1) // [':' expression?] |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13250 | ) |
| 13251 | { |
| 13252 | D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); |
| 13253 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13254 | if (_token == NULL) { |
| 13255 | D(p->level--); |
| 13256 | return NULL; |
| 13257 | } |
| 13258 | int _end_lineno = _token->end_lineno; |
| 13259 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13260 | int _end_col_offset = _token->end_col_offset; |
| 13261 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 13262 | _res = _PyAST_Slice ( a , b , c , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13263 | if (_res == NULL && PyErr_Occurred()) { |
| 13264 | p->error_indicator = 1; |
| 13265 | D(p->level--); |
| 13266 | return NULL; |
| 13267 | } |
| 13268 | goto done; |
| 13269 | } |
| 13270 | p->mark = _mark; |
| 13271 | D(fprintf(stderr, "%*c%s slice[%d-%d]: %s failed!\n", p->level, ' ', |
| 13272 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression? ':' expression? [':' expression?]")); |
| 13273 | } |
Lysandros Nikolaou | cae6018 | 2020-11-17 01:09:35 +0200 | [diff] [blame] | 13274 | { // named_expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13275 | if (p->error_indicator) { |
| 13276 | D(p->level--); |
| 13277 | return NULL; |
| 13278 | } |
Lysandros Nikolaou | cae6018 | 2020-11-17 01:09:35 +0200 | [diff] [blame] | 13279 | D(fprintf(stderr, "%*c> slice[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13280 | expr_ty a; |
| 13281 | if ( |
Lysandros Nikolaou | cae6018 | 2020-11-17 01:09:35 +0200 | [diff] [blame] | 13282 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13283 | ) |
| 13284 | { |
Lysandros Nikolaou | cae6018 | 2020-11-17 01:09:35 +0200 | [diff] [blame] | 13285 | D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13286 | _res = a; |
| 13287 | if (_res == NULL && PyErr_Occurred()) { |
| 13288 | p->error_indicator = 1; |
| 13289 | D(p->level--); |
| 13290 | return NULL; |
| 13291 | } |
| 13292 | goto done; |
| 13293 | } |
| 13294 | p->mark = _mark; |
| 13295 | D(fprintf(stderr, "%*c%s slice[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | cae6018 | 2020-11-17 01:09:35 +0200 | [diff] [blame] | 13296 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13297 | } |
| 13298 | _res = NULL; |
| 13299 | done: |
| 13300 | D(p->level--); |
| 13301 | return _res; |
| 13302 | } |
| 13303 | |
| 13304 | // atom: |
| 13305 | // | NAME |
| 13306 | // | 'True' |
| 13307 | // | 'False' |
| 13308 | // | 'None' |
| 13309 | // | &STRING strings |
| 13310 | // | NUMBER |
| 13311 | // | &'(' (tuple | group | genexp) |
| 13312 | // | &'[' (list | listcomp) |
| 13313 | // | &'{' (dict | set | dictcomp | setcomp) |
| 13314 | // | '...' |
| 13315 | static expr_ty |
| 13316 | atom_rule(Parser *p) |
| 13317 | { |
| 13318 | D(p->level++); |
| 13319 | if (p->error_indicator) { |
| 13320 | D(p->level--); |
| 13321 | return NULL; |
| 13322 | } |
| 13323 | expr_ty _res = NULL; |
| 13324 | int _mark = p->mark; |
| 13325 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 13326 | p->error_indicator = 1; |
| 13327 | D(p->level--); |
| 13328 | return NULL; |
| 13329 | } |
| 13330 | int _start_lineno = p->tokens[_mark]->lineno; |
| 13331 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 13332 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 13333 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 13334 | { // NAME |
| 13335 | if (p->error_indicator) { |
| 13336 | D(p->level--); |
| 13337 | return NULL; |
| 13338 | } |
| 13339 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); |
| 13340 | expr_ty name_var; |
| 13341 | if ( |
| 13342 | (name_var = _PyPegen_name_token(p)) // NAME |
| 13343 | ) |
| 13344 | { |
| 13345 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); |
| 13346 | _res = name_var; |
| 13347 | goto done; |
| 13348 | } |
| 13349 | p->mark = _mark; |
| 13350 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13351 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); |
| 13352 | } |
| 13353 | { // 'True' |
| 13354 | if (p->error_indicator) { |
| 13355 | D(p->level--); |
| 13356 | return NULL; |
| 13357 | } |
| 13358 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); |
| 13359 | Token * _keyword; |
| 13360 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13361 | (_keyword = _PyPegen_expect_token(p, 524)) // token='True' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13362 | ) |
| 13363 | { |
| 13364 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); |
| 13365 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13366 | if (_token == NULL) { |
| 13367 | D(p->level--); |
| 13368 | return NULL; |
| 13369 | } |
| 13370 | int _end_lineno = _token->end_lineno; |
| 13371 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13372 | int _end_col_offset = _token->end_col_offset; |
| 13373 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 13374 | _res = _PyAST_Constant ( Py_True , NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13375 | if (_res == NULL && PyErr_Occurred()) { |
| 13376 | p->error_indicator = 1; |
| 13377 | D(p->level--); |
| 13378 | return NULL; |
| 13379 | } |
| 13380 | goto done; |
| 13381 | } |
| 13382 | p->mark = _mark; |
| 13383 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13384 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); |
| 13385 | } |
| 13386 | { // 'False' |
| 13387 | if (p->error_indicator) { |
| 13388 | D(p->level--); |
| 13389 | return NULL; |
| 13390 | } |
| 13391 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); |
| 13392 | Token * _keyword; |
| 13393 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13394 | (_keyword = _PyPegen_expect_token(p, 525)) // token='False' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13395 | ) |
| 13396 | { |
| 13397 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); |
| 13398 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13399 | if (_token == NULL) { |
| 13400 | D(p->level--); |
| 13401 | return NULL; |
| 13402 | } |
| 13403 | int _end_lineno = _token->end_lineno; |
| 13404 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13405 | int _end_col_offset = _token->end_col_offset; |
| 13406 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 13407 | _res = _PyAST_Constant ( Py_False , NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13408 | if (_res == NULL && PyErr_Occurred()) { |
| 13409 | p->error_indicator = 1; |
| 13410 | D(p->level--); |
| 13411 | return NULL; |
| 13412 | } |
| 13413 | goto done; |
| 13414 | } |
| 13415 | p->mark = _mark; |
| 13416 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13417 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); |
| 13418 | } |
| 13419 | { // 'None' |
| 13420 | if (p->error_indicator) { |
| 13421 | D(p->level--); |
| 13422 | return NULL; |
| 13423 | } |
| 13424 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); |
| 13425 | Token * _keyword; |
| 13426 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13427 | (_keyword = _PyPegen_expect_token(p, 523)) // token='None' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13428 | ) |
| 13429 | { |
| 13430 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); |
| 13431 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13432 | if (_token == NULL) { |
| 13433 | D(p->level--); |
| 13434 | return NULL; |
| 13435 | } |
| 13436 | int _end_lineno = _token->end_lineno; |
| 13437 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13438 | int _end_col_offset = _token->end_col_offset; |
| 13439 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 13440 | _res = _PyAST_Constant ( Py_None , NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13441 | if (_res == NULL && PyErr_Occurred()) { |
| 13442 | p->error_indicator = 1; |
| 13443 | D(p->level--); |
| 13444 | return NULL; |
| 13445 | } |
| 13446 | goto done; |
| 13447 | } |
| 13448 | p->mark = _mark; |
| 13449 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13450 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); |
| 13451 | } |
| 13452 | { // &STRING strings |
| 13453 | if (p->error_indicator) { |
| 13454 | D(p->level--); |
| 13455 | return NULL; |
| 13456 | } |
| 13457 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&STRING strings")); |
| 13458 | expr_ty strings_var; |
| 13459 | if ( |
| 13460 | _PyPegen_lookahead(1, _PyPegen_string_token, p) |
| 13461 | && |
| 13462 | (strings_var = strings_rule(p)) // strings |
| 13463 | ) |
| 13464 | { |
| 13465 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&STRING strings")); |
| 13466 | _res = strings_var; |
| 13467 | goto done; |
| 13468 | } |
| 13469 | p->mark = _mark; |
| 13470 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13471 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&STRING strings")); |
| 13472 | } |
| 13473 | { // NUMBER |
| 13474 | if (p->error_indicator) { |
| 13475 | D(p->level--); |
| 13476 | return NULL; |
| 13477 | } |
| 13478 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NUMBER")); |
| 13479 | expr_ty number_var; |
| 13480 | if ( |
| 13481 | (number_var = _PyPegen_number_token(p)) // NUMBER |
| 13482 | ) |
| 13483 | { |
| 13484 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NUMBER")); |
| 13485 | _res = number_var; |
| 13486 | goto done; |
| 13487 | } |
| 13488 | p->mark = _mark; |
| 13489 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13490 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER")); |
| 13491 | } |
| 13492 | { // &'(' (tuple | group | genexp) |
| 13493 | if (p->error_indicator) { |
| 13494 | D(p->level--); |
| 13495 | return NULL; |
| 13496 | } |
| 13497 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13498 | void *_tmp_111_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13499 | if ( |
| 13500 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' |
| 13501 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13502 | (_tmp_111_var = _tmp_111_rule(p)) // tuple | group | genexp |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13503 | ) |
| 13504 | { |
| 13505 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13506 | _res = _tmp_111_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13507 | goto done; |
| 13508 | } |
| 13509 | p->mark = _mark; |
| 13510 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13511 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'(' (tuple | group | genexp)")); |
| 13512 | } |
| 13513 | { // &'[' (list | listcomp) |
| 13514 | if (p->error_indicator) { |
| 13515 | D(p->level--); |
| 13516 | return NULL; |
| 13517 | } |
| 13518 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13519 | void *_tmp_112_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13520 | if ( |
| 13521 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' |
| 13522 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13523 | (_tmp_112_var = _tmp_112_rule(p)) // list | listcomp |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13524 | ) |
| 13525 | { |
| 13526 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13527 | _res = _tmp_112_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13528 | goto done; |
| 13529 | } |
| 13530 | p->mark = _mark; |
| 13531 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13532 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'[' (list | listcomp)")); |
| 13533 | } |
| 13534 | { // &'{' (dict | set | dictcomp | setcomp) |
| 13535 | if (p->error_indicator) { |
| 13536 | D(p->level--); |
| 13537 | return NULL; |
| 13538 | } |
| 13539 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13540 | void *_tmp_113_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13541 | if ( |
| 13542 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' |
| 13543 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13544 | (_tmp_113_var = _tmp_113_rule(p)) // dict | set | dictcomp | setcomp |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13545 | ) |
| 13546 | { |
| 13547 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13548 | _res = _tmp_113_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13549 | goto done; |
| 13550 | } |
| 13551 | p->mark = _mark; |
| 13552 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13553 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); |
| 13554 | } |
| 13555 | { // '...' |
| 13556 | if (p->error_indicator) { |
| 13557 | D(p->level--); |
| 13558 | return NULL; |
| 13559 | } |
| 13560 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); |
| 13561 | Token * _literal; |
| 13562 | if ( |
| 13563 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
| 13564 | ) |
| 13565 | { |
| 13566 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); |
| 13567 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13568 | if (_token == NULL) { |
| 13569 | D(p->level--); |
| 13570 | return NULL; |
| 13571 | } |
| 13572 | int _end_lineno = _token->end_lineno; |
| 13573 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13574 | int _end_col_offset = _token->end_col_offset; |
| 13575 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 13576 | _res = _PyAST_Constant ( Py_Ellipsis , NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13577 | if (_res == NULL && PyErr_Occurred()) { |
| 13578 | p->error_indicator = 1; |
| 13579 | D(p->level--); |
| 13580 | return NULL; |
| 13581 | } |
| 13582 | goto done; |
| 13583 | } |
| 13584 | p->mark = _mark; |
| 13585 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13586 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); |
| 13587 | } |
| 13588 | _res = NULL; |
| 13589 | done: |
| 13590 | D(p->level--); |
| 13591 | return _res; |
| 13592 | } |
| 13593 | |
| 13594 | // strings: STRING+ |
| 13595 | static expr_ty |
| 13596 | strings_rule(Parser *p) |
| 13597 | { |
| 13598 | D(p->level++); |
| 13599 | if (p->error_indicator) { |
| 13600 | D(p->level--); |
| 13601 | return NULL; |
| 13602 | } |
| 13603 | expr_ty _res = NULL; |
| 13604 | if (_PyPegen_is_memoized(p, strings_type, &_res)) { |
| 13605 | D(p->level--); |
| 13606 | return _res; |
| 13607 | } |
| 13608 | int _mark = p->mark; |
| 13609 | { // STRING+ |
| 13610 | if (p->error_indicator) { |
| 13611 | D(p->level--); |
| 13612 | return NULL; |
| 13613 | } |
| 13614 | D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+")); |
| 13615 | asdl_seq * a; |
| 13616 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13617 | (a = _loop1_114_rule(p)) // STRING+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13618 | ) |
| 13619 | { |
| 13620 | D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+")); |
| 13621 | _res = _PyPegen_concatenate_strings ( p , a ); |
| 13622 | if (_res == NULL && PyErr_Occurred()) { |
| 13623 | p->error_indicator = 1; |
| 13624 | D(p->level--); |
| 13625 | return NULL; |
| 13626 | } |
| 13627 | goto done; |
| 13628 | } |
| 13629 | p->mark = _mark; |
| 13630 | D(fprintf(stderr, "%*c%s strings[%d-%d]: %s failed!\n", p->level, ' ', |
| 13631 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING+")); |
| 13632 | } |
| 13633 | _res = NULL; |
| 13634 | done: |
| 13635 | _PyPegen_insert_memo(p, _mark, strings_type, _res); |
| 13636 | D(p->level--); |
| 13637 | return _res; |
| 13638 | } |
| 13639 | |
| 13640 | // list: '[' star_named_expressions? ']' |
| 13641 | static expr_ty |
| 13642 | list_rule(Parser *p) |
| 13643 | { |
| 13644 | D(p->level++); |
| 13645 | if (p->error_indicator) { |
| 13646 | D(p->level--); |
| 13647 | return NULL; |
| 13648 | } |
| 13649 | expr_ty _res = NULL; |
| 13650 | int _mark = p->mark; |
| 13651 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 13652 | p->error_indicator = 1; |
| 13653 | D(p->level--); |
| 13654 | return NULL; |
| 13655 | } |
| 13656 | int _start_lineno = p->tokens[_mark]->lineno; |
| 13657 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 13658 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 13659 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 13660 | { // '[' star_named_expressions? ']' |
| 13661 | if (p->error_indicator) { |
| 13662 | D(p->level--); |
| 13663 | return NULL; |
| 13664 | } |
| 13665 | D(fprintf(stderr, "%*c> list[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' star_named_expressions? ']'")); |
| 13666 | Token * _literal; |
| 13667 | Token * _literal_1; |
| 13668 | void *a; |
| 13669 | if ( |
| 13670 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 13671 | && |
| 13672 | (a = star_named_expressions_rule(p), 1) // star_named_expressions? |
| 13673 | && |
| 13674 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
| 13675 | ) |
| 13676 | { |
| 13677 | D(fprintf(stderr, "%*c+ list[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' star_named_expressions? ']'")); |
| 13678 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13679 | if (_token == NULL) { |
| 13680 | D(p->level--); |
| 13681 | return NULL; |
| 13682 | } |
| 13683 | int _end_lineno = _token->end_lineno; |
| 13684 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13685 | int _end_col_offset = _token->end_col_offset; |
| 13686 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 13687 | _res = _PyAST_List ( a , Load , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13688 | if (_res == NULL && PyErr_Occurred()) { |
| 13689 | p->error_indicator = 1; |
| 13690 | D(p->level--); |
| 13691 | return NULL; |
| 13692 | } |
| 13693 | goto done; |
| 13694 | } |
| 13695 | p->mark = _mark; |
| 13696 | D(fprintf(stderr, "%*c%s list[%d-%d]: %s failed!\n", p->level, ' ', |
| 13697 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' star_named_expressions? ']'")); |
| 13698 | } |
| 13699 | _res = NULL; |
| 13700 | done: |
| 13701 | D(p->level--); |
| 13702 | return _res; |
| 13703 | } |
| 13704 | |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 13705 | // listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13706 | static expr_ty |
| 13707 | listcomp_rule(Parser *p) |
| 13708 | { |
| 13709 | D(p->level++); |
| 13710 | if (p->error_indicator) { |
| 13711 | D(p->level--); |
| 13712 | return NULL; |
| 13713 | } |
| 13714 | expr_ty _res = NULL; |
| 13715 | int _mark = p->mark; |
| 13716 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 13717 | p->error_indicator = 1; |
| 13718 | D(p->level--); |
| 13719 | return NULL; |
| 13720 | } |
| 13721 | int _start_lineno = p->tokens[_mark]->lineno; |
| 13722 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 13723 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 13724 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 13725 | { // '[' named_expression for_if_clauses ']' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13726 | if (p->error_indicator) { |
| 13727 | D(p->level--); |
| 13728 | return NULL; |
| 13729 | } |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 13730 | D(fprintf(stderr, "%*c> listcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' named_expression for_if_clauses ']'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13731 | Token * _literal; |
| 13732 | Token * _literal_1; |
| 13733 | expr_ty a; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 13734 | asdl_comprehension_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13735 | if ( |
| 13736 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 13737 | && |
| 13738 | (a = named_expression_rule(p)) // named_expression |
| 13739 | && |
| 13740 | (b = for_if_clauses_rule(p)) // for_if_clauses |
| 13741 | && |
| 13742 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
| 13743 | ) |
| 13744 | { |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 13745 | D(fprintf(stderr, "%*c+ listcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' named_expression for_if_clauses ']'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13746 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13747 | if (_token == NULL) { |
| 13748 | D(p->level--); |
| 13749 | return NULL; |
| 13750 | } |
| 13751 | int _end_lineno = _token->end_lineno; |
| 13752 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13753 | int _end_col_offset = _token->end_col_offset; |
| 13754 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 13755 | _res = _PyAST_ListComp ( a , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13756 | if (_res == NULL && PyErr_Occurred()) { |
| 13757 | p->error_indicator = 1; |
| 13758 | D(p->level--); |
| 13759 | return NULL; |
| 13760 | } |
| 13761 | goto done; |
| 13762 | } |
| 13763 | p->mark = _mark; |
| 13764 | D(fprintf(stderr, "%*c%s listcomp[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 13765 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' named_expression for_if_clauses ']'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13766 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 13767 | if (p->call_invalid_rules) { // invalid_comprehension |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13768 | if (p->error_indicator) { |
| 13769 | D(p->level--); |
| 13770 | return NULL; |
| 13771 | } |
| 13772 | D(fprintf(stderr, "%*c> listcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); |
| 13773 | void *invalid_comprehension_var; |
| 13774 | if ( |
| 13775 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
| 13776 | ) |
| 13777 | { |
| 13778 | D(fprintf(stderr, "%*c+ listcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); |
| 13779 | _res = invalid_comprehension_var; |
| 13780 | goto done; |
| 13781 | } |
| 13782 | p->mark = _mark; |
| 13783 | D(fprintf(stderr, "%*c%s listcomp[%d-%d]: %s failed!\n", p->level, ' ', |
| 13784 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension")); |
| 13785 | } |
| 13786 | _res = NULL; |
| 13787 | done: |
| 13788 | D(p->level--); |
| 13789 | return _res; |
| 13790 | } |
| 13791 | |
| 13792 | // tuple: '(' [star_named_expression ',' star_named_expressions?] ')' |
| 13793 | static expr_ty |
| 13794 | tuple_rule(Parser *p) |
| 13795 | { |
| 13796 | D(p->level++); |
| 13797 | if (p->error_indicator) { |
| 13798 | D(p->level--); |
| 13799 | return NULL; |
| 13800 | } |
| 13801 | expr_ty _res = NULL; |
| 13802 | int _mark = p->mark; |
| 13803 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 13804 | p->error_indicator = 1; |
| 13805 | D(p->level--); |
| 13806 | return NULL; |
| 13807 | } |
| 13808 | int _start_lineno = p->tokens[_mark]->lineno; |
| 13809 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 13810 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 13811 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 13812 | { // '(' [star_named_expression ',' star_named_expressions?] ')' |
| 13813 | if (p->error_indicator) { |
| 13814 | D(p->level--); |
| 13815 | return NULL; |
| 13816 | } |
| 13817 | D(fprintf(stderr, "%*c> tuple[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'")); |
| 13818 | Token * _literal; |
| 13819 | Token * _literal_1; |
| 13820 | void *a; |
| 13821 | if ( |
| 13822 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 13823 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13824 | (a = _tmp_115_rule(p), 1) // [star_named_expression ',' star_named_expressions?] |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13825 | && |
| 13826 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 13827 | ) |
| 13828 | { |
| 13829 | D(fprintf(stderr, "%*c+ tuple[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'")); |
| 13830 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13831 | if (_token == NULL) { |
| 13832 | D(p->level--); |
| 13833 | return NULL; |
| 13834 | } |
| 13835 | int _end_lineno = _token->end_lineno; |
| 13836 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13837 | int _end_col_offset = _token->end_col_offset; |
| 13838 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 13839 | _res = _PyAST_Tuple ( a , Load , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13840 | if (_res == NULL && PyErr_Occurred()) { |
| 13841 | p->error_indicator = 1; |
| 13842 | D(p->level--); |
| 13843 | return NULL; |
| 13844 | } |
| 13845 | goto done; |
| 13846 | } |
| 13847 | p->mark = _mark; |
| 13848 | D(fprintf(stderr, "%*c%s tuple[%d-%d]: %s failed!\n", p->level, ' ', |
| 13849 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'")); |
| 13850 | } |
| 13851 | _res = NULL; |
| 13852 | done: |
| 13853 | D(p->level--); |
| 13854 | return _res; |
| 13855 | } |
| 13856 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 13857 | // group: '(' (yield_expr | named_expression) ')' | invalid_group |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13858 | static expr_ty |
| 13859 | group_rule(Parser *p) |
| 13860 | { |
| 13861 | D(p->level++); |
| 13862 | if (p->error_indicator) { |
| 13863 | D(p->level--); |
| 13864 | return NULL; |
| 13865 | } |
| 13866 | expr_ty _res = NULL; |
| 13867 | int _mark = p->mark; |
| 13868 | { // '(' (yield_expr | named_expression) ')' |
| 13869 | if (p->error_indicator) { |
| 13870 | D(p->level--); |
| 13871 | return NULL; |
| 13872 | } |
| 13873 | D(fprintf(stderr, "%*c> group[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' (yield_expr | named_expression) ')'")); |
| 13874 | Token * _literal; |
| 13875 | Token * _literal_1; |
| 13876 | void *a; |
| 13877 | if ( |
| 13878 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 13879 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 13880 | (a = _tmp_116_rule(p)) // yield_expr | named_expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13881 | && |
| 13882 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 13883 | ) |
| 13884 | { |
| 13885 | D(fprintf(stderr, "%*c+ group[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' (yield_expr | named_expression) ')'")); |
| 13886 | _res = a; |
| 13887 | if (_res == NULL && PyErr_Occurred()) { |
| 13888 | p->error_indicator = 1; |
| 13889 | D(p->level--); |
| 13890 | return NULL; |
| 13891 | } |
| 13892 | goto done; |
| 13893 | } |
| 13894 | p->mark = _mark; |
| 13895 | D(fprintf(stderr, "%*c%s group[%d-%d]: %s failed!\n", p->level, ' ', |
| 13896 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' (yield_expr | named_expression) ')'")); |
| 13897 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 13898 | if (p->call_invalid_rules) { // invalid_group |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 13899 | if (p->error_indicator) { |
| 13900 | D(p->level--); |
| 13901 | return NULL; |
| 13902 | } |
| 13903 | D(fprintf(stderr, "%*c> group[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_group")); |
| 13904 | void *invalid_group_var; |
| 13905 | if ( |
| 13906 | (invalid_group_var = invalid_group_rule(p)) // invalid_group |
| 13907 | ) |
| 13908 | { |
| 13909 | D(fprintf(stderr, "%*c+ group[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_group")); |
| 13910 | _res = invalid_group_var; |
| 13911 | goto done; |
| 13912 | } |
| 13913 | p->mark = _mark; |
| 13914 | D(fprintf(stderr, "%*c%s group[%d-%d]: %s failed!\n", p->level, ' ', |
| 13915 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_group")); |
| 13916 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13917 | _res = NULL; |
| 13918 | done: |
| 13919 | D(p->level--); |
| 13920 | return _res; |
| 13921 | } |
| 13922 | |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 13923 | // genexp: '(' named_expression for_if_clauses ')' | invalid_comprehension |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13924 | static expr_ty |
| 13925 | genexp_rule(Parser *p) |
| 13926 | { |
| 13927 | D(p->level++); |
| 13928 | if (p->error_indicator) { |
| 13929 | D(p->level--); |
| 13930 | return NULL; |
| 13931 | } |
| 13932 | expr_ty _res = NULL; |
| 13933 | int _mark = p->mark; |
| 13934 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 13935 | p->error_indicator = 1; |
| 13936 | D(p->level--); |
| 13937 | return NULL; |
| 13938 | } |
| 13939 | int _start_lineno = p->tokens[_mark]->lineno; |
| 13940 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 13941 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 13942 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 13943 | { // '(' named_expression for_if_clauses ')' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13944 | if (p->error_indicator) { |
| 13945 | D(p->level--); |
| 13946 | return NULL; |
| 13947 | } |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 13948 | D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' named_expression for_if_clauses ')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13949 | Token * _literal; |
| 13950 | Token * _literal_1; |
| 13951 | expr_ty a; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 13952 | asdl_comprehension_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13953 | if ( |
| 13954 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 13955 | && |
Lysandros Nikolaou | cb3e5ed | 2020-11-17 01:08:35 +0200 | [diff] [blame] | 13956 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13957 | && |
| 13958 | (b = for_if_clauses_rule(p)) // for_if_clauses |
| 13959 | && |
| 13960 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 13961 | ) |
| 13962 | { |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 13963 | D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' named_expression for_if_clauses ')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13964 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13965 | if (_token == NULL) { |
| 13966 | D(p->level--); |
| 13967 | return NULL; |
| 13968 | } |
| 13969 | int _end_lineno = _token->end_lineno; |
| 13970 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13971 | int _end_col_offset = _token->end_col_offset; |
| 13972 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 13973 | _res = _PyAST_GeneratorExp ( a , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13974 | if (_res == NULL && PyErr_Occurred()) { |
| 13975 | p->error_indicator = 1; |
| 13976 | D(p->level--); |
| 13977 | return NULL; |
| 13978 | } |
| 13979 | goto done; |
| 13980 | } |
| 13981 | p->mark = _mark; |
| 13982 | D(fprintf(stderr, "%*c%s genexp[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 13983 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' named_expression for_if_clauses ')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13984 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 13985 | if (p->call_invalid_rules) { // invalid_comprehension |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 13986 | if (p->error_indicator) { |
| 13987 | D(p->level--); |
| 13988 | return NULL; |
| 13989 | } |
| 13990 | D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); |
| 13991 | void *invalid_comprehension_var; |
| 13992 | if ( |
| 13993 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
| 13994 | ) |
| 13995 | { |
| 13996 | D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); |
| 13997 | _res = invalid_comprehension_var; |
| 13998 | goto done; |
| 13999 | } |
| 14000 | p->mark = _mark; |
| 14001 | D(fprintf(stderr, "%*c%s genexp[%d-%d]: %s failed!\n", p->level, ' ', |
| 14002 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension")); |
| 14003 | } |
| 14004 | _res = NULL; |
| 14005 | done: |
| 14006 | D(p->level--); |
| 14007 | return _res; |
| 14008 | } |
| 14009 | |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 14010 | // set: '{' star_named_expressions '}' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14011 | static expr_ty |
| 14012 | set_rule(Parser *p) |
| 14013 | { |
| 14014 | D(p->level++); |
| 14015 | if (p->error_indicator) { |
| 14016 | D(p->level--); |
| 14017 | return NULL; |
| 14018 | } |
| 14019 | expr_ty _res = NULL; |
| 14020 | int _mark = p->mark; |
| 14021 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 14022 | p->error_indicator = 1; |
| 14023 | D(p->level--); |
| 14024 | return NULL; |
| 14025 | } |
| 14026 | int _start_lineno = p->tokens[_mark]->lineno; |
| 14027 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 14028 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 14029 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 14030 | { // '{' star_named_expressions '}' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14031 | if (p->error_indicator) { |
| 14032 | D(p->level--); |
| 14033 | return NULL; |
| 14034 | } |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 14035 | D(fprintf(stderr, "%*c> set[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' star_named_expressions '}'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14036 | Token * _literal; |
| 14037 | Token * _literal_1; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 14038 | asdl_expr_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14039 | if ( |
| 14040 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
| 14041 | && |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 14042 | (a = star_named_expressions_rule(p)) // star_named_expressions |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14043 | && |
| 14044 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
| 14045 | ) |
| 14046 | { |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 14047 | D(fprintf(stderr, "%*c+ set[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' star_named_expressions '}'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14048 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 14049 | if (_token == NULL) { |
| 14050 | D(p->level--); |
| 14051 | return NULL; |
| 14052 | } |
| 14053 | int _end_lineno = _token->end_lineno; |
| 14054 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 14055 | int _end_col_offset = _token->end_col_offset; |
| 14056 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 14057 | _res = _PyAST_Set ( a , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14058 | if (_res == NULL && PyErr_Occurred()) { |
| 14059 | p->error_indicator = 1; |
| 14060 | D(p->level--); |
| 14061 | return NULL; |
| 14062 | } |
| 14063 | goto done; |
| 14064 | } |
| 14065 | p->mark = _mark; |
| 14066 | D(fprintf(stderr, "%*c%s set[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 14067 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' star_named_expressions '}'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14068 | } |
| 14069 | _res = NULL; |
| 14070 | done: |
| 14071 | D(p->level--); |
| 14072 | return _res; |
| 14073 | } |
| 14074 | |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 14075 | // setcomp: '{' named_expression for_if_clauses '}' | invalid_comprehension |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14076 | static expr_ty |
| 14077 | setcomp_rule(Parser *p) |
| 14078 | { |
| 14079 | D(p->level++); |
| 14080 | if (p->error_indicator) { |
| 14081 | D(p->level--); |
| 14082 | return NULL; |
| 14083 | } |
| 14084 | expr_ty _res = NULL; |
| 14085 | int _mark = p->mark; |
| 14086 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 14087 | p->error_indicator = 1; |
| 14088 | D(p->level--); |
| 14089 | return NULL; |
| 14090 | } |
| 14091 | int _start_lineno = p->tokens[_mark]->lineno; |
| 14092 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 14093 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 14094 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 14095 | { // '{' named_expression for_if_clauses '}' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14096 | if (p->error_indicator) { |
| 14097 | D(p->level--); |
| 14098 | return NULL; |
| 14099 | } |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 14100 | D(fprintf(stderr, "%*c> setcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' named_expression for_if_clauses '}'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14101 | Token * _literal; |
| 14102 | Token * _literal_1; |
| 14103 | expr_ty a; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 14104 | asdl_comprehension_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14105 | if ( |
| 14106 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
| 14107 | && |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 14108 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14109 | && |
| 14110 | (b = for_if_clauses_rule(p)) // for_if_clauses |
| 14111 | && |
| 14112 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
| 14113 | ) |
| 14114 | { |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 14115 | D(fprintf(stderr, "%*c+ setcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' named_expression for_if_clauses '}'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14116 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 14117 | if (_token == NULL) { |
| 14118 | D(p->level--); |
| 14119 | return NULL; |
| 14120 | } |
| 14121 | int _end_lineno = _token->end_lineno; |
| 14122 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 14123 | int _end_col_offset = _token->end_col_offset; |
| 14124 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 14125 | _res = _PyAST_SetComp ( a , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14126 | if (_res == NULL && PyErr_Occurred()) { |
| 14127 | p->error_indicator = 1; |
| 14128 | D(p->level--); |
| 14129 | return NULL; |
| 14130 | } |
| 14131 | goto done; |
| 14132 | } |
| 14133 | p->mark = _mark; |
| 14134 | D(fprintf(stderr, "%*c%s setcomp[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 14135 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' named_expression for_if_clauses '}'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14136 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 14137 | if (p->call_invalid_rules) { // invalid_comprehension |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14138 | if (p->error_indicator) { |
| 14139 | D(p->level--); |
| 14140 | return NULL; |
| 14141 | } |
| 14142 | D(fprintf(stderr, "%*c> setcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); |
| 14143 | void *invalid_comprehension_var; |
| 14144 | if ( |
| 14145 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
| 14146 | ) |
| 14147 | { |
| 14148 | D(fprintf(stderr, "%*c+ setcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); |
| 14149 | _res = invalid_comprehension_var; |
| 14150 | goto done; |
| 14151 | } |
| 14152 | p->mark = _mark; |
| 14153 | D(fprintf(stderr, "%*c%s setcomp[%d-%d]: %s failed!\n", p->level, ' ', |
| 14154 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension")); |
| 14155 | } |
| 14156 | _res = NULL; |
| 14157 | done: |
| 14158 | D(p->level--); |
| 14159 | return _res; |
| 14160 | } |
| 14161 | |
| 14162 | // dict: '{' double_starred_kvpairs? '}' |
| 14163 | static expr_ty |
| 14164 | dict_rule(Parser *p) |
| 14165 | { |
| 14166 | D(p->level++); |
| 14167 | if (p->error_indicator) { |
| 14168 | D(p->level--); |
| 14169 | return NULL; |
| 14170 | } |
| 14171 | expr_ty _res = NULL; |
| 14172 | int _mark = p->mark; |
| 14173 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 14174 | p->error_indicator = 1; |
| 14175 | D(p->level--); |
| 14176 | return NULL; |
| 14177 | } |
| 14178 | int _start_lineno = p->tokens[_mark]->lineno; |
| 14179 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 14180 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 14181 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 14182 | { // '{' double_starred_kvpairs? '}' |
| 14183 | if (p->error_indicator) { |
| 14184 | D(p->level--); |
| 14185 | return NULL; |
| 14186 | } |
| 14187 | D(fprintf(stderr, "%*c> dict[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' double_starred_kvpairs? '}'")); |
| 14188 | Token * _literal; |
| 14189 | Token * _literal_1; |
| 14190 | void *a; |
| 14191 | if ( |
| 14192 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
| 14193 | && |
| 14194 | (a = double_starred_kvpairs_rule(p), 1) // double_starred_kvpairs? |
| 14195 | && |
| 14196 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
| 14197 | ) |
| 14198 | { |
| 14199 | D(fprintf(stderr, "%*c+ dict[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' double_starred_kvpairs? '}'")); |
| 14200 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 14201 | if (_token == NULL) { |
| 14202 | D(p->level--); |
| 14203 | return NULL; |
| 14204 | } |
| 14205 | int _end_lineno = _token->end_lineno; |
| 14206 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 14207 | int _end_col_offset = _token->end_col_offset; |
| 14208 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 14209 | _res = _PyAST_Dict ( CHECK ( asdl_expr_seq * , _PyPegen_get_keys ( p , a ) ) , CHECK ( asdl_expr_seq * , _PyPegen_get_values ( p , a ) ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14210 | if (_res == NULL && PyErr_Occurred()) { |
| 14211 | p->error_indicator = 1; |
| 14212 | D(p->level--); |
| 14213 | return NULL; |
| 14214 | } |
| 14215 | goto done; |
| 14216 | } |
| 14217 | p->mark = _mark; |
| 14218 | D(fprintf(stderr, "%*c%s dict[%d-%d]: %s failed!\n", p->level, ' ', |
| 14219 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' double_starred_kvpairs? '}'")); |
| 14220 | } |
| 14221 | _res = NULL; |
| 14222 | done: |
| 14223 | D(p->level--); |
| 14224 | return _res; |
| 14225 | } |
| 14226 | |
| 14227 | // dictcomp: '{' kvpair for_if_clauses '}' | invalid_dict_comprehension |
| 14228 | static expr_ty |
| 14229 | dictcomp_rule(Parser *p) |
| 14230 | { |
| 14231 | D(p->level++); |
| 14232 | if (p->error_indicator) { |
| 14233 | D(p->level--); |
| 14234 | return NULL; |
| 14235 | } |
| 14236 | expr_ty _res = NULL; |
| 14237 | int _mark = p->mark; |
| 14238 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 14239 | p->error_indicator = 1; |
| 14240 | D(p->level--); |
| 14241 | return NULL; |
| 14242 | } |
| 14243 | int _start_lineno = p->tokens[_mark]->lineno; |
| 14244 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 14245 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 14246 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 14247 | { // '{' kvpair for_if_clauses '}' |
| 14248 | if (p->error_indicator) { |
| 14249 | D(p->level--); |
| 14250 | return NULL; |
| 14251 | } |
| 14252 | D(fprintf(stderr, "%*c> dictcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' kvpair for_if_clauses '}'")); |
| 14253 | Token * _literal; |
| 14254 | Token * _literal_1; |
| 14255 | KeyValuePair* a; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 14256 | asdl_comprehension_seq* b; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14257 | if ( |
| 14258 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
| 14259 | && |
| 14260 | (a = kvpair_rule(p)) // kvpair |
| 14261 | && |
| 14262 | (b = for_if_clauses_rule(p)) // for_if_clauses |
| 14263 | && |
| 14264 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
| 14265 | ) |
| 14266 | { |
| 14267 | D(fprintf(stderr, "%*c+ dictcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' kvpair for_if_clauses '}'")); |
| 14268 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 14269 | if (_token == NULL) { |
| 14270 | D(p->level--); |
| 14271 | return NULL; |
| 14272 | } |
| 14273 | int _end_lineno = _token->end_lineno; |
| 14274 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 14275 | int _end_col_offset = _token->end_col_offset; |
| 14276 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 14277 | _res = _PyAST_DictComp ( a -> key , a -> value , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14278 | if (_res == NULL && PyErr_Occurred()) { |
| 14279 | p->error_indicator = 1; |
| 14280 | D(p->level--); |
| 14281 | return NULL; |
| 14282 | } |
| 14283 | goto done; |
| 14284 | } |
| 14285 | p->mark = _mark; |
| 14286 | D(fprintf(stderr, "%*c%s dictcomp[%d-%d]: %s failed!\n", p->level, ' ', |
| 14287 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' kvpair for_if_clauses '}'")); |
| 14288 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 14289 | if (p->call_invalid_rules) { // invalid_dict_comprehension |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14290 | if (p->error_indicator) { |
| 14291 | D(p->level--); |
| 14292 | return NULL; |
| 14293 | } |
| 14294 | D(fprintf(stderr, "%*c> dictcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_dict_comprehension")); |
| 14295 | void *invalid_dict_comprehension_var; |
| 14296 | if ( |
| 14297 | (invalid_dict_comprehension_var = invalid_dict_comprehension_rule(p)) // invalid_dict_comprehension |
| 14298 | ) |
| 14299 | { |
| 14300 | D(fprintf(stderr, "%*c+ dictcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_dict_comprehension")); |
| 14301 | _res = invalid_dict_comprehension_var; |
| 14302 | goto done; |
| 14303 | } |
| 14304 | p->mark = _mark; |
| 14305 | D(fprintf(stderr, "%*c%s dictcomp[%d-%d]: %s failed!\n", p->level, ' ', |
| 14306 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_dict_comprehension")); |
| 14307 | } |
| 14308 | _res = NULL; |
| 14309 | done: |
| 14310 | D(p->level--); |
| 14311 | return _res; |
| 14312 | } |
| 14313 | |
| 14314 | // double_starred_kvpairs: ','.double_starred_kvpair+ ','? |
| 14315 | static asdl_seq* |
| 14316 | double_starred_kvpairs_rule(Parser *p) |
| 14317 | { |
| 14318 | D(p->level++); |
| 14319 | if (p->error_indicator) { |
| 14320 | D(p->level--); |
| 14321 | return NULL; |
| 14322 | } |
| 14323 | asdl_seq* _res = NULL; |
| 14324 | int _mark = p->mark; |
| 14325 | { // ','.double_starred_kvpair+ ','? |
| 14326 | if (p->error_indicator) { |
| 14327 | D(p->level--); |
| 14328 | return NULL; |
| 14329 | } |
| 14330 | D(fprintf(stderr, "%*c> double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ','?")); |
| 14331 | void *_opt_var; |
| 14332 | UNUSED(_opt_var); // Silence compiler warnings |
| 14333 | asdl_seq * a; |
| 14334 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 14335 | (a = _gather_117_rule(p)) // ','.double_starred_kvpair+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14336 | && |
| 14337 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 14338 | ) |
| 14339 | { |
| 14340 | D(fprintf(stderr, "%*c+ double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ','?")); |
| 14341 | _res = a; |
| 14342 | if (_res == NULL && PyErr_Occurred()) { |
| 14343 | p->error_indicator = 1; |
| 14344 | D(p->level--); |
| 14345 | return NULL; |
| 14346 | } |
| 14347 | goto done; |
| 14348 | } |
| 14349 | p->mark = _mark; |
| 14350 | D(fprintf(stderr, "%*c%s double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ', |
| 14351 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.double_starred_kvpair+ ','?")); |
| 14352 | } |
| 14353 | _res = NULL; |
| 14354 | done: |
| 14355 | D(p->level--); |
| 14356 | return _res; |
| 14357 | } |
| 14358 | |
| 14359 | // double_starred_kvpair: '**' bitwise_or | kvpair |
| 14360 | static KeyValuePair* |
| 14361 | double_starred_kvpair_rule(Parser *p) |
| 14362 | { |
| 14363 | D(p->level++); |
| 14364 | if (p->error_indicator) { |
| 14365 | D(p->level--); |
| 14366 | return NULL; |
| 14367 | } |
| 14368 | KeyValuePair* _res = NULL; |
| 14369 | int _mark = p->mark; |
| 14370 | { // '**' bitwise_or |
| 14371 | if (p->error_indicator) { |
| 14372 | D(p->level--); |
| 14373 | return NULL; |
| 14374 | } |
| 14375 | D(fprintf(stderr, "%*c> double_starred_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or")); |
| 14376 | Token * _literal; |
| 14377 | expr_ty a; |
| 14378 | if ( |
| 14379 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
| 14380 | && |
| 14381 | (a = bitwise_or_rule(p)) // bitwise_or |
| 14382 | ) |
| 14383 | { |
| 14384 | D(fprintf(stderr, "%*c+ double_starred_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or")); |
| 14385 | _res = _PyPegen_key_value_pair ( p , NULL , a ); |
| 14386 | if (_res == NULL && PyErr_Occurred()) { |
| 14387 | p->error_indicator = 1; |
| 14388 | D(p->level--); |
| 14389 | return NULL; |
| 14390 | } |
| 14391 | goto done; |
| 14392 | } |
| 14393 | p->mark = _mark; |
| 14394 | D(fprintf(stderr, "%*c%s double_starred_kvpair[%d-%d]: %s failed!\n", p->level, ' ', |
| 14395 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' bitwise_or")); |
| 14396 | } |
| 14397 | { // kvpair |
| 14398 | if (p->error_indicator) { |
| 14399 | D(p->level--); |
| 14400 | return NULL; |
| 14401 | } |
| 14402 | D(fprintf(stderr, "%*c> double_starred_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kvpair")); |
| 14403 | KeyValuePair* kvpair_var; |
| 14404 | if ( |
| 14405 | (kvpair_var = kvpair_rule(p)) // kvpair |
| 14406 | ) |
| 14407 | { |
| 14408 | D(fprintf(stderr, "%*c+ double_starred_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kvpair")); |
| 14409 | _res = kvpair_var; |
| 14410 | goto done; |
| 14411 | } |
| 14412 | p->mark = _mark; |
| 14413 | D(fprintf(stderr, "%*c%s double_starred_kvpair[%d-%d]: %s failed!\n", p->level, ' ', |
| 14414 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kvpair")); |
| 14415 | } |
| 14416 | _res = NULL; |
| 14417 | done: |
| 14418 | D(p->level--); |
| 14419 | return _res; |
| 14420 | } |
| 14421 | |
| 14422 | // kvpair: expression ':' expression |
| 14423 | static KeyValuePair* |
| 14424 | kvpair_rule(Parser *p) |
| 14425 | { |
| 14426 | D(p->level++); |
| 14427 | if (p->error_indicator) { |
| 14428 | D(p->level--); |
| 14429 | return NULL; |
| 14430 | } |
| 14431 | KeyValuePair* _res = NULL; |
| 14432 | int _mark = p->mark; |
| 14433 | { // expression ':' expression |
| 14434 | if (p->error_indicator) { |
| 14435 | D(p->level--); |
| 14436 | return NULL; |
| 14437 | } |
| 14438 | D(fprintf(stderr, "%*c> kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' expression")); |
| 14439 | Token * _literal; |
| 14440 | expr_ty a; |
| 14441 | expr_ty b; |
| 14442 | if ( |
| 14443 | (a = expression_rule(p)) // expression |
| 14444 | && |
| 14445 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 14446 | && |
| 14447 | (b = expression_rule(p)) // expression |
| 14448 | ) |
| 14449 | { |
| 14450 | D(fprintf(stderr, "%*c+ kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression")); |
| 14451 | _res = _PyPegen_key_value_pair ( p , a , b ); |
| 14452 | if (_res == NULL && PyErr_Occurred()) { |
| 14453 | p->error_indicator = 1; |
| 14454 | D(p->level--); |
| 14455 | return NULL; |
| 14456 | } |
| 14457 | goto done; |
| 14458 | } |
| 14459 | p->mark = _mark; |
| 14460 | D(fprintf(stderr, "%*c%s kvpair[%d-%d]: %s failed!\n", p->level, ' ', |
| 14461 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' expression")); |
| 14462 | } |
| 14463 | _res = NULL; |
| 14464 | done: |
| 14465 | D(p->level--); |
| 14466 | return _res; |
| 14467 | } |
| 14468 | |
| 14469 | // for_if_clauses: for_if_clause+ |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 14470 | static asdl_comprehension_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14471 | for_if_clauses_rule(Parser *p) |
| 14472 | { |
| 14473 | D(p->level++); |
| 14474 | if (p->error_indicator) { |
| 14475 | D(p->level--); |
| 14476 | return NULL; |
| 14477 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 14478 | asdl_comprehension_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14479 | int _mark = p->mark; |
| 14480 | { // for_if_clause+ |
| 14481 | if (p->error_indicator) { |
| 14482 | D(p->level--); |
| 14483 | return NULL; |
| 14484 | } |
| 14485 | D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 14486 | asdl_comprehension_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14487 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 14488 | (a = (asdl_comprehension_seq*)_loop1_119_rule(p)) // for_if_clause+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14489 | ) |
| 14490 | { |
| 14491 | D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 14492 | _res = a; |
| 14493 | if (_res == NULL && PyErr_Occurred()) { |
| 14494 | p->error_indicator = 1; |
| 14495 | D(p->level--); |
| 14496 | return NULL; |
| 14497 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14498 | goto done; |
| 14499 | } |
| 14500 | p->mark = _mark; |
| 14501 | D(fprintf(stderr, "%*c%s for_if_clauses[%d-%d]: %s failed!\n", p->level, ' ', |
| 14502 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause+")); |
| 14503 | } |
| 14504 | _res = NULL; |
| 14505 | done: |
| 14506 | D(p->level--); |
| 14507 | return _res; |
| 14508 | } |
| 14509 | |
| 14510 | // for_if_clause: |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 14511 | // | ASYNC 'for' star_targets 'in' ~ disjunction (('if' disjunction))* |
| 14512 | // | 'for' star_targets 'in' ~ disjunction (('if' disjunction))* |
| 14513 | // | invalid_for_target |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14514 | static comprehension_ty |
| 14515 | for_if_clause_rule(Parser *p) |
| 14516 | { |
| 14517 | D(p->level++); |
| 14518 | if (p->error_indicator) { |
| 14519 | D(p->level--); |
| 14520 | return NULL; |
| 14521 | } |
| 14522 | comprehension_ty _res = NULL; |
| 14523 | int _mark = p->mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 14524 | { // ASYNC 'for' star_targets 'in' ~ disjunction (('if' disjunction))* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14525 | if (p->error_indicator) { |
| 14526 | D(p->level--); |
| 14527 | return NULL; |
| 14528 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 14529 | D(fprintf(stderr, "%*c> for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' ~ disjunction (('if' disjunction))*")); |
| 14530 | int _cut_var = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14531 | Token * _keyword; |
| 14532 | Token * _keyword_1; |
| 14533 | expr_ty a; |
| 14534 | Token * async_var; |
| 14535 | expr_ty b; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 14536 | asdl_expr_seq* c; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14537 | if ( |
| 14538 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
| 14539 | && |
| 14540 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
| 14541 | && |
| 14542 | (a = star_targets_rule(p)) // star_targets |
| 14543 | && |
| 14544 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
| 14545 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 14546 | (_cut_var = 1) |
| 14547 | && |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14548 | (b = disjunction_rule(p)) // disjunction |
| 14549 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 14550 | (c = (asdl_expr_seq*)_loop0_120_rule(p)) // (('if' disjunction))* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14551 | ) |
| 14552 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 14553 | D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' ~ disjunction (('if' disjunction))*")); |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 14554 | _res = CHECK_VERSION ( comprehension_ty , 6 , "Async comprehensions are" , _PyAST_comprehension ( a , b , c , 1 , p -> arena ) ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14555 | if (_res == NULL && PyErr_Occurred()) { |
| 14556 | p->error_indicator = 1; |
| 14557 | D(p->level--); |
| 14558 | return NULL; |
| 14559 | } |
| 14560 | goto done; |
| 14561 | } |
| 14562 | p->mark = _mark; |
| 14563 | D(fprintf(stderr, "%*c%s for_if_clause[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 14564 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'for' star_targets 'in' ~ disjunction (('if' disjunction))*")); |
| 14565 | if (_cut_var) { |
| 14566 | D(p->level--); |
| 14567 | return NULL; |
| 14568 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14569 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 14570 | { // 'for' star_targets 'in' ~ disjunction (('if' disjunction))* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14571 | if (p->error_indicator) { |
| 14572 | D(p->level--); |
| 14573 | return NULL; |
| 14574 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 14575 | D(fprintf(stderr, "%*c> for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' ~ disjunction (('if' disjunction))*")); |
| 14576 | int _cut_var = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14577 | Token * _keyword; |
| 14578 | Token * _keyword_1; |
| 14579 | expr_ty a; |
| 14580 | expr_ty b; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 14581 | asdl_expr_seq* c; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14582 | if ( |
| 14583 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
| 14584 | && |
| 14585 | (a = star_targets_rule(p)) // star_targets |
| 14586 | && |
| 14587 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
| 14588 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 14589 | (_cut_var = 1) |
| 14590 | && |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14591 | (b = disjunction_rule(p)) // disjunction |
| 14592 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 14593 | (c = (asdl_expr_seq*)_loop0_121_rule(p)) // (('if' disjunction))* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14594 | ) |
| 14595 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 14596 | D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' ~ disjunction (('if' disjunction))*")); |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 14597 | _res = _PyAST_comprehension ( a , b , c , 0 , p -> arena ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14598 | if (_res == NULL && PyErr_Occurred()) { |
| 14599 | p->error_indicator = 1; |
| 14600 | D(p->level--); |
| 14601 | return NULL; |
| 14602 | } |
| 14603 | goto done; |
| 14604 | } |
| 14605 | p->mark = _mark; |
| 14606 | D(fprintf(stderr, "%*c%s for_if_clause[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 14607 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for' star_targets 'in' ~ disjunction (('if' disjunction))*")); |
| 14608 | if (_cut_var) { |
| 14609 | D(p->level--); |
| 14610 | return NULL; |
| 14611 | } |
| 14612 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 14613 | if (p->call_invalid_rules) { // invalid_for_target |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 14614 | if (p->error_indicator) { |
| 14615 | D(p->level--); |
| 14616 | return NULL; |
| 14617 | } |
| 14618 | D(fprintf(stderr, "%*c> for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_for_target")); |
| 14619 | void *invalid_for_target_var; |
| 14620 | if ( |
| 14621 | (invalid_for_target_var = invalid_for_target_rule(p)) // invalid_for_target |
| 14622 | ) |
| 14623 | { |
| 14624 | D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_for_target")); |
| 14625 | _res = invalid_for_target_var; |
| 14626 | goto done; |
| 14627 | } |
| 14628 | p->mark = _mark; |
| 14629 | D(fprintf(stderr, "%*c%s for_if_clause[%d-%d]: %s failed!\n", p->level, ' ', |
| 14630 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_for_target")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14631 | } |
| 14632 | _res = NULL; |
| 14633 | done: |
| 14634 | D(p->level--); |
| 14635 | return _res; |
| 14636 | } |
| 14637 | |
| 14638 | // yield_expr: 'yield' 'from' expression | 'yield' star_expressions? |
| 14639 | static expr_ty |
| 14640 | yield_expr_rule(Parser *p) |
| 14641 | { |
| 14642 | D(p->level++); |
| 14643 | if (p->error_indicator) { |
| 14644 | D(p->level--); |
| 14645 | return NULL; |
| 14646 | } |
| 14647 | expr_ty _res = NULL; |
| 14648 | int _mark = p->mark; |
| 14649 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 14650 | p->error_indicator = 1; |
| 14651 | D(p->level--); |
| 14652 | return NULL; |
| 14653 | } |
| 14654 | int _start_lineno = p->tokens[_mark]->lineno; |
| 14655 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 14656 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 14657 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 14658 | { // 'yield' 'from' expression |
| 14659 | if (p->error_indicator) { |
| 14660 | D(p->level--); |
| 14661 | return NULL; |
| 14662 | } |
| 14663 | D(fprintf(stderr, "%*c> yield_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'yield' 'from' expression")); |
| 14664 | Token * _keyword; |
| 14665 | Token * _keyword_1; |
| 14666 | expr_ty a; |
| 14667 | if ( |
| 14668 | (_keyword = _PyPegen_expect_token(p, 504)) // token='yield' |
| 14669 | && |
| 14670 | (_keyword_1 = _PyPegen_expect_token(p, 514)) // token='from' |
| 14671 | && |
| 14672 | (a = expression_rule(p)) // expression |
| 14673 | ) |
| 14674 | { |
| 14675 | D(fprintf(stderr, "%*c+ yield_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'yield' 'from' expression")); |
| 14676 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 14677 | if (_token == NULL) { |
| 14678 | D(p->level--); |
| 14679 | return NULL; |
| 14680 | } |
| 14681 | int _end_lineno = _token->end_lineno; |
| 14682 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 14683 | int _end_col_offset = _token->end_col_offset; |
| 14684 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 14685 | _res = _PyAST_YieldFrom ( a , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14686 | if (_res == NULL && PyErr_Occurred()) { |
| 14687 | p->error_indicator = 1; |
| 14688 | D(p->level--); |
| 14689 | return NULL; |
| 14690 | } |
| 14691 | goto done; |
| 14692 | } |
| 14693 | p->mark = _mark; |
| 14694 | D(fprintf(stderr, "%*c%s yield_expr[%d-%d]: %s failed!\n", p->level, ' ', |
| 14695 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'yield' 'from' expression")); |
| 14696 | } |
| 14697 | { // 'yield' star_expressions? |
| 14698 | if (p->error_indicator) { |
| 14699 | D(p->level--); |
| 14700 | return NULL; |
| 14701 | } |
| 14702 | D(fprintf(stderr, "%*c> yield_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'yield' star_expressions?")); |
| 14703 | Token * _keyword; |
| 14704 | void *a; |
| 14705 | if ( |
| 14706 | (_keyword = _PyPegen_expect_token(p, 504)) // token='yield' |
| 14707 | && |
| 14708 | (a = star_expressions_rule(p), 1) // star_expressions? |
| 14709 | ) |
| 14710 | { |
| 14711 | D(fprintf(stderr, "%*c+ yield_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'yield' star_expressions?")); |
| 14712 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 14713 | if (_token == NULL) { |
| 14714 | D(p->level--); |
| 14715 | return NULL; |
| 14716 | } |
| 14717 | int _end_lineno = _token->end_lineno; |
| 14718 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 14719 | int _end_col_offset = _token->end_col_offset; |
| 14720 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 14721 | _res = _PyAST_Yield ( a , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14722 | if (_res == NULL && PyErr_Occurred()) { |
| 14723 | p->error_indicator = 1; |
| 14724 | D(p->level--); |
| 14725 | return NULL; |
| 14726 | } |
| 14727 | goto done; |
| 14728 | } |
| 14729 | p->mark = _mark; |
| 14730 | D(fprintf(stderr, "%*c%s yield_expr[%d-%d]: %s failed!\n", p->level, ' ', |
| 14731 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'yield' star_expressions?")); |
| 14732 | } |
| 14733 | _res = NULL; |
| 14734 | done: |
| 14735 | D(p->level--); |
| 14736 | return _res; |
| 14737 | } |
| 14738 | |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 14739 | // arguments: args ','? &')' | invalid_arguments |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14740 | static expr_ty |
| 14741 | arguments_rule(Parser *p) |
| 14742 | { |
| 14743 | D(p->level++); |
| 14744 | if (p->error_indicator) { |
| 14745 | D(p->level--); |
| 14746 | return NULL; |
| 14747 | } |
| 14748 | expr_ty _res = NULL; |
| 14749 | if (_PyPegen_is_memoized(p, arguments_type, &_res)) { |
| 14750 | D(p->level--); |
| 14751 | return _res; |
| 14752 | } |
| 14753 | int _mark = p->mark; |
| 14754 | { // args ','? &')' |
| 14755 | if (p->error_indicator) { |
| 14756 | D(p->level--); |
| 14757 | return NULL; |
| 14758 | } |
| 14759 | D(fprintf(stderr, "%*c> arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ','? &')'")); |
| 14760 | void *_opt_var; |
| 14761 | UNUSED(_opt_var); // Silence compiler warnings |
| 14762 | expr_ty a; |
| 14763 | if ( |
| 14764 | (a = args_rule(p)) // args |
| 14765 | && |
| 14766 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 14767 | && |
| 14768 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
| 14769 | ) |
| 14770 | { |
| 14771 | D(fprintf(stderr, "%*c+ arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ','? &')'")); |
| 14772 | _res = a; |
| 14773 | if (_res == NULL && PyErr_Occurred()) { |
| 14774 | p->error_indicator = 1; |
| 14775 | D(p->level--); |
| 14776 | return NULL; |
| 14777 | } |
| 14778 | goto done; |
| 14779 | } |
| 14780 | p->mark = _mark; |
| 14781 | D(fprintf(stderr, "%*c%s arguments[%d-%d]: %s failed!\n", p->level, ' ', |
| 14782 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ','? &')'")); |
| 14783 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 14784 | if (p->call_invalid_rules) { // invalid_arguments |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14785 | if (p->error_indicator) { |
| 14786 | D(p->level--); |
| 14787 | return NULL; |
| 14788 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 14789 | D(fprintf(stderr, "%*c> arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_arguments")); |
| 14790 | void *invalid_arguments_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14791 | if ( |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 14792 | (invalid_arguments_var = invalid_arguments_rule(p)) // invalid_arguments |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14793 | ) |
| 14794 | { |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 14795 | D(fprintf(stderr, "%*c+ arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_arguments")); |
| 14796 | _res = invalid_arguments_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14797 | goto done; |
| 14798 | } |
| 14799 | p->mark = _mark; |
| 14800 | D(fprintf(stderr, "%*c%s arguments[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 14801 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_arguments")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14802 | } |
| 14803 | _res = NULL; |
| 14804 | done: |
| 14805 | _PyPegen_insert_memo(p, _mark, arguments_type, _res); |
| 14806 | D(p->level--); |
| 14807 | return _res; |
| 14808 | } |
| 14809 | |
Pablo Galindo | 4a97b15 | 2020-09-02 17:44:19 +0100 | [diff] [blame] | 14810 | // args: ','.(starred_expression | named_expression !'=')+ [',' kwargs] | kwargs |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14811 | static expr_ty |
| 14812 | args_rule(Parser *p) |
| 14813 | { |
| 14814 | D(p->level++); |
| 14815 | if (p->error_indicator) { |
| 14816 | D(p->level--); |
| 14817 | return NULL; |
| 14818 | } |
| 14819 | expr_ty _res = NULL; |
| 14820 | int _mark = p->mark; |
| 14821 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 14822 | p->error_indicator = 1; |
| 14823 | D(p->level--); |
| 14824 | return NULL; |
| 14825 | } |
| 14826 | int _start_lineno = p->tokens[_mark]->lineno; |
| 14827 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 14828 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 14829 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 4a97b15 | 2020-09-02 17:44:19 +0100 | [diff] [blame] | 14830 | { // ','.(starred_expression | named_expression !'=')+ [',' kwargs] |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14831 | if (p->error_indicator) { |
| 14832 | D(p->level--); |
| 14833 | return NULL; |
| 14834 | } |
Pablo Galindo | 4a97b15 | 2020-09-02 17:44:19 +0100 | [diff] [blame] | 14835 | D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.(starred_expression | named_expression !'=')+ [',' kwargs]")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 14836 | asdl_expr_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14837 | void *b; |
| 14838 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 14839 | (a = (asdl_expr_seq*)_gather_122_rule(p)) // ','.(starred_expression | named_expression !'=')+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14840 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 14841 | (b = _tmp_124_rule(p), 1) // [',' kwargs] |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14842 | ) |
| 14843 | { |
Pablo Galindo | 4a97b15 | 2020-09-02 17:44:19 +0100 | [diff] [blame] | 14844 | D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.(starred_expression | named_expression !'=')+ [',' kwargs]")); |
Pablo Galindo | 315a61f | 2020-09-03 15:29:32 +0100 | [diff] [blame] | 14845 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 14846 | if (_token == NULL) { |
| 14847 | D(p->level--); |
| 14848 | return NULL; |
| 14849 | } |
| 14850 | int _end_lineno = _token->end_lineno; |
| 14851 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 14852 | int _end_col_offset = _token->end_col_offset; |
| 14853 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 14854 | _res = _PyPegen_collect_call_seqs ( p , a , b , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14855 | if (_res == NULL && PyErr_Occurred()) { |
| 14856 | p->error_indicator = 1; |
| 14857 | D(p->level--); |
| 14858 | return NULL; |
| 14859 | } |
| 14860 | goto done; |
| 14861 | } |
| 14862 | p->mark = _mark; |
| 14863 | D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 4a97b15 | 2020-09-02 17:44:19 +0100 | [diff] [blame] | 14864 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.(starred_expression | named_expression !'=')+ [',' kwargs]")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14865 | } |
| 14866 | { // kwargs |
| 14867 | if (p->error_indicator) { |
| 14868 | D(p->level--); |
| 14869 | return NULL; |
| 14870 | } |
| 14871 | D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwargs")); |
| 14872 | asdl_seq* a; |
| 14873 | if ( |
| 14874 | (a = kwargs_rule(p)) // kwargs |
| 14875 | ) |
| 14876 | { |
| 14877 | D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwargs")); |
| 14878 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 14879 | if (_token == NULL) { |
| 14880 | D(p->level--); |
| 14881 | return NULL; |
| 14882 | } |
| 14883 | int _end_lineno = _token->end_lineno; |
| 14884 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 14885 | int _end_col_offset = _token->end_col_offset; |
| 14886 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 14887 | _res = _PyAST_Call ( _PyPegen_dummy_name ( p ) , CHECK_NULL_ALLOWED ( asdl_expr_seq * , _PyPegen_seq_extract_starred_exprs ( p , a ) ) , CHECK_NULL_ALLOWED ( asdl_keyword_seq * , _PyPegen_seq_delete_starred_exprs ( p , a ) ) , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14888 | if (_res == NULL && PyErr_Occurred()) { |
| 14889 | p->error_indicator = 1; |
| 14890 | D(p->level--); |
| 14891 | return NULL; |
| 14892 | } |
| 14893 | goto done; |
| 14894 | } |
| 14895 | p->mark = _mark; |
| 14896 | D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ', |
| 14897 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwargs")); |
| 14898 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14899 | _res = NULL; |
| 14900 | done: |
| 14901 | D(p->level--); |
| 14902 | return _res; |
| 14903 | } |
| 14904 | |
| 14905 | // kwargs: |
| 14906 | // | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
| 14907 | // | ','.kwarg_or_starred+ |
| 14908 | // | ','.kwarg_or_double_starred+ |
| 14909 | static asdl_seq* |
| 14910 | kwargs_rule(Parser *p) |
| 14911 | { |
| 14912 | D(p->level++); |
| 14913 | if (p->error_indicator) { |
| 14914 | D(p->level--); |
| 14915 | return NULL; |
| 14916 | } |
| 14917 | asdl_seq* _res = NULL; |
| 14918 | int _mark = p->mark; |
| 14919 | { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
| 14920 | if (p->error_indicator) { |
| 14921 | D(p->level--); |
| 14922 | return NULL; |
| 14923 | } |
| 14924 | D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); |
| 14925 | Token * _literal; |
| 14926 | asdl_seq * a; |
| 14927 | asdl_seq * b; |
| 14928 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 14929 | (a = _gather_125_rule(p)) // ','.kwarg_or_starred+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14930 | && |
| 14931 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 14932 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 14933 | (b = _gather_127_rule(p)) // ','.kwarg_or_double_starred+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14934 | ) |
| 14935 | { |
| 14936 | D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); |
| 14937 | _res = _PyPegen_join_sequences ( p , a , b ); |
| 14938 | if (_res == NULL && PyErr_Occurred()) { |
| 14939 | p->error_indicator = 1; |
| 14940 | D(p->level--); |
| 14941 | return NULL; |
| 14942 | } |
| 14943 | goto done; |
| 14944 | } |
| 14945 | p->mark = _mark; |
| 14946 | D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ', |
| 14947 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); |
| 14948 | } |
| 14949 | { // ','.kwarg_or_starred+ |
| 14950 | if (p->error_indicator) { |
| 14951 | D(p->level--); |
| 14952 | return NULL; |
| 14953 | } |
| 14954 | D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 14955 | asdl_seq * _gather_129_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14956 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 14957 | (_gather_129_var = _gather_129_rule(p)) // ','.kwarg_or_starred+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14958 | ) |
| 14959 | { |
| 14960 | D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 14961 | _res = _gather_129_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14962 | goto done; |
| 14963 | } |
| 14964 | p->mark = _mark; |
| 14965 | D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ', |
| 14966 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+")); |
| 14967 | } |
| 14968 | { // ','.kwarg_or_double_starred+ |
| 14969 | if (p->error_indicator) { |
| 14970 | D(p->level--); |
| 14971 | return NULL; |
| 14972 | } |
| 14973 | D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 14974 | asdl_seq * _gather_131_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14975 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 14976 | (_gather_131_var = _gather_131_rule(p)) // ','.kwarg_or_double_starred+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14977 | ) |
| 14978 | { |
| 14979 | D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 14980 | _res = _gather_131_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 14981 | goto done; |
| 14982 | } |
| 14983 | p->mark = _mark; |
| 14984 | D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ', |
| 14985 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_double_starred+")); |
| 14986 | } |
| 14987 | _res = NULL; |
| 14988 | done: |
| 14989 | D(p->level--); |
| 14990 | return _res; |
| 14991 | } |
| 14992 | |
| 14993 | // starred_expression: '*' expression |
| 14994 | static expr_ty |
| 14995 | starred_expression_rule(Parser *p) |
| 14996 | { |
| 14997 | D(p->level++); |
| 14998 | if (p->error_indicator) { |
| 14999 | D(p->level--); |
| 15000 | return NULL; |
| 15001 | } |
| 15002 | expr_ty _res = NULL; |
| 15003 | int _mark = p->mark; |
| 15004 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 15005 | p->error_indicator = 1; |
| 15006 | D(p->level--); |
| 15007 | return NULL; |
| 15008 | } |
| 15009 | int _start_lineno = p->tokens[_mark]->lineno; |
| 15010 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 15011 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 15012 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 15013 | { // '*' expression |
| 15014 | if (p->error_indicator) { |
| 15015 | D(p->level--); |
| 15016 | return NULL; |
| 15017 | } |
| 15018 | D(fprintf(stderr, "%*c> starred_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression")); |
| 15019 | Token * _literal; |
| 15020 | expr_ty a; |
| 15021 | if ( |
| 15022 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 15023 | && |
| 15024 | (a = expression_rule(p)) // expression |
| 15025 | ) |
| 15026 | { |
| 15027 | D(fprintf(stderr, "%*c+ starred_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression")); |
| 15028 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 15029 | if (_token == NULL) { |
| 15030 | D(p->level--); |
| 15031 | return NULL; |
| 15032 | } |
| 15033 | int _end_lineno = _token->end_lineno; |
| 15034 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 15035 | int _end_col_offset = _token->end_col_offset; |
| 15036 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 15037 | _res = _PyAST_Starred ( a , Load , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15038 | if (_res == NULL && PyErr_Occurred()) { |
| 15039 | p->error_indicator = 1; |
| 15040 | D(p->level--); |
| 15041 | return NULL; |
| 15042 | } |
| 15043 | goto done; |
| 15044 | } |
| 15045 | p->mark = _mark; |
| 15046 | D(fprintf(stderr, "%*c%s starred_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 15047 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression")); |
| 15048 | } |
| 15049 | _res = NULL; |
| 15050 | done: |
| 15051 | D(p->level--); |
| 15052 | return _res; |
| 15053 | } |
| 15054 | |
| 15055 | // kwarg_or_starred: NAME '=' expression | starred_expression | invalid_kwarg |
| 15056 | static KeywordOrStarred* |
| 15057 | kwarg_or_starred_rule(Parser *p) |
| 15058 | { |
| 15059 | D(p->level++); |
| 15060 | if (p->error_indicator) { |
| 15061 | D(p->level--); |
| 15062 | return NULL; |
| 15063 | } |
| 15064 | KeywordOrStarred* _res = NULL; |
| 15065 | int _mark = p->mark; |
| 15066 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 15067 | p->error_indicator = 1; |
| 15068 | D(p->level--); |
| 15069 | return NULL; |
| 15070 | } |
| 15071 | int _start_lineno = p->tokens[_mark]->lineno; |
| 15072 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 15073 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 15074 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 15075 | { // NAME '=' expression |
| 15076 | if (p->error_indicator) { |
| 15077 | D(p->level--); |
| 15078 | return NULL; |
| 15079 | } |
| 15080 | D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); |
| 15081 | Token * _literal; |
| 15082 | expr_ty a; |
| 15083 | expr_ty b; |
| 15084 | if ( |
| 15085 | (a = _PyPegen_name_token(p)) // NAME |
| 15086 | && |
| 15087 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 15088 | && |
| 15089 | (b = expression_rule(p)) // expression |
| 15090 | ) |
| 15091 | { |
| 15092 | D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); |
| 15093 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 15094 | if (_token == NULL) { |
| 15095 | D(p->level--); |
| 15096 | return NULL; |
| 15097 | } |
| 15098 | int _end_lineno = _token->end_lineno; |
| 15099 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 15100 | int _end_col_offset = _token->end_col_offset; |
| 15101 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 15102 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( keyword_ty , _PyAST_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15103 | if (_res == NULL && PyErr_Occurred()) { |
| 15104 | p->error_indicator = 1; |
| 15105 | D(p->level--); |
| 15106 | return NULL; |
| 15107 | } |
| 15108 | goto done; |
| 15109 | } |
| 15110 | p->mark = _mark; |
| 15111 | D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ', |
| 15112 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression")); |
| 15113 | } |
| 15114 | { // starred_expression |
| 15115 | if (p->error_indicator) { |
| 15116 | D(p->level--); |
| 15117 | return NULL; |
| 15118 | } |
| 15119 | D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); |
| 15120 | expr_ty a; |
| 15121 | if ( |
| 15122 | (a = starred_expression_rule(p)) // starred_expression |
| 15123 | ) |
| 15124 | { |
| 15125 | D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); |
| 15126 | _res = _PyPegen_keyword_or_starred ( p , a , 0 ); |
| 15127 | if (_res == NULL && PyErr_Occurred()) { |
| 15128 | p->error_indicator = 1; |
| 15129 | D(p->level--); |
| 15130 | return NULL; |
| 15131 | } |
| 15132 | goto done; |
| 15133 | } |
| 15134 | p->mark = _mark; |
| 15135 | D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ', |
| 15136 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); |
| 15137 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 15138 | if (p->call_invalid_rules) { // invalid_kwarg |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15139 | if (p->error_indicator) { |
| 15140 | D(p->level--); |
| 15141 | return NULL; |
| 15142 | } |
| 15143 | D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); |
| 15144 | void *invalid_kwarg_var; |
| 15145 | if ( |
| 15146 | (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg |
| 15147 | ) |
| 15148 | { |
| 15149 | D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); |
| 15150 | _res = invalid_kwarg_var; |
| 15151 | goto done; |
| 15152 | } |
| 15153 | p->mark = _mark; |
| 15154 | D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ', |
| 15155 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kwarg")); |
| 15156 | } |
| 15157 | _res = NULL; |
| 15158 | done: |
| 15159 | D(p->level--); |
| 15160 | return _res; |
| 15161 | } |
| 15162 | |
| 15163 | // kwarg_or_double_starred: NAME '=' expression | '**' expression | invalid_kwarg |
| 15164 | static KeywordOrStarred* |
| 15165 | kwarg_or_double_starred_rule(Parser *p) |
| 15166 | { |
| 15167 | D(p->level++); |
| 15168 | if (p->error_indicator) { |
| 15169 | D(p->level--); |
| 15170 | return NULL; |
| 15171 | } |
| 15172 | KeywordOrStarred* _res = NULL; |
| 15173 | int _mark = p->mark; |
| 15174 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 15175 | p->error_indicator = 1; |
| 15176 | D(p->level--); |
| 15177 | return NULL; |
| 15178 | } |
| 15179 | int _start_lineno = p->tokens[_mark]->lineno; |
| 15180 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 15181 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 15182 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 15183 | { // NAME '=' expression |
| 15184 | if (p->error_indicator) { |
| 15185 | D(p->level--); |
| 15186 | return NULL; |
| 15187 | } |
| 15188 | D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); |
| 15189 | Token * _literal; |
| 15190 | expr_ty a; |
| 15191 | expr_ty b; |
| 15192 | if ( |
| 15193 | (a = _PyPegen_name_token(p)) // NAME |
| 15194 | && |
| 15195 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 15196 | && |
| 15197 | (b = expression_rule(p)) // expression |
| 15198 | ) |
| 15199 | { |
| 15200 | D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); |
| 15201 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 15202 | if (_token == NULL) { |
| 15203 | D(p->level--); |
| 15204 | return NULL; |
| 15205 | } |
| 15206 | int _end_lineno = _token->end_lineno; |
| 15207 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 15208 | int _end_col_offset = _token->end_col_offset; |
| 15209 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 15210 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( keyword_ty , _PyAST_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15211 | if (_res == NULL && PyErr_Occurred()) { |
| 15212 | p->error_indicator = 1; |
| 15213 | D(p->level--); |
| 15214 | return NULL; |
| 15215 | } |
| 15216 | goto done; |
| 15217 | } |
| 15218 | p->mark = _mark; |
| 15219 | D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ', |
| 15220 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression")); |
| 15221 | } |
| 15222 | { // '**' expression |
| 15223 | if (p->error_indicator) { |
| 15224 | D(p->level--); |
| 15225 | return NULL; |
| 15226 | } |
| 15227 | D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' expression")); |
| 15228 | Token * _literal; |
| 15229 | expr_ty a; |
| 15230 | if ( |
| 15231 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
| 15232 | && |
| 15233 | (a = expression_rule(p)) // expression |
| 15234 | ) |
| 15235 | { |
| 15236 | D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' expression")); |
| 15237 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 15238 | if (_token == NULL) { |
| 15239 | D(p->level--); |
| 15240 | return NULL; |
| 15241 | } |
| 15242 | int _end_lineno = _token->end_lineno; |
| 15243 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 15244 | int _end_col_offset = _token->end_col_offset; |
| 15245 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 15246 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( keyword_ty , _PyAST_keyword ( NULL , a , EXTRA ) ) , 1 ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15247 | if (_res == NULL && PyErr_Occurred()) { |
| 15248 | p->error_indicator = 1; |
| 15249 | D(p->level--); |
| 15250 | return NULL; |
| 15251 | } |
| 15252 | goto done; |
| 15253 | } |
| 15254 | p->mark = _mark; |
| 15255 | D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ', |
| 15256 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' expression")); |
| 15257 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 15258 | if (p->call_invalid_rules) { // invalid_kwarg |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15259 | if (p->error_indicator) { |
| 15260 | D(p->level--); |
| 15261 | return NULL; |
| 15262 | } |
| 15263 | D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); |
| 15264 | void *invalid_kwarg_var; |
| 15265 | if ( |
| 15266 | (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg |
| 15267 | ) |
| 15268 | { |
| 15269 | D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); |
| 15270 | _res = invalid_kwarg_var; |
| 15271 | goto done; |
| 15272 | } |
| 15273 | p->mark = _mark; |
| 15274 | D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ', |
| 15275 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kwarg")); |
| 15276 | } |
| 15277 | _res = NULL; |
| 15278 | done: |
| 15279 | D(p->level--); |
| 15280 | return _res; |
| 15281 | } |
| 15282 | |
| 15283 | // star_targets: star_target !',' | star_target ((',' star_target))* ','? |
| 15284 | static expr_ty |
| 15285 | star_targets_rule(Parser *p) |
| 15286 | { |
| 15287 | D(p->level++); |
| 15288 | if (p->error_indicator) { |
| 15289 | D(p->level--); |
| 15290 | return NULL; |
| 15291 | } |
| 15292 | expr_ty _res = NULL; |
| 15293 | int _mark = p->mark; |
| 15294 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 15295 | p->error_indicator = 1; |
| 15296 | D(p->level--); |
| 15297 | return NULL; |
| 15298 | } |
| 15299 | int _start_lineno = p->tokens[_mark]->lineno; |
| 15300 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 15301 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 15302 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 15303 | { // star_target !',' |
| 15304 | if (p->error_indicator) { |
| 15305 | D(p->level--); |
| 15306 | return NULL; |
| 15307 | } |
| 15308 | D(fprintf(stderr, "%*c> star_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target !','")); |
| 15309 | expr_ty a; |
| 15310 | if ( |
| 15311 | (a = star_target_rule(p)) // star_target |
| 15312 | && |
| 15313 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
| 15314 | ) |
| 15315 | { |
| 15316 | D(fprintf(stderr, "%*c+ star_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target !','")); |
| 15317 | _res = a; |
| 15318 | if (_res == NULL && PyErr_Occurred()) { |
| 15319 | p->error_indicator = 1; |
| 15320 | D(p->level--); |
| 15321 | return NULL; |
| 15322 | } |
| 15323 | goto done; |
| 15324 | } |
| 15325 | p->mark = _mark; |
| 15326 | D(fprintf(stderr, "%*c%s star_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 15327 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target !','")); |
| 15328 | } |
| 15329 | { // star_target ((',' star_target))* ','? |
| 15330 | if (p->error_indicator) { |
| 15331 | D(p->level--); |
| 15332 | return NULL; |
| 15333 | } |
| 15334 | D(fprintf(stderr, "%*c> star_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))* ','?")); |
| 15335 | void *_opt_var; |
| 15336 | UNUSED(_opt_var); // Silence compiler warnings |
| 15337 | expr_ty a; |
| 15338 | asdl_seq * b; |
| 15339 | if ( |
| 15340 | (a = star_target_rule(p)) // star_target |
| 15341 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 15342 | (b = _loop0_133_rule(p)) // ((',' star_target))* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15343 | && |
| 15344 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 15345 | ) |
| 15346 | { |
| 15347 | D(fprintf(stderr, "%*c+ star_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))* ','?")); |
| 15348 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 15349 | if (_token == NULL) { |
| 15350 | D(p->level--); |
| 15351 | return NULL; |
| 15352 | } |
| 15353 | int _end_lineno = _token->end_lineno; |
| 15354 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 15355 | int _end_col_offset = _token->end_col_offset; |
| 15356 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 15357 | _res = _PyAST_Tuple ( CHECK ( asdl_expr_seq * , _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15358 | if (_res == NULL && PyErr_Occurred()) { |
| 15359 | p->error_indicator = 1; |
| 15360 | D(p->level--); |
| 15361 | return NULL; |
| 15362 | } |
| 15363 | goto done; |
| 15364 | } |
| 15365 | p->mark = _mark; |
| 15366 | D(fprintf(stderr, "%*c%s star_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 15367 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target ((',' star_target))* ','?")); |
| 15368 | } |
| 15369 | _res = NULL; |
| 15370 | done: |
| 15371 | D(p->level--); |
| 15372 | return _res; |
| 15373 | } |
| 15374 | |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15375 | // star_targets_list_seq: ','.star_target+ ','? |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 15376 | static asdl_expr_seq* |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15377 | star_targets_list_seq_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15378 | { |
| 15379 | D(p->level++); |
| 15380 | if (p->error_indicator) { |
| 15381 | D(p->level--); |
| 15382 | return NULL; |
| 15383 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 15384 | asdl_expr_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15385 | int _mark = p->mark; |
| 15386 | { // ','.star_target+ ','? |
| 15387 | if (p->error_indicator) { |
| 15388 | D(p->level--); |
| 15389 | return NULL; |
| 15390 | } |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15391 | D(fprintf(stderr, "%*c> star_targets_list_seq[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_target+ ','?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15392 | void *_opt_var; |
| 15393 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 15394 | asdl_expr_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15395 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 15396 | (a = (asdl_expr_seq*)_gather_134_rule(p)) // ','.star_target+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15397 | && |
| 15398 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 15399 | ) |
| 15400 | { |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15401 | D(fprintf(stderr, "%*c+ star_targets_list_seq[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_target+ ','?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15402 | _res = a; |
| 15403 | if (_res == NULL && PyErr_Occurred()) { |
| 15404 | p->error_indicator = 1; |
| 15405 | D(p->level--); |
| 15406 | return NULL; |
| 15407 | } |
| 15408 | goto done; |
| 15409 | } |
| 15410 | p->mark = _mark; |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15411 | D(fprintf(stderr, "%*c%s star_targets_list_seq[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15412 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_target+ ','?")); |
| 15413 | } |
| 15414 | _res = NULL; |
| 15415 | done: |
| 15416 | D(p->level--); |
| 15417 | return _res; |
| 15418 | } |
| 15419 | |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15420 | // star_targets_tuple_seq: star_target ((',' star_target))+ ','? | star_target ',' |
| 15421 | static asdl_expr_seq* |
| 15422 | star_targets_tuple_seq_rule(Parser *p) |
| 15423 | { |
| 15424 | D(p->level++); |
| 15425 | if (p->error_indicator) { |
| 15426 | D(p->level--); |
| 15427 | return NULL; |
| 15428 | } |
| 15429 | asdl_expr_seq* _res = NULL; |
| 15430 | int _mark = p->mark; |
| 15431 | { // star_target ((',' star_target))+ ','? |
| 15432 | if (p->error_indicator) { |
| 15433 | D(p->level--); |
| 15434 | return NULL; |
| 15435 | } |
| 15436 | D(fprintf(stderr, "%*c> star_targets_tuple_seq[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))+ ','?")); |
| 15437 | void *_opt_var; |
| 15438 | UNUSED(_opt_var); // Silence compiler warnings |
| 15439 | expr_ty a; |
| 15440 | asdl_seq * b; |
| 15441 | if ( |
| 15442 | (a = star_target_rule(p)) // star_target |
| 15443 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 15444 | (b = _loop1_136_rule(p)) // ((',' star_target))+ |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15445 | && |
| 15446 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 15447 | ) |
| 15448 | { |
| 15449 | D(fprintf(stderr, "%*c+ star_targets_tuple_seq[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))+ ','?")); |
| 15450 | _res = ( asdl_expr_seq * ) _PyPegen_seq_insert_in_front ( p , a , b ); |
| 15451 | if (_res == NULL && PyErr_Occurred()) { |
| 15452 | p->error_indicator = 1; |
| 15453 | D(p->level--); |
| 15454 | return NULL; |
| 15455 | } |
| 15456 | goto done; |
| 15457 | } |
| 15458 | p->mark = _mark; |
| 15459 | D(fprintf(stderr, "%*c%s star_targets_tuple_seq[%d-%d]: %s failed!\n", p->level, ' ', |
| 15460 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target ((',' star_target))+ ','?")); |
| 15461 | } |
| 15462 | { // star_target ',' |
| 15463 | if (p->error_indicator) { |
| 15464 | D(p->level--); |
| 15465 | return NULL; |
| 15466 | } |
| 15467 | D(fprintf(stderr, "%*c> star_targets_tuple_seq[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target ','")); |
| 15468 | Token * _literal; |
| 15469 | expr_ty a; |
| 15470 | if ( |
| 15471 | (a = star_target_rule(p)) // star_target |
| 15472 | && |
| 15473 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 15474 | ) |
| 15475 | { |
| 15476 | D(fprintf(stderr, "%*c+ star_targets_tuple_seq[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target ','")); |
| 15477 | _res = ( asdl_expr_seq * ) _PyPegen_singleton_seq ( p , a ); |
| 15478 | if (_res == NULL && PyErr_Occurred()) { |
| 15479 | p->error_indicator = 1; |
| 15480 | D(p->level--); |
| 15481 | return NULL; |
| 15482 | } |
| 15483 | goto done; |
| 15484 | } |
| 15485 | p->mark = _mark; |
| 15486 | D(fprintf(stderr, "%*c%s star_targets_tuple_seq[%d-%d]: %s failed!\n", p->level, ' ', |
| 15487 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target ','")); |
| 15488 | } |
| 15489 | _res = NULL; |
| 15490 | done: |
| 15491 | D(p->level--); |
| 15492 | return _res; |
| 15493 | } |
| 15494 | |
| 15495 | // star_target: '*' (!'*' star_target) | target_with_star_atom |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15496 | static expr_ty |
| 15497 | star_target_rule(Parser *p) |
| 15498 | { |
| 15499 | D(p->level++); |
| 15500 | if (p->error_indicator) { |
| 15501 | D(p->level--); |
| 15502 | return NULL; |
| 15503 | } |
| 15504 | expr_ty _res = NULL; |
| 15505 | if (_PyPegen_is_memoized(p, star_target_type, &_res)) { |
| 15506 | D(p->level--); |
| 15507 | return _res; |
| 15508 | } |
| 15509 | int _mark = p->mark; |
| 15510 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 15511 | p->error_indicator = 1; |
| 15512 | D(p->level--); |
| 15513 | return NULL; |
| 15514 | } |
| 15515 | int _start_lineno = p->tokens[_mark]->lineno; |
| 15516 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 15517 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 15518 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 15519 | { // '*' (!'*' star_target) |
| 15520 | if (p->error_indicator) { |
| 15521 | D(p->level--); |
| 15522 | return NULL; |
| 15523 | } |
| 15524 | D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); |
| 15525 | Token * _literal; |
| 15526 | void *a; |
| 15527 | if ( |
| 15528 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 15529 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 15530 | (a = _tmp_137_rule(p)) // !'*' star_target |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15531 | ) |
| 15532 | { |
| 15533 | D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); |
| 15534 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 15535 | if (_token == NULL) { |
| 15536 | D(p->level--); |
| 15537 | return NULL; |
| 15538 | } |
| 15539 | int _end_lineno = _token->end_lineno; |
| 15540 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 15541 | int _end_col_offset = _token->end_col_offset; |
| 15542 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 15543 | _res = _PyAST_Starred ( CHECK ( expr_ty , _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15544 | if (_res == NULL && PyErr_Occurred()) { |
| 15545 | p->error_indicator = 1; |
| 15546 | D(p->level--); |
| 15547 | return NULL; |
| 15548 | } |
| 15549 | goto done; |
| 15550 | } |
| 15551 | p->mark = _mark; |
| 15552 | D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 15553 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (!'*' star_target)")); |
| 15554 | } |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15555 | { // target_with_star_atom |
| 15556 | if (p->error_indicator) { |
| 15557 | D(p->level--); |
| 15558 | return NULL; |
| 15559 | } |
| 15560 | D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target_with_star_atom")); |
| 15561 | expr_ty target_with_star_atom_var; |
| 15562 | if ( |
| 15563 | (target_with_star_atom_var = target_with_star_atom_rule(p)) // target_with_star_atom |
| 15564 | ) |
| 15565 | { |
| 15566 | D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target_with_star_atom")); |
| 15567 | _res = target_with_star_atom_var; |
| 15568 | goto done; |
| 15569 | } |
| 15570 | p->mark = _mark; |
| 15571 | D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 15572 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target_with_star_atom")); |
| 15573 | } |
| 15574 | _res = NULL; |
| 15575 | done: |
| 15576 | _PyPegen_insert_memo(p, _mark, star_target_type, _res); |
| 15577 | D(p->level--); |
| 15578 | return _res; |
| 15579 | } |
| 15580 | |
| 15581 | // target_with_star_atom: |
| 15582 | // | t_primary '.' NAME !t_lookahead |
| 15583 | // | t_primary '[' slices ']' !t_lookahead |
| 15584 | // | star_atom |
| 15585 | static expr_ty |
| 15586 | target_with_star_atom_rule(Parser *p) |
| 15587 | { |
| 15588 | D(p->level++); |
| 15589 | if (p->error_indicator) { |
| 15590 | D(p->level--); |
| 15591 | return NULL; |
| 15592 | } |
| 15593 | expr_ty _res = NULL; |
| 15594 | if (_PyPegen_is_memoized(p, target_with_star_atom_type, &_res)) { |
| 15595 | D(p->level--); |
| 15596 | return _res; |
| 15597 | } |
| 15598 | int _mark = p->mark; |
| 15599 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 15600 | p->error_indicator = 1; |
| 15601 | D(p->level--); |
| 15602 | return NULL; |
| 15603 | } |
| 15604 | int _start_lineno = p->tokens[_mark]->lineno; |
| 15605 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 15606 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 15607 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15608 | { // t_primary '.' NAME !t_lookahead |
| 15609 | if (p->error_indicator) { |
| 15610 | D(p->level--); |
| 15611 | return NULL; |
| 15612 | } |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15613 | D(fprintf(stderr, "%*c> target_with_star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15614 | Token * _literal; |
| 15615 | expr_ty a; |
| 15616 | expr_ty b; |
| 15617 | if ( |
| 15618 | (a = t_primary_rule(p)) // t_primary |
| 15619 | && |
| 15620 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 15621 | && |
| 15622 | (b = _PyPegen_name_token(p)) // NAME |
| 15623 | && |
| 15624 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 15625 | ) |
| 15626 | { |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15627 | D(fprintf(stderr, "%*c+ target_with_star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15628 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 15629 | if (_token == NULL) { |
| 15630 | D(p->level--); |
| 15631 | return NULL; |
| 15632 | } |
| 15633 | int _end_lineno = _token->end_lineno; |
| 15634 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 15635 | int _end_col_offset = _token->end_col_offset; |
| 15636 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 15637 | _res = _PyAST_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15638 | if (_res == NULL && PyErr_Occurred()) { |
| 15639 | p->error_indicator = 1; |
| 15640 | D(p->level--); |
| 15641 | return NULL; |
| 15642 | } |
| 15643 | goto done; |
| 15644 | } |
| 15645 | p->mark = _mark; |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15646 | D(fprintf(stderr, "%*c%s target_with_star_atom[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15647 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
| 15648 | } |
| 15649 | { // t_primary '[' slices ']' !t_lookahead |
| 15650 | if (p->error_indicator) { |
| 15651 | D(p->level--); |
| 15652 | return NULL; |
| 15653 | } |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15654 | D(fprintf(stderr, "%*c> target_with_star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15655 | Token * _literal; |
| 15656 | Token * _literal_1; |
| 15657 | expr_ty a; |
| 15658 | expr_ty b; |
| 15659 | if ( |
| 15660 | (a = t_primary_rule(p)) // t_primary |
| 15661 | && |
| 15662 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 15663 | && |
| 15664 | (b = slices_rule(p)) // slices |
| 15665 | && |
| 15666 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
| 15667 | && |
| 15668 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 15669 | ) |
| 15670 | { |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15671 | D(fprintf(stderr, "%*c+ target_with_star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15672 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 15673 | if (_token == NULL) { |
| 15674 | D(p->level--); |
| 15675 | return NULL; |
| 15676 | } |
| 15677 | int _end_lineno = _token->end_lineno; |
| 15678 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 15679 | int _end_col_offset = _token->end_col_offset; |
| 15680 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 15681 | _res = _PyAST_Subscript ( a , b , Store , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15682 | if (_res == NULL && PyErr_Occurred()) { |
| 15683 | p->error_indicator = 1; |
| 15684 | D(p->level--); |
| 15685 | return NULL; |
| 15686 | } |
| 15687 | goto done; |
| 15688 | } |
| 15689 | p->mark = _mark; |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15690 | D(fprintf(stderr, "%*c%s target_with_star_atom[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15691 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
| 15692 | } |
| 15693 | { // star_atom |
| 15694 | if (p->error_indicator) { |
| 15695 | D(p->level--); |
| 15696 | return NULL; |
| 15697 | } |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15698 | D(fprintf(stderr, "%*c> target_with_star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_atom")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15699 | expr_ty star_atom_var; |
| 15700 | if ( |
| 15701 | (star_atom_var = star_atom_rule(p)) // star_atom |
| 15702 | ) |
| 15703 | { |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15704 | D(fprintf(stderr, "%*c+ target_with_star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_atom")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15705 | _res = star_atom_var; |
| 15706 | goto done; |
| 15707 | } |
| 15708 | p->mark = _mark; |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15709 | D(fprintf(stderr, "%*c%s target_with_star_atom[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15710 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_atom")); |
| 15711 | } |
| 15712 | _res = NULL; |
| 15713 | done: |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15714 | _PyPegen_insert_memo(p, _mark, target_with_star_atom_type, _res); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15715 | D(p->level--); |
| 15716 | return _res; |
| 15717 | } |
| 15718 | |
| 15719 | // star_atom: |
| 15720 | // | NAME |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15721 | // | '(' target_with_star_atom ')' |
| 15722 | // | '(' star_targets_tuple_seq? ')' |
| 15723 | // | '[' star_targets_list_seq? ']' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15724 | static expr_ty |
| 15725 | star_atom_rule(Parser *p) |
| 15726 | { |
| 15727 | D(p->level++); |
| 15728 | if (p->error_indicator) { |
| 15729 | D(p->level--); |
| 15730 | return NULL; |
| 15731 | } |
| 15732 | expr_ty _res = NULL; |
| 15733 | int _mark = p->mark; |
| 15734 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 15735 | p->error_indicator = 1; |
| 15736 | D(p->level--); |
| 15737 | return NULL; |
| 15738 | } |
| 15739 | int _start_lineno = p->tokens[_mark]->lineno; |
| 15740 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 15741 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 15742 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 15743 | { // NAME |
| 15744 | if (p->error_indicator) { |
| 15745 | D(p->level--); |
| 15746 | return NULL; |
| 15747 | } |
| 15748 | D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); |
| 15749 | expr_ty a; |
| 15750 | if ( |
| 15751 | (a = _PyPegen_name_token(p)) // NAME |
| 15752 | ) |
| 15753 | { |
| 15754 | D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); |
| 15755 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 15756 | if (_res == NULL && PyErr_Occurred()) { |
| 15757 | p->error_indicator = 1; |
| 15758 | D(p->level--); |
| 15759 | return NULL; |
| 15760 | } |
| 15761 | goto done; |
| 15762 | } |
| 15763 | p->mark = _mark; |
| 15764 | D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 15765 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); |
| 15766 | } |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15767 | { // '(' target_with_star_atom ')' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15768 | if (p->error_indicator) { |
| 15769 | D(p->level--); |
| 15770 | return NULL; |
| 15771 | } |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15772 | D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' target_with_star_atom ')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15773 | Token * _literal; |
| 15774 | Token * _literal_1; |
| 15775 | expr_ty a; |
| 15776 | if ( |
| 15777 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 15778 | && |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15779 | (a = target_with_star_atom_rule(p)) // target_with_star_atom |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15780 | && |
| 15781 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 15782 | ) |
| 15783 | { |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15784 | D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' target_with_star_atom ')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15785 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 15786 | if (_res == NULL && PyErr_Occurred()) { |
| 15787 | p->error_indicator = 1; |
| 15788 | D(p->level--); |
| 15789 | return NULL; |
| 15790 | } |
| 15791 | goto done; |
| 15792 | } |
| 15793 | p->mark = _mark; |
| 15794 | D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15795 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' target_with_star_atom ')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15796 | } |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15797 | { // '(' star_targets_tuple_seq? ')' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15798 | if (p->error_indicator) { |
| 15799 | D(p->level--); |
| 15800 | return NULL; |
| 15801 | } |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15802 | D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' star_targets_tuple_seq? ')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15803 | Token * _literal; |
| 15804 | Token * _literal_1; |
| 15805 | void *a; |
| 15806 | if ( |
| 15807 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 15808 | && |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15809 | (a = star_targets_tuple_seq_rule(p), 1) // star_targets_tuple_seq? |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15810 | && |
| 15811 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 15812 | ) |
| 15813 | { |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15814 | D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' star_targets_tuple_seq? ')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15815 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 15816 | if (_token == NULL) { |
| 15817 | D(p->level--); |
| 15818 | return NULL; |
| 15819 | } |
| 15820 | int _end_lineno = _token->end_lineno; |
| 15821 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 15822 | int _end_col_offset = _token->end_col_offset; |
| 15823 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 15824 | _res = _PyAST_Tuple ( a , Store , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15825 | if (_res == NULL && PyErr_Occurred()) { |
| 15826 | p->error_indicator = 1; |
| 15827 | D(p->level--); |
| 15828 | return NULL; |
| 15829 | } |
| 15830 | goto done; |
| 15831 | } |
| 15832 | p->mark = _mark; |
| 15833 | D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15834 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' star_targets_tuple_seq? ')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15835 | } |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15836 | { // '[' star_targets_list_seq? ']' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15837 | if (p->error_indicator) { |
| 15838 | D(p->level--); |
| 15839 | return NULL; |
| 15840 | } |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15841 | D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' star_targets_list_seq? ']'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15842 | Token * _literal; |
| 15843 | Token * _literal_1; |
| 15844 | void *a; |
| 15845 | if ( |
| 15846 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 15847 | && |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15848 | (a = star_targets_list_seq_rule(p), 1) // star_targets_list_seq? |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15849 | && |
| 15850 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
| 15851 | ) |
| 15852 | { |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15853 | D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' star_targets_list_seq? ']'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15854 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 15855 | if (_token == NULL) { |
| 15856 | D(p->level--); |
| 15857 | return NULL; |
| 15858 | } |
| 15859 | int _end_lineno = _token->end_lineno; |
| 15860 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 15861 | int _end_col_offset = _token->end_col_offset; |
| 15862 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 15863 | _res = _PyAST_List ( a , Store , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15864 | if (_res == NULL && PyErr_Occurred()) { |
| 15865 | p->error_indicator = 1; |
| 15866 | D(p->level--); |
| 15867 | return NULL; |
| 15868 | } |
| 15869 | goto done; |
| 15870 | } |
| 15871 | p->mark = _mark; |
| 15872 | D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 15873 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' star_targets_list_seq? ']'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 15874 | } |
| 15875 | _res = NULL; |
| 15876 | done: |
| 15877 | D(p->level--); |
| 15878 | return _res; |
| 15879 | } |
| 15880 | |
| 15881 | // single_target: single_subscript_attribute_target | NAME | '(' single_target ')' |
| 15882 | static expr_ty |
| 15883 | single_target_rule(Parser *p) |
| 15884 | { |
| 15885 | D(p->level++); |
| 15886 | if (p->error_indicator) { |
| 15887 | D(p->level--); |
| 15888 | return NULL; |
| 15889 | } |
| 15890 | expr_ty _res = NULL; |
| 15891 | int _mark = p->mark; |
| 15892 | { // single_subscript_attribute_target |
| 15893 | if (p->error_indicator) { |
| 15894 | D(p->level--); |
| 15895 | return NULL; |
| 15896 | } |
| 15897 | D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); |
| 15898 | expr_ty single_subscript_attribute_target_var; |
| 15899 | if ( |
| 15900 | (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target |
| 15901 | ) |
| 15902 | { |
| 15903 | D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); |
| 15904 | _res = single_subscript_attribute_target_var; |
| 15905 | goto done; |
| 15906 | } |
| 15907 | p->mark = _mark; |
| 15908 | D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 15909 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_subscript_attribute_target")); |
| 15910 | } |
| 15911 | { // NAME |
| 15912 | if (p->error_indicator) { |
| 15913 | D(p->level--); |
| 15914 | return NULL; |
| 15915 | } |
| 15916 | D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); |
| 15917 | expr_ty a; |
| 15918 | if ( |
| 15919 | (a = _PyPegen_name_token(p)) // NAME |
| 15920 | ) |
| 15921 | { |
| 15922 | D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); |
| 15923 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 15924 | if (_res == NULL && PyErr_Occurred()) { |
| 15925 | p->error_indicator = 1; |
| 15926 | D(p->level--); |
| 15927 | return NULL; |
| 15928 | } |
| 15929 | goto done; |
| 15930 | } |
| 15931 | p->mark = _mark; |
| 15932 | D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 15933 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); |
| 15934 | } |
| 15935 | { // '(' single_target ')' |
| 15936 | if (p->error_indicator) { |
| 15937 | D(p->level--); |
| 15938 | return NULL; |
| 15939 | } |
| 15940 | D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); |
| 15941 | Token * _literal; |
| 15942 | Token * _literal_1; |
| 15943 | expr_ty a; |
| 15944 | if ( |
| 15945 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 15946 | && |
| 15947 | (a = single_target_rule(p)) // single_target |
| 15948 | && |
| 15949 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 15950 | ) |
| 15951 | { |
| 15952 | D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); |
| 15953 | _res = a; |
| 15954 | if (_res == NULL && PyErr_Occurred()) { |
| 15955 | p->error_indicator = 1; |
| 15956 | D(p->level--); |
| 15957 | return NULL; |
| 15958 | } |
| 15959 | goto done; |
| 15960 | } |
| 15961 | p->mark = _mark; |
| 15962 | D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 15963 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'")); |
| 15964 | } |
| 15965 | _res = NULL; |
| 15966 | done: |
| 15967 | D(p->level--); |
| 15968 | return _res; |
| 15969 | } |
| 15970 | |
| 15971 | // single_subscript_attribute_target: |
| 15972 | // | t_primary '.' NAME !t_lookahead |
| 15973 | // | t_primary '[' slices ']' !t_lookahead |
| 15974 | static expr_ty |
| 15975 | single_subscript_attribute_target_rule(Parser *p) |
| 15976 | { |
| 15977 | D(p->level++); |
| 15978 | if (p->error_indicator) { |
| 15979 | D(p->level--); |
| 15980 | return NULL; |
| 15981 | } |
| 15982 | expr_ty _res = NULL; |
| 15983 | int _mark = p->mark; |
| 15984 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 15985 | p->error_indicator = 1; |
| 15986 | D(p->level--); |
| 15987 | return NULL; |
| 15988 | } |
| 15989 | int _start_lineno = p->tokens[_mark]->lineno; |
| 15990 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 15991 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 15992 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 15993 | { // t_primary '.' NAME !t_lookahead |
| 15994 | if (p->error_indicator) { |
| 15995 | D(p->level--); |
| 15996 | return NULL; |
| 15997 | } |
| 15998 | D(fprintf(stderr, "%*c> single_subscript_attribute_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
| 15999 | Token * _literal; |
| 16000 | expr_ty a; |
| 16001 | expr_ty b; |
| 16002 | if ( |
| 16003 | (a = t_primary_rule(p)) // t_primary |
| 16004 | && |
| 16005 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 16006 | && |
| 16007 | (b = _PyPegen_name_token(p)) // NAME |
| 16008 | && |
| 16009 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 16010 | ) |
| 16011 | { |
| 16012 | D(fprintf(stderr, "%*c+ single_subscript_attribute_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
| 16013 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 16014 | if (_token == NULL) { |
| 16015 | D(p->level--); |
| 16016 | return NULL; |
| 16017 | } |
| 16018 | int _end_lineno = _token->end_lineno; |
| 16019 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 16020 | int _end_col_offset = _token->end_col_offset; |
| 16021 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 16022 | _res = _PyAST_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16023 | if (_res == NULL && PyErr_Occurred()) { |
| 16024 | p->error_indicator = 1; |
| 16025 | D(p->level--); |
| 16026 | return NULL; |
| 16027 | } |
| 16028 | goto done; |
| 16029 | } |
| 16030 | p->mark = _mark; |
| 16031 | D(fprintf(stderr, "%*c%s single_subscript_attribute_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 16032 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
| 16033 | } |
| 16034 | { // t_primary '[' slices ']' !t_lookahead |
| 16035 | if (p->error_indicator) { |
| 16036 | D(p->level--); |
| 16037 | return NULL; |
| 16038 | } |
| 16039 | D(fprintf(stderr, "%*c> single_subscript_attribute_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
| 16040 | Token * _literal; |
| 16041 | Token * _literal_1; |
| 16042 | expr_ty a; |
| 16043 | expr_ty b; |
| 16044 | if ( |
| 16045 | (a = t_primary_rule(p)) // t_primary |
| 16046 | && |
| 16047 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 16048 | && |
| 16049 | (b = slices_rule(p)) // slices |
| 16050 | && |
| 16051 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
| 16052 | && |
| 16053 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 16054 | ) |
| 16055 | { |
| 16056 | D(fprintf(stderr, "%*c+ single_subscript_attribute_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
| 16057 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 16058 | if (_token == NULL) { |
| 16059 | D(p->level--); |
| 16060 | return NULL; |
| 16061 | } |
| 16062 | int _end_lineno = _token->end_lineno; |
| 16063 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 16064 | int _end_col_offset = _token->end_col_offset; |
| 16065 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 16066 | _res = _PyAST_Subscript ( a , b , Store , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16067 | if (_res == NULL && PyErr_Occurred()) { |
| 16068 | p->error_indicator = 1; |
| 16069 | D(p->level--); |
| 16070 | return NULL; |
| 16071 | } |
| 16072 | goto done; |
| 16073 | } |
| 16074 | p->mark = _mark; |
| 16075 | D(fprintf(stderr, "%*c%s single_subscript_attribute_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 16076 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
| 16077 | } |
| 16078 | _res = NULL; |
| 16079 | done: |
| 16080 | D(p->level--); |
| 16081 | return _res; |
| 16082 | } |
| 16083 | |
| 16084 | // del_targets: ','.del_target+ ','? |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 16085 | static asdl_expr_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16086 | del_targets_rule(Parser *p) |
| 16087 | { |
| 16088 | D(p->level++); |
| 16089 | if (p->error_indicator) { |
| 16090 | D(p->level--); |
| 16091 | return NULL; |
| 16092 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 16093 | asdl_expr_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16094 | int _mark = p->mark; |
| 16095 | { // ','.del_target+ ','? |
| 16096 | if (p->error_indicator) { |
| 16097 | D(p->level--); |
| 16098 | return NULL; |
| 16099 | } |
| 16100 | D(fprintf(stderr, "%*c> del_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?")); |
| 16101 | void *_opt_var; |
| 16102 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 16103 | asdl_expr_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16104 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 16105 | (a = (asdl_expr_seq*)_gather_138_rule(p)) // ','.del_target+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16106 | && |
| 16107 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 16108 | ) |
| 16109 | { |
| 16110 | D(fprintf(stderr, "%*c+ del_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?")); |
| 16111 | _res = a; |
| 16112 | if (_res == NULL && PyErr_Occurred()) { |
| 16113 | p->error_indicator = 1; |
| 16114 | D(p->level--); |
| 16115 | return NULL; |
| 16116 | } |
| 16117 | goto done; |
| 16118 | } |
| 16119 | p->mark = _mark; |
| 16120 | D(fprintf(stderr, "%*c%s del_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 16121 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.del_target+ ','?")); |
| 16122 | } |
| 16123 | _res = NULL; |
| 16124 | done: |
| 16125 | D(p->level--); |
| 16126 | return _res; |
| 16127 | } |
| 16128 | |
| 16129 | // del_target: |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16130 | // | t_primary '.' NAME !t_lookahead |
| 16131 | // | t_primary '[' slices ']' !t_lookahead |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16132 | // | del_t_atom |
| 16133 | static expr_ty |
| 16134 | del_target_rule(Parser *p) |
| 16135 | { |
| 16136 | D(p->level++); |
| 16137 | if (p->error_indicator) { |
| 16138 | D(p->level--); |
| 16139 | return NULL; |
| 16140 | } |
| 16141 | expr_ty _res = NULL; |
| 16142 | if (_PyPegen_is_memoized(p, del_target_type, &_res)) { |
| 16143 | D(p->level--); |
| 16144 | return _res; |
| 16145 | } |
| 16146 | int _mark = p->mark; |
| 16147 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 16148 | p->error_indicator = 1; |
| 16149 | D(p->level--); |
| 16150 | return NULL; |
| 16151 | } |
| 16152 | int _start_lineno = p->tokens[_mark]->lineno; |
| 16153 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 16154 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 16155 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16156 | { // t_primary '.' NAME !t_lookahead |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16157 | if (p->error_indicator) { |
| 16158 | D(p->level--); |
| 16159 | return NULL; |
| 16160 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16161 | D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16162 | Token * _literal; |
| 16163 | expr_ty a; |
| 16164 | expr_ty b; |
| 16165 | if ( |
| 16166 | (a = t_primary_rule(p)) // t_primary |
| 16167 | && |
| 16168 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 16169 | && |
| 16170 | (b = _PyPegen_name_token(p)) // NAME |
| 16171 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16172 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16173 | ) |
| 16174 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16175 | D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16176 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 16177 | if (_token == NULL) { |
| 16178 | D(p->level--); |
| 16179 | return NULL; |
| 16180 | } |
| 16181 | int _end_lineno = _token->end_lineno; |
| 16182 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 16183 | int _end_col_offset = _token->end_col_offset; |
| 16184 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 16185 | _res = _PyAST_Attribute ( a , b -> v . Name . id , Del , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16186 | if (_res == NULL && PyErr_Occurred()) { |
| 16187 | p->error_indicator = 1; |
| 16188 | D(p->level--); |
| 16189 | return NULL; |
| 16190 | } |
| 16191 | goto done; |
| 16192 | } |
| 16193 | p->mark = _mark; |
| 16194 | D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16195 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16196 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16197 | { // t_primary '[' slices ']' !t_lookahead |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16198 | if (p->error_indicator) { |
| 16199 | D(p->level--); |
| 16200 | return NULL; |
| 16201 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16202 | D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16203 | Token * _literal; |
| 16204 | Token * _literal_1; |
| 16205 | expr_ty a; |
| 16206 | expr_ty b; |
| 16207 | if ( |
| 16208 | (a = t_primary_rule(p)) // t_primary |
| 16209 | && |
| 16210 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 16211 | && |
| 16212 | (b = slices_rule(p)) // slices |
| 16213 | && |
| 16214 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
| 16215 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16216 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16217 | ) |
| 16218 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16219 | D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16220 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 16221 | if (_token == NULL) { |
| 16222 | D(p->level--); |
| 16223 | return NULL; |
| 16224 | } |
| 16225 | int _end_lineno = _token->end_lineno; |
| 16226 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 16227 | int _end_col_offset = _token->end_col_offset; |
| 16228 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 16229 | _res = _PyAST_Subscript ( a , b , Del , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16230 | if (_res == NULL && PyErr_Occurred()) { |
| 16231 | p->error_indicator = 1; |
| 16232 | D(p->level--); |
| 16233 | return NULL; |
| 16234 | } |
| 16235 | goto done; |
| 16236 | } |
| 16237 | p->mark = _mark; |
| 16238 | D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16239 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16240 | } |
| 16241 | { // del_t_atom |
| 16242 | if (p->error_indicator) { |
| 16243 | D(p->level--); |
| 16244 | return NULL; |
| 16245 | } |
| 16246 | D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_t_atom")); |
| 16247 | expr_ty del_t_atom_var; |
| 16248 | if ( |
| 16249 | (del_t_atom_var = del_t_atom_rule(p)) // del_t_atom |
| 16250 | ) |
| 16251 | { |
| 16252 | D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_t_atom")); |
| 16253 | _res = del_t_atom_var; |
| 16254 | goto done; |
| 16255 | } |
| 16256 | p->mark = _mark; |
| 16257 | D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 16258 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_t_atom")); |
| 16259 | } |
| 16260 | _res = NULL; |
| 16261 | done: |
| 16262 | _PyPegen_insert_memo(p, _mark, del_target_type, _res); |
| 16263 | D(p->level--); |
| 16264 | return _res; |
| 16265 | } |
| 16266 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16267 | // del_t_atom: NAME | '(' del_target ')' | '(' del_targets? ')' | '[' del_targets? ']' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16268 | static expr_ty |
| 16269 | del_t_atom_rule(Parser *p) |
| 16270 | { |
| 16271 | D(p->level++); |
| 16272 | if (p->error_indicator) { |
| 16273 | D(p->level--); |
| 16274 | return NULL; |
| 16275 | } |
| 16276 | expr_ty _res = NULL; |
| 16277 | int _mark = p->mark; |
| 16278 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 16279 | p->error_indicator = 1; |
| 16280 | D(p->level--); |
| 16281 | return NULL; |
| 16282 | } |
| 16283 | int _start_lineno = p->tokens[_mark]->lineno; |
| 16284 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 16285 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 16286 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16287 | { // NAME |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16288 | if (p->error_indicator) { |
| 16289 | D(p->level--); |
| 16290 | return NULL; |
| 16291 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16292 | D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16293 | expr_ty a; |
| 16294 | if ( |
| 16295 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16296 | ) |
| 16297 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16298 | D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16299 | _res = _PyPegen_set_expr_context ( p , a , Del ); |
| 16300 | if (_res == NULL && PyErr_Occurred()) { |
| 16301 | p->error_indicator = 1; |
| 16302 | D(p->level--); |
| 16303 | return NULL; |
| 16304 | } |
| 16305 | goto done; |
| 16306 | } |
| 16307 | p->mark = _mark; |
| 16308 | D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 16309 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16310 | } |
| 16311 | { // '(' del_target ')' |
| 16312 | if (p->error_indicator) { |
| 16313 | D(p->level--); |
| 16314 | return NULL; |
| 16315 | } |
| 16316 | D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' del_target ')'")); |
| 16317 | Token * _literal; |
| 16318 | Token * _literal_1; |
| 16319 | expr_ty a; |
| 16320 | if ( |
| 16321 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 16322 | && |
| 16323 | (a = del_target_rule(p)) // del_target |
| 16324 | && |
| 16325 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 16326 | ) |
| 16327 | { |
| 16328 | D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' del_target ')'")); |
| 16329 | _res = _PyPegen_set_expr_context ( p , a , Del ); |
| 16330 | if (_res == NULL && PyErr_Occurred()) { |
| 16331 | p->error_indicator = 1; |
| 16332 | D(p->level--); |
| 16333 | return NULL; |
| 16334 | } |
| 16335 | goto done; |
| 16336 | } |
| 16337 | p->mark = _mark; |
| 16338 | D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 16339 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' del_target ')'")); |
| 16340 | } |
| 16341 | { // '(' del_targets? ')' |
| 16342 | if (p->error_indicator) { |
| 16343 | D(p->level--); |
| 16344 | return NULL; |
| 16345 | } |
| 16346 | D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' del_targets? ')'")); |
| 16347 | Token * _literal; |
| 16348 | Token * _literal_1; |
| 16349 | void *a; |
| 16350 | if ( |
| 16351 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 16352 | && |
| 16353 | (a = del_targets_rule(p), 1) // del_targets? |
| 16354 | && |
| 16355 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 16356 | ) |
| 16357 | { |
| 16358 | D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' del_targets? ')'")); |
| 16359 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 16360 | if (_token == NULL) { |
| 16361 | D(p->level--); |
| 16362 | return NULL; |
| 16363 | } |
| 16364 | int _end_lineno = _token->end_lineno; |
| 16365 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 16366 | int _end_col_offset = _token->end_col_offset; |
| 16367 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 16368 | _res = _PyAST_Tuple ( a , Del , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16369 | if (_res == NULL && PyErr_Occurred()) { |
| 16370 | p->error_indicator = 1; |
| 16371 | D(p->level--); |
| 16372 | return NULL; |
| 16373 | } |
| 16374 | goto done; |
| 16375 | } |
| 16376 | p->mark = _mark; |
| 16377 | D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 16378 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' del_targets? ')'")); |
| 16379 | } |
| 16380 | { // '[' del_targets? ']' |
| 16381 | if (p->error_indicator) { |
| 16382 | D(p->level--); |
| 16383 | return NULL; |
| 16384 | } |
| 16385 | D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' del_targets? ']'")); |
| 16386 | Token * _literal; |
| 16387 | Token * _literal_1; |
| 16388 | void *a; |
| 16389 | if ( |
| 16390 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 16391 | && |
| 16392 | (a = del_targets_rule(p), 1) // del_targets? |
| 16393 | && |
| 16394 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
| 16395 | ) |
| 16396 | { |
| 16397 | D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' del_targets? ']'")); |
| 16398 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 16399 | if (_token == NULL) { |
| 16400 | D(p->level--); |
| 16401 | return NULL; |
| 16402 | } |
| 16403 | int _end_lineno = _token->end_lineno; |
| 16404 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 16405 | int _end_col_offset = _token->end_col_offset; |
| 16406 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 16407 | _res = _PyAST_List ( a , Del , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16408 | if (_res == NULL && PyErr_Occurred()) { |
| 16409 | p->error_indicator = 1; |
| 16410 | D(p->level--); |
| 16411 | return NULL; |
| 16412 | } |
| 16413 | goto done; |
| 16414 | } |
| 16415 | p->mark = _mark; |
| 16416 | D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 16417 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' del_targets? ']'")); |
| 16418 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16419 | _res = NULL; |
| 16420 | done: |
| 16421 | D(p->level--); |
| 16422 | return _res; |
| 16423 | } |
| 16424 | |
| 16425 | // targets: ','.target+ ','? |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 16426 | static asdl_expr_seq* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16427 | targets_rule(Parser *p) |
| 16428 | { |
| 16429 | D(p->level++); |
| 16430 | if (p->error_indicator) { |
| 16431 | D(p->level--); |
| 16432 | return NULL; |
| 16433 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 16434 | asdl_expr_seq* _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16435 | int _mark = p->mark; |
| 16436 | { // ','.target+ ','? |
| 16437 | if (p->error_indicator) { |
| 16438 | D(p->level--); |
| 16439 | return NULL; |
| 16440 | } |
| 16441 | D(fprintf(stderr, "%*c> targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.target+ ','?")); |
| 16442 | void *_opt_var; |
| 16443 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 16444 | asdl_expr_seq* a; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16445 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 16446 | (a = (asdl_expr_seq*)_gather_140_rule(p)) // ','.target+ |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16447 | && |
| 16448 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
| 16449 | ) |
| 16450 | { |
| 16451 | D(fprintf(stderr, "%*c+ targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.target+ ','?")); |
| 16452 | _res = a; |
| 16453 | if (_res == NULL && PyErr_Occurred()) { |
| 16454 | p->error_indicator = 1; |
| 16455 | D(p->level--); |
| 16456 | return NULL; |
| 16457 | } |
| 16458 | goto done; |
| 16459 | } |
| 16460 | p->mark = _mark; |
| 16461 | D(fprintf(stderr, "%*c%s targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 16462 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.target+ ','?")); |
| 16463 | } |
| 16464 | _res = NULL; |
| 16465 | done: |
| 16466 | D(p->level--); |
| 16467 | return _res; |
| 16468 | } |
| 16469 | |
| 16470 | // target: |
| 16471 | // | t_primary '.' NAME !t_lookahead |
| 16472 | // | t_primary '[' slices ']' !t_lookahead |
| 16473 | // | t_atom |
| 16474 | static expr_ty |
| 16475 | target_rule(Parser *p) |
| 16476 | { |
| 16477 | D(p->level++); |
| 16478 | if (p->error_indicator) { |
| 16479 | D(p->level--); |
| 16480 | return NULL; |
| 16481 | } |
| 16482 | expr_ty _res = NULL; |
| 16483 | if (_PyPegen_is_memoized(p, target_type, &_res)) { |
| 16484 | D(p->level--); |
| 16485 | return _res; |
| 16486 | } |
| 16487 | int _mark = p->mark; |
| 16488 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 16489 | p->error_indicator = 1; |
| 16490 | D(p->level--); |
| 16491 | return NULL; |
| 16492 | } |
| 16493 | int _start_lineno = p->tokens[_mark]->lineno; |
| 16494 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 16495 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 16496 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 16497 | { // t_primary '.' NAME !t_lookahead |
| 16498 | if (p->error_indicator) { |
| 16499 | D(p->level--); |
| 16500 | return NULL; |
| 16501 | } |
| 16502 | D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
| 16503 | Token * _literal; |
| 16504 | expr_ty a; |
| 16505 | expr_ty b; |
| 16506 | if ( |
| 16507 | (a = t_primary_rule(p)) // t_primary |
| 16508 | && |
| 16509 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 16510 | && |
| 16511 | (b = _PyPegen_name_token(p)) // NAME |
| 16512 | && |
| 16513 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 16514 | ) |
| 16515 | { |
| 16516 | D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
| 16517 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 16518 | if (_token == NULL) { |
| 16519 | D(p->level--); |
| 16520 | return NULL; |
| 16521 | } |
| 16522 | int _end_lineno = _token->end_lineno; |
| 16523 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 16524 | int _end_col_offset = _token->end_col_offset; |
| 16525 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 16526 | _res = _PyAST_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16527 | if (_res == NULL && PyErr_Occurred()) { |
| 16528 | p->error_indicator = 1; |
| 16529 | D(p->level--); |
| 16530 | return NULL; |
| 16531 | } |
| 16532 | goto done; |
| 16533 | } |
| 16534 | p->mark = _mark; |
| 16535 | D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ', |
| 16536 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
| 16537 | } |
| 16538 | { // t_primary '[' slices ']' !t_lookahead |
| 16539 | if (p->error_indicator) { |
| 16540 | D(p->level--); |
| 16541 | return NULL; |
| 16542 | } |
| 16543 | D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
| 16544 | Token * _literal; |
| 16545 | Token * _literal_1; |
| 16546 | expr_ty a; |
| 16547 | expr_ty b; |
| 16548 | if ( |
| 16549 | (a = t_primary_rule(p)) // t_primary |
| 16550 | && |
| 16551 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 16552 | && |
| 16553 | (b = slices_rule(p)) // slices |
| 16554 | && |
| 16555 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
| 16556 | && |
| 16557 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 16558 | ) |
| 16559 | { |
| 16560 | D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
| 16561 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 16562 | if (_token == NULL) { |
| 16563 | D(p->level--); |
| 16564 | return NULL; |
| 16565 | } |
| 16566 | int _end_lineno = _token->end_lineno; |
| 16567 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 16568 | int _end_col_offset = _token->end_col_offset; |
| 16569 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 16570 | _res = _PyAST_Subscript ( a , b , Store , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16571 | if (_res == NULL && PyErr_Occurred()) { |
| 16572 | p->error_indicator = 1; |
| 16573 | D(p->level--); |
| 16574 | return NULL; |
| 16575 | } |
| 16576 | goto done; |
| 16577 | } |
| 16578 | p->mark = _mark; |
| 16579 | D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ', |
| 16580 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
| 16581 | } |
| 16582 | { // t_atom |
| 16583 | if (p->error_indicator) { |
| 16584 | D(p->level--); |
| 16585 | return NULL; |
| 16586 | } |
| 16587 | D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_atom")); |
| 16588 | expr_ty t_atom_var; |
| 16589 | if ( |
| 16590 | (t_atom_var = t_atom_rule(p)) // t_atom |
| 16591 | ) |
| 16592 | { |
| 16593 | D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_atom")); |
| 16594 | _res = t_atom_var; |
| 16595 | goto done; |
| 16596 | } |
| 16597 | p->mark = _mark; |
| 16598 | D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ', |
| 16599 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_atom")); |
| 16600 | } |
| 16601 | _res = NULL; |
| 16602 | done: |
| 16603 | _PyPegen_insert_memo(p, _mark, target_type, _res); |
| 16604 | D(p->level--); |
| 16605 | return _res; |
| 16606 | } |
| 16607 | |
| 16608 | // Left-recursive |
| 16609 | // t_primary: |
| 16610 | // | t_primary '.' NAME &t_lookahead |
| 16611 | // | t_primary '[' slices ']' &t_lookahead |
| 16612 | // | t_primary genexp &t_lookahead |
| 16613 | // | t_primary '(' arguments? ')' &t_lookahead |
| 16614 | // | atom &t_lookahead |
| 16615 | static expr_ty t_primary_raw(Parser *); |
| 16616 | static expr_ty |
| 16617 | t_primary_rule(Parser *p) |
| 16618 | { |
| 16619 | D(p->level++); |
| 16620 | expr_ty _res = NULL; |
| 16621 | if (_PyPegen_is_memoized(p, t_primary_type, &_res)) { |
| 16622 | D(p->level--); |
| 16623 | return _res; |
| 16624 | } |
| 16625 | int _mark = p->mark; |
| 16626 | int _resmark = p->mark; |
| 16627 | while (1) { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 16628 | int tmpvar_9 = _PyPegen_update_memo(p, _mark, t_primary_type, _res); |
| 16629 | if (tmpvar_9) { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16630 | D(p->level--); |
| 16631 | return _res; |
| 16632 | } |
| 16633 | p->mark = _mark; |
| 16634 | void *_raw = t_primary_raw(p); |
Lysandros Nikolaou | 02cdfc9 | 2020-10-31 20:31:41 +0200 | [diff] [blame] | 16635 | if (p->error_indicator) |
| 16636 | return NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16637 | if (_raw == NULL || p->mark <= _resmark) |
| 16638 | break; |
| 16639 | _resmark = p->mark; |
| 16640 | _res = _raw; |
| 16641 | } |
| 16642 | p->mark = _resmark; |
| 16643 | D(p->level--); |
| 16644 | return _res; |
| 16645 | } |
| 16646 | static expr_ty |
| 16647 | t_primary_raw(Parser *p) |
| 16648 | { |
| 16649 | D(p->level++); |
| 16650 | if (p->error_indicator) { |
| 16651 | D(p->level--); |
| 16652 | return NULL; |
| 16653 | } |
| 16654 | expr_ty _res = NULL; |
| 16655 | int _mark = p->mark; |
| 16656 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 16657 | p->error_indicator = 1; |
| 16658 | D(p->level--); |
| 16659 | return NULL; |
| 16660 | } |
| 16661 | int _start_lineno = p->tokens[_mark]->lineno; |
| 16662 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 16663 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 16664 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 16665 | { // t_primary '.' NAME &t_lookahead |
| 16666 | if (p->error_indicator) { |
| 16667 | D(p->level--); |
| 16668 | return NULL; |
| 16669 | } |
| 16670 | D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &t_lookahead")); |
| 16671 | Token * _literal; |
| 16672 | expr_ty a; |
| 16673 | expr_ty b; |
| 16674 | if ( |
| 16675 | (a = t_primary_rule(p)) // t_primary |
| 16676 | && |
| 16677 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 16678 | && |
| 16679 | (b = _PyPegen_name_token(p)) // NAME |
| 16680 | && |
| 16681 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 16682 | ) |
| 16683 | { |
| 16684 | D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &t_lookahead")); |
| 16685 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 16686 | if (_token == NULL) { |
| 16687 | D(p->level--); |
| 16688 | return NULL; |
| 16689 | } |
| 16690 | int _end_lineno = _token->end_lineno; |
| 16691 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 16692 | int _end_col_offset = _token->end_col_offset; |
| 16693 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 16694 | _res = _PyAST_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16695 | if (_res == NULL && PyErr_Occurred()) { |
| 16696 | p->error_indicator = 1; |
| 16697 | D(p->level--); |
| 16698 | return NULL; |
| 16699 | } |
| 16700 | goto done; |
| 16701 | } |
| 16702 | p->mark = _mark; |
| 16703 | D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 16704 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME &t_lookahead")); |
| 16705 | } |
| 16706 | { // t_primary '[' slices ']' &t_lookahead |
| 16707 | if (p->error_indicator) { |
| 16708 | D(p->level--); |
| 16709 | return NULL; |
| 16710 | } |
| 16711 | D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); |
| 16712 | Token * _literal; |
| 16713 | Token * _literal_1; |
| 16714 | expr_ty a; |
| 16715 | expr_ty b; |
| 16716 | if ( |
| 16717 | (a = t_primary_rule(p)) // t_primary |
| 16718 | && |
| 16719 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 16720 | && |
| 16721 | (b = slices_rule(p)) // slices |
| 16722 | && |
| 16723 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
| 16724 | && |
| 16725 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 16726 | ) |
| 16727 | { |
| 16728 | D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); |
| 16729 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 16730 | if (_token == NULL) { |
| 16731 | D(p->level--); |
| 16732 | return NULL; |
| 16733 | } |
| 16734 | int _end_lineno = _token->end_lineno; |
| 16735 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 16736 | int _end_col_offset = _token->end_col_offset; |
| 16737 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 16738 | _res = _PyAST_Subscript ( a , b , Load , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16739 | if (_res == NULL && PyErr_Occurred()) { |
| 16740 | p->error_indicator = 1; |
| 16741 | D(p->level--); |
| 16742 | return NULL; |
| 16743 | } |
| 16744 | goto done; |
| 16745 | } |
| 16746 | p->mark = _mark; |
| 16747 | D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 16748 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); |
| 16749 | } |
| 16750 | { // t_primary genexp &t_lookahead |
| 16751 | if (p->error_indicator) { |
| 16752 | D(p->level--); |
| 16753 | return NULL; |
| 16754 | } |
| 16755 | D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary genexp &t_lookahead")); |
| 16756 | expr_ty a; |
| 16757 | expr_ty b; |
| 16758 | if ( |
| 16759 | (a = t_primary_rule(p)) // t_primary |
| 16760 | && |
| 16761 | (b = genexp_rule(p)) // genexp |
| 16762 | && |
| 16763 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 16764 | ) |
| 16765 | { |
| 16766 | D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary genexp &t_lookahead")); |
| 16767 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 16768 | if (_token == NULL) { |
| 16769 | D(p->level--); |
| 16770 | return NULL; |
| 16771 | } |
| 16772 | int _end_lineno = _token->end_lineno; |
| 16773 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 16774 | int _end_col_offset = _token->end_col_offset; |
| 16775 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 16776 | _res = _PyAST_Call ( a , CHECK ( asdl_expr_seq * , ( asdl_expr_seq * ) _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16777 | if (_res == NULL && PyErr_Occurred()) { |
| 16778 | p->error_indicator = 1; |
| 16779 | D(p->level--); |
| 16780 | return NULL; |
| 16781 | } |
| 16782 | goto done; |
| 16783 | } |
| 16784 | p->mark = _mark; |
| 16785 | D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 16786 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary genexp &t_lookahead")); |
| 16787 | } |
| 16788 | { // t_primary '(' arguments? ')' &t_lookahead |
| 16789 | if (p->error_indicator) { |
| 16790 | D(p->level--); |
| 16791 | return NULL; |
| 16792 | } |
| 16793 | D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); |
| 16794 | Token * _literal; |
| 16795 | Token * _literal_1; |
| 16796 | expr_ty a; |
| 16797 | void *b; |
| 16798 | if ( |
| 16799 | (a = t_primary_rule(p)) // t_primary |
| 16800 | && |
| 16801 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 16802 | && |
| 16803 | (b = arguments_rule(p), 1) // arguments? |
| 16804 | && |
| 16805 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 16806 | && |
| 16807 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 16808 | ) |
| 16809 | { |
| 16810 | D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); |
| 16811 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 16812 | if (_token == NULL) { |
| 16813 | D(p->level--); |
| 16814 | return NULL; |
| 16815 | } |
| 16816 | int _end_lineno = _token->end_lineno; |
| 16817 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 16818 | int _end_col_offset = _token->end_col_offset; |
| 16819 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 16820 | _res = _PyAST_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 16821 | if (_res == NULL && PyErr_Occurred()) { |
| 16822 | p->error_indicator = 1; |
| 16823 | D(p->level--); |
| 16824 | return NULL; |
| 16825 | } |
| 16826 | goto done; |
| 16827 | } |
| 16828 | p->mark = _mark; |
| 16829 | D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 16830 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); |
| 16831 | } |
| 16832 | { // atom &t_lookahead |
| 16833 | if (p->error_indicator) { |
| 16834 | D(p->level--); |
| 16835 | return NULL; |
| 16836 | } |
| 16837 | D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "atom &t_lookahead")); |
| 16838 | expr_ty a; |
| 16839 | if ( |
| 16840 | (a = atom_rule(p)) // atom |
| 16841 | && |
| 16842 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 16843 | ) |
| 16844 | { |
| 16845 | D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "atom &t_lookahead")); |
| 16846 | _res = a; |
| 16847 | if (_res == NULL && PyErr_Occurred()) { |
| 16848 | p->error_indicator = 1; |
| 16849 | D(p->level--); |
| 16850 | return NULL; |
| 16851 | } |
| 16852 | goto done; |
| 16853 | } |
| 16854 | p->mark = _mark; |
| 16855 | D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 16856 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "atom &t_lookahead")); |
| 16857 | } |
| 16858 | _res = NULL; |
| 16859 | done: |
| 16860 | D(p->level--); |
| 16861 | return _res; |
| 16862 | } |
| 16863 | |
| 16864 | // t_lookahead: '(' | '[' | '.' |
| 16865 | static void * |
| 16866 | t_lookahead_rule(Parser *p) |
| 16867 | { |
| 16868 | D(p->level++); |
| 16869 | if (p->error_indicator) { |
| 16870 | D(p->level--); |
| 16871 | return NULL; |
| 16872 | } |
| 16873 | void * _res = NULL; |
| 16874 | int _mark = p->mark; |
| 16875 | { // '(' |
| 16876 | if (p->error_indicator) { |
| 16877 | D(p->level--); |
| 16878 | return NULL; |
| 16879 | } |
| 16880 | D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); |
| 16881 | Token * _literal; |
| 16882 | if ( |
| 16883 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 16884 | ) |
| 16885 | { |
| 16886 | D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); |
| 16887 | _res = _literal; |
| 16888 | goto done; |
| 16889 | } |
| 16890 | p->mark = _mark; |
| 16891 | D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ', |
| 16892 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); |
| 16893 | } |
| 16894 | { // '[' |
| 16895 | if (p->error_indicator) { |
| 16896 | D(p->level--); |
| 16897 | return NULL; |
| 16898 | } |
| 16899 | D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); |
| 16900 | Token * _literal; |
| 16901 | if ( |
| 16902 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 16903 | ) |
| 16904 | { |
| 16905 | D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); |
| 16906 | _res = _literal; |
| 16907 | goto done; |
| 16908 | } |
| 16909 | p->mark = _mark; |
| 16910 | D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ', |
| 16911 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); |
| 16912 | } |
| 16913 | { // '.' |
| 16914 | if (p->error_indicator) { |
| 16915 | D(p->level--); |
| 16916 | return NULL; |
| 16917 | } |
| 16918 | D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); |
| 16919 | Token * _literal; |
| 16920 | if ( |
| 16921 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 16922 | ) |
| 16923 | { |
| 16924 | D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); |
| 16925 | _res = _literal; |
| 16926 | goto done; |
| 16927 | } |
| 16928 | p->mark = _mark; |
| 16929 | D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ', |
| 16930 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); |
| 16931 | } |
| 16932 | _res = NULL; |
| 16933 | done: |
| 16934 | D(p->level--); |
| 16935 | return _res; |
| 16936 | } |
| 16937 | |
| 16938 | // t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']' |
| 16939 | static expr_ty |
| 16940 | t_atom_rule(Parser *p) |
| 16941 | { |
| 16942 | D(p->level++); |
| 16943 | if (p->error_indicator) { |
| 16944 | D(p->level--); |
| 16945 | return NULL; |
| 16946 | } |
| 16947 | expr_ty _res = NULL; |
| 16948 | int _mark = p->mark; |
| 16949 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 16950 | p->error_indicator = 1; |
| 16951 | D(p->level--); |
| 16952 | return NULL; |
| 16953 | } |
| 16954 | int _start_lineno = p->tokens[_mark]->lineno; |
| 16955 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 16956 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 16957 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
| 16958 | { // NAME |
| 16959 | if (p->error_indicator) { |
| 16960 | D(p->level--); |
| 16961 | return NULL; |
| 16962 | } |
| 16963 | D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); |
| 16964 | expr_ty a; |
| 16965 | if ( |
| 16966 | (a = _PyPegen_name_token(p)) // NAME |
| 16967 | ) |
| 16968 | { |
| 16969 | D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); |
| 16970 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 16971 | if (_res == NULL && PyErr_Occurred()) { |
| 16972 | p->error_indicator = 1; |
| 16973 | D(p->level--); |
| 16974 | return NULL; |
| 16975 | } |
| 16976 | goto done; |
| 16977 | } |
| 16978 | p->mark = _mark; |
| 16979 | D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 16980 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); |
| 16981 | } |
| 16982 | { // '(' target ')' |
| 16983 | if (p->error_indicator) { |
| 16984 | D(p->level--); |
| 16985 | return NULL; |
| 16986 | } |
| 16987 | D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' target ')'")); |
| 16988 | Token * _literal; |
| 16989 | Token * _literal_1; |
| 16990 | expr_ty a; |
| 16991 | if ( |
| 16992 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 16993 | && |
| 16994 | (a = target_rule(p)) // target |
| 16995 | && |
| 16996 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 16997 | ) |
| 16998 | { |
| 16999 | D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' target ')'")); |
| 17000 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 17001 | if (_res == NULL && PyErr_Occurred()) { |
| 17002 | p->error_indicator = 1; |
| 17003 | D(p->level--); |
| 17004 | return NULL; |
| 17005 | } |
| 17006 | goto done; |
| 17007 | } |
| 17008 | p->mark = _mark; |
| 17009 | D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 17010 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' target ')'")); |
| 17011 | } |
| 17012 | { // '(' targets? ')' |
| 17013 | if (p->error_indicator) { |
| 17014 | D(p->level--); |
| 17015 | return NULL; |
| 17016 | } |
| 17017 | D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' targets? ')'")); |
| 17018 | Token * _literal; |
| 17019 | Token * _literal_1; |
| 17020 | void *b; |
| 17021 | if ( |
| 17022 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 17023 | && |
| 17024 | (b = targets_rule(p), 1) // targets? |
| 17025 | && |
| 17026 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 17027 | ) |
| 17028 | { |
| 17029 | D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' targets? ')'")); |
| 17030 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 17031 | if (_token == NULL) { |
| 17032 | D(p->level--); |
| 17033 | return NULL; |
| 17034 | } |
| 17035 | int _end_lineno = _token->end_lineno; |
| 17036 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 17037 | int _end_col_offset = _token->end_col_offset; |
| 17038 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 17039 | _res = _PyAST_Tuple ( b , Store , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17040 | if (_res == NULL && PyErr_Occurred()) { |
| 17041 | p->error_indicator = 1; |
| 17042 | D(p->level--); |
| 17043 | return NULL; |
| 17044 | } |
| 17045 | goto done; |
| 17046 | } |
| 17047 | p->mark = _mark; |
| 17048 | D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 17049 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' targets? ')'")); |
| 17050 | } |
| 17051 | { // '[' targets? ']' |
| 17052 | if (p->error_indicator) { |
| 17053 | D(p->level--); |
| 17054 | return NULL; |
| 17055 | } |
| 17056 | D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' targets? ']'")); |
| 17057 | Token * _literal; |
| 17058 | Token * _literal_1; |
| 17059 | void *b; |
| 17060 | if ( |
| 17061 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 17062 | && |
| 17063 | (b = targets_rule(p), 1) // targets? |
| 17064 | && |
| 17065 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
| 17066 | ) |
| 17067 | { |
| 17068 | D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' targets? ']'")); |
| 17069 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 17070 | if (_token == NULL) { |
| 17071 | D(p->level--); |
| 17072 | return NULL; |
| 17073 | } |
| 17074 | int _end_lineno = _token->end_lineno; |
| 17075 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 17076 | int _end_col_offset = _token->end_col_offset; |
| 17077 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
Victor Stinner | d27f8d2 | 2021-04-07 21:34:22 +0200 | [diff] [blame] | 17078 | _res = _PyAST_List ( b , Store , EXTRA ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17079 | if (_res == NULL && PyErr_Occurred()) { |
| 17080 | p->error_indicator = 1; |
| 17081 | D(p->level--); |
| 17082 | return NULL; |
| 17083 | } |
| 17084 | goto done; |
| 17085 | } |
| 17086 | p->mark = _mark; |
| 17087 | D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 17088 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' targets? ']'")); |
| 17089 | } |
| 17090 | _res = NULL; |
| 17091 | done: |
| 17092 | D(p->level--); |
| 17093 | return _res; |
| 17094 | } |
| 17095 | |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17096 | // invalid_arguments: |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17097 | // | args ',' '*' |
| 17098 | // | expression for_if_clauses ',' [args | expression for_if_clauses] |
| 17099 | // | args for_if_clauses |
| 17100 | // | args ',' expression for_if_clauses |
| 17101 | // | args ',' args |
| 17102 | static void * |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17103 | invalid_arguments_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17104 | { |
| 17105 | D(p->level++); |
| 17106 | if (p->error_indicator) { |
| 17107 | D(p->level--); |
| 17108 | return NULL; |
| 17109 | } |
| 17110 | void * _res = NULL; |
| 17111 | int _mark = p->mark; |
| 17112 | { // args ',' '*' |
| 17113 | if (p->error_indicator) { |
| 17114 | D(p->level--); |
| 17115 | return NULL; |
| 17116 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17117 | D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' '*'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17118 | Token * _literal; |
| 17119 | Token * _literal_1; |
| 17120 | expr_ty args_var; |
| 17121 | if ( |
| 17122 | (args_var = args_rule(p)) // args |
| 17123 | && |
| 17124 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 17125 | && |
| 17126 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
| 17127 | ) |
| 17128 | { |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17129 | D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' '*'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17130 | _res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" ); |
| 17131 | if (_res == NULL && PyErr_Occurred()) { |
| 17132 | p->error_indicator = 1; |
| 17133 | D(p->level--); |
| 17134 | return NULL; |
| 17135 | } |
| 17136 | goto done; |
| 17137 | } |
| 17138 | p->mark = _mark; |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17139 | D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17140 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' '*'")); |
| 17141 | } |
| 17142 | { // expression for_if_clauses ',' [args | expression for_if_clauses] |
| 17143 | if (p->error_indicator) { |
| 17144 | D(p->level--); |
| 17145 | return NULL; |
| 17146 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17147 | D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17148 | Token * _literal; |
| 17149 | void *_opt_var; |
| 17150 | UNUSED(_opt_var); // Silence compiler warnings |
| 17151 | expr_ty a; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 17152 | asdl_comprehension_seq* for_if_clauses_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17153 | if ( |
| 17154 | (a = expression_rule(p)) // expression |
| 17155 | && |
| 17156 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
| 17157 | && |
| 17158 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 17159 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 17160 | (_opt_var = _tmp_142_rule(p), 1) // [args | expression for_if_clauses] |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17161 | ) |
| 17162 | { |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17163 | D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17164 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "Generator expression must be parenthesized" ); |
| 17165 | if (_res == NULL && PyErr_Occurred()) { |
| 17166 | p->error_indicator = 1; |
| 17167 | D(p->level--); |
| 17168 | return NULL; |
| 17169 | } |
| 17170 | goto done; |
| 17171 | } |
| 17172 | p->mark = _mark; |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17173 | D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17174 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); |
| 17175 | } |
| 17176 | { // args for_if_clauses |
| 17177 | if (p->error_indicator) { |
| 17178 | D(p->level--); |
| 17179 | return NULL; |
| 17180 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17181 | D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args for_if_clauses")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17182 | expr_ty a; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 17183 | asdl_comprehension_seq* for_if_clauses_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17184 | if ( |
| 17185 | (a = args_rule(p)) // args |
| 17186 | && |
| 17187 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
| 17188 | ) |
| 17189 | { |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17190 | D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args for_if_clauses")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17191 | _res = _PyPegen_nonparen_genexp_in_call ( p , a ); |
| 17192 | if (_res == NULL && PyErr_Occurred()) { |
| 17193 | p->error_indicator = 1; |
| 17194 | D(p->level--); |
| 17195 | return NULL; |
| 17196 | } |
| 17197 | goto done; |
| 17198 | } |
| 17199 | p->mark = _mark; |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17200 | D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17201 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args for_if_clauses")); |
| 17202 | } |
| 17203 | { // args ',' expression for_if_clauses |
| 17204 | if (p->error_indicator) { |
| 17205 | D(p->level--); |
| 17206 | return NULL; |
| 17207 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17208 | D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17209 | Token * _literal; |
| 17210 | expr_ty a; |
| 17211 | expr_ty args_var; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 17212 | asdl_comprehension_seq* for_if_clauses_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17213 | if ( |
| 17214 | (args_var = args_rule(p)) // args |
| 17215 | && |
| 17216 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 17217 | && |
| 17218 | (a = expression_rule(p)) // expression |
| 17219 | && |
| 17220 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
| 17221 | ) |
| 17222 | { |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17223 | D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17224 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "Generator expression must be parenthesized" ); |
| 17225 | if (_res == NULL && PyErr_Occurred()) { |
| 17226 | p->error_indicator = 1; |
| 17227 | D(p->level--); |
| 17228 | return NULL; |
| 17229 | } |
| 17230 | goto done; |
| 17231 | } |
| 17232 | p->mark = _mark; |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17233 | D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17234 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' expression for_if_clauses")); |
| 17235 | } |
| 17236 | { // args ',' args |
| 17237 | if (p->error_indicator) { |
| 17238 | D(p->level--); |
| 17239 | return NULL; |
| 17240 | } |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17241 | D(fprintf(stderr, "%*c> invalid_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' args")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17242 | Token * _literal; |
| 17243 | expr_ty a; |
| 17244 | expr_ty args_var; |
| 17245 | if ( |
| 17246 | (a = args_rule(p)) // args |
| 17247 | && |
| 17248 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 17249 | && |
| 17250 | (args_var = args_rule(p)) // args |
| 17251 | ) |
| 17252 | { |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17253 | D(fprintf(stderr, "%*c+ invalid_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' args")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17254 | _res = _PyPegen_arguments_parsing_error ( p , a ); |
| 17255 | if (_res == NULL && PyErr_Occurred()) { |
| 17256 | p->error_indicator = 1; |
| 17257 | D(p->level--); |
| 17258 | return NULL; |
| 17259 | } |
| 17260 | goto done; |
| 17261 | } |
| 17262 | p->mark = _mark; |
Lysandros Nikolaou | bca7014 | 2020-10-27 00:42:04 +0200 | [diff] [blame] | 17263 | D(fprintf(stderr, "%*c%s invalid_arguments[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17264 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' args")); |
| 17265 | } |
| 17266 | _res = NULL; |
| 17267 | done: |
| 17268 | D(p->level--); |
| 17269 | return _res; |
| 17270 | } |
| 17271 | |
| 17272 | // invalid_kwarg: expression '=' |
| 17273 | static void * |
| 17274 | invalid_kwarg_rule(Parser *p) |
| 17275 | { |
| 17276 | D(p->level++); |
| 17277 | if (p->error_indicator) { |
| 17278 | D(p->level--); |
| 17279 | return NULL; |
| 17280 | } |
| 17281 | void * _res = NULL; |
| 17282 | int _mark = p->mark; |
| 17283 | { // expression '=' |
| 17284 | if (p->error_indicator) { |
| 17285 | D(p->level--); |
| 17286 | return NULL; |
| 17287 | } |
| 17288 | D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression '='")); |
Pablo Galindo | 43c4fb6 | 2020-12-13 16:46:48 +0000 | [diff] [blame] | 17289 | Token * a; |
| 17290 | expr_ty expression_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17291 | if ( |
Pablo Galindo | 43c4fb6 | 2020-12-13 16:46:48 +0000 | [diff] [blame] | 17292 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17293 | && |
Pablo Galindo | 43c4fb6 | 2020-12-13 16:46:48 +0000 | [diff] [blame] | 17294 | (a = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17295 | ) |
| 17296 | { |
| 17297 | D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression '='")); |
| 17298 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expression cannot contain assignment, perhaps you meant \"==\"?" ); |
| 17299 | if (_res == NULL && PyErr_Occurred()) { |
| 17300 | p->error_indicator = 1; |
| 17301 | D(p->level--); |
| 17302 | return NULL; |
| 17303 | } |
| 17304 | goto done; |
| 17305 | } |
| 17306 | p->mark = _mark; |
| 17307 | D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ', |
| 17308 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression '='")); |
| 17309 | } |
| 17310 | _res = NULL; |
| 17311 | done: |
| 17312 | D(p->level--); |
| 17313 | return _res; |
| 17314 | } |
| 17315 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 17316 | // invalid_named_expression: |
| 17317 | // | expression ':=' expression |
| 17318 | // | NAME '=' bitwise_or !('=' | ':=' | ',') |
| 17319 | // | !(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=' | ',') |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17320 | static void * |
| 17321 | invalid_named_expression_rule(Parser *p) |
| 17322 | { |
| 17323 | D(p->level++); |
| 17324 | if (p->error_indicator) { |
| 17325 | D(p->level--); |
| 17326 | return NULL; |
| 17327 | } |
| 17328 | void * _res = NULL; |
| 17329 | int _mark = p->mark; |
| 17330 | { // expression ':=' expression |
| 17331 | if (p->error_indicator) { |
| 17332 | D(p->level--); |
| 17333 | return NULL; |
| 17334 | } |
| 17335 | D(fprintf(stderr, "%*c> invalid_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':=' expression")); |
| 17336 | Token * _literal; |
| 17337 | expr_ty a; |
| 17338 | expr_ty expression_var; |
| 17339 | if ( |
| 17340 | (a = expression_rule(p)) // expression |
| 17341 | && |
| 17342 | (_literal = _PyPegen_expect_token(p, 53)) // token=':=' |
| 17343 | && |
| 17344 | (expression_var = expression_rule(p)) // expression |
| 17345 | ) |
| 17346 | { |
| 17347 | D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':=' expression")); |
| 17348 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) ); |
| 17349 | if (_res == NULL && PyErr_Occurred()) { |
| 17350 | p->error_indicator = 1; |
| 17351 | D(p->level--); |
| 17352 | return NULL; |
| 17353 | } |
| 17354 | goto done; |
| 17355 | } |
| 17356 | p->mark = _mark; |
| 17357 | D(fprintf(stderr, "%*c%s invalid_named_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 17358 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':=' expression")); |
| 17359 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 17360 | { // NAME '=' bitwise_or !('=' | ':=' | ',') |
| 17361 | if (p->error_indicator) { |
| 17362 | D(p->level--); |
| 17363 | return NULL; |
| 17364 | } |
| 17365 | D(fprintf(stderr, "%*c> invalid_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' bitwise_or !('=' | ':=' | ',')")); |
| 17366 | expr_ty a; |
| 17367 | Token * b; |
| 17368 | expr_ty bitwise_or_var; |
| 17369 | if ( |
| 17370 | (a = _PyPegen_name_token(p)) // NAME |
| 17371 | && |
| 17372 | (b = _PyPegen_expect_token(p, 22)) // token='=' |
| 17373 | && |
| 17374 | (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or |
| 17375 | && |
| 17376 | _PyPegen_lookahead(0, _tmp_143_rule, p) |
| 17377 | ) |
| 17378 | { |
| 17379 | D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' bitwise_or !('=' | ':=' | ',')")); |
| 17380 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( b , "invalid syntax. Maybe you meant '==' or ':=' instead of '='?" ); |
| 17381 | if (_res == NULL && PyErr_Occurred()) { |
| 17382 | p->error_indicator = 1; |
| 17383 | D(p->level--); |
| 17384 | return NULL; |
| 17385 | } |
| 17386 | goto done; |
| 17387 | } |
| 17388 | p->mark = _mark; |
| 17389 | D(fprintf(stderr, "%*c%s invalid_named_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 17390 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' bitwise_or !('=' | ':=' | ',')")); |
| 17391 | } |
| 17392 | { // !(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=' | ',') |
| 17393 | if (p->error_indicator) { |
| 17394 | D(p->level--); |
| 17395 | return NULL; |
| 17396 | } |
| 17397 | D(fprintf(stderr, "%*c> invalid_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=' | ',')")); |
| 17398 | expr_ty a; |
| 17399 | Token * b; |
| 17400 | expr_ty bitwise_or_var; |
| 17401 | if ( |
| 17402 | _PyPegen_lookahead(0, _tmp_144_rule, p) |
| 17403 | && |
| 17404 | (a = bitwise_or_rule(p)) // bitwise_or |
| 17405 | && |
| 17406 | (b = _PyPegen_expect_token(p, 22)) // token='=' |
| 17407 | && |
| 17408 | (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or |
| 17409 | && |
| 17410 | _PyPegen_lookahead(0, _tmp_145_rule, p) |
| 17411 | ) |
| 17412 | { |
| 17413 | D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=' | ',')")); |
| 17414 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( b , "cannot assign to %s here. Maybe you meant '==' instead of '='?" , _PyPegen_get_expr_name ( a ) ); |
| 17415 | if (_res == NULL && PyErr_Occurred()) { |
| 17416 | p->error_indicator = 1; |
| 17417 | D(p->level--); |
| 17418 | return NULL; |
| 17419 | } |
| 17420 | goto done; |
| 17421 | } |
| 17422 | p->mark = _mark; |
| 17423 | D(fprintf(stderr, "%*c%s invalid_named_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 17424 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!(list | tuple | genexp | 'True' | 'None' | 'False') bitwise_or '=' bitwise_or !('=' | ':=' | ',')")); |
| 17425 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17426 | _res = NULL; |
| 17427 | done: |
| 17428 | D(p->level--); |
| 17429 | return _res; |
| 17430 | } |
| 17431 | |
| 17432 | // invalid_assignment: |
Batuhan Taskaya | c8f29ad | 2020-06-27 21:33:08 +0300 | [diff] [blame] | 17433 | // | invalid_ann_assign_target ':' expression |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 17434 | // | star_named_expression ',' star_named_expressions* ':' expression |
| 17435 | // | expression ':' expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17436 | // | ((star_targets '='))* star_expressions '=' |
| 17437 | // | ((star_targets '='))* yield_expr '=' |
| 17438 | // | star_expressions augassign (yield_expr | star_expressions) |
| 17439 | static void * |
| 17440 | invalid_assignment_rule(Parser *p) |
| 17441 | { |
| 17442 | D(p->level++); |
| 17443 | if (p->error_indicator) { |
| 17444 | D(p->level--); |
| 17445 | return NULL; |
| 17446 | } |
| 17447 | void * _res = NULL; |
| 17448 | int _mark = p->mark; |
Batuhan Taskaya | c8f29ad | 2020-06-27 21:33:08 +0300 | [diff] [blame] | 17449 | { // invalid_ann_assign_target ':' expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17450 | if (p->error_indicator) { |
| 17451 | D(p->level--); |
| 17452 | return NULL; |
| 17453 | } |
Batuhan Taskaya | c8f29ad | 2020-06-27 21:33:08 +0300 | [diff] [blame] | 17454 | D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_ann_assign_target ':' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17455 | Token * _literal; |
| 17456 | expr_ty a; |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 17457 | expr_ty expression_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17458 | if ( |
Batuhan Taskaya | c8f29ad | 2020-06-27 21:33:08 +0300 | [diff] [blame] | 17459 | (a = invalid_ann_assign_target_rule(p)) // invalid_ann_assign_target |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17460 | && |
| 17461 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 17462 | && |
| 17463 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17464 | ) |
| 17465 | { |
Batuhan Taskaya | c8f29ad | 2020-06-27 21:33:08 +0300 | [diff] [blame] | 17466 | D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_ann_assign_target ':' expression")); |
| 17467 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not %s) can be annotated" , _PyPegen_get_expr_name ( a ) ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17468 | if (_res == NULL && PyErr_Occurred()) { |
| 17469 | p->error_indicator = 1; |
| 17470 | D(p->level--); |
| 17471 | return NULL; |
| 17472 | } |
| 17473 | goto done; |
| 17474 | } |
| 17475 | p->mark = _mark; |
| 17476 | D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', |
Batuhan Taskaya | c8f29ad | 2020-06-27 21:33:08 +0300 | [diff] [blame] | 17477 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_ann_assign_target ':' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17478 | } |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 17479 | { // star_named_expression ',' star_named_expressions* ':' expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17480 | if (p->error_indicator) { |
| 17481 | D(p->level--); |
| 17482 | return NULL; |
| 17483 | } |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 17484 | D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17485 | Token * _literal; |
| 17486 | Token * _literal_1; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 17487 | asdl_seq * _loop0_146_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17488 | expr_ty a; |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 17489 | expr_ty expression_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17490 | if ( |
| 17491 | (a = star_named_expression_rule(p)) // star_named_expression |
| 17492 | && |
| 17493 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 17494 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 17495 | (_loop0_146_var = _loop0_146_rule(p)) // star_named_expressions* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17496 | && |
| 17497 | (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 17498 | && |
| 17499 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17500 | ) |
| 17501 | { |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 17502 | D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17503 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" ); |
| 17504 | if (_res == NULL && PyErr_Occurred()) { |
| 17505 | p->error_indicator = 1; |
| 17506 | D(p->level--); |
| 17507 | return NULL; |
| 17508 | } |
| 17509 | goto done; |
| 17510 | } |
| 17511 | p->mark = _mark; |
| 17512 | D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 17513 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions* ':' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17514 | } |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 17515 | { // expression ':' expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17516 | if (p->error_indicator) { |
| 17517 | D(p->level--); |
| 17518 | return NULL; |
| 17519 | } |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 17520 | D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17521 | Token * _literal; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17522 | expr_ty a; |
| 17523 | expr_ty expression_var; |
| 17524 | if ( |
| 17525 | (a = expression_rule(p)) // expression |
| 17526 | && |
| 17527 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 17528 | && |
| 17529 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17530 | ) |
| 17531 | { |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 17532 | D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17533 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "illegal target for annotation" ); |
| 17534 | if (_res == NULL && PyErr_Occurred()) { |
| 17535 | p->error_indicator = 1; |
| 17536 | D(p->level--); |
| 17537 | return NULL; |
| 17538 | } |
| 17539 | goto done; |
| 17540 | } |
| 17541 | p->mark = _mark; |
| 17542 | D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 17543 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17544 | } |
| 17545 | { // ((star_targets '='))* star_expressions '=' |
| 17546 | if (p->error_indicator) { |
| 17547 | D(p->level--); |
| 17548 | return NULL; |
| 17549 | } |
| 17550 | D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='")); |
| 17551 | Token * _literal; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 17552 | asdl_seq * _loop0_147_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17553 | expr_ty a; |
| 17554 | if ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 17555 | (_loop0_147_var = _loop0_147_rule(p)) // ((star_targets '='))* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17556 | && |
| 17557 | (a = star_expressions_rule(p)) // star_expressions |
| 17558 | && |
| 17559 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 17560 | ) |
| 17561 | { |
| 17562 | D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='")); |
Lysandros Nikolaou | 6c4e0bd | 2020-06-21 05:18:01 +0300 | [diff] [blame] | 17563 | _res = RAISE_SYNTAX_ERROR_INVALID_TARGET ( STAR_TARGETS , a ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17564 | if (_res == NULL && PyErr_Occurred()) { |
| 17565 | p->error_indicator = 1; |
| 17566 | D(p->level--); |
| 17567 | return NULL; |
| 17568 | } |
| 17569 | goto done; |
| 17570 | } |
| 17571 | p->mark = _mark; |
| 17572 | D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 17573 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))* star_expressions '='")); |
| 17574 | } |
| 17575 | { // ((star_targets '='))* yield_expr '=' |
| 17576 | if (p->error_indicator) { |
| 17577 | D(p->level--); |
| 17578 | return NULL; |
| 17579 | } |
| 17580 | D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='")); |
| 17581 | Token * _literal; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 17582 | asdl_seq * _loop0_148_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17583 | expr_ty a; |
| 17584 | if ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 17585 | (_loop0_148_var = _loop0_148_rule(p)) // ((star_targets '='))* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17586 | && |
| 17587 | (a = yield_expr_rule(p)) // yield_expr |
| 17588 | && |
| 17589 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 17590 | ) |
| 17591 | { |
| 17592 | D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='")); |
| 17593 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "assignment to yield expression not possible" ); |
| 17594 | if (_res == NULL && PyErr_Occurred()) { |
| 17595 | p->error_indicator = 1; |
| 17596 | D(p->level--); |
| 17597 | return NULL; |
| 17598 | } |
| 17599 | goto done; |
| 17600 | } |
| 17601 | p->mark = _mark; |
| 17602 | D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 17603 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))* yield_expr '='")); |
| 17604 | } |
| 17605 | { // star_expressions augassign (yield_expr | star_expressions) |
| 17606 | if (p->error_indicator) { |
| 17607 | D(p->level--); |
| 17608 | return NULL; |
| 17609 | } |
| 17610 | D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 17611 | void *_tmp_149_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17612 | expr_ty a; |
| 17613 | AugOperator* augassign_var; |
| 17614 | if ( |
| 17615 | (a = star_expressions_rule(p)) // star_expressions |
| 17616 | && |
| 17617 | (augassign_var = augassign_rule(p)) // augassign |
| 17618 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 17619 | (_tmp_149_var = _tmp_149_rule(p)) // yield_expr | star_expressions |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17620 | ) |
| 17621 | { |
| 17622 | D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); |
| 17623 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "'%s' is an illegal expression for augmented assignment" , _PyPegen_get_expr_name ( a ) ); |
| 17624 | if (_res == NULL && PyErr_Occurred()) { |
| 17625 | p->error_indicator = 1; |
| 17626 | D(p->level--); |
| 17627 | return NULL; |
| 17628 | } |
| 17629 | goto done; |
| 17630 | } |
| 17631 | p->mark = _mark; |
| 17632 | D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 17633 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); |
| 17634 | } |
| 17635 | _res = NULL; |
| 17636 | done: |
| 17637 | D(p->level--); |
| 17638 | return _res; |
| 17639 | } |
| 17640 | |
Batuhan Taskaya | c8f29ad | 2020-06-27 21:33:08 +0300 | [diff] [blame] | 17641 | // invalid_ann_assign_target: list | tuple | '(' invalid_ann_assign_target ')' |
| 17642 | static expr_ty |
| 17643 | invalid_ann_assign_target_rule(Parser *p) |
| 17644 | { |
| 17645 | D(p->level++); |
| 17646 | if (p->error_indicator) { |
| 17647 | D(p->level--); |
| 17648 | return NULL; |
| 17649 | } |
| 17650 | expr_ty _res = NULL; |
| 17651 | int _mark = p->mark; |
| 17652 | { // list |
| 17653 | if (p->error_indicator) { |
| 17654 | D(p->level--); |
| 17655 | return NULL; |
| 17656 | } |
| 17657 | D(fprintf(stderr, "%*c> invalid_ann_assign_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); |
| 17658 | expr_ty list_var; |
| 17659 | if ( |
| 17660 | (list_var = list_rule(p)) // list |
| 17661 | ) |
| 17662 | { |
| 17663 | D(fprintf(stderr, "%*c+ invalid_ann_assign_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); |
| 17664 | _res = list_var; |
| 17665 | goto done; |
| 17666 | } |
| 17667 | p->mark = _mark; |
| 17668 | D(fprintf(stderr, "%*c%s invalid_ann_assign_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 17669 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); |
| 17670 | } |
| 17671 | { // tuple |
| 17672 | if (p->error_indicator) { |
| 17673 | D(p->level--); |
| 17674 | return NULL; |
| 17675 | } |
| 17676 | D(fprintf(stderr, "%*c> invalid_ann_assign_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); |
| 17677 | expr_ty tuple_var; |
| 17678 | if ( |
| 17679 | (tuple_var = tuple_rule(p)) // tuple |
| 17680 | ) |
| 17681 | { |
| 17682 | D(fprintf(stderr, "%*c+ invalid_ann_assign_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); |
| 17683 | _res = tuple_var; |
| 17684 | goto done; |
| 17685 | } |
| 17686 | p->mark = _mark; |
| 17687 | D(fprintf(stderr, "%*c%s invalid_ann_assign_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 17688 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); |
| 17689 | } |
| 17690 | { // '(' invalid_ann_assign_target ')' |
| 17691 | if (p->error_indicator) { |
| 17692 | D(p->level--); |
| 17693 | return NULL; |
| 17694 | } |
| 17695 | D(fprintf(stderr, "%*c> invalid_ann_assign_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' invalid_ann_assign_target ')'")); |
| 17696 | Token * _literal; |
| 17697 | Token * _literal_1; |
| 17698 | expr_ty a; |
| 17699 | if ( |
| 17700 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 17701 | && |
| 17702 | (a = invalid_ann_assign_target_rule(p)) // invalid_ann_assign_target |
| 17703 | && |
| 17704 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 17705 | ) |
| 17706 | { |
| 17707 | D(fprintf(stderr, "%*c+ invalid_ann_assign_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' invalid_ann_assign_target ')'")); |
| 17708 | _res = a; |
| 17709 | if (_res == NULL && PyErr_Occurred()) { |
| 17710 | p->error_indicator = 1; |
| 17711 | D(p->level--); |
| 17712 | return NULL; |
| 17713 | } |
| 17714 | goto done; |
| 17715 | } |
| 17716 | p->mark = _mark; |
| 17717 | D(fprintf(stderr, "%*c%s invalid_ann_assign_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 17718 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' invalid_ann_assign_target ')'")); |
| 17719 | } |
| 17720 | _res = NULL; |
| 17721 | done: |
| 17722 | D(p->level--); |
| 17723 | return _res; |
| 17724 | } |
| 17725 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 17726 | // invalid_del_stmt: 'del' star_expressions |
| 17727 | static void * |
| 17728 | invalid_del_stmt_rule(Parser *p) |
| 17729 | { |
| 17730 | D(p->level++); |
| 17731 | if (p->error_indicator) { |
| 17732 | D(p->level--); |
| 17733 | return NULL; |
| 17734 | } |
| 17735 | void * _res = NULL; |
| 17736 | int _mark = p->mark; |
| 17737 | { // 'del' star_expressions |
| 17738 | if (p->error_indicator) { |
| 17739 | D(p->level--); |
| 17740 | return NULL; |
| 17741 | } |
| 17742 | D(fprintf(stderr, "%*c> invalid_del_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'del' star_expressions")); |
| 17743 | Token * _keyword; |
| 17744 | expr_ty a; |
| 17745 | if ( |
| 17746 | (_keyword = _PyPegen_expect_token(p, 503)) // token='del' |
| 17747 | && |
| 17748 | (a = star_expressions_rule(p)) // star_expressions |
| 17749 | ) |
| 17750 | { |
| 17751 | D(fprintf(stderr, "%*c+ invalid_del_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'del' star_expressions")); |
Lysandros Nikolaou | 6c4e0bd | 2020-06-21 05:18:01 +0300 | [diff] [blame] | 17752 | _res = RAISE_SYNTAX_ERROR_INVALID_TARGET ( DEL_TARGETS , a ); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 17753 | if (_res == NULL && PyErr_Occurred()) { |
| 17754 | p->error_indicator = 1; |
| 17755 | D(p->level--); |
| 17756 | return NULL; |
| 17757 | } |
| 17758 | goto done; |
| 17759 | } |
| 17760 | p->mark = _mark; |
| 17761 | D(fprintf(stderr, "%*c%s invalid_del_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 17762 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'del' star_expressions")); |
| 17763 | } |
| 17764 | _res = NULL; |
| 17765 | done: |
| 17766 | D(p->level--); |
| 17767 | return _res; |
| 17768 | } |
| 17769 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17770 | // invalid_block: NEWLINE !INDENT |
| 17771 | static void * |
| 17772 | invalid_block_rule(Parser *p) |
| 17773 | { |
| 17774 | D(p->level++); |
| 17775 | if (p->error_indicator) { |
| 17776 | D(p->level--); |
| 17777 | return NULL; |
| 17778 | } |
| 17779 | void * _res = NULL; |
| 17780 | int _mark = p->mark; |
| 17781 | { // NEWLINE !INDENT |
| 17782 | if (p->error_indicator) { |
| 17783 | D(p->level--); |
| 17784 | return NULL; |
| 17785 | } |
| 17786 | D(fprintf(stderr, "%*c> invalid_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT")); |
| 17787 | Token * newline_var; |
| 17788 | if ( |
| 17789 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 17790 | && |
| 17791 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT |
| 17792 | ) |
| 17793 | { |
| 17794 | D(fprintf(stderr, "%*c+ invalid_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT")); |
| 17795 | _res = RAISE_INDENTATION_ERROR ( "expected an indented block" ); |
| 17796 | if (_res == NULL && PyErr_Occurred()) { |
| 17797 | p->error_indicator = 1; |
| 17798 | D(p->level--); |
| 17799 | return NULL; |
| 17800 | } |
| 17801 | goto done; |
| 17802 | } |
| 17803 | p->mark = _mark; |
| 17804 | D(fprintf(stderr, "%*c%s invalid_block[%d-%d]: %s failed!\n", p->level, ' ', |
| 17805 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE !INDENT")); |
| 17806 | } |
| 17807 | _res = NULL; |
| 17808 | done: |
| 17809 | D(p->level--); |
| 17810 | return _res; |
| 17811 | } |
| 17812 | |
Lysandros Nikolaou | 15acc4e | 2020-10-27 20:54:20 +0200 | [diff] [blame] | 17813 | // Left-recursive |
| 17814 | // invalid_primary: primary '{' |
| 17815 | static void * |
| 17816 | invalid_primary_rule(Parser *p) |
| 17817 | { |
| 17818 | D(p->level++); |
| 17819 | if (p->error_indicator) { |
| 17820 | D(p->level--); |
| 17821 | return NULL; |
| 17822 | } |
| 17823 | void * _res = NULL; |
| 17824 | int _mark = p->mark; |
| 17825 | { // primary '{' |
| 17826 | if (p->error_indicator) { |
| 17827 | D(p->level--); |
| 17828 | return NULL; |
| 17829 | } |
| 17830 | D(fprintf(stderr, "%*c> invalid_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '{'")); |
| 17831 | Token * a; |
| 17832 | expr_ty primary_var; |
| 17833 | if ( |
| 17834 | (primary_var = primary_rule(p)) // primary |
| 17835 | && |
| 17836 | (a = _PyPegen_expect_token(p, 25)) // token='{' |
| 17837 | ) |
| 17838 | { |
| 17839 | D(fprintf(stderr, "%*c+ invalid_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '{'")); |
| 17840 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "invalid syntax" ); |
| 17841 | if (_res == NULL && PyErr_Occurred()) { |
| 17842 | p->error_indicator = 1; |
| 17843 | D(p->level--); |
| 17844 | return NULL; |
| 17845 | } |
| 17846 | goto done; |
| 17847 | } |
| 17848 | p->mark = _mark; |
| 17849 | D(fprintf(stderr, "%*c%s invalid_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 17850 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '{'")); |
| 17851 | } |
| 17852 | _res = NULL; |
| 17853 | done: |
| 17854 | D(p->level--); |
| 17855 | return _res; |
| 17856 | } |
| 17857 | |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 17858 | // invalid_comprehension: |
| 17859 | // | ('[' | '(' | '{') starred_expression for_if_clauses |
Pablo Galindo | d4e6ed7 | 2021-02-03 23:29:26 +0000 | [diff] [blame] | 17860 | // | ('[' | '{') star_named_expression ',' star_named_expressions? for_if_clauses |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17861 | static void * |
| 17862 | invalid_comprehension_rule(Parser *p) |
| 17863 | { |
| 17864 | D(p->level++); |
| 17865 | if (p->error_indicator) { |
| 17866 | D(p->level--); |
| 17867 | return NULL; |
| 17868 | } |
| 17869 | void * _res = NULL; |
| 17870 | int _mark = p->mark; |
| 17871 | { // ('[' | '(' | '{') starred_expression for_if_clauses |
| 17872 | if (p->error_indicator) { |
| 17873 | D(p->level--); |
| 17874 | return NULL; |
| 17875 | } |
| 17876 | D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 17877 | void *_tmp_150_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17878 | expr_ty a; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 17879 | asdl_comprehension_seq* for_if_clauses_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17880 | if ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 17881 | (_tmp_150_var = _tmp_150_rule(p)) // '[' | '(' | '{' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17882 | && |
| 17883 | (a = starred_expression_rule(p)) // starred_expression |
| 17884 | && |
| 17885 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
| 17886 | ) |
| 17887 | { |
| 17888 | D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); |
| 17889 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "iterable unpacking cannot be used in comprehension" ); |
| 17890 | if (_res == NULL && PyErr_Occurred()) { |
| 17891 | p->error_indicator = 1; |
| 17892 | D(p->level--); |
| 17893 | return NULL; |
| 17894 | } |
| 17895 | goto done; |
| 17896 | } |
| 17897 | p->mark = _mark; |
| 17898 | D(fprintf(stderr, "%*c%s invalid_comprehension[%d-%d]: %s failed!\n", p->level, ' ', |
| 17899 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); |
| 17900 | } |
Pablo Galindo | d4e6ed7 | 2021-02-03 23:29:26 +0000 | [diff] [blame] | 17901 | { // ('[' | '{') star_named_expression ',' star_named_expressions? for_if_clauses |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 17902 | if (p->error_indicator) { |
| 17903 | D(p->level--); |
| 17904 | return NULL; |
| 17905 | } |
Pablo Galindo | d4e6ed7 | 2021-02-03 23:29:26 +0000 | [diff] [blame] | 17906 | D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '{') star_named_expression ',' star_named_expressions? for_if_clauses")); |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 17907 | Token * _literal; |
| 17908 | void *_opt_var; |
| 17909 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 17910 | void *_tmp_151_var; |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 17911 | expr_ty a; |
Pablo Galindo | d4e6ed7 | 2021-02-03 23:29:26 +0000 | [diff] [blame] | 17912 | asdl_comprehension_seq* for_if_clauses_var; |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 17913 | if ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 17914 | (_tmp_151_var = _tmp_151_rule(p)) // '[' | '{' |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 17915 | && |
| 17916 | (a = star_named_expression_rule(p)) // star_named_expression |
| 17917 | && |
| 17918 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 17919 | && |
| 17920 | (_opt_var = star_named_expressions_rule(p), 1) // star_named_expressions? |
Pablo Galindo | d4e6ed7 | 2021-02-03 23:29:26 +0000 | [diff] [blame] | 17921 | && |
| 17922 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 17923 | ) |
| 17924 | { |
Pablo Galindo | d4e6ed7 | 2021-02-03 23:29:26 +0000 | [diff] [blame] | 17925 | D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('[' | '{') star_named_expression ',' star_named_expressions? for_if_clauses")); |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 17926 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "did you forget parentheses around the comprehension target?" ); |
| 17927 | if (_res == NULL && PyErr_Occurred()) { |
| 17928 | p->error_indicator = 1; |
| 17929 | D(p->level--); |
| 17930 | return NULL; |
| 17931 | } |
| 17932 | goto done; |
| 17933 | } |
| 17934 | p->mark = _mark; |
| 17935 | D(fprintf(stderr, "%*c%s invalid_comprehension[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | d4e6ed7 | 2021-02-03 23:29:26 +0000 | [diff] [blame] | 17936 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('[' | '{') star_named_expression ',' star_named_expressions? for_if_clauses")); |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 17937 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17938 | _res = NULL; |
| 17939 | done: |
| 17940 | D(p->level--); |
| 17941 | return _res; |
| 17942 | } |
| 17943 | |
| 17944 | // invalid_dict_comprehension: '{' '**' bitwise_or for_if_clauses '}' |
| 17945 | static void * |
| 17946 | invalid_dict_comprehension_rule(Parser *p) |
| 17947 | { |
| 17948 | D(p->level++); |
| 17949 | if (p->error_indicator) { |
| 17950 | D(p->level--); |
| 17951 | return NULL; |
| 17952 | } |
| 17953 | void * _res = NULL; |
| 17954 | int _mark = p->mark; |
| 17955 | { // '{' '**' bitwise_or for_if_clauses '}' |
| 17956 | if (p->error_indicator) { |
| 17957 | D(p->level--); |
| 17958 | return NULL; |
| 17959 | } |
| 17960 | D(fprintf(stderr, "%*c> invalid_dict_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'")); |
| 17961 | Token * _literal; |
| 17962 | Token * _literal_1; |
| 17963 | Token * a; |
| 17964 | expr_ty bitwise_or_var; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 17965 | asdl_comprehension_seq* for_if_clauses_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17966 | if ( |
| 17967 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
| 17968 | && |
| 17969 | (a = _PyPegen_expect_token(p, 35)) // token='**' |
| 17970 | && |
| 17971 | (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or |
| 17972 | && |
| 17973 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
| 17974 | && |
| 17975 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
| 17976 | ) |
| 17977 | { |
| 17978 | D(fprintf(stderr, "%*c+ invalid_dict_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'")); |
| 17979 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "dict unpacking cannot be used in dict comprehension" ); |
| 17980 | if (_res == NULL && PyErr_Occurred()) { |
| 17981 | p->error_indicator = 1; |
| 17982 | D(p->level--); |
| 17983 | return NULL; |
| 17984 | } |
| 17985 | goto done; |
| 17986 | } |
| 17987 | p->mark = _mark; |
| 17988 | D(fprintf(stderr, "%*c%s invalid_dict_comprehension[%d-%d]: %s failed!\n", p->level, ' ', |
| 17989 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'")); |
| 17990 | } |
| 17991 | _res = NULL; |
| 17992 | done: |
| 17993 | D(p->level--); |
| 17994 | return _res; |
| 17995 | } |
| 17996 | |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 17997 | // invalid_parameters: param_no_default* invalid_parameters_helper param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 17998 | static void * |
| 17999 | invalid_parameters_rule(Parser *p) |
| 18000 | { |
| 18001 | D(p->level++); |
| 18002 | if (p->error_indicator) { |
| 18003 | D(p->level--); |
| 18004 | return NULL; |
| 18005 | } |
| 18006 | void * _res = NULL; |
| 18007 | int _mark = p->mark; |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18008 | { // param_no_default* invalid_parameters_helper param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18009 | if (p->error_indicator) { |
| 18010 | D(p->level--); |
| 18011 | return NULL; |
| 18012 | } |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18013 | D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* invalid_parameters_helper param_no_default")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18014 | asdl_seq * _loop0_152_var; |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18015 | void *invalid_parameters_helper_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18016 | arg_ty param_no_default_var; |
| 18017 | if ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18018 | (_loop0_152_var = _loop0_152_rule(p)) // param_no_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18019 | && |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18020 | (invalid_parameters_helper_var = invalid_parameters_helper_rule(p)) // invalid_parameters_helper |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18021 | && |
| 18022 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
| 18023 | ) |
| 18024 | { |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18025 | D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* invalid_parameters_helper param_no_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18026 | _res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" ); |
| 18027 | if (_res == NULL && PyErr_Occurred()) { |
| 18028 | p->error_indicator = 1; |
| 18029 | D(p->level--); |
| 18030 | return NULL; |
| 18031 | } |
| 18032 | goto done; |
| 18033 | } |
| 18034 | p->mark = _mark; |
| 18035 | D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18036 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* invalid_parameters_helper param_no_default")); |
| 18037 | } |
| 18038 | _res = NULL; |
| 18039 | done: |
| 18040 | D(p->level--); |
| 18041 | return _res; |
| 18042 | } |
| 18043 | |
| 18044 | // invalid_parameters_helper: slash_with_default | param_with_default+ |
| 18045 | static void * |
| 18046 | invalid_parameters_helper_rule(Parser *p) |
| 18047 | { |
| 18048 | D(p->level++); |
| 18049 | if (p->error_indicator) { |
| 18050 | D(p->level--); |
| 18051 | return NULL; |
| 18052 | } |
| 18053 | void * _res = NULL; |
| 18054 | int _mark = p->mark; |
| 18055 | { // slash_with_default |
| 18056 | if (p->error_indicator) { |
| 18057 | D(p->level--); |
| 18058 | return NULL; |
| 18059 | } |
| 18060 | D(fprintf(stderr, "%*c> invalid_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); |
| 18061 | SlashWithDefault* a; |
| 18062 | if ( |
| 18063 | (a = slash_with_default_rule(p)) // slash_with_default |
| 18064 | ) |
| 18065 | { |
| 18066 | D(fprintf(stderr, "%*c+ invalid_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); |
| 18067 | _res = _PyPegen_singleton_seq ( p , a ); |
| 18068 | if (_res == NULL && PyErr_Occurred()) { |
| 18069 | p->error_indicator = 1; |
| 18070 | D(p->level--); |
| 18071 | return NULL; |
| 18072 | } |
| 18073 | goto done; |
| 18074 | } |
| 18075 | p->mark = _mark; |
| 18076 | D(fprintf(stderr, "%*c%s invalid_parameters_helper[%d-%d]: %s failed!\n", p->level, ' ', |
| 18077 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); |
| 18078 | } |
| 18079 | { // param_with_default+ |
| 18080 | if (p->error_indicator) { |
| 18081 | D(p->level--); |
| 18082 | return NULL; |
| 18083 | } |
| 18084 | D(fprintf(stderr, "%*c> invalid_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18085 | asdl_seq * _loop1_153_var; |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18086 | if ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18087 | (_loop1_153_var = _loop1_153_rule(p)) // param_with_default+ |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18088 | ) |
| 18089 | { |
| 18090 | D(fprintf(stderr, "%*c+ invalid_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18091 | _res = _loop1_153_var; |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18092 | goto done; |
| 18093 | } |
| 18094 | p->mark = _mark; |
| 18095 | D(fprintf(stderr, "%*c%s invalid_parameters_helper[%d-%d]: %s failed!\n", p->level, ' ', |
| 18096 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18097 | } |
| 18098 | _res = NULL; |
| 18099 | done: |
| 18100 | D(p->level--); |
| 18101 | return _res; |
| 18102 | } |
| 18103 | |
| 18104 | // invalid_lambda_parameters: |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18105 | // | lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18106 | static void * |
| 18107 | invalid_lambda_parameters_rule(Parser *p) |
| 18108 | { |
| 18109 | D(p->level++); |
| 18110 | if (p->error_indicator) { |
| 18111 | D(p->level--); |
| 18112 | return NULL; |
| 18113 | } |
| 18114 | void * _res = NULL; |
| 18115 | int _mark = p->mark; |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18116 | { // lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18117 | if (p->error_indicator) { |
| 18118 | D(p->level--); |
| 18119 | return NULL; |
| 18120 | } |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18121 | D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18122 | asdl_seq * _loop0_154_var; |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18123 | void *invalid_lambda_parameters_helper_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18124 | arg_ty lambda_param_no_default_var; |
| 18125 | if ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18126 | (_loop0_154_var = _loop0_154_rule(p)) // lambda_param_no_default* |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18127 | && |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18128 | (invalid_lambda_parameters_helper_var = invalid_lambda_parameters_helper_rule(p)) // invalid_lambda_parameters_helper |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18129 | && |
| 18130 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
| 18131 | ) |
| 18132 | { |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18133 | D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18134 | _res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" ); |
| 18135 | if (_res == NULL && PyErr_Occurred()) { |
| 18136 | p->error_indicator = 1; |
| 18137 | D(p->level--); |
| 18138 | return NULL; |
| 18139 | } |
| 18140 | goto done; |
| 18141 | } |
| 18142 | p->mark = _mark; |
| 18143 | D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18144 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* invalid_lambda_parameters_helper lambda_param_no_default")); |
| 18145 | } |
| 18146 | _res = NULL; |
| 18147 | done: |
| 18148 | D(p->level--); |
| 18149 | return _res; |
| 18150 | } |
| 18151 | |
| 18152 | // invalid_lambda_parameters_helper: |
| 18153 | // | lambda_slash_with_default |
| 18154 | // | lambda_param_with_default+ |
| 18155 | static void * |
| 18156 | invalid_lambda_parameters_helper_rule(Parser *p) |
| 18157 | { |
| 18158 | D(p->level++); |
| 18159 | if (p->error_indicator) { |
| 18160 | D(p->level--); |
| 18161 | return NULL; |
| 18162 | } |
| 18163 | void * _res = NULL; |
| 18164 | int _mark = p->mark; |
| 18165 | { // lambda_slash_with_default |
| 18166 | if (p->error_indicator) { |
| 18167 | D(p->level--); |
| 18168 | return NULL; |
| 18169 | } |
| 18170 | D(fprintf(stderr, "%*c> invalid_lambda_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); |
| 18171 | SlashWithDefault* a; |
| 18172 | if ( |
| 18173 | (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default |
| 18174 | ) |
| 18175 | { |
| 18176 | D(fprintf(stderr, "%*c+ invalid_lambda_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); |
| 18177 | _res = _PyPegen_singleton_seq ( p , a ); |
| 18178 | if (_res == NULL && PyErr_Occurred()) { |
| 18179 | p->error_indicator = 1; |
| 18180 | D(p->level--); |
| 18181 | return NULL; |
| 18182 | } |
| 18183 | goto done; |
| 18184 | } |
| 18185 | p->mark = _mark; |
| 18186 | D(fprintf(stderr, "%*c%s invalid_lambda_parameters_helper[%d-%d]: %s failed!\n", p->level, ' ', |
| 18187 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default")); |
| 18188 | } |
| 18189 | { // lambda_param_with_default+ |
| 18190 | if (p->error_indicator) { |
| 18191 | D(p->level--); |
| 18192 | return NULL; |
| 18193 | } |
| 18194 | D(fprintf(stderr, "%*c> invalid_lambda_parameters_helper[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18195 | asdl_seq * _loop1_155_var; |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18196 | if ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18197 | (_loop1_155_var = _loop1_155_rule(p)) // lambda_param_with_default+ |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18198 | ) |
| 18199 | { |
| 18200 | D(fprintf(stderr, "%*c+ invalid_lambda_parameters_helper[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18201 | _res = _loop1_155_var; |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 18202 | goto done; |
| 18203 | } |
| 18204 | p->mark = _mark; |
| 18205 | D(fprintf(stderr, "%*c%s invalid_lambda_parameters_helper[%d-%d]: %s failed!\n", p->level, ' ', |
| 18206 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18207 | } |
| 18208 | _res = NULL; |
| 18209 | done: |
| 18210 | D(p->level--); |
| 18211 | return _res; |
| 18212 | } |
| 18213 | |
| 18214 | // invalid_star_etc: '*' (')' | ',' (')' | '**')) | '*' ',' TYPE_COMMENT |
| 18215 | static void * |
| 18216 | invalid_star_etc_rule(Parser *p) |
| 18217 | { |
| 18218 | D(p->level++); |
| 18219 | if (p->error_indicator) { |
| 18220 | D(p->level--); |
| 18221 | return NULL; |
| 18222 | } |
| 18223 | void * _res = NULL; |
| 18224 | int _mark = p->mark; |
| 18225 | { // '*' (')' | ',' (')' | '**')) |
| 18226 | if (p->error_indicator) { |
| 18227 | D(p->level--); |
| 18228 | return NULL; |
| 18229 | } |
| 18230 | D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); |
| 18231 | Token * _literal; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18232 | void *_tmp_156_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18233 | if ( |
| 18234 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 18235 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18236 | (_tmp_156_var = _tmp_156_rule(p)) // ')' | ',' (')' | '**') |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18237 | ) |
| 18238 | { |
| 18239 | D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); |
| 18240 | _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); |
| 18241 | if (_res == NULL && PyErr_Occurred()) { |
| 18242 | p->error_indicator = 1; |
| 18243 | D(p->level--); |
| 18244 | return NULL; |
| 18245 | } |
| 18246 | goto done; |
| 18247 | } |
| 18248 | p->mark = _mark; |
| 18249 | D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 18250 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); |
| 18251 | } |
| 18252 | { // '*' ',' TYPE_COMMENT |
| 18253 | if (p->error_indicator) { |
| 18254 | D(p->level--); |
| 18255 | return NULL; |
| 18256 | } |
| 18257 | D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT")); |
| 18258 | Token * _literal; |
| 18259 | Token * _literal_1; |
| 18260 | Token * type_comment_var; |
| 18261 | if ( |
| 18262 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 18263 | && |
| 18264 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
| 18265 | && |
| 18266 | (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
| 18267 | ) |
| 18268 | { |
| 18269 | D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT")); |
| 18270 | _res = RAISE_SYNTAX_ERROR ( "bare * has associated type comment" ); |
| 18271 | if (_res == NULL && PyErr_Occurred()) { |
| 18272 | p->error_indicator = 1; |
| 18273 | D(p->level--); |
| 18274 | return NULL; |
| 18275 | } |
| 18276 | goto done; |
| 18277 | } |
| 18278 | p->mark = _mark; |
| 18279 | D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 18280 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' TYPE_COMMENT")); |
| 18281 | } |
| 18282 | _res = NULL; |
| 18283 | done: |
| 18284 | D(p->level--); |
| 18285 | return _res; |
| 18286 | } |
| 18287 | |
| 18288 | // invalid_lambda_star_etc: '*' (':' | ',' (':' | '**')) |
| 18289 | static void * |
| 18290 | invalid_lambda_star_etc_rule(Parser *p) |
| 18291 | { |
| 18292 | D(p->level++); |
| 18293 | if (p->error_indicator) { |
| 18294 | D(p->level--); |
| 18295 | return NULL; |
| 18296 | } |
| 18297 | void * _res = NULL; |
| 18298 | int _mark = p->mark; |
| 18299 | { // '*' (':' | ',' (':' | '**')) |
| 18300 | if (p->error_indicator) { |
| 18301 | D(p->level--); |
| 18302 | return NULL; |
| 18303 | } |
| 18304 | D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); |
| 18305 | Token * _literal; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18306 | void *_tmp_157_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18307 | if ( |
| 18308 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 18309 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18310 | (_tmp_157_var = _tmp_157_rule(p)) // ':' | ',' (':' | '**') |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18311 | ) |
| 18312 | { |
| 18313 | D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); |
| 18314 | _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); |
| 18315 | if (_res == NULL && PyErr_Occurred()) { |
| 18316 | p->error_indicator = 1; |
| 18317 | D(p->level--); |
| 18318 | return NULL; |
| 18319 | } |
| 18320 | goto done; |
| 18321 | } |
| 18322 | p->mark = _mark; |
| 18323 | D(fprintf(stderr, "%*c%s invalid_lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 18324 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); |
| 18325 | } |
| 18326 | _res = NULL; |
| 18327 | done: |
| 18328 | D(p->level--); |
| 18329 | return _res; |
| 18330 | } |
| 18331 | |
| 18332 | // invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
| 18333 | static void * |
| 18334 | invalid_double_type_comments_rule(Parser *p) |
| 18335 | { |
| 18336 | D(p->level++); |
| 18337 | if (p->error_indicator) { |
| 18338 | D(p->level--); |
| 18339 | return NULL; |
| 18340 | } |
| 18341 | void * _res = NULL; |
| 18342 | int _mark = p->mark; |
| 18343 | { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
| 18344 | if (p->error_indicator) { |
| 18345 | D(p->level--); |
| 18346 | return NULL; |
| 18347 | } |
| 18348 | D(fprintf(stderr, "%*c> invalid_double_type_comments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); |
| 18349 | Token * indent_var; |
| 18350 | Token * newline_var; |
| 18351 | Token * newline_var_1; |
| 18352 | Token * type_comment_var; |
| 18353 | Token * type_comment_var_1; |
| 18354 | if ( |
| 18355 | (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
| 18356 | && |
| 18357 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 18358 | && |
| 18359 | (type_comment_var_1 = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
| 18360 | && |
| 18361 | (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 18362 | && |
| 18363 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
| 18364 | ) |
| 18365 | { |
| 18366 | D(fprintf(stderr, "%*c+ invalid_double_type_comments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); |
| 18367 | _res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" ); |
| 18368 | if (_res == NULL && PyErr_Occurred()) { |
| 18369 | p->error_indicator = 1; |
| 18370 | D(p->level--); |
| 18371 | return NULL; |
| 18372 | } |
| 18373 | goto done; |
| 18374 | } |
| 18375 | p->mark = _mark; |
| 18376 | D(fprintf(stderr, "%*c%s invalid_double_type_comments[%d-%d]: %s failed!\n", p->level, ' ', |
| 18377 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); |
| 18378 | } |
| 18379 | _res = NULL; |
| 18380 | done: |
| 18381 | D(p->level--); |
| 18382 | return _res; |
| 18383 | } |
| 18384 | |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 18385 | // invalid_with_item: expression 'as' expression &(',' | ')' | ':') |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18386 | static void * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 18387 | invalid_with_item_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18388 | { |
| 18389 | D(p->level++); |
| 18390 | if (p->error_indicator) { |
| 18391 | D(p->level--); |
| 18392 | return NULL; |
| 18393 | } |
| 18394 | void * _res = NULL; |
| 18395 | int _mark = p->mark; |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 18396 | { // expression 'as' expression &(',' | ')' | ':') |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18397 | if (p->error_indicator) { |
| 18398 | D(p->level--); |
| 18399 | return NULL; |
| 18400 | } |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 18401 | D(fprintf(stderr, "%*c> invalid_with_item[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression 'as' expression &(',' | ')' | ':')")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 18402 | Token * _keyword; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18403 | expr_ty a; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 18404 | expr_ty expression_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18405 | if ( |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 18406 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18407 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 18408 | (_keyword = _PyPegen_expect_token(p, 520)) // token='as' |
| 18409 | && |
| 18410 | (a = expression_rule(p)) // expression |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 18411 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18412 | _PyPegen_lookahead(1, _tmp_158_rule, p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18413 | ) |
| 18414 | { |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 18415 | D(fprintf(stderr, "%*c+ invalid_with_item[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression 'as' expression &(',' | ')' | ':')")); |
Lysandros Nikolaou | 6c4e0bd | 2020-06-21 05:18:01 +0300 | [diff] [blame] | 18416 | _res = RAISE_SYNTAX_ERROR_INVALID_TARGET ( STAR_TARGETS , a ); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18417 | if (_res == NULL && PyErr_Occurred()) { |
| 18418 | p->error_indicator = 1; |
| 18419 | D(p->level--); |
| 18420 | return NULL; |
| 18421 | } |
| 18422 | goto done; |
| 18423 | } |
| 18424 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 18425 | D(fprintf(stderr, "%*c%s invalid_with_item[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 18426 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression 'as' expression &(',' | ')' | ':')")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 18427 | } |
| 18428 | _res = NULL; |
| 18429 | done: |
| 18430 | D(p->level--); |
| 18431 | return _res; |
| 18432 | } |
| 18433 | |
| 18434 | // invalid_for_target: ASYNC? 'for' star_expressions |
| 18435 | static void * |
| 18436 | invalid_for_target_rule(Parser *p) |
| 18437 | { |
| 18438 | D(p->level++); |
| 18439 | if (p->error_indicator) { |
| 18440 | D(p->level--); |
| 18441 | return NULL; |
| 18442 | } |
| 18443 | void * _res = NULL; |
| 18444 | int _mark = p->mark; |
| 18445 | { // ASYNC? 'for' star_expressions |
| 18446 | if (p->error_indicator) { |
| 18447 | D(p->level--); |
| 18448 | return NULL; |
| 18449 | } |
| 18450 | D(fprintf(stderr, "%*c> invalid_for_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC? 'for' star_expressions")); |
| 18451 | Token * _keyword; |
| 18452 | void *_opt_var; |
| 18453 | UNUSED(_opt_var); // Silence compiler warnings |
| 18454 | expr_ty a; |
| 18455 | if ( |
| 18456 | (_opt_var = _PyPegen_expect_token(p, ASYNC), 1) // ASYNC? |
| 18457 | && |
| 18458 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
| 18459 | && |
| 18460 | (a = star_expressions_rule(p)) // star_expressions |
| 18461 | ) |
| 18462 | { |
| 18463 | D(fprintf(stderr, "%*c+ invalid_for_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC? 'for' star_expressions")); |
Lysandros Nikolaou | 6c4e0bd | 2020-06-21 05:18:01 +0300 | [diff] [blame] | 18464 | _res = RAISE_SYNTAX_ERROR_INVALID_TARGET ( FOR_TARGETS , a ); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 18465 | if (_res == NULL && PyErr_Occurred()) { |
| 18466 | p->error_indicator = 1; |
| 18467 | D(p->level--); |
| 18468 | return NULL; |
| 18469 | } |
| 18470 | goto done; |
| 18471 | } |
| 18472 | p->mark = _mark; |
| 18473 | D(fprintf(stderr, "%*c%s invalid_for_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 18474 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC? 'for' star_expressions")); |
| 18475 | } |
| 18476 | _res = NULL; |
| 18477 | done: |
| 18478 | D(p->level--); |
| 18479 | return _res; |
| 18480 | } |
| 18481 | |
Pablo Galindo | 8efad61 | 2021-03-24 19:34:17 +0000 | [diff] [blame] | 18482 | // invalid_group: '(' starred_expression ')' | '(' '**' expression ')' |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 18483 | static void * |
| 18484 | invalid_group_rule(Parser *p) |
| 18485 | { |
| 18486 | D(p->level++); |
| 18487 | if (p->error_indicator) { |
| 18488 | D(p->level--); |
| 18489 | return NULL; |
| 18490 | } |
| 18491 | void * _res = NULL; |
| 18492 | int _mark = p->mark; |
| 18493 | { // '(' starred_expression ')' |
| 18494 | if (p->error_indicator) { |
| 18495 | D(p->level--); |
| 18496 | return NULL; |
| 18497 | } |
| 18498 | D(fprintf(stderr, "%*c> invalid_group[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' starred_expression ')'")); |
| 18499 | Token * _literal; |
| 18500 | Token * _literal_1; |
| 18501 | expr_ty a; |
| 18502 | if ( |
| 18503 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 18504 | && |
| 18505 | (a = starred_expression_rule(p)) // starred_expression |
| 18506 | && |
| 18507 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 18508 | ) |
| 18509 | { |
| 18510 | D(fprintf(stderr, "%*c+ invalid_group[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' starred_expression ')'")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18511 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use starred expression here" ); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 18512 | if (_res == NULL && PyErr_Occurred()) { |
| 18513 | p->error_indicator = 1; |
| 18514 | D(p->level--); |
| 18515 | return NULL; |
| 18516 | } |
| 18517 | goto done; |
| 18518 | } |
| 18519 | p->mark = _mark; |
| 18520 | D(fprintf(stderr, "%*c%s invalid_group[%d-%d]: %s failed!\n", p->level, ' ', |
| 18521 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' starred_expression ')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18522 | } |
Pablo Galindo | 8efad61 | 2021-03-24 19:34:17 +0000 | [diff] [blame] | 18523 | { // '(' '**' expression ')' |
| 18524 | if (p->error_indicator) { |
| 18525 | D(p->level--); |
| 18526 | return NULL; |
| 18527 | } |
| 18528 | D(fprintf(stderr, "%*c> invalid_group[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' '**' expression ')'")); |
| 18529 | Token * _literal; |
| 18530 | Token * _literal_1; |
| 18531 | Token * a; |
| 18532 | expr_ty expression_var; |
| 18533 | if ( |
| 18534 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 18535 | && |
| 18536 | (a = _PyPegen_expect_token(p, 35)) // token='**' |
| 18537 | && |
| 18538 | (expression_var = expression_rule(p)) // expression |
| 18539 | && |
| 18540 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 18541 | ) |
| 18542 | { |
| 18543 | D(fprintf(stderr, "%*c+ invalid_group[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' '**' expression ')'")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18544 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use double starred expression here" ); |
Pablo Galindo | 8efad61 | 2021-03-24 19:34:17 +0000 | [diff] [blame] | 18545 | if (_res == NULL && PyErr_Occurred()) { |
| 18546 | p->error_indicator = 1; |
| 18547 | D(p->level--); |
| 18548 | return NULL; |
| 18549 | } |
| 18550 | goto done; |
| 18551 | } |
| 18552 | p->mark = _mark; |
| 18553 | D(fprintf(stderr, "%*c%s invalid_group[%d-%d]: %s failed!\n", p->level, ' ', |
| 18554 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' '**' expression ')'")); |
| 18555 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18556 | _res = NULL; |
| 18557 | done: |
| 18558 | D(p->level--); |
| 18559 | return _res; |
| 18560 | } |
| 18561 | |
| 18562 | // invalid_import_from_targets: import_from_as_names ',' |
| 18563 | static void * |
| 18564 | invalid_import_from_targets_rule(Parser *p) |
| 18565 | { |
| 18566 | D(p->level++); |
| 18567 | if (p->error_indicator) { |
| 18568 | D(p->level--); |
| 18569 | return NULL; |
| 18570 | } |
| 18571 | void * _res = NULL; |
| 18572 | int _mark = p->mark; |
| 18573 | { // import_from_as_names ',' |
| 18574 | if (p->error_indicator) { |
| 18575 | D(p->level--); |
| 18576 | return NULL; |
| 18577 | } |
| 18578 | D(fprintf(stderr, "%*c> invalid_import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_names ','")); |
| 18579 | Token * _literal; |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 18580 | asdl_alias_seq* import_from_as_names_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 18581 | if ( |
| 18582 | (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names |
| 18583 | && |
| 18584 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 18585 | ) |
| 18586 | { |
| 18587 | D(fprintf(stderr, "%*c+ invalid_import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_names ','")); |
| 18588 | _res = RAISE_SYNTAX_ERROR ( "trailing comma not allowed without surrounding parentheses" ); |
| 18589 | if (_res == NULL && PyErr_Occurred()) { |
| 18590 | p->error_indicator = 1; |
| 18591 | D(p->level--); |
| 18592 | return NULL; |
| 18593 | } |
| 18594 | goto done; |
| 18595 | } |
| 18596 | p->mark = _mark; |
| 18597 | D(fprintf(stderr, "%*c%s invalid_import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 18598 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_names ','")); |
| 18599 | } |
| 18600 | _res = NULL; |
| 18601 | done: |
| 18602 | D(p->level--); |
| 18603 | return _res; |
| 18604 | } |
| 18605 | |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 18606 | // invalid_with_stmt: |
| 18607 | // | ASYNC? 'with' ','.(expression ['as' star_target])+ &&':' |
| 18608 | // | ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' &&':' |
| 18609 | static void * |
| 18610 | invalid_with_stmt_rule(Parser *p) |
| 18611 | { |
| 18612 | D(p->level++); |
| 18613 | if (p->error_indicator) { |
| 18614 | D(p->level--); |
| 18615 | return NULL; |
| 18616 | } |
| 18617 | void * _res = NULL; |
| 18618 | int _mark = p->mark; |
| 18619 | { // ASYNC? 'with' ','.(expression ['as' star_target])+ &&':' |
| 18620 | if (p->error_indicator) { |
| 18621 | D(p->level--); |
| 18622 | return NULL; |
| 18623 | } |
| 18624 | D(fprintf(stderr, "%*c> invalid_with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' ','.(expression ['as' star_target])+ &&':'")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18625 | asdl_seq * _gather_159_var; |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 18626 | Token * _keyword; |
| 18627 | Token * _literal; |
| 18628 | void *_opt_var; |
| 18629 | UNUSED(_opt_var); // Silence compiler warnings |
| 18630 | if ( |
| 18631 | (_opt_var = _PyPegen_expect_token(p, ASYNC), 1) // ASYNC? |
| 18632 | && |
| 18633 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
| 18634 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18635 | (_gather_159_var = _gather_159_rule(p)) // ','.(expression ['as' star_target])+ |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 18636 | && |
| 18637 | (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' |
| 18638 | ) |
| 18639 | { |
| 18640 | D(fprintf(stderr, "%*c+ invalid_with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' ','.(expression ['as' star_target])+ &&':'")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18641 | _res = _PyPegen_dummy_name(p, _opt_var, _keyword, _gather_159_var, _literal); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 18642 | goto done; |
| 18643 | } |
| 18644 | p->mark = _mark; |
| 18645 | D(fprintf(stderr, "%*c%s invalid_with_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 18646 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC? 'with' ','.(expression ['as' star_target])+ &&':'")); |
| 18647 | } |
| 18648 | { // ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' &&':' |
| 18649 | if (p->error_indicator) { |
| 18650 | D(p->level--); |
| 18651 | return NULL; |
| 18652 | } |
| 18653 | D(fprintf(stderr, "%*c> invalid_with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' &&':'")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18654 | asdl_seq * _gather_161_var; |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 18655 | Token * _keyword; |
| 18656 | Token * _literal; |
| 18657 | Token * _literal_1; |
| 18658 | Token * _literal_2; |
| 18659 | void *_opt_var; |
| 18660 | UNUSED(_opt_var); // Silence compiler warnings |
| 18661 | void *_opt_var_1; |
| 18662 | UNUSED(_opt_var_1); // Silence compiler warnings |
| 18663 | if ( |
| 18664 | (_opt_var = _PyPegen_expect_token(p, ASYNC), 1) // ASYNC? |
| 18665 | && |
| 18666 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
| 18667 | && |
| 18668 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 18669 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18670 | (_gather_161_var = _gather_161_rule(p)) // ','.(expressions ['as' star_target])+ |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 18671 | && |
| 18672 | (_opt_var_1 = _PyPegen_expect_token(p, 12), 1) // ','? |
| 18673 | && |
| 18674 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 18675 | && |
| 18676 | (_literal_2 = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' |
| 18677 | ) |
| 18678 | { |
| 18679 | D(fprintf(stderr, "%*c+ invalid_with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' &&':'")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18680 | _res = _PyPegen_dummy_name(p, _opt_var, _keyword, _literal, _gather_161_var, _opt_var_1, _literal_1, _literal_2); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 18681 | goto done; |
| 18682 | } |
| 18683 | p->mark = _mark; |
| 18684 | D(fprintf(stderr, "%*c%s invalid_with_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 18685 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC? 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' &&':'")); |
| 18686 | } |
| 18687 | _res = NULL; |
| 18688 | done: |
| 18689 | D(p->level--); |
| 18690 | return _res; |
| 18691 | } |
| 18692 | |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 18693 | // invalid_except_block: |
| 18694 | // | 'except' expression ',' expressions ['as' NAME] ':' |
| 18695 | // | 'except' expression ['as' NAME] &&':' |
| 18696 | // | 'except' &&':' |
| 18697 | static void * |
| 18698 | invalid_except_block_rule(Parser *p) |
| 18699 | { |
| 18700 | D(p->level++); |
| 18701 | if (p->error_indicator) { |
| 18702 | D(p->level--); |
| 18703 | return NULL; |
| 18704 | } |
| 18705 | void * _res = NULL; |
| 18706 | int _mark = p->mark; |
| 18707 | { // 'except' expression ',' expressions ['as' NAME] ':' |
| 18708 | if (p->error_indicator) { |
| 18709 | D(p->level--); |
| 18710 | return NULL; |
| 18711 | } |
| 18712 | D(fprintf(stderr, "%*c> invalid_except_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' expression ',' expressions ['as' NAME] ':'")); |
| 18713 | Token * _keyword; |
| 18714 | Token * _literal; |
| 18715 | Token * _literal_1; |
| 18716 | void *_opt_var; |
| 18717 | UNUSED(_opt_var); // Silence compiler warnings |
| 18718 | expr_ty a; |
| 18719 | expr_ty expressions_var; |
| 18720 | if ( |
| 18721 | (_keyword = _PyPegen_expect_token(p, 521)) // token='except' |
| 18722 | && |
| 18723 | (a = expression_rule(p)) // expression |
| 18724 | && |
| 18725 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 18726 | && |
| 18727 | (expressions_var = expressions_rule(p)) // expressions |
| 18728 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18729 | (_opt_var = _tmp_163_rule(p), 1) // ['as' NAME] |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 18730 | && |
| 18731 | (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' |
| 18732 | ) |
| 18733 | { |
| 18734 | D(fprintf(stderr, "%*c+ invalid_except_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression ',' expressions ['as' NAME] ':'")); |
| 18735 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "exception group must be parenthesized" ); |
| 18736 | if (_res == NULL && PyErr_Occurred()) { |
| 18737 | p->error_indicator = 1; |
| 18738 | D(p->level--); |
| 18739 | return NULL; |
| 18740 | } |
| 18741 | goto done; |
| 18742 | } |
| 18743 | p->mark = _mark; |
| 18744 | D(fprintf(stderr, "%*c%s invalid_except_block[%d-%d]: %s failed!\n", p->level, ' ', |
| 18745 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' expression ',' expressions ['as' NAME] ':'")); |
| 18746 | } |
| 18747 | { // 'except' expression ['as' NAME] &&':' |
| 18748 | if (p->error_indicator) { |
| 18749 | D(p->level--); |
| 18750 | return NULL; |
| 18751 | } |
| 18752 | D(fprintf(stderr, "%*c> invalid_except_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] &&':'")); |
| 18753 | Token * _keyword; |
| 18754 | Token * _literal; |
| 18755 | void *_opt_var; |
| 18756 | UNUSED(_opt_var); // Silence compiler warnings |
| 18757 | expr_ty expression_var; |
| 18758 | if ( |
| 18759 | (_keyword = _PyPegen_expect_token(p, 521)) // token='except' |
| 18760 | && |
| 18761 | (expression_var = expression_rule(p)) // expression |
| 18762 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18763 | (_opt_var = _tmp_164_rule(p), 1) // ['as' NAME] |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 18764 | && |
| 18765 | (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' |
| 18766 | ) |
| 18767 | { |
| 18768 | D(fprintf(stderr, "%*c+ invalid_except_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] &&':'")); |
| 18769 | _res = _PyPegen_dummy_name(p, _keyword, expression_var, _opt_var, _literal); |
| 18770 | goto done; |
| 18771 | } |
| 18772 | p->mark = _mark; |
| 18773 | D(fprintf(stderr, "%*c%s invalid_except_block[%d-%d]: %s failed!\n", p->level, ' ', |
| 18774 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' expression ['as' NAME] &&':'")); |
| 18775 | } |
| 18776 | { // 'except' &&':' |
| 18777 | if (p->error_indicator) { |
| 18778 | D(p->level--); |
| 18779 | return NULL; |
| 18780 | } |
| 18781 | D(fprintf(stderr, "%*c> invalid_except_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' &&':'")); |
| 18782 | Token * _keyword; |
| 18783 | Token * _literal; |
| 18784 | if ( |
| 18785 | (_keyword = _PyPegen_expect_token(p, 521)) // token='except' |
| 18786 | && |
| 18787 | (_literal = _PyPegen_expect_forced_token(p, 11, ":")) // forced_token=':' |
| 18788 | ) |
| 18789 | { |
| 18790 | D(fprintf(stderr, "%*c+ invalid_except_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' &&':'")); |
| 18791 | _res = _PyPegen_dummy_name(p, _keyword, _literal); |
| 18792 | goto done; |
| 18793 | } |
| 18794 | p->mark = _mark; |
| 18795 | D(fprintf(stderr, "%*c%s invalid_except_block[%d-%d]: %s failed!\n", p->level, ' ', |
| 18796 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' &&':'")); |
| 18797 | } |
| 18798 | _res = NULL; |
| 18799 | done: |
| 18800 | D(p->level--); |
| 18801 | return _res; |
| 18802 | } |
| 18803 | |
Pablo Galindo | 08fb8ac | 2021-03-18 01:03:11 +0000 | [diff] [blame] | 18804 | // invalid_match_stmt: "match" subject_expr !':' |
| 18805 | static void * |
| 18806 | invalid_match_stmt_rule(Parser *p) |
| 18807 | { |
| 18808 | D(p->level++); |
| 18809 | if (p->error_indicator) { |
| 18810 | D(p->level--); |
| 18811 | return NULL; |
| 18812 | } |
| 18813 | void * _res = NULL; |
| 18814 | int _mark = p->mark; |
| 18815 | { // "match" subject_expr !':' |
| 18816 | if (p->error_indicator) { |
| 18817 | D(p->level--); |
| 18818 | return NULL; |
| 18819 | } |
| 18820 | D(fprintf(stderr, "%*c> invalid_match_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"match\" subject_expr !':'")); |
| 18821 | expr_ty _keyword; |
| 18822 | expr_ty subject_expr_var; |
| 18823 | if ( |
| 18824 | (_keyword = _PyPegen_expect_soft_keyword(p, "match")) // soft_keyword='"match"' |
| 18825 | && |
| 18826 | (subject_expr_var = subject_expr_rule(p)) // subject_expr |
| 18827 | && |
| 18828 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 11) // token=':' |
| 18829 | ) |
| 18830 | { |
| 18831 | D(fprintf(stderr, "%*c+ invalid_match_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"match\" subject_expr !':'")); |
| 18832 | _res = CHECK_VERSION ( void * , 10 , "Pattern matching is" , RAISE_SYNTAX_ERROR ( "expected ':'" ) ); |
| 18833 | if (_res == NULL && PyErr_Occurred()) { |
| 18834 | p->error_indicator = 1; |
| 18835 | D(p->level--); |
| 18836 | return NULL; |
| 18837 | } |
| 18838 | goto done; |
| 18839 | } |
| 18840 | p->mark = _mark; |
| 18841 | D(fprintf(stderr, "%*c%s invalid_match_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 18842 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"match\" subject_expr !':'")); |
| 18843 | } |
| 18844 | _res = NULL; |
| 18845 | done: |
| 18846 | D(p->level--); |
| 18847 | return _res; |
| 18848 | } |
| 18849 | |
| 18850 | // invalid_case_block: "case" patterns guard? !':' |
| 18851 | static void * |
| 18852 | invalid_case_block_rule(Parser *p) |
| 18853 | { |
| 18854 | D(p->level++); |
| 18855 | if (p->error_indicator) { |
| 18856 | D(p->level--); |
| 18857 | return NULL; |
| 18858 | } |
| 18859 | void * _res = NULL; |
| 18860 | int _mark = p->mark; |
| 18861 | { // "case" patterns guard? !':' |
| 18862 | if (p->error_indicator) { |
| 18863 | D(p->level--); |
| 18864 | return NULL; |
| 18865 | } |
| 18866 | D(fprintf(stderr, "%*c> invalid_case_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? !':'")); |
| 18867 | expr_ty _keyword; |
| 18868 | void *_opt_var; |
| 18869 | UNUSED(_opt_var); // Silence compiler warnings |
| 18870 | expr_ty patterns_var; |
| 18871 | if ( |
| 18872 | (_keyword = _PyPegen_expect_soft_keyword(p, "case")) // soft_keyword='"case"' |
| 18873 | && |
| 18874 | (patterns_var = patterns_rule(p)) // patterns |
| 18875 | && |
| 18876 | (_opt_var = guard_rule(p), 1) // guard? |
| 18877 | && |
| 18878 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 11) // token=':' |
| 18879 | ) |
| 18880 | { |
| 18881 | D(fprintf(stderr, "%*c+ invalid_case_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "\"case\" patterns guard? !':'")); |
| 18882 | _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); |
| 18883 | if (_res == NULL && PyErr_Occurred()) { |
| 18884 | p->error_indicator = 1; |
| 18885 | D(p->level--); |
| 18886 | return NULL; |
| 18887 | } |
| 18888 | goto done; |
| 18889 | } |
| 18890 | p->mark = _mark; |
| 18891 | D(fprintf(stderr, "%*c%s invalid_case_block[%d-%d]: %s failed!\n", p->level, ' ', |
| 18892 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "\"case\" patterns guard? !':'")); |
| 18893 | } |
| 18894 | _res = NULL; |
| 18895 | done: |
| 18896 | D(p->level--); |
| 18897 | return _res; |
| 18898 | } |
| 18899 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 18900 | // invalid_if_stmt: 'if' named_expression NEWLINE |
| 18901 | static void * |
| 18902 | invalid_if_stmt_rule(Parser *p) |
| 18903 | { |
| 18904 | D(p->level++); |
| 18905 | if (p->error_indicator) { |
| 18906 | D(p->level--); |
| 18907 | return NULL; |
| 18908 | } |
| 18909 | void * _res = NULL; |
| 18910 | int _mark = p->mark; |
| 18911 | { // 'if' named_expression NEWLINE |
| 18912 | if (p->error_indicator) { |
| 18913 | D(p->level--); |
| 18914 | return NULL; |
| 18915 | } |
| 18916 | D(fprintf(stderr, "%*c> invalid_if_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression NEWLINE")); |
| 18917 | Token * _keyword; |
| 18918 | expr_ty named_expression_var; |
| 18919 | Token * newline_var; |
| 18920 | if ( |
| 18921 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
| 18922 | && |
| 18923 | (named_expression_var = named_expression_rule(p)) // named_expression |
| 18924 | && |
| 18925 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 18926 | ) |
| 18927 | { |
| 18928 | D(fprintf(stderr, "%*c+ invalid_if_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression NEWLINE")); |
| 18929 | _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); |
| 18930 | if (_res == NULL && PyErr_Occurred()) { |
| 18931 | p->error_indicator = 1; |
| 18932 | D(p->level--); |
| 18933 | return NULL; |
| 18934 | } |
| 18935 | goto done; |
| 18936 | } |
| 18937 | p->mark = _mark; |
| 18938 | D(fprintf(stderr, "%*c%s invalid_if_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 18939 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression NEWLINE")); |
| 18940 | } |
| 18941 | _res = NULL; |
| 18942 | done: |
| 18943 | D(p->level--); |
| 18944 | return _res; |
| 18945 | } |
| 18946 | |
| 18947 | // invalid_elif_stmt: 'elif' named_expression NEWLINE |
| 18948 | static void * |
| 18949 | invalid_elif_stmt_rule(Parser *p) |
| 18950 | { |
| 18951 | D(p->level++); |
| 18952 | if (p->error_indicator) { |
| 18953 | D(p->level--); |
| 18954 | return NULL; |
| 18955 | } |
| 18956 | void * _res = NULL; |
| 18957 | int _mark = p->mark; |
| 18958 | { // 'elif' named_expression NEWLINE |
| 18959 | if (p->error_indicator) { |
| 18960 | D(p->level--); |
| 18961 | return NULL; |
| 18962 | } |
| 18963 | D(fprintf(stderr, "%*c> invalid_elif_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'elif' named_expression NEWLINE")); |
| 18964 | Token * _keyword; |
| 18965 | expr_ty named_expression_var; |
| 18966 | Token * newline_var; |
| 18967 | if ( |
| 18968 | (_keyword = _PyPegen_expect_token(p, 515)) // token='elif' |
| 18969 | && |
| 18970 | (named_expression_var = named_expression_rule(p)) // named_expression |
| 18971 | && |
| 18972 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 18973 | ) |
| 18974 | { |
| 18975 | D(fprintf(stderr, "%*c+ invalid_elif_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'elif' named_expression NEWLINE")); |
| 18976 | _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); |
| 18977 | if (_res == NULL && PyErr_Occurred()) { |
| 18978 | p->error_indicator = 1; |
| 18979 | D(p->level--); |
| 18980 | return NULL; |
| 18981 | } |
| 18982 | goto done; |
| 18983 | } |
| 18984 | p->mark = _mark; |
| 18985 | D(fprintf(stderr, "%*c%s invalid_elif_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 18986 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'elif' named_expression NEWLINE")); |
| 18987 | } |
| 18988 | _res = NULL; |
| 18989 | done: |
| 18990 | D(p->level--); |
| 18991 | return _res; |
| 18992 | } |
| 18993 | |
| 18994 | // invalid_while_stmt: 'while' named_expression NEWLINE |
| 18995 | static void * |
| 18996 | invalid_while_stmt_rule(Parser *p) |
| 18997 | { |
| 18998 | D(p->level++); |
| 18999 | if (p->error_indicator) { |
| 19000 | D(p->level--); |
| 19001 | return NULL; |
| 19002 | } |
| 19003 | void * _res = NULL; |
| 19004 | int _mark = p->mark; |
| 19005 | { // 'while' named_expression NEWLINE |
| 19006 | if (p->error_indicator) { |
| 19007 | D(p->level--); |
| 19008 | return NULL; |
| 19009 | } |
| 19010 | D(fprintf(stderr, "%*c> invalid_while_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'while' named_expression NEWLINE")); |
| 19011 | Token * _keyword; |
| 19012 | expr_ty named_expression_var; |
| 19013 | Token * newline_var; |
| 19014 | if ( |
| 19015 | (_keyword = _PyPegen_expect_token(p, 512)) // token='while' |
| 19016 | && |
| 19017 | (named_expression_var = named_expression_rule(p)) // named_expression |
| 19018 | && |
| 19019 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 19020 | ) |
| 19021 | { |
| 19022 | D(fprintf(stderr, "%*c+ invalid_while_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'while' named_expression NEWLINE")); |
| 19023 | _res = RAISE_SYNTAX_ERROR ( "expected ':'" ); |
| 19024 | if (_res == NULL && PyErr_Occurred()) { |
| 19025 | p->error_indicator = 1; |
| 19026 | D(p->level--); |
| 19027 | return NULL; |
| 19028 | } |
| 19029 | goto done; |
| 19030 | } |
| 19031 | p->mark = _mark; |
| 19032 | D(fprintf(stderr, "%*c%s invalid_while_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 19033 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'while' named_expression NEWLINE")); |
| 19034 | } |
| 19035 | _res = NULL; |
| 19036 | done: |
| 19037 | D(p->level--); |
| 19038 | return _res; |
| 19039 | } |
| 19040 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19041 | // _loop0_1: NEWLINE |
| 19042 | static asdl_seq * |
| 19043 | _loop0_1_rule(Parser *p) |
| 19044 | { |
| 19045 | D(p->level++); |
| 19046 | if (p->error_indicator) { |
| 19047 | D(p->level--); |
| 19048 | return NULL; |
| 19049 | } |
| 19050 | void *_res = NULL; |
| 19051 | int _mark = p->mark; |
| 19052 | int _start_mark = p->mark; |
| 19053 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19054 | if (!_children) { |
| 19055 | p->error_indicator = 1; |
| 19056 | PyErr_NoMemory(); |
| 19057 | D(p->level--); |
| 19058 | return NULL; |
| 19059 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 19060 | Py_ssize_t _children_capacity = 1; |
| 19061 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19062 | { // NEWLINE |
| 19063 | if (p->error_indicator) { |
| 19064 | D(p->level--); |
| 19065 | return NULL; |
| 19066 | } |
| 19067 | D(fprintf(stderr, "%*c> _loop0_1[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); |
| 19068 | Token * newline_var; |
| 19069 | while ( |
| 19070 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 19071 | ) |
| 19072 | { |
| 19073 | _res = newline_var; |
| 19074 | if (_n == _children_capacity) { |
| 19075 | _children_capacity *= 2; |
| 19076 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19077 | if (!_new_children) { |
| 19078 | p->error_indicator = 1; |
| 19079 | PyErr_NoMemory(); |
| 19080 | D(p->level--); |
| 19081 | return NULL; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 19082 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19083 | _children = _new_children; |
| 19084 | } |
| 19085 | _children[_n++] = _res; |
| 19086 | _mark = p->mark; |
| 19087 | } |
| 19088 | p->mark = _mark; |
| 19089 | D(fprintf(stderr, "%*c%s _loop0_1[%d-%d]: %s failed!\n", p->level, ' ', |
| 19090 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); |
| 19091 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19092 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19093 | if (!_seq) { |
| 19094 | PyMem_Free(_children); |
| 19095 | p->error_indicator = 1; |
| 19096 | PyErr_NoMemory(); |
| 19097 | D(p->level--); |
| 19098 | return NULL; |
| 19099 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19100 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19101 | PyMem_Free(_children); |
| 19102 | _PyPegen_insert_memo(p, _start_mark, _loop0_1_type, _seq); |
| 19103 | D(p->level--); |
| 19104 | return _seq; |
| 19105 | } |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 19106 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19107 | // _loop0_2: NEWLINE |
| 19108 | static asdl_seq * |
| 19109 | _loop0_2_rule(Parser *p) |
| 19110 | { |
| 19111 | D(p->level++); |
| 19112 | if (p->error_indicator) { |
| 19113 | D(p->level--); |
| 19114 | return NULL; |
| 19115 | } |
| 19116 | void *_res = NULL; |
| 19117 | int _mark = p->mark; |
| 19118 | int _start_mark = p->mark; |
| 19119 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19120 | if (!_children) { |
| 19121 | p->error_indicator = 1; |
| 19122 | PyErr_NoMemory(); |
| 19123 | D(p->level--); |
| 19124 | return NULL; |
| 19125 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 19126 | Py_ssize_t _children_capacity = 1; |
| 19127 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19128 | { // NEWLINE |
| 19129 | if (p->error_indicator) { |
| 19130 | D(p->level--); |
| 19131 | return NULL; |
| 19132 | } |
| 19133 | D(fprintf(stderr, "%*c> _loop0_2[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); |
| 19134 | Token * newline_var; |
| 19135 | while ( |
| 19136 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 19137 | ) |
| 19138 | { |
| 19139 | _res = newline_var; |
| 19140 | if (_n == _children_capacity) { |
| 19141 | _children_capacity *= 2; |
| 19142 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19143 | if (!_new_children) { |
| 19144 | p->error_indicator = 1; |
| 19145 | PyErr_NoMemory(); |
| 19146 | D(p->level--); |
| 19147 | return NULL; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 19148 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19149 | _children = _new_children; |
| 19150 | } |
| 19151 | _children[_n++] = _res; |
| 19152 | _mark = p->mark; |
| 19153 | } |
| 19154 | p->mark = _mark; |
| 19155 | D(fprintf(stderr, "%*c%s _loop0_2[%d-%d]: %s failed!\n", p->level, ' ', |
| 19156 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); |
| 19157 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19158 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19159 | if (!_seq) { |
| 19160 | PyMem_Free(_children); |
| 19161 | p->error_indicator = 1; |
| 19162 | PyErr_NoMemory(); |
| 19163 | D(p->level--); |
| 19164 | return NULL; |
| 19165 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19166 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19167 | PyMem_Free(_children); |
| 19168 | _PyPegen_insert_memo(p, _start_mark, _loop0_2_type, _seq); |
| 19169 | D(p->level--); |
| 19170 | return _seq; |
| 19171 | } |
| 19172 | |
| 19173 | // _loop0_4: ',' expression |
| 19174 | static asdl_seq * |
| 19175 | _loop0_4_rule(Parser *p) |
| 19176 | { |
| 19177 | D(p->level++); |
| 19178 | if (p->error_indicator) { |
| 19179 | D(p->level--); |
| 19180 | return NULL; |
| 19181 | } |
| 19182 | void *_res = NULL; |
| 19183 | int _mark = p->mark; |
| 19184 | int _start_mark = p->mark; |
| 19185 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19186 | if (!_children) { |
| 19187 | p->error_indicator = 1; |
| 19188 | PyErr_NoMemory(); |
| 19189 | D(p->level--); |
| 19190 | return NULL; |
| 19191 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 19192 | Py_ssize_t _children_capacity = 1; |
| 19193 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19194 | { // ',' expression |
| 19195 | if (p->error_indicator) { |
| 19196 | D(p->level--); |
| 19197 | return NULL; |
| 19198 | } |
| 19199 | D(fprintf(stderr, "%*c> _loop0_4[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); |
| 19200 | Token * _literal; |
| 19201 | expr_ty elem; |
| 19202 | while ( |
| 19203 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 19204 | && |
| 19205 | (elem = expression_rule(p)) // expression |
| 19206 | ) |
| 19207 | { |
| 19208 | _res = elem; |
| 19209 | if (_res == NULL && PyErr_Occurred()) { |
| 19210 | p->error_indicator = 1; |
| 19211 | PyMem_Free(_children); |
| 19212 | D(p->level--); |
| 19213 | return NULL; |
| 19214 | } |
| 19215 | if (_n == _children_capacity) { |
| 19216 | _children_capacity *= 2; |
| 19217 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19218 | if (!_new_children) { |
| 19219 | p->error_indicator = 1; |
| 19220 | PyErr_NoMemory(); |
| 19221 | D(p->level--); |
| 19222 | return NULL; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 19223 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19224 | _children = _new_children; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 19225 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19226 | _children[_n++] = _res; |
| 19227 | _mark = p->mark; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 19228 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19229 | p->mark = _mark; |
| 19230 | D(fprintf(stderr, "%*c%s _loop0_4[%d-%d]: %s failed!\n", p->level, ' ', |
| 19231 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 19232 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19233 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19234 | if (!_seq) { |
| 19235 | PyMem_Free(_children); |
| 19236 | p->error_indicator = 1; |
| 19237 | PyErr_NoMemory(); |
| 19238 | D(p->level--); |
| 19239 | return NULL; |
| 19240 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19241 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19242 | PyMem_Free(_children); |
| 19243 | _PyPegen_insert_memo(p, _start_mark, _loop0_4_type, _seq); |
| 19244 | D(p->level--); |
| 19245 | return _seq; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19246 | } |
| 19247 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19248 | // _gather_3: expression _loop0_4 |
| 19249 | static asdl_seq * |
| 19250 | _gather_3_rule(Parser *p) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19251 | { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19252 | D(p->level++); |
| 19253 | if (p->error_indicator) { |
| 19254 | D(p->level--); |
| 19255 | return NULL; |
| 19256 | } |
| 19257 | asdl_seq * _res = NULL; |
| 19258 | int _mark = p->mark; |
| 19259 | { // expression _loop0_4 |
| 19260 | if (p->error_indicator) { |
| 19261 | D(p->level--); |
| 19262 | return NULL; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 19263 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19264 | D(fprintf(stderr, "%*c> _gather_3[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_4")); |
| 19265 | expr_ty elem; |
| 19266 | asdl_seq * seq; |
| 19267 | if ( |
| 19268 | (elem = expression_rule(p)) // expression |
| 19269 | && |
| 19270 | (seq = _loop0_4_rule(p)) // _loop0_4 |
| 19271 | ) |
| 19272 | { |
| 19273 | D(fprintf(stderr, "%*c+ _gather_3[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_4")); |
| 19274 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 19275 | goto done; |
| 19276 | } |
| 19277 | p->mark = _mark; |
| 19278 | D(fprintf(stderr, "%*c%s _gather_3[%d-%d]: %s failed!\n", p->level, ' ', |
| 19279 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_4")); |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 19280 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19281 | _res = NULL; |
| 19282 | done: |
| 19283 | D(p->level--); |
| 19284 | return _res; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19285 | } |
| 19286 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19287 | // _loop0_6: ',' expression |
| 19288 | static asdl_seq * |
| 19289 | _loop0_6_rule(Parser *p) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19290 | { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19291 | D(p->level++); |
| 19292 | if (p->error_indicator) { |
| 19293 | D(p->level--); |
| 19294 | return NULL; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 19295 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19296 | void *_res = NULL; |
| 19297 | int _mark = p->mark; |
| 19298 | int _start_mark = p->mark; |
| 19299 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19300 | if (!_children) { |
| 19301 | p->error_indicator = 1; |
| 19302 | PyErr_NoMemory(); |
| 19303 | D(p->level--); |
| 19304 | return NULL; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 19305 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 19306 | Py_ssize_t _children_capacity = 1; |
| 19307 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19308 | { // ',' expression |
| 19309 | if (p->error_indicator) { |
| 19310 | D(p->level--); |
| 19311 | return NULL; |
| 19312 | } |
| 19313 | D(fprintf(stderr, "%*c> _loop0_6[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); |
| 19314 | Token * _literal; |
| 19315 | expr_ty elem; |
| 19316 | while ( |
| 19317 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 19318 | && |
| 19319 | (elem = expression_rule(p)) // expression |
| 19320 | ) |
| 19321 | { |
| 19322 | _res = elem; |
| 19323 | if (_res == NULL && PyErr_Occurred()) { |
| 19324 | p->error_indicator = 1; |
| 19325 | PyMem_Free(_children); |
| 19326 | D(p->level--); |
| 19327 | return NULL; |
| 19328 | } |
| 19329 | if (_n == _children_capacity) { |
| 19330 | _children_capacity *= 2; |
| 19331 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19332 | if (!_new_children) { |
| 19333 | p->error_indicator = 1; |
| 19334 | PyErr_NoMemory(); |
| 19335 | D(p->level--); |
| 19336 | return NULL; |
| 19337 | } |
| 19338 | _children = _new_children; |
| 19339 | } |
| 19340 | _children[_n++] = _res; |
| 19341 | _mark = p->mark; |
| 19342 | } |
| 19343 | p->mark = _mark; |
| 19344 | D(fprintf(stderr, "%*c%s _loop0_6[%d-%d]: %s failed!\n", p->level, ' ', |
| 19345 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); |
| 19346 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19347 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19348 | if (!_seq) { |
| 19349 | PyMem_Free(_children); |
| 19350 | p->error_indicator = 1; |
| 19351 | PyErr_NoMemory(); |
| 19352 | D(p->level--); |
| 19353 | return NULL; |
| 19354 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19355 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19356 | PyMem_Free(_children); |
| 19357 | _PyPegen_insert_memo(p, _start_mark, _loop0_6_type, _seq); |
| 19358 | D(p->level--); |
| 19359 | return _seq; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19360 | } |
| 19361 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19362 | // _gather_5: expression _loop0_6 |
| 19363 | static asdl_seq * |
| 19364 | _gather_5_rule(Parser *p) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19365 | { |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19366 | D(p->level++); |
| 19367 | if (p->error_indicator) { |
| 19368 | D(p->level--); |
| 19369 | return NULL; |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 19370 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19371 | asdl_seq * _res = NULL; |
| 19372 | int _mark = p->mark; |
| 19373 | { // expression _loop0_6 |
| 19374 | if (p->error_indicator) { |
| 19375 | D(p->level--); |
| 19376 | return NULL; |
| 19377 | } |
| 19378 | D(fprintf(stderr, "%*c> _gather_5[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_6")); |
| 19379 | expr_ty elem; |
| 19380 | asdl_seq * seq; |
| 19381 | if ( |
| 19382 | (elem = expression_rule(p)) // expression |
| 19383 | && |
| 19384 | (seq = _loop0_6_rule(p)) // _loop0_6 |
| 19385 | ) |
| 19386 | { |
| 19387 | D(fprintf(stderr, "%*c+ _gather_5[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_6")); |
| 19388 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 19389 | goto done; |
| 19390 | } |
| 19391 | p->mark = _mark; |
| 19392 | D(fprintf(stderr, "%*c%s _gather_5[%d-%d]: %s failed!\n", p->level, ' ', |
| 19393 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_6")); |
| 19394 | } |
| 19395 | _res = NULL; |
| 19396 | done: |
| 19397 | D(p->level--); |
| 19398 | return _res; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19399 | } |
| 19400 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19401 | // _loop0_8: ',' expression |
| 19402 | static asdl_seq * |
| 19403 | _loop0_8_rule(Parser *p) |
| 19404 | { |
| 19405 | D(p->level++); |
| 19406 | if (p->error_indicator) { |
| 19407 | D(p->level--); |
| 19408 | return NULL; |
| 19409 | } |
| 19410 | void *_res = NULL; |
| 19411 | int _mark = p->mark; |
| 19412 | int _start_mark = p->mark; |
| 19413 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19414 | if (!_children) { |
| 19415 | p->error_indicator = 1; |
| 19416 | PyErr_NoMemory(); |
| 19417 | D(p->level--); |
| 19418 | return NULL; |
| 19419 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 19420 | Py_ssize_t _children_capacity = 1; |
| 19421 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19422 | { // ',' expression |
| 19423 | if (p->error_indicator) { |
| 19424 | D(p->level--); |
| 19425 | return NULL; |
| 19426 | } |
| 19427 | D(fprintf(stderr, "%*c> _loop0_8[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); |
| 19428 | Token * _literal; |
| 19429 | expr_ty elem; |
| 19430 | while ( |
| 19431 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 19432 | && |
| 19433 | (elem = expression_rule(p)) // expression |
| 19434 | ) |
| 19435 | { |
| 19436 | _res = elem; |
| 19437 | if (_res == NULL && PyErr_Occurred()) { |
| 19438 | p->error_indicator = 1; |
| 19439 | PyMem_Free(_children); |
| 19440 | D(p->level--); |
| 19441 | return NULL; |
| 19442 | } |
| 19443 | if (_n == _children_capacity) { |
| 19444 | _children_capacity *= 2; |
| 19445 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19446 | if (!_new_children) { |
| 19447 | p->error_indicator = 1; |
| 19448 | PyErr_NoMemory(); |
| 19449 | D(p->level--); |
| 19450 | return NULL; |
| 19451 | } |
| 19452 | _children = _new_children; |
| 19453 | } |
| 19454 | _children[_n++] = _res; |
| 19455 | _mark = p->mark; |
| 19456 | } |
| 19457 | p->mark = _mark; |
| 19458 | D(fprintf(stderr, "%*c%s _loop0_8[%d-%d]: %s failed!\n", p->level, ' ', |
| 19459 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); |
| 19460 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19461 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19462 | if (!_seq) { |
| 19463 | PyMem_Free(_children); |
| 19464 | p->error_indicator = 1; |
| 19465 | PyErr_NoMemory(); |
| 19466 | D(p->level--); |
| 19467 | return NULL; |
| 19468 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19469 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19470 | PyMem_Free(_children); |
| 19471 | _PyPegen_insert_memo(p, _start_mark, _loop0_8_type, _seq); |
| 19472 | D(p->level--); |
| 19473 | return _seq; |
| 19474 | } |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19475 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19476 | // _gather_7: expression _loop0_8 |
| 19477 | static asdl_seq * |
| 19478 | _gather_7_rule(Parser *p) |
| 19479 | { |
| 19480 | D(p->level++); |
| 19481 | if (p->error_indicator) { |
| 19482 | D(p->level--); |
| 19483 | return NULL; |
| 19484 | } |
| 19485 | asdl_seq * _res = NULL; |
| 19486 | int _mark = p->mark; |
| 19487 | { // expression _loop0_8 |
| 19488 | if (p->error_indicator) { |
| 19489 | D(p->level--); |
| 19490 | return NULL; |
| 19491 | } |
| 19492 | D(fprintf(stderr, "%*c> _gather_7[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_8")); |
| 19493 | expr_ty elem; |
| 19494 | asdl_seq * seq; |
| 19495 | if ( |
| 19496 | (elem = expression_rule(p)) // expression |
| 19497 | && |
| 19498 | (seq = _loop0_8_rule(p)) // _loop0_8 |
| 19499 | ) |
| 19500 | { |
| 19501 | D(fprintf(stderr, "%*c+ _gather_7[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_8")); |
| 19502 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 19503 | goto done; |
| 19504 | } |
| 19505 | p->mark = _mark; |
| 19506 | D(fprintf(stderr, "%*c%s _gather_7[%d-%d]: %s failed!\n", p->level, ' ', |
| 19507 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_8")); |
| 19508 | } |
| 19509 | _res = NULL; |
| 19510 | done: |
| 19511 | D(p->level--); |
| 19512 | return _res; |
| 19513 | } |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19514 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19515 | // _loop0_10: ',' expression |
| 19516 | static asdl_seq * |
| 19517 | _loop0_10_rule(Parser *p) |
| 19518 | { |
| 19519 | D(p->level++); |
| 19520 | if (p->error_indicator) { |
| 19521 | D(p->level--); |
| 19522 | return NULL; |
| 19523 | } |
| 19524 | void *_res = NULL; |
| 19525 | int _mark = p->mark; |
| 19526 | int _start_mark = p->mark; |
| 19527 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19528 | if (!_children) { |
| 19529 | p->error_indicator = 1; |
| 19530 | PyErr_NoMemory(); |
| 19531 | D(p->level--); |
| 19532 | return NULL; |
| 19533 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 19534 | Py_ssize_t _children_capacity = 1; |
| 19535 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19536 | { // ',' expression |
| 19537 | if (p->error_indicator) { |
| 19538 | D(p->level--); |
| 19539 | return NULL; |
| 19540 | } |
| 19541 | D(fprintf(stderr, "%*c> _loop0_10[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); |
| 19542 | Token * _literal; |
| 19543 | expr_ty elem; |
| 19544 | while ( |
| 19545 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 19546 | && |
| 19547 | (elem = expression_rule(p)) // expression |
| 19548 | ) |
| 19549 | { |
| 19550 | _res = elem; |
| 19551 | if (_res == NULL && PyErr_Occurred()) { |
| 19552 | p->error_indicator = 1; |
| 19553 | PyMem_Free(_children); |
| 19554 | D(p->level--); |
| 19555 | return NULL; |
| 19556 | } |
| 19557 | if (_n == _children_capacity) { |
| 19558 | _children_capacity *= 2; |
| 19559 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19560 | if (!_new_children) { |
| 19561 | p->error_indicator = 1; |
| 19562 | PyErr_NoMemory(); |
| 19563 | D(p->level--); |
| 19564 | return NULL; |
| 19565 | } |
| 19566 | _children = _new_children; |
| 19567 | } |
| 19568 | _children[_n++] = _res; |
| 19569 | _mark = p->mark; |
| 19570 | } |
| 19571 | p->mark = _mark; |
| 19572 | D(fprintf(stderr, "%*c%s _loop0_10[%d-%d]: %s failed!\n", p->level, ' ', |
| 19573 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); |
| 19574 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19575 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19576 | if (!_seq) { |
| 19577 | PyMem_Free(_children); |
| 19578 | p->error_indicator = 1; |
| 19579 | PyErr_NoMemory(); |
| 19580 | D(p->level--); |
| 19581 | return NULL; |
| 19582 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19583 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19584 | PyMem_Free(_children); |
| 19585 | _PyPegen_insert_memo(p, _start_mark, _loop0_10_type, _seq); |
| 19586 | D(p->level--); |
| 19587 | return _seq; |
| 19588 | } |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19589 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19590 | // _gather_9: expression _loop0_10 |
| 19591 | static asdl_seq * |
| 19592 | _gather_9_rule(Parser *p) |
| 19593 | { |
| 19594 | D(p->level++); |
| 19595 | if (p->error_indicator) { |
| 19596 | D(p->level--); |
| 19597 | return NULL; |
| 19598 | } |
| 19599 | asdl_seq * _res = NULL; |
| 19600 | int _mark = p->mark; |
| 19601 | { // expression _loop0_10 |
| 19602 | if (p->error_indicator) { |
| 19603 | D(p->level--); |
| 19604 | return NULL; |
| 19605 | } |
| 19606 | D(fprintf(stderr, "%*c> _gather_9[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_10")); |
| 19607 | expr_ty elem; |
| 19608 | asdl_seq * seq; |
| 19609 | if ( |
| 19610 | (elem = expression_rule(p)) // expression |
| 19611 | && |
| 19612 | (seq = _loop0_10_rule(p)) // _loop0_10 |
| 19613 | ) |
| 19614 | { |
| 19615 | D(fprintf(stderr, "%*c+ _gather_9[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_10")); |
| 19616 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 19617 | goto done; |
| 19618 | } |
| 19619 | p->mark = _mark; |
| 19620 | D(fprintf(stderr, "%*c%s _gather_9[%d-%d]: %s failed!\n", p->level, ' ', |
| 19621 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_10")); |
| 19622 | } |
| 19623 | _res = NULL; |
| 19624 | done: |
| 19625 | D(p->level--); |
| 19626 | return _res; |
| 19627 | } |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19628 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19629 | // _loop1_11: statement |
| 19630 | static asdl_seq * |
| 19631 | _loop1_11_rule(Parser *p) |
| 19632 | { |
| 19633 | D(p->level++); |
| 19634 | if (p->error_indicator) { |
| 19635 | D(p->level--); |
| 19636 | return NULL; |
| 19637 | } |
| 19638 | void *_res = NULL; |
| 19639 | int _mark = p->mark; |
| 19640 | int _start_mark = p->mark; |
| 19641 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19642 | if (!_children) { |
| 19643 | p->error_indicator = 1; |
| 19644 | PyErr_NoMemory(); |
| 19645 | D(p->level--); |
| 19646 | return NULL; |
| 19647 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 19648 | Py_ssize_t _children_capacity = 1; |
| 19649 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19650 | { // statement |
| 19651 | if (p->error_indicator) { |
| 19652 | D(p->level--); |
| 19653 | return NULL; |
| 19654 | } |
| 19655 | D(fprintf(stderr, "%*c> _loop1_11[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement")); |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19656 | asdl_stmt_seq* statement_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19657 | while ( |
| 19658 | (statement_var = statement_rule(p)) // statement |
| 19659 | ) |
| 19660 | { |
| 19661 | _res = statement_var; |
| 19662 | if (_n == _children_capacity) { |
| 19663 | _children_capacity *= 2; |
| 19664 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19665 | if (!_new_children) { |
| 19666 | p->error_indicator = 1; |
| 19667 | PyErr_NoMemory(); |
| 19668 | D(p->level--); |
| 19669 | return NULL; |
| 19670 | } |
| 19671 | _children = _new_children; |
| 19672 | } |
| 19673 | _children[_n++] = _res; |
| 19674 | _mark = p->mark; |
| 19675 | } |
| 19676 | p->mark = _mark; |
| 19677 | D(fprintf(stderr, "%*c%s _loop1_11[%d-%d]: %s failed!\n", p->level, ' ', |
| 19678 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement")); |
| 19679 | } |
| 19680 | if (_n == 0 || p->error_indicator) { |
| 19681 | PyMem_Free(_children); |
| 19682 | D(p->level--); |
| 19683 | return NULL; |
| 19684 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19685 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19686 | if (!_seq) { |
| 19687 | PyMem_Free(_children); |
| 19688 | p->error_indicator = 1; |
| 19689 | PyErr_NoMemory(); |
| 19690 | D(p->level--); |
| 19691 | return NULL; |
| 19692 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19693 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19694 | PyMem_Free(_children); |
| 19695 | _PyPegen_insert_memo(p, _start_mark, _loop1_11_type, _seq); |
| 19696 | D(p->level--); |
| 19697 | return _seq; |
| 19698 | } |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19699 | |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 19700 | // _loop0_13: ';' simple_stmt |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19701 | static asdl_seq * |
| 19702 | _loop0_13_rule(Parser *p) |
| 19703 | { |
| 19704 | D(p->level++); |
| 19705 | if (p->error_indicator) { |
| 19706 | D(p->level--); |
| 19707 | return NULL; |
| 19708 | } |
| 19709 | void *_res = NULL; |
| 19710 | int _mark = p->mark; |
| 19711 | int _start_mark = p->mark; |
| 19712 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19713 | if (!_children) { |
| 19714 | p->error_indicator = 1; |
| 19715 | PyErr_NoMemory(); |
| 19716 | D(p->level--); |
| 19717 | return NULL; |
| 19718 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 19719 | Py_ssize_t _children_capacity = 1; |
| 19720 | Py_ssize_t _n = 0; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 19721 | { // ';' simple_stmt |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19722 | if (p->error_indicator) { |
| 19723 | D(p->level--); |
| 19724 | return NULL; |
| 19725 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 19726 | D(fprintf(stderr, "%*c> _loop0_13[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';' simple_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19727 | Token * _literal; |
| 19728 | stmt_ty elem; |
| 19729 | while ( |
| 19730 | (_literal = _PyPegen_expect_token(p, 13)) // token=';' |
| 19731 | && |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 19732 | (elem = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19733 | ) |
| 19734 | { |
| 19735 | _res = elem; |
| 19736 | if (_res == NULL && PyErr_Occurred()) { |
| 19737 | p->error_indicator = 1; |
| 19738 | PyMem_Free(_children); |
| 19739 | D(p->level--); |
| 19740 | return NULL; |
| 19741 | } |
| 19742 | if (_n == _children_capacity) { |
| 19743 | _children_capacity *= 2; |
| 19744 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19745 | if (!_new_children) { |
| 19746 | p->error_indicator = 1; |
| 19747 | PyErr_NoMemory(); |
| 19748 | D(p->level--); |
| 19749 | return NULL; |
| 19750 | } |
| 19751 | _children = _new_children; |
| 19752 | } |
| 19753 | _children[_n++] = _res; |
| 19754 | _mark = p->mark; |
| 19755 | } |
| 19756 | p->mark = _mark; |
| 19757 | D(fprintf(stderr, "%*c%s _loop0_13[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 19758 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';' simple_stmt")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19759 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19760 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19761 | if (!_seq) { |
| 19762 | PyMem_Free(_children); |
| 19763 | p->error_indicator = 1; |
| 19764 | PyErr_NoMemory(); |
| 19765 | D(p->level--); |
| 19766 | return NULL; |
| 19767 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 19768 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19769 | PyMem_Free(_children); |
| 19770 | _PyPegen_insert_memo(p, _start_mark, _loop0_13_type, _seq); |
| 19771 | D(p->level--); |
| 19772 | return _seq; |
| 19773 | } |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19774 | |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 19775 | // _gather_12: simple_stmt _loop0_13 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19776 | static asdl_seq * |
| 19777 | _gather_12_rule(Parser *p) |
| 19778 | { |
| 19779 | D(p->level++); |
| 19780 | if (p->error_indicator) { |
| 19781 | D(p->level--); |
| 19782 | return NULL; |
| 19783 | } |
| 19784 | asdl_seq * _res = NULL; |
| 19785 | int _mark = p->mark; |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 19786 | { // simple_stmt _loop0_13 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19787 | if (p->error_indicator) { |
| 19788 | D(p->level--); |
| 19789 | return NULL; |
| 19790 | } |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 19791 | D(fprintf(stderr, "%*c> _gather_12[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt _loop0_13")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19792 | stmt_ty elem; |
| 19793 | asdl_seq * seq; |
| 19794 | if ( |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 19795 | (elem = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19796 | && |
| 19797 | (seq = _loop0_13_rule(p)) // _loop0_13 |
| 19798 | ) |
| 19799 | { |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 19800 | D(fprintf(stderr, "%*c+ _gather_12[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt _loop0_13")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19801 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 19802 | goto done; |
| 19803 | } |
| 19804 | p->mark = _mark; |
| 19805 | D(fprintf(stderr, "%*c%s _gather_12[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 9bdc40e | 2020-11-30 19:42:38 +0000 | [diff] [blame] | 19806 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt _loop0_13")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19807 | } |
| 19808 | _res = NULL; |
| 19809 | done: |
| 19810 | D(p->level--); |
| 19811 | return _res; |
| 19812 | } |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19813 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19814 | // _tmp_14: 'import' | 'from' |
| 19815 | static void * |
| 19816 | _tmp_14_rule(Parser *p) |
| 19817 | { |
| 19818 | D(p->level++); |
| 19819 | if (p->error_indicator) { |
| 19820 | D(p->level--); |
| 19821 | return NULL; |
| 19822 | } |
| 19823 | void * _res = NULL; |
| 19824 | int _mark = p->mark; |
| 19825 | { // 'import' |
| 19826 | if (p->error_indicator) { |
| 19827 | D(p->level--); |
| 19828 | return NULL; |
| 19829 | } |
| 19830 | D(fprintf(stderr, "%*c> _tmp_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import'")); |
| 19831 | Token * _keyword; |
| 19832 | if ( |
| 19833 | (_keyword = _PyPegen_expect_token(p, 513)) // token='import' |
| 19834 | ) |
| 19835 | { |
| 19836 | D(fprintf(stderr, "%*c+ _tmp_14[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import'")); |
| 19837 | _res = _keyword; |
| 19838 | goto done; |
| 19839 | } |
| 19840 | p->mark = _mark; |
| 19841 | D(fprintf(stderr, "%*c%s _tmp_14[%d-%d]: %s failed!\n", p->level, ' ', |
| 19842 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import'")); |
| 19843 | } |
| 19844 | { // 'from' |
| 19845 | if (p->error_indicator) { |
| 19846 | D(p->level--); |
| 19847 | return NULL; |
| 19848 | } |
| 19849 | D(fprintf(stderr, "%*c> _tmp_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from'")); |
| 19850 | Token * _keyword; |
| 19851 | if ( |
| 19852 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
| 19853 | ) |
| 19854 | { |
| 19855 | D(fprintf(stderr, "%*c+ _tmp_14[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from'")); |
| 19856 | _res = _keyword; |
| 19857 | goto done; |
| 19858 | } |
| 19859 | p->mark = _mark; |
| 19860 | D(fprintf(stderr, "%*c%s _tmp_14[%d-%d]: %s failed!\n", p->level, ' ', |
| 19861 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from'")); |
| 19862 | } |
| 19863 | _res = NULL; |
| 19864 | done: |
| 19865 | D(p->level--); |
| 19866 | return _res; |
| 19867 | } |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19868 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19869 | // _tmp_15: 'def' | '@' | ASYNC |
| 19870 | static void * |
| 19871 | _tmp_15_rule(Parser *p) |
| 19872 | { |
| 19873 | D(p->level++); |
| 19874 | if (p->error_indicator) { |
| 19875 | D(p->level--); |
| 19876 | return NULL; |
| 19877 | } |
| 19878 | void * _res = NULL; |
| 19879 | int _mark = p->mark; |
| 19880 | { // 'def' |
| 19881 | if (p->error_indicator) { |
| 19882 | D(p->level--); |
| 19883 | return NULL; |
| 19884 | } |
| 19885 | D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def'")); |
| 19886 | Token * _keyword; |
| 19887 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 19888 | (_keyword = _PyPegen_expect_token(p, 526)) // token='def' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19889 | ) |
| 19890 | { |
| 19891 | D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def'")); |
| 19892 | _res = _keyword; |
| 19893 | goto done; |
| 19894 | } |
| 19895 | p->mark = _mark; |
| 19896 | D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', |
| 19897 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def'")); |
| 19898 | } |
| 19899 | { // '@' |
| 19900 | if (p->error_indicator) { |
| 19901 | D(p->level--); |
| 19902 | return NULL; |
| 19903 | } |
| 19904 | D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'")); |
| 19905 | Token * _literal; |
| 19906 | if ( |
| 19907 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
| 19908 | ) |
| 19909 | { |
| 19910 | D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'")); |
| 19911 | _res = _literal; |
| 19912 | goto done; |
| 19913 | } |
| 19914 | p->mark = _mark; |
| 19915 | D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', |
| 19916 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'")); |
| 19917 | } |
| 19918 | { // ASYNC |
| 19919 | if (p->error_indicator) { |
| 19920 | D(p->level--); |
| 19921 | return NULL; |
| 19922 | } |
| 19923 | D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC")); |
| 19924 | Token * async_var; |
| 19925 | if ( |
| 19926 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
| 19927 | ) |
| 19928 | { |
| 19929 | D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC")); |
| 19930 | _res = async_var; |
| 19931 | goto done; |
| 19932 | } |
| 19933 | p->mark = _mark; |
| 19934 | D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', |
| 19935 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC")); |
| 19936 | } |
| 19937 | _res = NULL; |
| 19938 | done: |
| 19939 | D(p->level--); |
| 19940 | return _res; |
| 19941 | } |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19942 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19943 | // _tmp_16: 'class' | '@' |
| 19944 | static void * |
| 19945 | _tmp_16_rule(Parser *p) |
| 19946 | { |
| 19947 | D(p->level++); |
| 19948 | if (p->error_indicator) { |
| 19949 | D(p->level--); |
| 19950 | return NULL; |
| 19951 | } |
| 19952 | void * _res = NULL; |
| 19953 | int _mark = p->mark; |
| 19954 | { // 'class' |
| 19955 | if (p->error_indicator) { |
| 19956 | D(p->level--); |
| 19957 | return NULL; |
| 19958 | } |
| 19959 | D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class'")); |
| 19960 | Token * _keyword; |
| 19961 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 19962 | (_keyword = _PyPegen_expect_token(p, 527)) // token='class' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19963 | ) |
| 19964 | { |
| 19965 | D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class'")); |
| 19966 | _res = _keyword; |
| 19967 | goto done; |
| 19968 | } |
| 19969 | p->mark = _mark; |
| 19970 | D(fprintf(stderr, "%*c%s _tmp_16[%d-%d]: %s failed!\n", p->level, ' ', |
| 19971 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class'")); |
| 19972 | } |
| 19973 | { // '@' |
| 19974 | if (p->error_indicator) { |
| 19975 | D(p->level--); |
| 19976 | return NULL; |
| 19977 | } |
| 19978 | D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'")); |
| 19979 | Token * _literal; |
| 19980 | if ( |
| 19981 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
| 19982 | ) |
| 19983 | { |
| 19984 | D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'")); |
| 19985 | _res = _literal; |
| 19986 | goto done; |
| 19987 | } |
| 19988 | p->mark = _mark; |
| 19989 | D(fprintf(stderr, "%*c%s _tmp_16[%d-%d]: %s failed!\n", p->level, ' ', |
| 19990 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'")); |
| 19991 | } |
| 19992 | _res = NULL; |
| 19993 | done: |
| 19994 | D(p->level--); |
| 19995 | return _res; |
| 19996 | } |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 19997 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 19998 | // _tmp_17: 'with' | ASYNC |
| 19999 | static void * |
| 20000 | _tmp_17_rule(Parser *p) |
| 20001 | { |
| 20002 | D(p->level++); |
| 20003 | if (p->error_indicator) { |
| 20004 | D(p->level--); |
| 20005 | return NULL; |
| 20006 | } |
| 20007 | void * _res = NULL; |
| 20008 | int _mark = p->mark; |
| 20009 | { // 'with' |
| 20010 | if (p->error_indicator) { |
| 20011 | D(p->level--); |
| 20012 | return NULL; |
| 20013 | } |
| 20014 | D(fprintf(stderr, "%*c> _tmp_17[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with'")); |
| 20015 | Token * _keyword; |
| 20016 | if ( |
| 20017 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
| 20018 | ) |
| 20019 | { |
| 20020 | D(fprintf(stderr, "%*c+ _tmp_17[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with'")); |
| 20021 | _res = _keyword; |
| 20022 | goto done; |
| 20023 | } |
| 20024 | p->mark = _mark; |
| 20025 | D(fprintf(stderr, "%*c%s _tmp_17[%d-%d]: %s failed!\n", p->level, ' ', |
| 20026 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with'")); |
| 20027 | } |
| 20028 | { // ASYNC |
| 20029 | if (p->error_indicator) { |
| 20030 | D(p->level--); |
| 20031 | return NULL; |
| 20032 | } |
| 20033 | D(fprintf(stderr, "%*c> _tmp_17[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC")); |
| 20034 | Token * async_var; |
| 20035 | if ( |
| 20036 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
| 20037 | ) |
| 20038 | { |
| 20039 | D(fprintf(stderr, "%*c+ _tmp_17[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC")); |
| 20040 | _res = async_var; |
| 20041 | goto done; |
| 20042 | } |
| 20043 | p->mark = _mark; |
| 20044 | D(fprintf(stderr, "%*c%s _tmp_17[%d-%d]: %s failed!\n", p->level, ' ', |
| 20045 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC")); |
| 20046 | } |
| 20047 | _res = NULL; |
| 20048 | done: |
| 20049 | D(p->level--); |
| 20050 | return _res; |
| 20051 | } |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 20052 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20053 | // _tmp_18: 'for' | ASYNC |
| 20054 | static void * |
| 20055 | _tmp_18_rule(Parser *p) |
| 20056 | { |
| 20057 | D(p->level++); |
| 20058 | if (p->error_indicator) { |
| 20059 | D(p->level--); |
| 20060 | return NULL; |
| 20061 | } |
| 20062 | void * _res = NULL; |
| 20063 | int _mark = p->mark; |
| 20064 | { // 'for' |
| 20065 | if (p->error_indicator) { |
| 20066 | D(p->level--); |
| 20067 | return NULL; |
| 20068 | } |
| 20069 | D(fprintf(stderr, "%*c> _tmp_18[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for'")); |
| 20070 | Token * _keyword; |
| 20071 | if ( |
| 20072 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
| 20073 | ) |
| 20074 | { |
| 20075 | D(fprintf(stderr, "%*c+ _tmp_18[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for'")); |
| 20076 | _res = _keyword; |
| 20077 | goto done; |
| 20078 | } |
| 20079 | p->mark = _mark; |
| 20080 | D(fprintf(stderr, "%*c%s _tmp_18[%d-%d]: %s failed!\n", p->level, ' ', |
| 20081 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for'")); |
| 20082 | } |
| 20083 | { // ASYNC |
| 20084 | if (p->error_indicator) { |
| 20085 | D(p->level--); |
| 20086 | return NULL; |
| 20087 | } |
| 20088 | D(fprintf(stderr, "%*c> _tmp_18[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC")); |
| 20089 | Token * async_var; |
| 20090 | if ( |
| 20091 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
| 20092 | ) |
| 20093 | { |
| 20094 | D(fprintf(stderr, "%*c+ _tmp_18[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC")); |
| 20095 | _res = async_var; |
| 20096 | goto done; |
| 20097 | } |
| 20098 | p->mark = _mark; |
| 20099 | D(fprintf(stderr, "%*c%s _tmp_18[%d-%d]: %s failed!\n", p->level, ' ', |
| 20100 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC")); |
| 20101 | } |
| 20102 | _res = NULL; |
| 20103 | done: |
| 20104 | D(p->level--); |
| 20105 | return _res; |
| 20106 | } |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 20107 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20108 | // _tmp_19: '=' annotated_rhs |
| 20109 | static void * |
| 20110 | _tmp_19_rule(Parser *p) |
| 20111 | { |
| 20112 | D(p->level++); |
| 20113 | if (p->error_indicator) { |
| 20114 | D(p->level--); |
| 20115 | return NULL; |
| 20116 | } |
| 20117 | void * _res = NULL; |
| 20118 | int _mark = p->mark; |
| 20119 | { // '=' annotated_rhs |
| 20120 | if (p->error_indicator) { |
| 20121 | D(p->level--); |
| 20122 | return NULL; |
| 20123 | } |
| 20124 | D(fprintf(stderr, "%*c> _tmp_19[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); |
| 20125 | Token * _literal; |
| 20126 | expr_ty d; |
| 20127 | if ( |
| 20128 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 20129 | && |
| 20130 | (d = annotated_rhs_rule(p)) // annotated_rhs |
| 20131 | ) |
| 20132 | { |
| 20133 | D(fprintf(stderr, "%*c+ _tmp_19[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); |
| 20134 | _res = d; |
| 20135 | if (_res == NULL && PyErr_Occurred()) { |
| 20136 | p->error_indicator = 1; |
| 20137 | D(p->level--); |
| 20138 | return NULL; |
| 20139 | } |
| 20140 | goto done; |
| 20141 | } |
| 20142 | p->mark = _mark; |
| 20143 | D(fprintf(stderr, "%*c%s _tmp_19[%d-%d]: %s failed!\n", p->level, ' ', |
| 20144 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); |
| 20145 | } |
| 20146 | _res = NULL; |
| 20147 | done: |
| 20148 | D(p->level--); |
| 20149 | return _res; |
| 20150 | } |
| 20151 | |
| 20152 | // _tmp_20: '(' single_target ')' | single_subscript_attribute_target |
| 20153 | static void * |
| 20154 | _tmp_20_rule(Parser *p) |
| 20155 | { |
| 20156 | D(p->level++); |
| 20157 | if (p->error_indicator) { |
| 20158 | D(p->level--); |
| 20159 | return NULL; |
| 20160 | } |
| 20161 | void * _res = NULL; |
| 20162 | int _mark = p->mark; |
| 20163 | { // '(' single_target ')' |
| 20164 | if (p->error_indicator) { |
| 20165 | D(p->level--); |
| 20166 | return NULL; |
| 20167 | } |
| 20168 | D(fprintf(stderr, "%*c> _tmp_20[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); |
| 20169 | Token * _literal; |
| 20170 | Token * _literal_1; |
| 20171 | expr_ty b; |
| 20172 | if ( |
| 20173 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 20174 | && |
| 20175 | (b = single_target_rule(p)) // single_target |
| 20176 | && |
| 20177 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 20178 | ) |
| 20179 | { |
| 20180 | D(fprintf(stderr, "%*c+ _tmp_20[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); |
| 20181 | _res = b; |
| 20182 | if (_res == NULL && PyErr_Occurred()) { |
| 20183 | p->error_indicator = 1; |
| 20184 | D(p->level--); |
| 20185 | return NULL; |
| 20186 | } |
| 20187 | goto done; |
| 20188 | } |
| 20189 | p->mark = _mark; |
| 20190 | D(fprintf(stderr, "%*c%s _tmp_20[%d-%d]: %s failed!\n", p->level, ' ', |
| 20191 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'")); |
| 20192 | } |
| 20193 | { // single_subscript_attribute_target |
| 20194 | if (p->error_indicator) { |
| 20195 | D(p->level--); |
| 20196 | return NULL; |
| 20197 | } |
| 20198 | D(fprintf(stderr, "%*c> _tmp_20[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); |
| 20199 | expr_ty single_subscript_attribute_target_var; |
| 20200 | if ( |
| 20201 | (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target |
| 20202 | ) |
| 20203 | { |
| 20204 | D(fprintf(stderr, "%*c+ _tmp_20[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); |
| 20205 | _res = single_subscript_attribute_target_var; |
| 20206 | goto done; |
| 20207 | } |
| 20208 | p->mark = _mark; |
| 20209 | D(fprintf(stderr, "%*c%s _tmp_20[%d-%d]: %s failed!\n", p->level, ' ', |
| 20210 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_subscript_attribute_target")); |
| 20211 | } |
| 20212 | _res = NULL; |
| 20213 | done: |
| 20214 | D(p->level--); |
| 20215 | return _res; |
| 20216 | } |
| 20217 | |
| 20218 | // _tmp_21: '=' annotated_rhs |
| 20219 | static void * |
| 20220 | _tmp_21_rule(Parser *p) |
| 20221 | { |
| 20222 | D(p->level++); |
| 20223 | if (p->error_indicator) { |
| 20224 | D(p->level--); |
| 20225 | return NULL; |
| 20226 | } |
| 20227 | void * _res = NULL; |
| 20228 | int _mark = p->mark; |
| 20229 | { // '=' annotated_rhs |
| 20230 | if (p->error_indicator) { |
| 20231 | D(p->level--); |
| 20232 | return NULL; |
| 20233 | } |
| 20234 | D(fprintf(stderr, "%*c> _tmp_21[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); |
| 20235 | Token * _literal; |
| 20236 | expr_ty d; |
| 20237 | if ( |
| 20238 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 20239 | && |
| 20240 | (d = annotated_rhs_rule(p)) // annotated_rhs |
| 20241 | ) |
| 20242 | { |
| 20243 | D(fprintf(stderr, "%*c+ _tmp_21[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); |
| 20244 | _res = d; |
| 20245 | if (_res == NULL && PyErr_Occurred()) { |
| 20246 | p->error_indicator = 1; |
| 20247 | D(p->level--); |
| 20248 | return NULL; |
| 20249 | } |
| 20250 | goto done; |
| 20251 | } |
| 20252 | p->mark = _mark; |
| 20253 | D(fprintf(stderr, "%*c%s _tmp_21[%d-%d]: %s failed!\n", p->level, ' ', |
| 20254 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); |
| 20255 | } |
| 20256 | _res = NULL; |
| 20257 | done: |
| 20258 | D(p->level--); |
| 20259 | return _res; |
| 20260 | } |
| 20261 | |
| 20262 | // _loop1_22: (star_targets '=') |
| 20263 | static asdl_seq * |
| 20264 | _loop1_22_rule(Parser *p) |
| 20265 | { |
| 20266 | D(p->level++); |
| 20267 | if (p->error_indicator) { |
| 20268 | D(p->level--); |
| 20269 | return NULL; |
| 20270 | } |
| 20271 | void *_res = NULL; |
| 20272 | int _mark = p->mark; |
| 20273 | int _start_mark = p->mark; |
| 20274 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20275 | if (!_children) { |
| 20276 | p->error_indicator = 1; |
| 20277 | PyErr_NoMemory(); |
| 20278 | D(p->level--); |
| 20279 | return NULL; |
| 20280 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 20281 | Py_ssize_t _children_capacity = 1; |
| 20282 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20283 | { // (star_targets '=') |
| 20284 | if (p->error_indicator) { |
| 20285 | D(p->level--); |
| 20286 | return NULL; |
| 20287 | } |
| 20288 | D(fprintf(stderr, "%*c> _loop1_22[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 20289 | void *_tmp_165_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20290 | while ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 20291 | (_tmp_165_var = _tmp_165_rule(p)) // star_targets '=' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20292 | ) |
| 20293 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 20294 | _res = _tmp_165_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20295 | if (_n == _children_capacity) { |
| 20296 | _children_capacity *= 2; |
| 20297 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20298 | if (!_new_children) { |
| 20299 | p->error_indicator = 1; |
| 20300 | PyErr_NoMemory(); |
| 20301 | D(p->level--); |
| 20302 | return NULL; |
| 20303 | } |
| 20304 | _children = _new_children; |
| 20305 | } |
| 20306 | _children[_n++] = _res; |
| 20307 | _mark = p->mark; |
| 20308 | } |
| 20309 | p->mark = _mark; |
| 20310 | D(fprintf(stderr, "%*c%s _loop1_22[%d-%d]: %s failed!\n", p->level, ' ', |
| 20311 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); |
| 20312 | } |
| 20313 | if (_n == 0 || p->error_indicator) { |
| 20314 | PyMem_Free(_children); |
| 20315 | D(p->level--); |
| 20316 | return NULL; |
| 20317 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 20318 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20319 | if (!_seq) { |
| 20320 | PyMem_Free(_children); |
| 20321 | p->error_indicator = 1; |
| 20322 | PyErr_NoMemory(); |
| 20323 | D(p->level--); |
| 20324 | return NULL; |
| 20325 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 20326 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20327 | PyMem_Free(_children); |
| 20328 | _PyPegen_insert_memo(p, _start_mark, _loop1_22_type, _seq); |
| 20329 | D(p->level--); |
| 20330 | return _seq; |
| 20331 | } |
| 20332 | |
| 20333 | // _tmp_23: yield_expr | star_expressions |
| 20334 | static void * |
| 20335 | _tmp_23_rule(Parser *p) |
| 20336 | { |
| 20337 | D(p->level++); |
| 20338 | if (p->error_indicator) { |
| 20339 | D(p->level--); |
| 20340 | return NULL; |
| 20341 | } |
| 20342 | void * _res = NULL; |
| 20343 | int _mark = p->mark; |
| 20344 | { // yield_expr |
| 20345 | if (p->error_indicator) { |
| 20346 | D(p->level--); |
| 20347 | return NULL; |
| 20348 | } |
| 20349 | D(fprintf(stderr, "%*c> _tmp_23[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
| 20350 | expr_ty yield_expr_var; |
| 20351 | if ( |
| 20352 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
| 20353 | ) |
| 20354 | { |
| 20355 | D(fprintf(stderr, "%*c+ _tmp_23[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
| 20356 | _res = yield_expr_var; |
| 20357 | goto done; |
| 20358 | } |
| 20359 | p->mark = _mark; |
| 20360 | D(fprintf(stderr, "%*c%s _tmp_23[%d-%d]: %s failed!\n", p->level, ' ', |
| 20361 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); |
| 20362 | } |
| 20363 | { // star_expressions |
| 20364 | if (p->error_indicator) { |
| 20365 | D(p->level--); |
| 20366 | return NULL; |
| 20367 | } |
| 20368 | D(fprintf(stderr, "%*c> _tmp_23[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
| 20369 | expr_ty star_expressions_var; |
| 20370 | if ( |
| 20371 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
| 20372 | ) |
| 20373 | { |
| 20374 | D(fprintf(stderr, "%*c+ _tmp_23[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
| 20375 | _res = star_expressions_var; |
| 20376 | goto done; |
| 20377 | } |
| 20378 | p->mark = _mark; |
| 20379 | D(fprintf(stderr, "%*c%s _tmp_23[%d-%d]: %s failed!\n", p->level, ' ', |
| 20380 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); |
| 20381 | } |
| 20382 | _res = NULL; |
| 20383 | done: |
| 20384 | D(p->level--); |
| 20385 | return _res; |
| 20386 | } |
| 20387 | |
| 20388 | // _tmp_24: yield_expr | star_expressions |
| 20389 | static void * |
| 20390 | _tmp_24_rule(Parser *p) |
| 20391 | { |
| 20392 | D(p->level++); |
| 20393 | if (p->error_indicator) { |
| 20394 | D(p->level--); |
| 20395 | return NULL; |
| 20396 | } |
| 20397 | void * _res = NULL; |
| 20398 | int _mark = p->mark; |
| 20399 | { // yield_expr |
| 20400 | if (p->error_indicator) { |
| 20401 | D(p->level--); |
| 20402 | return NULL; |
| 20403 | } |
| 20404 | D(fprintf(stderr, "%*c> _tmp_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
| 20405 | expr_ty yield_expr_var; |
| 20406 | if ( |
| 20407 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
| 20408 | ) |
| 20409 | { |
| 20410 | D(fprintf(stderr, "%*c+ _tmp_24[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
| 20411 | _res = yield_expr_var; |
| 20412 | goto done; |
| 20413 | } |
| 20414 | p->mark = _mark; |
| 20415 | D(fprintf(stderr, "%*c%s _tmp_24[%d-%d]: %s failed!\n", p->level, ' ', |
| 20416 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); |
| 20417 | } |
| 20418 | { // star_expressions |
| 20419 | if (p->error_indicator) { |
| 20420 | D(p->level--); |
| 20421 | return NULL; |
| 20422 | } |
| 20423 | D(fprintf(stderr, "%*c> _tmp_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
| 20424 | expr_ty star_expressions_var; |
| 20425 | if ( |
| 20426 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
| 20427 | ) |
| 20428 | { |
| 20429 | D(fprintf(stderr, "%*c+ _tmp_24[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
| 20430 | _res = star_expressions_var; |
| 20431 | goto done; |
| 20432 | } |
| 20433 | p->mark = _mark; |
| 20434 | D(fprintf(stderr, "%*c%s _tmp_24[%d-%d]: %s failed!\n", p->level, ' ', |
| 20435 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); |
| 20436 | } |
| 20437 | _res = NULL; |
| 20438 | done: |
| 20439 | D(p->level--); |
| 20440 | return _res; |
| 20441 | } |
| 20442 | |
| 20443 | // _loop0_26: ',' NAME |
| 20444 | static asdl_seq * |
| 20445 | _loop0_26_rule(Parser *p) |
| 20446 | { |
| 20447 | D(p->level++); |
| 20448 | if (p->error_indicator) { |
| 20449 | D(p->level--); |
| 20450 | return NULL; |
| 20451 | } |
| 20452 | void *_res = NULL; |
| 20453 | int _mark = p->mark; |
| 20454 | int _start_mark = p->mark; |
| 20455 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20456 | if (!_children) { |
| 20457 | p->error_indicator = 1; |
| 20458 | PyErr_NoMemory(); |
| 20459 | D(p->level--); |
| 20460 | return NULL; |
| 20461 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 20462 | Py_ssize_t _children_capacity = 1; |
| 20463 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20464 | { // ',' NAME |
| 20465 | if (p->error_indicator) { |
| 20466 | D(p->level--); |
| 20467 | return NULL; |
| 20468 | } |
| 20469 | D(fprintf(stderr, "%*c> _loop0_26[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME")); |
| 20470 | Token * _literal; |
| 20471 | expr_ty elem; |
| 20472 | while ( |
| 20473 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 20474 | && |
| 20475 | (elem = _PyPegen_name_token(p)) // NAME |
| 20476 | ) |
| 20477 | { |
| 20478 | _res = elem; |
| 20479 | if (_res == NULL && PyErr_Occurred()) { |
| 20480 | p->error_indicator = 1; |
| 20481 | PyMem_Free(_children); |
| 20482 | D(p->level--); |
| 20483 | return NULL; |
| 20484 | } |
| 20485 | if (_n == _children_capacity) { |
| 20486 | _children_capacity *= 2; |
| 20487 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20488 | if (!_new_children) { |
| 20489 | p->error_indicator = 1; |
| 20490 | PyErr_NoMemory(); |
| 20491 | D(p->level--); |
| 20492 | return NULL; |
| 20493 | } |
| 20494 | _children = _new_children; |
| 20495 | } |
| 20496 | _children[_n++] = _res; |
| 20497 | _mark = p->mark; |
| 20498 | } |
| 20499 | p->mark = _mark; |
| 20500 | D(fprintf(stderr, "%*c%s _loop0_26[%d-%d]: %s failed!\n", p->level, ' ', |
| 20501 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME")); |
| 20502 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 20503 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20504 | if (!_seq) { |
| 20505 | PyMem_Free(_children); |
| 20506 | p->error_indicator = 1; |
| 20507 | PyErr_NoMemory(); |
| 20508 | D(p->level--); |
| 20509 | return NULL; |
| 20510 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 20511 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20512 | PyMem_Free(_children); |
| 20513 | _PyPegen_insert_memo(p, _start_mark, _loop0_26_type, _seq); |
| 20514 | D(p->level--); |
| 20515 | return _seq; |
| 20516 | } |
| 20517 | |
| 20518 | // _gather_25: NAME _loop0_26 |
| 20519 | static asdl_seq * |
| 20520 | _gather_25_rule(Parser *p) |
| 20521 | { |
| 20522 | D(p->level++); |
| 20523 | if (p->error_indicator) { |
| 20524 | D(p->level--); |
| 20525 | return NULL; |
| 20526 | } |
| 20527 | asdl_seq * _res = NULL; |
| 20528 | int _mark = p->mark; |
| 20529 | { // NAME _loop0_26 |
| 20530 | if (p->error_indicator) { |
| 20531 | D(p->level--); |
| 20532 | return NULL; |
| 20533 | } |
| 20534 | D(fprintf(stderr, "%*c> _gather_25[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26")); |
| 20535 | expr_ty elem; |
| 20536 | asdl_seq * seq; |
| 20537 | if ( |
| 20538 | (elem = _PyPegen_name_token(p)) // NAME |
| 20539 | && |
| 20540 | (seq = _loop0_26_rule(p)) // _loop0_26 |
| 20541 | ) |
| 20542 | { |
| 20543 | D(fprintf(stderr, "%*c+ _gather_25[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26")); |
| 20544 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 20545 | goto done; |
| 20546 | } |
| 20547 | p->mark = _mark; |
| 20548 | D(fprintf(stderr, "%*c%s _gather_25[%d-%d]: %s failed!\n", p->level, ' ', |
| 20549 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_26")); |
| 20550 | } |
| 20551 | _res = NULL; |
| 20552 | done: |
| 20553 | D(p->level--); |
| 20554 | return _res; |
| 20555 | } |
| 20556 | |
| 20557 | // _loop0_28: ',' NAME |
| 20558 | static asdl_seq * |
| 20559 | _loop0_28_rule(Parser *p) |
| 20560 | { |
| 20561 | D(p->level++); |
| 20562 | if (p->error_indicator) { |
| 20563 | D(p->level--); |
| 20564 | return NULL; |
| 20565 | } |
| 20566 | void *_res = NULL; |
| 20567 | int _mark = p->mark; |
| 20568 | int _start_mark = p->mark; |
| 20569 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20570 | if (!_children) { |
| 20571 | p->error_indicator = 1; |
| 20572 | PyErr_NoMemory(); |
| 20573 | D(p->level--); |
| 20574 | return NULL; |
| 20575 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 20576 | Py_ssize_t _children_capacity = 1; |
| 20577 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20578 | { // ',' NAME |
| 20579 | if (p->error_indicator) { |
| 20580 | D(p->level--); |
| 20581 | return NULL; |
| 20582 | } |
| 20583 | D(fprintf(stderr, "%*c> _loop0_28[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME")); |
| 20584 | Token * _literal; |
| 20585 | expr_ty elem; |
| 20586 | while ( |
| 20587 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 20588 | && |
| 20589 | (elem = _PyPegen_name_token(p)) // NAME |
| 20590 | ) |
| 20591 | { |
| 20592 | _res = elem; |
| 20593 | if (_res == NULL && PyErr_Occurred()) { |
| 20594 | p->error_indicator = 1; |
| 20595 | PyMem_Free(_children); |
| 20596 | D(p->level--); |
| 20597 | return NULL; |
| 20598 | } |
| 20599 | if (_n == _children_capacity) { |
| 20600 | _children_capacity *= 2; |
| 20601 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20602 | if (!_new_children) { |
| 20603 | p->error_indicator = 1; |
| 20604 | PyErr_NoMemory(); |
| 20605 | D(p->level--); |
| 20606 | return NULL; |
| 20607 | } |
| 20608 | _children = _new_children; |
| 20609 | } |
| 20610 | _children[_n++] = _res; |
| 20611 | _mark = p->mark; |
| 20612 | } |
| 20613 | p->mark = _mark; |
| 20614 | D(fprintf(stderr, "%*c%s _loop0_28[%d-%d]: %s failed!\n", p->level, ' ', |
| 20615 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME")); |
| 20616 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 20617 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20618 | if (!_seq) { |
| 20619 | PyMem_Free(_children); |
| 20620 | p->error_indicator = 1; |
| 20621 | PyErr_NoMemory(); |
| 20622 | D(p->level--); |
| 20623 | return NULL; |
| 20624 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 20625 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20626 | PyMem_Free(_children); |
| 20627 | _PyPegen_insert_memo(p, _start_mark, _loop0_28_type, _seq); |
| 20628 | D(p->level--); |
| 20629 | return _seq; |
| 20630 | } |
| 20631 | |
| 20632 | // _gather_27: NAME _loop0_28 |
| 20633 | static asdl_seq * |
| 20634 | _gather_27_rule(Parser *p) |
| 20635 | { |
| 20636 | D(p->level++); |
| 20637 | if (p->error_indicator) { |
| 20638 | D(p->level--); |
| 20639 | return NULL; |
| 20640 | } |
| 20641 | asdl_seq * _res = NULL; |
| 20642 | int _mark = p->mark; |
| 20643 | { // NAME _loop0_28 |
| 20644 | if (p->error_indicator) { |
| 20645 | D(p->level--); |
| 20646 | return NULL; |
| 20647 | } |
| 20648 | D(fprintf(stderr, "%*c> _gather_27[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28")); |
| 20649 | expr_ty elem; |
| 20650 | asdl_seq * seq; |
| 20651 | if ( |
| 20652 | (elem = _PyPegen_name_token(p)) // NAME |
| 20653 | && |
| 20654 | (seq = _loop0_28_rule(p)) // _loop0_28 |
| 20655 | ) |
| 20656 | { |
| 20657 | D(fprintf(stderr, "%*c+ _gather_27[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28")); |
| 20658 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 20659 | goto done; |
| 20660 | } |
| 20661 | p->mark = _mark; |
| 20662 | D(fprintf(stderr, "%*c%s _gather_27[%d-%d]: %s failed!\n", p->level, ' ', |
| 20663 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_28")); |
| 20664 | } |
| 20665 | _res = NULL; |
| 20666 | done: |
| 20667 | D(p->level--); |
| 20668 | return _res; |
| 20669 | } |
| 20670 | |
| 20671 | // _tmp_29: ',' expression |
| 20672 | static void * |
| 20673 | _tmp_29_rule(Parser *p) |
| 20674 | { |
| 20675 | D(p->level++); |
| 20676 | if (p->error_indicator) { |
| 20677 | D(p->level--); |
| 20678 | return NULL; |
| 20679 | } |
| 20680 | void * _res = NULL; |
| 20681 | int _mark = p->mark; |
| 20682 | { // ',' expression |
| 20683 | if (p->error_indicator) { |
| 20684 | D(p->level--); |
| 20685 | return NULL; |
| 20686 | } |
| 20687 | D(fprintf(stderr, "%*c> _tmp_29[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); |
| 20688 | Token * _literal; |
| 20689 | expr_ty z; |
| 20690 | if ( |
| 20691 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 20692 | && |
| 20693 | (z = expression_rule(p)) // expression |
| 20694 | ) |
| 20695 | { |
| 20696 | D(fprintf(stderr, "%*c+ _tmp_29[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); |
| 20697 | _res = z; |
| 20698 | if (_res == NULL && PyErr_Occurred()) { |
| 20699 | p->error_indicator = 1; |
| 20700 | D(p->level--); |
| 20701 | return NULL; |
| 20702 | } |
| 20703 | goto done; |
| 20704 | } |
| 20705 | p->mark = _mark; |
| 20706 | D(fprintf(stderr, "%*c%s _tmp_29[%d-%d]: %s failed!\n", p->level, ' ', |
| 20707 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); |
| 20708 | } |
| 20709 | _res = NULL; |
| 20710 | done: |
| 20711 | D(p->level--); |
| 20712 | return _res; |
| 20713 | } |
| 20714 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20715 | // _tmp_30: ';' | NEWLINE |
| 20716 | static void * |
| 20717 | _tmp_30_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20718 | { |
| 20719 | D(p->level++); |
| 20720 | if (p->error_indicator) { |
| 20721 | D(p->level--); |
| 20722 | return NULL; |
| 20723 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20724 | void * _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20725 | int _mark = p->mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20726 | { // ';' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20727 | if (p->error_indicator) { |
| 20728 | D(p->level--); |
| 20729 | return NULL; |
| 20730 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20731 | D(fprintf(stderr, "%*c> _tmp_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'")); |
| 20732 | Token * _literal; |
| 20733 | if ( |
| 20734 | (_literal = _PyPegen_expect_token(p, 13)) // token=';' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20735 | ) |
| 20736 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20737 | D(fprintf(stderr, "%*c+ _tmp_30[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'")); |
| 20738 | _res = _literal; |
| 20739 | goto done; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20740 | } |
| 20741 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20742 | D(fprintf(stderr, "%*c%s _tmp_30[%d-%d]: %s failed!\n", p->level, ' ', |
| 20743 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20744 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20745 | { // NEWLINE |
| 20746 | if (p->error_indicator) { |
| 20747 | D(p->level--); |
| 20748 | return NULL; |
| 20749 | } |
| 20750 | D(fprintf(stderr, "%*c> _tmp_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); |
| 20751 | Token * newline_var; |
| 20752 | if ( |
| 20753 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 20754 | ) |
| 20755 | { |
| 20756 | D(fprintf(stderr, "%*c+ _tmp_30[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); |
| 20757 | _res = newline_var; |
| 20758 | goto done; |
| 20759 | } |
| 20760 | p->mark = _mark; |
| 20761 | D(fprintf(stderr, "%*c%s _tmp_30[%d-%d]: %s failed!\n", p->level, ' ', |
| 20762 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20763 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20764 | _res = NULL; |
| 20765 | done: |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20766 | D(p->level--); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20767 | return _res; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20768 | } |
| 20769 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20770 | // _loop0_31: ('.' | '...') |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20771 | static asdl_seq * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20772 | _loop0_31_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20773 | { |
| 20774 | D(p->level++); |
| 20775 | if (p->error_indicator) { |
| 20776 | D(p->level--); |
| 20777 | return NULL; |
| 20778 | } |
| 20779 | void *_res = NULL; |
| 20780 | int _mark = p->mark; |
| 20781 | int _start_mark = p->mark; |
| 20782 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20783 | if (!_children) { |
| 20784 | p->error_indicator = 1; |
| 20785 | PyErr_NoMemory(); |
| 20786 | D(p->level--); |
| 20787 | return NULL; |
| 20788 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 20789 | Py_ssize_t _children_capacity = 1; |
| 20790 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20791 | { // ('.' | '...') |
| 20792 | if (p->error_indicator) { |
| 20793 | D(p->level--); |
| 20794 | return NULL; |
| 20795 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20796 | D(fprintf(stderr, "%*c> _loop0_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 20797 | void *_tmp_166_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20798 | while ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 20799 | (_tmp_166_var = _tmp_166_rule(p)) // '.' | '...' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20800 | ) |
| 20801 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 20802 | _res = _tmp_166_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20803 | if (_n == _children_capacity) { |
| 20804 | _children_capacity *= 2; |
| 20805 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20806 | if (!_new_children) { |
| 20807 | p->error_indicator = 1; |
| 20808 | PyErr_NoMemory(); |
| 20809 | D(p->level--); |
| 20810 | return NULL; |
| 20811 | } |
| 20812 | _children = _new_children; |
| 20813 | } |
| 20814 | _children[_n++] = _res; |
| 20815 | _mark = p->mark; |
| 20816 | } |
| 20817 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20818 | D(fprintf(stderr, "%*c%s _loop0_31[%d-%d]: %s failed!\n", p->level, ' ', |
| 20819 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); |
| 20820 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 20821 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20822 | if (!_seq) { |
| 20823 | PyMem_Free(_children); |
| 20824 | p->error_indicator = 1; |
| 20825 | PyErr_NoMemory(); |
| 20826 | D(p->level--); |
| 20827 | return NULL; |
| 20828 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 20829 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20830 | PyMem_Free(_children); |
| 20831 | _PyPegen_insert_memo(p, _start_mark, _loop0_31_type, _seq); |
| 20832 | D(p->level--); |
| 20833 | return _seq; |
| 20834 | } |
| 20835 | |
| 20836 | // _loop1_32: ('.' | '...') |
| 20837 | static asdl_seq * |
| 20838 | _loop1_32_rule(Parser *p) |
| 20839 | { |
| 20840 | D(p->level++); |
| 20841 | if (p->error_indicator) { |
| 20842 | D(p->level--); |
| 20843 | return NULL; |
| 20844 | } |
| 20845 | void *_res = NULL; |
| 20846 | int _mark = p->mark; |
| 20847 | int _start_mark = p->mark; |
| 20848 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20849 | if (!_children) { |
| 20850 | p->error_indicator = 1; |
| 20851 | PyErr_NoMemory(); |
| 20852 | D(p->level--); |
| 20853 | return NULL; |
| 20854 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 20855 | Py_ssize_t _children_capacity = 1; |
| 20856 | Py_ssize_t _n = 0; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20857 | { // ('.' | '...') |
| 20858 | if (p->error_indicator) { |
| 20859 | D(p->level--); |
| 20860 | return NULL; |
| 20861 | } |
| 20862 | D(fprintf(stderr, "%*c> _loop1_32[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 20863 | void *_tmp_167_var; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20864 | while ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 20865 | (_tmp_167_var = _tmp_167_rule(p)) // '.' | '...' |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20866 | ) |
| 20867 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 20868 | _res = _tmp_167_var; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20869 | if (_n == _children_capacity) { |
| 20870 | _children_capacity *= 2; |
| 20871 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20872 | if (!_new_children) { |
| 20873 | p->error_indicator = 1; |
| 20874 | PyErr_NoMemory(); |
| 20875 | D(p->level--); |
| 20876 | return NULL; |
| 20877 | } |
| 20878 | _children = _new_children; |
| 20879 | } |
| 20880 | _children[_n++] = _res; |
| 20881 | _mark = p->mark; |
| 20882 | } |
| 20883 | p->mark = _mark; |
| 20884 | D(fprintf(stderr, "%*c%s _loop1_32[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20885 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); |
| 20886 | } |
| 20887 | if (_n == 0 || p->error_indicator) { |
| 20888 | PyMem_Free(_children); |
| 20889 | D(p->level--); |
| 20890 | return NULL; |
| 20891 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 20892 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20893 | if (!_seq) { |
| 20894 | PyMem_Free(_children); |
| 20895 | p->error_indicator = 1; |
| 20896 | PyErr_NoMemory(); |
| 20897 | D(p->level--); |
| 20898 | return NULL; |
| 20899 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 20900 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20901 | PyMem_Free(_children); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20902 | _PyPegen_insert_memo(p, _start_mark, _loop1_32_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20903 | D(p->level--); |
| 20904 | return _seq; |
| 20905 | } |
| 20906 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20907 | // _loop0_34: ',' import_from_as_name |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20908 | static asdl_seq * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20909 | _loop0_34_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20910 | { |
| 20911 | D(p->level++); |
| 20912 | if (p->error_indicator) { |
| 20913 | D(p->level--); |
| 20914 | return NULL; |
| 20915 | } |
| 20916 | void *_res = NULL; |
| 20917 | int _mark = p->mark; |
| 20918 | int _start_mark = p->mark; |
| 20919 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20920 | if (!_children) { |
| 20921 | p->error_indicator = 1; |
| 20922 | PyErr_NoMemory(); |
| 20923 | D(p->level--); |
| 20924 | return NULL; |
| 20925 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 20926 | Py_ssize_t _children_capacity = 1; |
| 20927 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20928 | { // ',' import_from_as_name |
| 20929 | if (p->error_indicator) { |
| 20930 | D(p->level--); |
| 20931 | return NULL; |
| 20932 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20933 | D(fprintf(stderr, "%*c> _loop0_34[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' import_from_as_name")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20934 | Token * _literal; |
| 20935 | alias_ty elem; |
| 20936 | while ( |
| 20937 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 20938 | && |
| 20939 | (elem = import_from_as_name_rule(p)) // import_from_as_name |
| 20940 | ) |
| 20941 | { |
| 20942 | _res = elem; |
| 20943 | if (_res == NULL && PyErr_Occurred()) { |
| 20944 | p->error_indicator = 1; |
| 20945 | PyMem_Free(_children); |
| 20946 | D(p->level--); |
| 20947 | return NULL; |
| 20948 | } |
| 20949 | if (_n == _children_capacity) { |
| 20950 | _children_capacity *= 2; |
| 20951 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20952 | if (!_new_children) { |
| 20953 | p->error_indicator = 1; |
| 20954 | PyErr_NoMemory(); |
| 20955 | D(p->level--); |
| 20956 | return NULL; |
| 20957 | } |
| 20958 | _children = _new_children; |
| 20959 | } |
| 20960 | _children[_n++] = _res; |
| 20961 | _mark = p->mark; |
| 20962 | } |
| 20963 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20964 | D(fprintf(stderr, "%*c%s _loop0_34[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20965 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' import_from_as_name")); |
| 20966 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 20967 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20968 | if (!_seq) { |
| 20969 | PyMem_Free(_children); |
| 20970 | p->error_indicator = 1; |
| 20971 | PyErr_NoMemory(); |
| 20972 | D(p->level--); |
| 20973 | return NULL; |
| 20974 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 20975 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20976 | PyMem_Free(_children); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20977 | _PyPegen_insert_memo(p, _start_mark, _loop0_34_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20978 | D(p->level--); |
| 20979 | return _seq; |
| 20980 | } |
| 20981 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20982 | // _gather_33: import_from_as_name _loop0_34 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20983 | static asdl_seq * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20984 | _gather_33_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20985 | { |
| 20986 | D(p->level++); |
| 20987 | if (p->error_indicator) { |
| 20988 | D(p->level--); |
| 20989 | return NULL; |
| 20990 | } |
| 20991 | asdl_seq * _res = NULL; |
| 20992 | int _mark = p->mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20993 | { // import_from_as_name _loop0_34 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20994 | if (p->error_indicator) { |
| 20995 | D(p->level--); |
| 20996 | return NULL; |
| 20997 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 20998 | D(fprintf(stderr, "%*c> _gather_33[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_34")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 20999 | alias_ty elem; |
| 21000 | asdl_seq * seq; |
| 21001 | if ( |
| 21002 | (elem = import_from_as_name_rule(p)) // import_from_as_name |
| 21003 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21004 | (seq = _loop0_34_rule(p)) // _loop0_34 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21005 | ) |
| 21006 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21007 | D(fprintf(stderr, "%*c+ _gather_33[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_34")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21008 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 21009 | goto done; |
| 21010 | } |
| 21011 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21012 | D(fprintf(stderr, "%*c%s _gather_33[%d-%d]: %s failed!\n", p->level, ' ', |
| 21013 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_name _loop0_34")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21014 | } |
| 21015 | _res = NULL; |
| 21016 | done: |
| 21017 | D(p->level--); |
| 21018 | return _res; |
| 21019 | } |
| 21020 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21021 | // _tmp_35: 'as' NAME |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21022 | static void * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21023 | _tmp_35_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21024 | { |
| 21025 | D(p->level++); |
| 21026 | if (p->error_indicator) { |
| 21027 | D(p->level--); |
| 21028 | return NULL; |
| 21029 | } |
| 21030 | void * _res = NULL; |
| 21031 | int _mark = p->mark; |
| 21032 | { // 'as' NAME |
| 21033 | if (p->error_indicator) { |
| 21034 | D(p->level--); |
| 21035 | return NULL; |
| 21036 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21037 | D(fprintf(stderr, "%*c> _tmp_35[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21038 | Token * _keyword; |
| 21039 | expr_ty z; |
| 21040 | if ( |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21041 | (_keyword = _PyPegen_expect_token(p, 520)) // token='as' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21042 | && |
| 21043 | (z = _PyPegen_name_token(p)) // NAME |
| 21044 | ) |
| 21045 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21046 | D(fprintf(stderr, "%*c+ _tmp_35[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21047 | _res = z; |
| 21048 | if (_res == NULL && PyErr_Occurred()) { |
| 21049 | p->error_indicator = 1; |
| 21050 | D(p->level--); |
| 21051 | return NULL; |
| 21052 | } |
| 21053 | goto done; |
| 21054 | } |
| 21055 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21056 | D(fprintf(stderr, "%*c%s _tmp_35[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21057 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); |
| 21058 | } |
| 21059 | _res = NULL; |
| 21060 | done: |
| 21061 | D(p->level--); |
| 21062 | return _res; |
| 21063 | } |
| 21064 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21065 | // _loop0_37: ',' dotted_as_name |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21066 | static asdl_seq * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21067 | _loop0_37_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21068 | { |
| 21069 | D(p->level++); |
| 21070 | if (p->error_indicator) { |
| 21071 | D(p->level--); |
| 21072 | return NULL; |
| 21073 | } |
| 21074 | void *_res = NULL; |
| 21075 | int _mark = p->mark; |
| 21076 | int _start_mark = p->mark; |
| 21077 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 21078 | if (!_children) { |
| 21079 | p->error_indicator = 1; |
| 21080 | PyErr_NoMemory(); |
| 21081 | D(p->level--); |
| 21082 | return NULL; |
| 21083 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 21084 | Py_ssize_t _children_capacity = 1; |
| 21085 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21086 | { // ',' dotted_as_name |
| 21087 | if (p->error_indicator) { |
| 21088 | D(p->level--); |
| 21089 | return NULL; |
| 21090 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21091 | D(fprintf(stderr, "%*c> _loop0_37[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' dotted_as_name")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21092 | Token * _literal; |
| 21093 | alias_ty elem; |
| 21094 | while ( |
| 21095 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 21096 | && |
| 21097 | (elem = dotted_as_name_rule(p)) // dotted_as_name |
| 21098 | ) |
| 21099 | { |
| 21100 | _res = elem; |
| 21101 | if (_res == NULL && PyErr_Occurred()) { |
| 21102 | p->error_indicator = 1; |
| 21103 | PyMem_Free(_children); |
| 21104 | D(p->level--); |
| 21105 | return NULL; |
| 21106 | } |
| 21107 | if (_n == _children_capacity) { |
| 21108 | _children_capacity *= 2; |
| 21109 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 21110 | if (!_new_children) { |
| 21111 | p->error_indicator = 1; |
| 21112 | PyErr_NoMemory(); |
| 21113 | D(p->level--); |
| 21114 | return NULL; |
| 21115 | } |
| 21116 | _children = _new_children; |
| 21117 | } |
| 21118 | _children[_n++] = _res; |
| 21119 | _mark = p->mark; |
| 21120 | } |
| 21121 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21122 | D(fprintf(stderr, "%*c%s _loop0_37[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21123 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' dotted_as_name")); |
| 21124 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 21125 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21126 | if (!_seq) { |
| 21127 | PyMem_Free(_children); |
| 21128 | p->error_indicator = 1; |
| 21129 | PyErr_NoMemory(); |
| 21130 | D(p->level--); |
| 21131 | return NULL; |
| 21132 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 21133 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21134 | PyMem_Free(_children); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21135 | _PyPegen_insert_memo(p, _start_mark, _loop0_37_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21136 | D(p->level--); |
| 21137 | return _seq; |
| 21138 | } |
| 21139 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21140 | // _gather_36: dotted_as_name _loop0_37 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21141 | static asdl_seq * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21142 | _gather_36_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21143 | { |
| 21144 | D(p->level++); |
| 21145 | if (p->error_indicator) { |
| 21146 | D(p->level--); |
| 21147 | return NULL; |
| 21148 | } |
| 21149 | asdl_seq * _res = NULL; |
| 21150 | int _mark = p->mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21151 | { // dotted_as_name _loop0_37 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21152 | if (p->error_indicator) { |
| 21153 | D(p->level--); |
| 21154 | return NULL; |
| 21155 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21156 | D(fprintf(stderr, "%*c> _gather_36[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_37")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21157 | alias_ty elem; |
| 21158 | asdl_seq * seq; |
| 21159 | if ( |
| 21160 | (elem = dotted_as_name_rule(p)) // dotted_as_name |
| 21161 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21162 | (seq = _loop0_37_rule(p)) // _loop0_37 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21163 | ) |
| 21164 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21165 | D(fprintf(stderr, "%*c+ _gather_36[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_37")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21166 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 21167 | goto done; |
| 21168 | } |
| 21169 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21170 | D(fprintf(stderr, "%*c%s _gather_36[%d-%d]: %s failed!\n", p->level, ' ', |
| 21171 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_as_name _loop0_37")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21172 | } |
| 21173 | _res = NULL; |
| 21174 | done: |
| 21175 | D(p->level--); |
| 21176 | return _res; |
| 21177 | } |
| 21178 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21179 | // _tmp_38: 'as' NAME |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21180 | static void * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21181 | _tmp_38_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21182 | { |
| 21183 | D(p->level++); |
| 21184 | if (p->error_indicator) { |
| 21185 | D(p->level--); |
| 21186 | return NULL; |
| 21187 | } |
| 21188 | void * _res = NULL; |
| 21189 | int _mark = p->mark; |
| 21190 | { // 'as' NAME |
| 21191 | if (p->error_indicator) { |
| 21192 | D(p->level--); |
| 21193 | return NULL; |
| 21194 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21195 | D(fprintf(stderr, "%*c> _tmp_38[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21196 | Token * _keyword; |
| 21197 | expr_ty z; |
| 21198 | if ( |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21199 | (_keyword = _PyPegen_expect_token(p, 520)) // token='as' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21200 | && |
| 21201 | (z = _PyPegen_name_token(p)) // NAME |
| 21202 | ) |
| 21203 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21204 | D(fprintf(stderr, "%*c+ _tmp_38[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21205 | _res = z; |
| 21206 | if (_res == NULL && PyErr_Occurred()) { |
| 21207 | p->error_indicator = 1; |
| 21208 | D(p->level--); |
| 21209 | return NULL; |
| 21210 | } |
| 21211 | goto done; |
| 21212 | } |
| 21213 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21214 | D(fprintf(stderr, "%*c%s _tmp_38[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21215 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); |
| 21216 | } |
| 21217 | _res = NULL; |
| 21218 | done: |
| 21219 | D(p->level--); |
| 21220 | return _res; |
| 21221 | } |
| 21222 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21223 | // _loop0_40: ',' with_item |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21224 | static asdl_seq * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21225 | _loop0_40_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21226 | { |
| 21227 | D(p->level++); |
| 21228 | if (p->error_indicator) { |
| 21229 | D(p->level--); |
| 21230 | return NULL; |
| 21231 | } |
| 21232 | void *_res = NULL; |
| 21233 | int _mark = p->mark; |
| 21234 | int _start_mark = p->mark; |
| 21235 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 21236 | if (!_children) { |
| 21237 | p->error_indicator = 1; |
| 21238 | PyErr_NoMemory(); |
| 21239 | D(p->level--); |
| 21240 | return NULL; |
| 21241 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 21242 | Py_ssize_t _children_capacity = 1; |
| 21243 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21244 | { // ',' with_item |
| 21245 | if (p->error_indicator) { |
| 21246 | D(p->level--); |
| 21247 | return NULL; |
| 21248 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21249 | D(fprintf(stderr, "%*c> _loop0_40[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21250 | Token * _literal; |
| 21251 | withitem_ty elem; |
| 21252 | while ( |
| 21253 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 21254 | && |
| 21255 | (elem = with_item_rule(p)) // with_item |
| 21256 | ) |
| 21257 | { |
| 21258 | _res = elem; |
| 21259 | if (_res == NULL && PyErr_Occurred()) { |
| 21260 | p->error_indicator = 1; |
| 21261 | PyMem_Free(_children); |
| 21262 | D(p->level--); |
| 21263 | return NULL; |
| 21264 | } |
| 21265 | if (_n == _children_capacity) { |
| 21266 | _children_capacity *= 2; |
| 21267 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 21268 | if (!_new_children) { |
| 21269 | p->error_indicator = 1; |
| 21270 | PyErr_NoMemory(); |
| 21271 | D(p->level--); |
| 21272 | return NULL; |
| 21273 | } |
| 21274 | _children = _new_children; |
| 21275 | } |
| 21276 | _children[_n++] = _res; |
| 21277 | _mark = p->mark; |
| 21278 | } |
| 21279 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21280 | D(fprintf(stderr, "%*c%s _loop0_40[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21281 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); |
| 21282 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 21283 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21284 | if (!_seq) { |
| 21285 | PyMem_Free(_children); |
| 21286 | p->error_indicator = 1; |
| 21287 | PyErr_NoMemory(); |
| 21288 | D(p->level--); |
| 21289 | return NULL; |
| 21290 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 21291 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21292 | PyMem_Free(_children); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21293 | _PyPegen_insert_memo(p, _start_mark, _loop0_40_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21294 | D(p->level--); |
| 21295 | return _seq; |
| 21296 | } |
| 21297 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21298 | // _gather_39: with_item _loop0_40 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21299 | static asdl_seq * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21300 | _gather_39_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21301 | { |
| 21302 | D(p->level++); |
| 21303 | if (p->error_indicator) { |
| 21304 | D(p->level--); |
| 21305 | return NULL; |
| 21306 | } |
| 21307 | asdl_seq * _res = NULL; |
| 21308 | int _mark = p->mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21309 | { // with_item _loop0_40 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21310 | if (p->error_indicator) { |
| 21311 | D(p->level--); |
| 21312 | return NULL; |
| 21313 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21314 | D(fprintf(stderr, "%*c> _gather_39[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_40")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21315 | withitem_ty elem; |
| 21316 | asdl_seq * seq; |
| 21317 | if ( |
| 21318 | (elem = with_item_rule(p)) // with_item |
| 21319 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21320 | (seq = _loop0_40_rule(p)) // _loop0_40 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21321 | ) |
| 21322 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21323 | D(fprintf(stderr, "%*c+ _gather_39[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_40")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21324 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 21325 | goto done; |
| 21326 | } |
| 21327 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21328 | D(fprintf(stderr, "%*c%s _gather_39[%d-%d]: %s failed!\n", p->level, ' ', |
| 21329 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_40")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21330 | } |
| 21331 | _res = NULL; |
| 21332 | done: |
| 21333 | D(p->level--); |
| 21334 | return _res; |
| 21335 | } |
| 21336 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21337 | // _loop0_42: ',' with_item |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21338 | static asdl_seq * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21339 | _loop0_42_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21340 | { |
| 21341 | D(p->level++); |
| 21342 | if (p->error_indicator) { |
| 21343 | D(p->level--); |
| 21344 | return NULL; |
| 21345 | } |
| 21346 | void *_res = NULL; |
| 21347 | int _mark = p->mark; |
| 21348 | int _start_mark = p->mark; |
| 21349 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 21350 | if (!_children) { |
| 21351 | p->error_indicator = 1; |
| 21352 | PyErr_NoMemory(); |
| 21353 | D(p->level--); |
| 21354 | return NULL; |
| 21355 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 21356 | Py_ssize_t _children_capacity = 1; |
| 21357 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21358 | { // ',' with_item |
| 21359 | if (p->error_indicator) { |
| 21360 | D(p->level--); |
| 21361 | return NULL; |
| 21362 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21363 | D(fprintf(stderr, "%*c> _loop0_42[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21364 | Token * _literal; |
| 21365 | withitem_ty elem; |
| 21366 | while ( |
| 21367 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 21368 | && |
| 21369 | (elem = with_item_rule(p)) // with_item |
| 21370 | ) |
| 21371 | { |
| 21372 | _res = elem; |
| 21373 | if (_res == NULL && PyErr_Occurred()) { |
| 21374 | p->error_indicator = 1; |
| 21375 | PyMem_Free(_children); |
| 21376 | D(p->level--); |
| 21377 | return NULL; |
| 21378 | } |
| 21379 | if (_n == _children_capacity) { |
| 21380 | _children_capacity *= 2; |
| 21381 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 21382 | if (!_new_children) { |
| 21383 | p->error_indicator = 1; |
| 21384 | PyErr_NoMemory(); |
| 21385 | D(p->level--); |
| 21386 | return NULL; |
| 21387 | } |
| 21388 | _children = _new_children; |
| 21389 | } |
| 21390 | _children[_n++] = _res; |
| 21391 | _mark = p->mark; |
| 21392 | } |
| 21393 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21394 | D(fprintf(stderr, "%*c%s _loop0_42[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21395 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); |
| 21396 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 21397 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21398 | if (!_seq) { |
| 21399 | PyMem_Free(_children); |
| 21400 | p->error_indicator = 1; |
| 21401 | PyErr_NoMemory(); |
| 21402 | D(p->level--); |
| 21403 | return NULL; |
| 21404 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 21405 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21406 | PyMem_Free(_children); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21407 | _PyPegen_insert_memo(p, _start_mark, _loop0_42_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21408 | D(p->level--); |
| 21409 | return _seq; |
| 21410 | } |
| 21411 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21412 | // _gather_41: with_item _loop0_42 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21413 | static asdl_seq * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21414 | _gather_41_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21415 | { |
| 21416 | D(p->level++); |
| 21417 | if (p->error_indicator) { |
| 21418 | D(p->level--); |
| 21419 | return NULL; |
| 21420 | } |
| 21421 | asdl_seq * _res = NULL; |
| 21422 | int _mark = p->mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21423 | { // with_item _loop0_42 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21424 | if (p->error_indicator) { |
| 21425 | D(p->level--); |
| 21426 | return NULL; |
| 21427 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21428 | D(fprintf(stderr, "%*c> _gather_41[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_42")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21429 | withitem_ty elem; |
| 21430 | asdl_seq * seq; |
| 21431 | if ( |
| 21432 | (elem = with_item_rule(p)) // with_item |
| 21433 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21434 | (seq = _loop0_42_rule(p)) // _loop0_42 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21435 | ) |
| 21436 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21437 | D(fprintf(stderr, "%*c+ _gather_41[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_42")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21438 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 21439 | goto done; |
| 21440 | } |
| 21441 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21442 | D(fprintf(stderr, "%*c%s _gather_41[%d-%d]: %s failed!\n", p->level, ' ', |
| 21443 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_42")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21444 | } |
| 21445 | _res = NULL; |
| 21446 | done: |
| 21447 | D(p->level--); |
| 21448 | return _res; |
| 21449 | } |
| 21450 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21451 | // _loop0_44: ',' with_item |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21452 | static asdl_seq * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21453 | _loop0_44_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21454 | { |
| 21455 | D(p->level++); |
| 21456 | if (p->error_indicator) { |
| 21457 | D(p->level--); |
| 21458 | return NULL; |
| 21459 | } |
| 21460 | void *_res = NULL; |
| 21461 | int _mark = p->mark; |
| 21462 | int _start_mark = p->mark; |
| 21463 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 21464 | if (!_children) { |
| 21465 | p->error_indicator = 1; |
| 21466 | PyErr_NoMemory(); |
| 21467 | D(p->level--); |
| 21468 | return NULL; |
| 21469 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 21470 | Py_ssize_t _children_capacity = 1; |
| 21471 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21472 | { // ',' with_item |
| 21473 | if (p->error_indicator) { |
| 21474 | D(p->level--); |
| 21475 | return NULL; |
| 21476 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21477 | D(fprintf(stderr, "%*c> _loop0_44[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21478 | Token * _literal; |
| 21479 | withitem_ty elem; |
| 21480 | while ( |
| 21481 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 21482 | && |
| 21483 | (elem = with_item_rule(p)) // with_item |
| 21484 | ) |
| 21485 | { |
| 21486 | _res = elem; |
| 21487 | if (_res == NULL && PyErr_Occurred()) { |
| 21488 | p->error_indicator = 1; |
| 21489 | PyMem_Free(_children); |
| 21490 | D(p->level--); |
| 21491 | return NULL; |
| 21492 | } |
| 21493 | if (_n == _children_capacity) { |
| 21494 | _children_capacity *= 2; |
| 21495 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 21496 | if (!_new_children) { |
| 21497 | p->error_indicator = 1; |
| 21498 | PyErr_NoMemory(); |
| 21499 | D(p->level--); |
| 21500 | return NULL; |
| 21501 | } |
| 21502 | _children = _new_children; |
| 21503 | } |
| 21504 | _children[_n++] = _res; |
| 21505 | _mark = p->mark; |
| 21506 | } |
| 21507 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21508 | D(fprintf(stderr, "%*c%s _loop0_44[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21509 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); |
| 21510 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 21511 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21512 | if (!_seq) { |
| 21513 | PyMem_Free(_children); |
| 21514 | p->error_indicator = 1; |
| 21515 | PyErr_NoMemory(); |
| 21516 | D(p->level--); |
| 21517 | return NULL; |
| 21518 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 21519 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21520 | PyMem_Free(_children); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21521 | _PyPegen_insert_memo(p, _start_mark, _loop0_44_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21522 | D(p->level--); |
| 21523 | return _seq; |
| 21524 | } |
| 21525 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21526 | // _gather_43: with_item _loop0_44 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21527 | static asdl_seq * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21528 | _gather_43_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21529 | { |
| 21530 | D(p->level++); |
| 21531 | if (p->error_indicator) { |
| 21532 | D(p->level--); |
| 21533 | return NULL; |
| 21534 | } |
| 21535 | asdl_seq * _res = NULL; |
| 21536 | int _mark = p->mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21537 | { // with_item _loop0_44 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21538 | if (p->error_indicator) { |
| 21539 | D(p->level--); |
| 21540 | return NULL; |
| 21541 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21542 | D(fprintf(stderr, "%*c> _gather_43[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_44")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21543 | withitem_ty elem; |
| 21544 | asdl_seq * seq; |
| 21545 | if ( |
| 21546 | (elem = with_item_rule(p)) // with_item |
| 21547 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21548 | (seq = _loop0_44_rule(p)) // _loop0_44 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21549 | ) |
| 21550 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21551 | D(fprintf(stderr, "%*c+ _gather_43[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_44")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21552 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 21553 | goto done; |
| 21554 | } |
| 21555 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21556 | D(fprintf(stderr, "%*c%s _gather_43[%d-%d]: %s failed!\n", p->level, ' ', |
| 21557 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_44")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21558 | } |
| 21559 | _res = NULL; |
| 21560 | done: |
| 21561 | D(p->level--); |
| 21562 | return _res; |
| 21563 | } |
| 21564 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21565 | // _loop0_46: ',' with_item |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21566 | static asdl_seq * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21567 | _loop0_46_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21568 | { |
| 21569 | D(p->level++); |
| 21570 | if (p->error_indicator) { |
| 21571 | D(p->level--); |
| 21572 | return NULL; |
| 21573 | } |
| 21574 | void *_res = NULL; |
| 21575 | int _mark = p->mark; |
| 21576 | int _start_mark = p->mark; |
| 21577 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 21578 | if (!_children) { |
| 21579 | p->error_indicator = 1; |
| 21580 | PyErr_NoMemory(); |
| 21581 | D(p->level--); |
| 21582 | return NULL; |
| 21583 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 21584 | Py_ssize_t _children_capacity = 1; |
| 21585 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21586 | { // ',' with_item |
| 21587 | if (p->error_indicator) { |
| 21588 | D(p->level--); |
| 21589 | return NULL; |
| 21590 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21591 | D(fprintf(stderr, "%*c> _loop0_46[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21592 | Token * _literal; |
| 21593 | withitem_ty elem; |
| 21594 | while ( |
| 21595 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 21596 | && |
| 21597 | (elem = with_item_rule(p)) // with_item |
| 21598 | ) |
| 21599 | { |
| 21600 | _res = elem; |
| 21601 | if (_res == NULL && PyErr_Occurred()) { |
| 21602 | p->error_indicator = 1; |
| 21603 | PyMem_Free(_children); |
| 21604 | D(p->level--); |
| 21605 | return NULL; |
| 21606 | } |
| 21607 | if (_n == _children_capacity) { |
| 21608 | _children_capacity *= 2; |
| 21609 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 21610 | if (!_new_children) { |
| 21611 | p->error_indicator = 1; |
| 21612 | PyErr_NoMemory(); |
| 21613 | D(p->level--); |
| 21614 | return NULL; |
| 21615 | } |
| 21616 | _children = _new_children; |
| 21617 | } |
| 21618 | _children[_n++] = _res; |
| 21619 | _mark = p->mark; |
| 21620 | } |
| 21621 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21622 | D(fprintf(stderr, "%*c%s _loop0_46[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21623 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); |
| 21624 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 21625 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21626 | if (!_seq) { |
| 21627 | PyMem_Free(_children); |
| 21628 | p->error_indicator = 1; |
| 21629 | PyErr_NoMemory(); |
| 21630 | D(p->level--); |
| 21631 | return NULL; |
| 21632 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 21633 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21634 | PyMem_Free(_children); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21635 | _PyPegen_insert_memo(p, _start_mark, _loop0_46_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21636 | D(p->level--); |
| 21637 | return _seq; |
| 21638 | } |
| 21639 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21640 | // _gather_45: with_item _loop0_46 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21641 | static asdl_seq * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21642 | _gather_45_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21643 | { |
| 21644 | D(p->level++); |
| 21645 | if (p->error_indicator) { |
| 21646 | D(p->level--); |
| 21647 | return NULL; |
| 21648 | } |
| 21649 | asdl_seq * _res = NULL; |
| 21650 | int _mark = p->mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21651 | { // with_item _loop0_46 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21652 | if (p->error_indicator) { |
| 21653 | D(p->level--); |
| 21654 | return NULL; |
| 21655 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21656 | D(fprintf(stderr, "%*c> _gather_45[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_46")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21657 | withitem_ty elem; |
| 21658 | asdl_seq * seq; |
| 21659 | if ( |
| 21660 | (elem = with_item_rule(p)) // with_item |
| 21661 | && |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21662 | (seq = _loop0_46_rule(p)) // _loop0_46 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21663 | ) |
| 21664 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21665 | D(fprintf(stderr, "%*c+ _gather_45[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_46")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21666 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 21667 | goto done; |
| 21668 | } |
| 21669 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21670 | D(fprintf(stderr, "%*c%s _gather_45[%d-%d]: %s failed!\n", p->level, ' ', |
| 21671 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_46")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21672 | } |
| 21673 | _res = NULL; |
| 21674 | done: |
| 21675 | D(p->level--); |
| 21676 | return _res; |
| 21677 | } |
| 21678 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21679 | // _tmp_47: ',' | ')' | ':' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21680 | static void * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21681 | _tmp_47_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21682 | { |
| 21683 | D(p->level++); |
| 21684 | if (p->error_indicator) { |
| 21685 | D(p->level--); |
| 21686 | return NULL; |
| 21687 | } |
| 21688 | void * _res = NULL; |
| 21689 | int _mark = p->mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21690 | { // ',' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21691 | if (p->error_indicator) { |
| 21692 | D(p->level--); |
| 21693 | return NULL; |
| 21694 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21695 | D(fprintf(stderr, "%*c> _tmp_47[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); |
| 21696 | Token * _literal; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21697 | if ( |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21698 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21699 | ) |
| 21700 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21701 | D(fprintf(stderr, "%*c+ _tmp_47[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); |
| 21702 | _res = _literal; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21703 | goto done; |
| 21704 | } |
| 21705 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21706 | D(fprintf(stderr, "%*c%s _tmp_47[%d-%d]: %s failed!\n", p->level, ' ', |
| 21707 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); |
| 21708 | } |
| 21709 | { // ')' |
| 21710 | if (p->error_indicator) { |
| 21711 | D(p->level--); |
| 21712 | return NULL; |
| 21713 | } |
| 21714 | D(fprintf(stderr, "%*c> _tmp_47[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); |
| 21715 | Token * _literal; |
| 21716 | if ( |
| 21717 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
| 21718 | ) |
| 21719 | { |
| 21720 | D(fprintf(stderr, "%*c+ _tmp_47[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); |
| 21721 | _res = _literal; |
| 21722 | goto done; |
| 21723 | } |
| 21724 | p->mark = _mark; |
| 21725 | D(fprintf(stderr, "%*c%s _tmp_47[%d-%d]: %s failed!\n", p->level, ' ', |
| 21726 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); |
| 21727 | } |
| 21728 | { // ':' |
| 21729 | if (p->error_indicator) { |
| 21730 | D(p->level--); |
| 21731 | return NULL; |
| 21732 | } |
| 21733 | D(fprintf(stderr, "%*c> _tmp_47[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); |
| 21734 | Token * _literal; |
| 21735 | if ( |
| 21736 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 21737 | ) |
| 21738 | { |
| 21739 | D(fprintf(stderr, "%*c+ _tmp_47[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); |
| 21740 | _res = _literal; |
| 21741 | goto done; |
| 21742 | } |
| 21743 | p->mark = _mark; |
| 21744 | D(fprintf(stderr, "%*c%s _tmp_47[%d-%d]: %s failed!\n", p->level, ' ', |
| 21745 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21746 | } |
| 21747 | _res = NULL; |
| 21748 | done: |
| 21749 | D(p->level--); |
| 21750 | return _res; |
| 21751 | } |
| 21752 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21753 | // _loop1_48: except_block |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21754 | static asdl_seq * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21755 | _loop1_48_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21756 | { |
| 21757 | D(p->level++); |
| 21758 | if (p->error_indicator) { |
| 21759 | D(p->level--); |
| 21760 | return NULL; |
| 21761 | } |
| 21762 | void *_res = NULL; |
| 21763 | int _mark = p->mark; |
| 21764 | int _start_mark = p->mark; |
| 21765 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 21766 | if (!_children) { |
| 21767 | p->error_indicator = 1; |
| 21768 | PyErr_NoMemory(); |
| 21769 | D(p->level--); |
| 21770 | return NULL; |
| 21771 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 21772 | Py_ssize_t _children_capacity = 1; |
| 21773 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21774 | { // except_block |
| 21775 | if (p->error_indicator) { |
| 21776 | D(p->level--); |
| 21777 | return NULL; |
| 21778 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21779 | D(fprintf(stderr, "%*c> _loop1_48[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21780 | excepthandler_ty except_block_var; |
| 21781 | while ( |
| 21782 | (except_block_var = except_block_rule(p)) // except_block |
| 21783 | ) |
| 21784 | { |
| 21785 | _res = except_block_var; |
| 21786 | if (_n == _children_capacity) { |
| 21787 | _children_capacity *= 2; |
| 21788 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 21789 | if (!_new_children) { |
| 21790 | p->error_indicator = 1; |
| 21791 | PyErr_NoMemory(); |
| 21792 | D(p->level--); |
| 21793 | return NULL; |
| 21794 | } |
| 21795 | _children = _new_children; |
| 21796 | } |
| 21797 | _children[_n++] = _res; |
| 21798 | _mark = p->mark; |
| 21799 | } |
| 21800 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21801 | D(fprintf(stderr, "%*c%s _loop1_48[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21802 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_block")); |
| 21803 | } |
| 21804 | if (_n == 0 || p->error_indicator) { |
| 21805 | PyMem_Free(_children); |
| 21806 | D(p->level--); |
| 21807 | return NULL; |
| 21808 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 21809 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21810 | if (!_seq) { |
| 21811 | PyMem_Free(_children); |
| 21812 | p->error_indicator = 1; |
| 21813 | PyErr_NoMemory(); |
| 21814 | D(p->level--); |
| 21815 | return NULL; |
| 21816 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 21817 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21818 | PyMem_Free(_children); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21819 | _PyPegen_insert_memo(p, _start_mark, _loop1_48_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21820 | D(p->level--); |
| 21821 | return _seq; |
| 21822 | } |
| 21823 | |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21824 | // _tmp_49: 'as' NAME |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21825 | static void * |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21826 | _tmp_49_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21827 | { |
| 21828 | D(p->level++); |
| 21829 | if (p->error_indicator) { |
| 21830 | D(p->level--); |
| 21831 | return NULL; |
| 21832 | } |
| 21833 | void * _res = NULL; |
| 21834 | int _mark = p->mark; |
| 21835 | { // 'as' NAME |
| 21836 | if (p->error_indicator) { |
| 21837 | D(p->level--); |
| 21838 | return NULL; |
| 21839 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21840 | D(fprintf(stderr, "%*c> _tmp_49[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21841 | Token * _keyword; |
| 21842 | expr_ty z; |
| 21843 | if ( |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21844 | (_keyword = _PyPegen_expect_token(p, 520)) // token='as' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21845 | && |
| 21846 | (z = _PyPegen_name_token(p)) // NAME |
| 21847 | ) |
| 21848 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21849 | D(fprintf(stderr, "%*c+ _tmp_49[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21850 | _res = z; |
| 21851 | if (_res == NULL && PyErr_Occurred()) { |
| 21852 | p->error_indicator = 1; |
| 21853 | D(p->level--); |
| 21854 | return NULL; |
| 21855 | } |
| 21856 | goto done; |
| 21857 | } |
| 21858 | p->mark = _mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 21859 | D(fprintf(stderr, "%*c%s _tmp_49[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 21860 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); |
| 21861 | } |
| 21862 | _res = NULL; |
| 21863 | done: |
| 21864 | D(p->level--); |
| 21865 | return _res; |
| 21866 | } |
| 21867 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 21868 | // _loop1_50: case_block |
| 21869 | static asdl_seq * |
| 21870 | _loop1_50_rule(Parser *p) |
| 21871 | { |
| 21872 | D(p->level++); |
| 21873 | if (p->error_indicator) { |
| 21874 | D(p->level--); |
| 21875 | return NULL; |
| 21876 | } |
| 21877 | void *_res = NULL; |
| 21878 | int _mark = p->mark; |
| 21879 | int _start_mark = p->mark; |
| 21880 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 21881 | if (!_children) { |
| 21882 | p->error_indicator = 1; |
| 21883 | PyErr_NoMemory(); |
| 21884 | D(p->level--); |
| 21885 | return NULL; |
| 21886 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 21887 | Py_ssize_t _children_capacity = 1; |
| 21888 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 21889 | { // case_block |
| 21890 | if (p->error_indicator) { |
| 21891 | D(p->level--); |
| 21892 | return NULL; |
| 21893 | } |
| 21894 | D(fprintf(stderr, "%*c> _loop1_50[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "case_block")); |
| 21895 | match_case_ty case_block_var; |
| 21896 | while ( |
| 21897 | (case_block_var = case_block_rule(p)) // case_block |
| 21898 | ) |
| 21899 | { |
| 21900 | _res = case_block_var; |
| 21901 | if (_n == _children_capacity) { |
| 21902 | _children_capacity *= 2; |
| 21903 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 21904 | if (!_new_children) { |
| 21905 | p->error_indicator = 1; |
| 21906 | PyErr_NoMemory(); |
| 21907 | D(p->level--); |
| 21908 | return NULL; |
| 21909 | } |
| 21910 | _children = _new_children; |
| 21911 | } |
| 21912 | _children[_n++] = _res; |
| 21913 | _mark = p->mark; |
| 21914 | } |
| 21915 | p->mark = _mark; |
| 21916 | D(fprintf(stderr, "%*c%s _loop1_50[%d-%d]: %s failed!\n", p->level, ' ', |
| 21917 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "case_block")); |
| 21918 | } |
| 21919 | if (_n == 0 || p->error_indicator) { |
| 21920 | PyMem_Free(_children); |
| 21921 | D(p->level--); |
| 21922 | return NULL; |
| 21923 | } |
| 21924 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 21925 | if (!_seq) { |
| 21926 | PyMem_Free(_children); |
| 21927 | p->error_indicator = 1; |
| 21928 | PyErr_NoMemory(); |
| 21929 | D(p->level--); |
| 21930 | return NULL; |
| 21931 | } |
| 21932 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 21933 | PyMem_Free(_children); |
| 21934 | _PyPegen_insert_memo(p, _start_mark, _loop1_50_type, _seq); |
| 21935 | D(p->level--); |
| 21936 | return _seq; |
| 21937 | } |
| 21938 | |
| 21939 | // _loop0_52: '|' closed_pattern |
| 21940 | static asdl_seq * |
| 21941 | _loop0_52_rule(Parser *p) |
| 21942 | { |
| 21943 | D(p->level++); |
| 21944 | if (p->error_indicator) { |
| 21945 | D(p->level--); |
| 21946 | return NULL; |
| 21947 | } |
| 21948 | void *_res = NULL; |
| 21949 | int _mark = p->mark; |
| 21950 | int _start_mark = p->mark; |
| 21951 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 21952 | if (!_children) { |
| 21953 | p->error_indicator = 1; |
| 21954 | PyErr_NoMemory(); |
| 21955 | D(p->level--); |
| 21956 | return NULL; |
| 21957 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 21958 | Py_ssize_t _children_capacity = 1; |
| 21959 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 21960 | { // '|' closed_pattern |
| 21961 | if (p->error_indicator) { |
| 21962 | D(p->level--); |
| 21963 | return NULL; |
| 21964 | } |
| 21965 | D(fprintf(stderr, "%*c> _loop0_52[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|' closed_pattern")); |
| 21966 | Token * _literal; |
| 21967 | expr_ty elem; |
| 21968 | while ( |
| 21969 | (_literal = _PyPegen_expect_token(p, 18)) // token='|' |
| 21970 | && |
| 21971 | (elem = closed_pattern_rule(p)) // closed_pattern |
| 21972 | ) |
| 21973 | { |
| 21974 | _res = elem; |
| 21975 | if (_res == NULL && PyErr_Occurred()) { |
| 21976 | p->error_indicator = 1; |
| 21977 | PyMem_Free(_children); |
| 21978 | D(p->level--); |
| 21979 | return NULL; |
| 21980 | } |
| 21981 | if (_n == _children_capacity) { |
| 21982 | _children_capacity *= 2; |
| 21983 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 21984 | if (!_new_children) { |
| 21985 | p->error_indicator = 1; |
| 21986 | PyErr_NoMemory(); |
| 21987 | D(p->level--); |
| 21988 | return NULL; |
| 21989 | } |
| 21990 | _children = _new_children; |
| 21991 | } |
| 21992 | _children[_n++] = _res; |
| 21993 | _mark = p->mark; |
| 21994 | } |
| 21995 | p->mark = _mark; |
| 21996 | D(fprintf(stderr, "%*c%s _loop0_52[%d-%d]: %s failed!\n", p->level, ' ', |
| 21997 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|' closed_pattern")); |
| 21998 | } |
| 21999 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 22000 | if (!_seq) { |
| 22001 | PyMem_Free(_children); |
| 22002 | p->error_indicator = 1; |
| 22003 | PyErr_NoMemory(); |
| 22004 | D(p->level--); |
| 22005 | return NULL; |
| 22006 | } |
| 22007 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 22008 | PyMem_Free(_children); |
| 22009 | _PyPegen_insert_memo(p, _start_mark, _loop0_52_type, _seq); |
| 22010 | D(p->level--); |
| 22011 | return _seq; |
| 22012 | } |
| 22013 | |
| 22014 | // _gather_51: closed_pattern _loop0_52 |
| 22015 | static asdl_seq * |
| 22016 | _gather_51_rule(Parser *p) |
| 22017 | { |
| 22018 | D(p->level++); |
| 22019 | if (p->error_indicator) { |
| 22020 | D(p->level--); |
| 22021 | return NULL; |
| 22022 | } |
| 22023 | asdl_seq * _res = NULL; |
| 22024 | int _mark = p->mark; |
| 22025 | { // closed_pattern _loop0_52 |
| 22026 | if (p->error_indicator) { |
| 22027 | D(p->level--); |
| 22028 | return NULL; |
| 22029 | } |
| 22030 | D(fprintf(stderr, "%*c> _gather_51[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "closed_pattern _loop0_52")); |
| 22031 | expr_ty elem; |
| 22032 | asdl_seq * seq; |
| 22033 | if ( |
| 22034 | (elem = closed_pattern_rule(p)) // closed_pattern |
| 22035 | && |
| 22036 | (seq = _loop0_52_rule(p)) // _loop0_52 |
| 22037 | ) |
| 22038 | { |
| 22039 | D(fprintf(stderr, "%*c+ _gather_51[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "closed_pattern _loop0_52")); |
| 22040 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 22041 | goto done; |
| 22042 | } |
| 22043 | p->mark = _mark; |
| 22044 | D(fprintf(stderr, "%*c%s _gather_51[%d-%d]: %s failed!\n", p->level, ' ', |
| 22045 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "closed_pattern _loop0_52")); |
| 22046 | } |
| 22047 | _res = NULL; |
| 22048 | done: |
| 22049 | D(p->level--); |
| 22050 | return _res; |
| 22051 | } |
| 22052 | |
| 22053 | // _tmp_53: '+' | '-' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22054 | static void * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22055 | _tmp_53_rule(Parser *p) |
| 22056 | { |
| 22057 | D(p->level++); |
| 22058 | if (p->error_indicator) { |
| 22059 | D(p->level--); |
| 22060 | return NULL; |
| 22061 | } |
| 22062 | void * _res = NULL; |
| 22063 | int _mark = p->mark; |
| 22064 | { // '+' |
| 22065 | if (p->error_indicator) { |
| 22066 | D(p->level--); |
| 22067 | return NULL; |
| 22068 | } |
| 22069 | D(fprintf(stderr, "%*c> _tmp_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+'")); |
| 22070 | Token * _literal; |
| 22071 | if ( |
| 22072 | (_literal = _PyPegen_expect_token(p, 14)) // token='+' |
| 22073 | ) |
| 22074 | { |
| 22075 | D(fprintf(stderr, "%*c+ _tmp_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+'")); |
| 22076 | _res = _literal; |
| 22077 | goto done; |
| 22078 | } |
| 22079 | p->mark = _mark; |
| 22080 | D(fprintf(stderr, "%*c%s _tmp_53[%d-%d]: %s failed!\n", p->level, ' ', |
| 22081 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+'")); |
| 22082 | } |
| 22083 | { // '-' |
| 22084 | if (p->error_indicator) { |
| 22085 | D(p->level--); |
| 22086 | return NULL; |
| 22087 | } |
| 22088 | D(fprintf(stderr, "%*c> _tmp_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-'")); |
| 22089 | Token * _literal; |
| 22090 | if ( |
| 22091 | (_literal = _PyPegen_expect_token(p, 15)) // token='-' |
| 22092 | ) |
| 22093 | { |
| 22094 | D(fprintf(stderr, "%*c+ _tmp_53[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-'")); |
| 22095 | _res = _literal; |
| 22096 | goto done; |
| 22097 | } |
| 22098 | p->mark = _mark; |
| 22099 | D(fprintf(stderr, "%*c%s _tmp_53[%d-%d]: %s failed!\n", p->level, ' ', |
| 22100 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-'")); |
| 22101 | } |
| 22102 | _res = NULL; |
| 22103 | done: |
| 22104 | D(p->level--); |
| 22105 | return _res; |
| 22106 | } |
| 22107 | |
| 22108 | // _tmp_54: '.' | '(' | '=' |
| 22109 | static void * |
| 22110 | _tmp_54_rule(Parser *p) |
| 22111 | { |
| 22112 | D(p->level++); |
| 22113 | if (p->error_indicator) { |
| 22114 | D(p->level--); |
| 22115 | return NULL; |
| 22116 | } |
| 22117 | void * _res = NULL; |
| 22118 | int _mark = p->mark; |
| 22119 | { // '.' |
| 22120 | if (p->error_indicator) { |
| 22121 | D(p->level--); |
| 22122 | return NULL; |
| 22123 | } |
| 22124 | D(fprintf(stderr, "%*c> _tmp_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); |
| 22125 | Token * _literal; |
| 22126 | if ( |
| 22127 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 22128 | ) |
| 22129 | { |
| 22130 | D(fprintf(stderr, "%*c+ _tmp_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); |
| 22131 | _res = _literal; |
| 22132 | goto done; |
| 22133 | } |
| 22134 | p->mark = _mark; |
| 22135 | D(fprintf(stderr, "%*c%s _tmp_54[%d-%d]: %s failed!\n", p->level, ' ', |
| 22136 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); |
| 22137 | } |
| 22138 | { // '(' |
| 22139 | if (p->error_indicator) { |
| 22140 | D(p->level--); |
| 22141 | return NULL; |
| 22142 | } |
| 22143 | D(fprintf(stderr, "%*c> _tmp_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); |
| 22144 | Token * _literal; |
| 22145 | if ( |
| 22146 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 22147 | ) |
| 22148 | { |
| 22149 | D(fprintf(stderr, "%*c+ _tmp_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); |
| 22150 | _res = _literal; |
| 22151 | goto done; |
| 22152 | } |
| 22153 | p->mark = _mark; |
| 22154 | D(fprintf(stderr, "%*c%s _tmp_54[%d-%d]: %s failed!\n", p->level, ' ', |
| 22155 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); |
| 22156 | } |
| 22157 | { // '=' |
| 22158 | if (p->error_indicator) { |
| 22159 | D(p->level--); |
| 22160 | return NULL; |
| 22161 | } |
| 22162 | D(fprintf(stderr, "%*c> _tmp_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); |
| 22163 | Token * _literal; |
| 22164 | if ( |
| 22165 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 22166 | ) |
| 22167 | { |
| 22168 | D(fprintf(stderr, "%*c+ _tmp_54[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); |
| 22169 | _res = _literal; |
| 22170 | goto done; |
| 22171 | } |
| 22172 | p->mark = _mark; |
| 22173 | D(fprintf(stderr, "%*c%s _tmp_54[%d-%d]: %s failed!\n", p->level, ' ', |
| 22174 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); |
| 22175 | } |
| 22176 | _res = NULL; |
| 22177 | done: |
| 22178 | D(p->level--); |
| 22179 | return _res; |
| 22180 | } |
| 22181 | |
| 22182 | // _tmp_55: '.' | '(' | '=' |
| 22183 | static void * |
| 22184 | _tmp_55_rule(Parser *p) |
| 22185 | { |
| 22186 | D(p->level++); |
| 22187 | if (p->error_indicator) { |
| 22188 | D(p->level--); |
| 22189 | return NULL; |
| 22190 | } |
| 22191 | void * _res = NULL; |
| 22192 | int _mark = p->mark; |
| 22193 | { // '.' |
| 22194 | if (p->error_indicator) { |
| 22195 | D(p->level--); |
| 22196 | return NULL; |
| 22197 | } |
| 22198 | D(fprintf(stderr, "%*c> _tmp_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); |
| 22199 | Token * _literal; |
| 22200 | if ( |
| 22201 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 22202 | ) |
| 22203 | { |
| 22204 | D(fprintf(stderr, "%*c+ _tmp_55[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); |
| 22205 | _res = _literal; |
| 22206 | goto done; |
| 22207 | } |
| 22208 | p->mark = _mark; |
| 22209 | D(fprintf(stderr, "%*c%s _tmp_55[%d-%d]: %s failed!\n", p->level, ' ', |
| 22210 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); |
| 22211 | } |
| 22212 | { // '(' |
| 22213 | if (p->error_indicator) { |
| 22214 | D(p->level--); |
| 22215 | return NULL; |
| 22216 | } |
| 22217 | D(fprintf(stderr, "%*c> _tmp_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); |
| 22218 | Token * _literal; |
| 22219 | if ( |
| 22220 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 22221 | ) |
| 22222 | { |
| 22223 | D(fprintf(stderr, "%*c+ _tmp_55[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); |
| 22224 | _res = _literal; |
| 22225 | goto done; |
| 22226 | } |
| 22227 | p->mark = _mark; |
| 22228 | D(fprintf(stderr, "%*c%s _tmp_55[%d-%d]: %s failed!\n", p->level, ' ', |
| 22229 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); |
| 22230 | } |
| 22231 | { // '=' |
| 22232 | if (p->error_indicator) { |
| 22233 | D(p->level--); |
| 22234 | return NULL; |
| 22235 | } |
| 22236 | D(fprintf(stderr, "%*c> _tmp_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); |
| 22237 | Token * _literal; |
| 22238 | if ( |
| 22239 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 22240 | ) |
| 22241 | { |
| 22242 | D(fprintf(stderr, "%*c+ _tmp_55[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); |
| 22243 | _res = _literal; |
| 22244 | goto done; |
| 22245 | } |
| 22246 | p->mark = _mark; |
| 22247 | D(fprintf(stderr, "%*c%s _tmp_55[%d-%d]: %s failed!\n", p->level, ' ', |
| 22248 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); |
| 22249 | } |
| 22250 | _res = NULL; |
| 22251 | done: |
| 22252 | D(p->level--); |
| 22253 | return _res; |
| 22254 | } |
| 22255 | |
| 22256 | // _loop0_57: ',' maybe_star_pattern |
| 22257 | static asdl_seq * |
| 22258 | _loop0_57_rule(Parser *p) |
| 22259 | { |
| 22260 | D(p->level++); |
| 22261 | if (p->error_indicator) { |
| 22262 | D(p->level--); |
| 22263 | return NULL; |
| 22264 | } |
| 22265 | void *_res = NULL; |
| 22266 | int _mark = p->mark; |
| 22267 | int _start_mark = p->mark; |
| 22268 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 22269 | if (!_children) { |
| 22270 | p->error_indicator = 1; |
| 22271 | PyErr_NoMemory(); |
| 22272 | D(p->level--); |
| 22273 | return NULL; |
| 22274 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 22275 | Py_ssize_t _children_capacity = 1; |
| 22276 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22277 | { // ',' maybe_star_pattern |
| 22278 | if (p->error_indicator) { |
| 22279 | D(p->level--); |
| 22280 | return NULL; |
| 22281 | } |
| 22282 | D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' maybe_star_pattern")); |
| 22283 | Token * _literal; |
| 22284 | expr_ty elem; |
| 22285 | while ( |
| 22286 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 22287 | && |
| 22288 | (elem = maybe_star_pattern_rule(p)) // maybe_star_pattern |
| 22289 | ) |
| 22290 | { |
| 22291 | _res = elem; |
| 22292 | if (_res == NULL && PyErr_Occurred()) { |
| 22293 | p->error_indicator = 1; |
| 22294 | PyMem_Free(_children); |
| 22295 | D(p->level--); |
| 22296 | return NULL; |
| 22297 | } |
| 22298 | if (_n == _children_capacity) { |
| 22299 | _children_capacity *= 2; |
| 22300 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 22301 | if (!_new_children) { |
| 22302 | p->error_indicator = 1; |
| 22303 | PyErr_NoMemory(); |
| 22304 | D(p->level--); |
| 22305 | return NULL; |
| 22306 | } |
| 22307 | _children = _new_children; |
| 22308 | } |
| 22309 | _children[_n++] = _res; |
| 22310 | _mark = p->mark; |
| 22311 | } |
| 22312 | p->mark = _mark; |
| 22313 | D(fprintf(stderr, "%*c%s _loop0_57[%d-%d]: %s failed!\n", p->level, ' ', |
| 22314 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' maybe_star_pattern")); |
| 22315 | } |
| 22316 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 22317 | if (!_seq) { |
| 22318 | PyMem_Free(_children); |
| 22319 | p->error_indicator = 1; |
| 22320 | PyErr_NoMemory(); |
| 22321 | D(p->level--); |
| 22322 | return NULL; |
| 22323 | } |
| 22324 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 22325 | PyMem_Free(_children); |
| 22326 | _PyPegen_insert_memo(p, _start_mark, _loop0_57_type, _seq); |
| 22327 | D(p->level--); |
| 22328 | return _seq; |
| 22329 | } |
| 22330 | |
| 22331 | // _gather_56: maybe_star_pattern _loop0_57 |
| 22332 | static asdl_seq * |
| 22333 | _gather_56_rule(Parser *p) |
| 22334 | { |
| 22335 | D(p->level++); |
| 22336 | if (p->error_indicator) { |
| 22337 | D(p->level--); |
| 22338 | return NULL; |
| 22339 | } |
| 22340 | asdl_seq * _res = NULL; |
| 22341 | int _mark = p->mark; |
| 22342 | { // maybe_star_pattern _loop0_57 |
| 22343 | if (p->error_indicator) { |
| 22344 | D(p->level--); |
| 22345 | return NULL; |
| 22346 | } |
| 22347 | D(fprintf(stderr, "%*c> _gather_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern _loop0_57")); |
| 22348 | expr_ty elem; |
| 22349 | asdl_seq * seq; |
| 22350 | if ( |
| 22351 | (elem = maybe_star_pattern_rule(p)) // maybe_star_pattern |
| 22352 | && |
| 22353 | (seq = _loop0_57_rule(p)) // _loop0_57 |
| 22354 | ) |
| 22355 | { |
| 22356 | D(fprintf(stderr, "%*c+ _gather_56[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "maybe_star_pattern _loop0_57")); |
| 22357 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 22358 | goto done; |
| 22359 | } |
| 22360 | p->mark = _mark; |
| 22361 | D(fprintf(stderr, "%*c%s _gather_56[%d-%d]: %s failed!\n", p->level, ' ', |
| 22362 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "maybe_star_pattern _loop0_57")); |
| 22363 | } |
| 22364 | _res = NULL; |
| 22365 | done: |
| 22366 | D(p->level--); |
| 22367 | return _res; |
| 22368 | } |
| 22369 | |
| 22370 | // _tmp_58: capture_pattern | wildcard_pattern |
| 22371 | static void * |
| 22372 | _tmp_58_rule(Parser *p) |
| 22373 | { |
| 22374 | D(p->level++); |
| 22375 | if (p->error_indicator) { |
| 22376 | D(p->level--); |
| 22377 | return NULL; |
| 22378 | } |
| 22379 | void * _res = NULL; |
| 22380 | int _mark = p->mark; |
| 22381 | { // capture_pattern |
| 22382 | if (p->error_indicator) { |
| 22383 | D(p->level--); |
| 22384 | return NULL; |
| 22385 | } |
| 22386 | D(fprintf(stderr, "%*c> _tmp_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "capture_pattern")); |
| 22387 | expr_ty capture_pattern_var; |
| 22388 | if ( |
| 22389 | (capture_pattern_var = capture_pattern_rule(p)) // capture_pattern |
| 22390 | ) |
| 22391 | { |
| 22392 | D(fprintf(stderr, "%*c+ _tmp_58[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "capture_pattern")); |
| 22393 | _res = capture_pattern_var; |
| 22394 | goto done; |
| 22395 | } |
| 22396 | p->mark = _mark; |
| 22397 | D(fprintf(stderr, "%*c%s _tmp_58[%d-%d]: %s failed!\n", p->level, ' ', |
| 22398 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "capture_pattern")); |
| 22399 | } |
| 22400 | { // wildcard_pattern |
| 22401 | if (p->error_indicator) { |
| 22402 | D(p->level--); |
| 22403 | return NULL; |
| 22404 | } |
| 22405 | D(fprintf(stderr, "%*c> _tmp_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "wildcard_pattern")); |
| 22406 | expr_ty wildcard_pattern_var; |
| 22407 | if ( |
| 22408 | (wildcard_pattern_var = wildcard_pattern_rule(p)) // wildcard_pattern |
| 22409 | ) |
| 22410 | { |
| 22411 | D(fprintf(stderr, "%*c+ _tmp_58[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "wildcard_pattern")); |
| 22412 | _res = wildcard_pattern_var; |
| 22413 | goto done; |
| 22414 | } |
| 22415 | p->mark = _mark; |
| 22416 | D(fprintf(stderr, "%*c%s _tmp_58[%d-%d]: %s failed!\n", p->level, ' ', |
| 22417 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "wildcard_pattern")); |
| 22418 | } |
| 22419 | _res = NULL; |
| 22420 | done: |
| 22421 | D(p->level--); |
| 22422 | return _res; |
| 22423 | } |
| 22424 | |
| 22425 | // _loop0_60: ',' key_value_pattern |
| 22426 | static asdl_seq * |
| 22427 | _loop0_60_rule(Parser *p) |
| 22428 | { |
| 22429 | D(p->level++); |
| 22430 | if (p->error_indicator) { |
| 22431 | D(p->level--); |
| 22432 | return NULL; |
| 22433 | } |
| 22434 | void *_res = NULL; |
| 22435 | int _mark = p->mark; |
| 22436 | int _start_mark = p->mark; |
| 22437 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 22438 | if (!_children) { |
| 22439 | p->error_indicator = 1; |
| 22440 | PyErr_NoMemory(); |
| 22441 | D(p->level--); |
| 22442 | return NULL; |
| 22443 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 22444 | Py_ssize_t _children_capacity = 1; |
| 22445 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22446 | { // ',' key_value_pattern |
| 22447 | if (p->error_indicator) { |
| 22448 | D(p->level--); |
| 22449 | return NULL; |
| 22450 | } |
| 22451 | D(fprintf(stderr, "%*c> _loop0_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' key_value_pattern")); |
| 22452 | Token * _literal; |
| 22453 | KeyValuePair* elem; |
| 22454 | while ( |
| 22455 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 22456 | && |
| 22457 | (elem = key_value_pattern_rule(p)) // key_value_pattern |
| 22458 | ) |
| 22459 | { |
| 22460 | _res = elem; |
| 22461 | if (_res == NULL && PyErr_Occurred()) { |
| 22462 | p->error_indicator = 1; |
| 22463 | PyMem_Free(_children); |
| 22464 | D(p->level--); |
| 22465 | return NULL; |
| 22466 | } |
| 22467 | if (_n == _children_capacity) { |
| 22468 | _children_capacity *= 2; |
| 22469 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 22470 | if (!_new_children) { |
| 22471 | p->error_indicator = 1; |
| 22472 | PyErr_NoMemory(); |
| 22473 | D(p->level--); |
| 22474 | return NULL; |
| 22475 | } |
| 22476 | _children = _new_children; |
| 22477 | } |
| 22478 | _children[_n++] = _res; |
| 22479 | _mark = p->mark; |
| 22480 | } |
| 22481 | p->mark = _mark; |
| 22482 | D(fprintf(stderr, "%*c%s _loop0_60[%d-%d]: %s failed!\n", p->level, ' ', |
| 22483 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' key_value_pattern")); |
| 22484 | } |
| 22485 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 22486 | if (!_seq) { |
| 22487 | PyMem_Free(_children); |
| 22488 | p->error_indicator = 1; |
| 22489 | PyErr_NoMemory(); |
| 22490 | D(p->level--); |
| 22491 | return NULL; |
| 22492 | } |
| 22493 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 22494 | PyMem_Free(_children); |
| 22495 | _PyPegen_insert_memo(p, _start_mark, _loop0_60_type, _seq); |
| 22496 | D(p->level--); |
| 22497 | return _seq; |
| 22498 | } |
| 22499 | |
| 22500 | // _gather_59: key_value_pattern _loop0_60 |
| 22501 | static asdl_seq * |
| 22502 | _gather_59_rule(Parser *p) |
| 22503 | { |
| 22504 | D(p->level++); |
| 22505 | if (p->error_indicator) { |
| 22506 | D(p->level--); |
| 22507 | return NULL; |
| 22508 | } |
| 22509 | asdl_seq * _res = NULL; |
| 22510 | int _mark = p->mark; |
| 22511 | { // key_value_pattern _loop0_60 |
| 22512 | if (p->error_indicator) { |
| 22513 | D(p->level--); |
| 22514 | return NULL; |
| 22515 | } |
| 22516 | D(fprintf(stderr, "%*c> _gather_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_60")); |
| 22517 | KeyValuePair* elem; |
| 22518 | asdl_seq * seq; |
| 22519 | if ( |
| 22520 | (elem = key_value_pattern_rule(p)) // key_value_pattern |
| 22521 | && |
| 22522 | (seq = _loop0_60_rule(p)) // _loop0_60 |
| 22523 | ) |
| 22524 | { |
| 22525 | D(fprintf(stderr, "%*c+ _gather_59[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "key_value_pattern _loop0_60")); |
| 22526 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 22527 | goto done; |
| 22528 | } |
| 22529 | p->mark = _mark; |
| 22530 | D(fprintf(stderr, "%*c%s _gather_59[%d-%d]: %s failed!\n", p->level, ' ', |
| 22531 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "key_value_pattern _loop0_60")); |
| 22532 | } |
| 22533 | _res = NULL; |
| 22534 | done: |
| 22535 | D(p->level--); |
| 22536 | return _res; |
| 22537 | } |
| 22538 | |
| 22539 | // _tmp_61: literal_pattern | value_pattern |
| 22540 | static void * |
| 22541 | _tmp_61_rule(Parser *p) |
| 22542 | { |
| 22543 | D(p->level++); |
| 22544 | if (p->error_indicator) { |
| 22545 | D(p->level--); |
| 22546 | return NULL; |
| 22547 | } |
| 22548 | void * _res = NULL; |
| 22549 | int _mark = p->mark; |
| 22550 | { // literal_pattern |
| 22551 | if (p->error_indicator) { |
| 22552 | D(p->level--); |
| 22553 | return NULL; |
| 22554 | } |
| 22555 | D(fprintf(stderr, "%*c> _tmp_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "literal_pattern")); |
| 22556 | expr_ty literal_pattern_var; |
| 22557 | if ( |
| 22558 | (literal_pattern_var = literal_pattern_rule(p)) // literal_pattern |
| 22559 | ) |
| 22560 | { |
| 22561 | D(fprintf(stderr, "%*c+ _tmp_61[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "literal_pattern")); |
| 22562 | _res = literal_pattern_var; |
| 22563 | goto done; |
| 22564 | } |
| 22565 | p->mark = _mark; |
| 22566 | D(fprintf(stderr, "%*c%s _tmp_61[%d-%d]: %s failed!\n", p->level, ' ', |
| 22567 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "literal_pattern")); |
| 22568 | } |
| 22569 | { // value_pattern |
| 22570 | if (p->error_indicator) { |
| 22571 | D(p->level--); |
| 22572 | return NULL; |
| 22573 | } |
| 22574 | D(fprintf(stderr, "%*c> _tmp_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "value_pattern")); |
| 22575 | expr_ty value_pattern_var; |
| 22576 | if ( |
| 22577 | (value_pattern_var = value_pattern_rule(p)) // value_pattern |
| 22578 | ) |
| 22579 | { |
| 22580 | D(fprintf(stderr, "%*c+ _tmp_61[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "value_pattern")); |
| 22581 | _res = value_pattern_var; |
| 22582 | goto done; |
| 22583 | } |
| 22584 | p->mark = _mark; |
| 22585 | D(fprintf(stderr, "%*c%s _tmp_61[%d-%d]: %s failed!\n", p->level, ' ', |
| 22586 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "value_pattern")); |
| 22587 | } |
| 22588 | _res = NULL; |
| 22589 | done: |
| 22590 | D(p->level--); |
| 22591 | return _res; |
| 22592 | } |
| 22593 | |
| 22594 | // _loop0_63: ',' pattern |
| 22595 | static asdl_seq * |
| 22596 | _loop0_63_rule(Parser *p) |
| 22597 | { |
| 22598 | D(p->level++); |
| 22599 | if (p->error_indicator) { |
| 22600 | D(p->level--); |
| 22601 | return NULL; |
| 22602 | } |
| 22603 | void *_res = NULL; |
| 22604 | int _mark = p->mark; |
| 22605 | int _start_mark = p->mark; |
| 22606 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 22607 | if (!_children) { |
| 22608 | p->error_indicator = 1; |
| 22609 | PyErr_NoMemory(); |
| 22610 | D(p->level--); |
| 22611 | return NULL; |
| 22612 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 22613 | Py_ssize_t _children_capacity = 1; |
| 22614 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22615 | { // ',' pattern |
| 22616 | if (p->error_indicator) { |
| 22617 | D(p->level--); |
| 22618 | return NULL; |
| 22619 | } |
| 22620 | D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' pattern")); |
| 22621 | Token * _literal; |
| 22622 | expr_ty elem; |
| 22623 | while ( |
| 22624 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 22625 | && |
| 22626 | (elem = pattern_rule(p)) // pattern |
| 22627 | ) |
| 22628 | { |
| 22629 | _res = elem; |
| 22630 | if (_res == NULL && PyErr_Occurred()) { |
| 22631 | p->error_indicator = 1; |
| 22632 | PyMem_Free(_children); |
| 22633 | D(p->level--); |
| 22634 | return NULL; |
| 22635 | } |
| 22636 | if (_n == _children_capacity) { |
| 22637 | _children_capacity *= 2; |
| 22638 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 22639 | if (!_new_children) { |
| 22640 | p->error_indicator = 1; |
| 22641 | PyErr_NoMemory(); |
| 22642 | D(p->level--); |
| 22643 | return NULL; |
| 22644 | } |
| 22645 | _children = _new_children; |
| 22646 | } |
| 22647 | _children[_n++] = _res; |
| 22648 | _mark = p->mark; |
| 22649 | } |
| 22650 | p->mark = _mark; |
| 22651 | D(fprintf(stderr, "%*c%s _loop0_63[%d-%d]: %s failed!\n", p->level, ' ', |
| 22652 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' pattern")); |
| 22653 | } |
| 22654 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 22655 | if (!_seq) { |
| 22656 | PyMem_Free(_children); |
| 22657 | p->error_indicator = 1; |
| 22658 | PyErr_NoMemory(); |
| 22659 | D(p->level--); |
| 22660 | return NULL; |
| 22661 | } |
| 22662 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 22663 | PyMem_Free(_children); |
| 22664 | _PyPegen_insert_memo(p, _start_mark, _loop0_63_type, _seq); |
| 22665 | D(p->level--); |
| 22666 | return _seq; |
| 22667 | } |
| 22668 | |
| 22669 | // _gather_62: pattern _loop0_63 |
| 22670 | static asdl_seq * |
| 22671 | _gather_62_rule(Parser *p) |
| 22672 | { |
| 22673 | D(p->level++); |
| 22674 | if (p->error_indicator) { |
| 22675 | D(p->level--); |
| 22676 | return NULL; |
| 22677 | } |
| 22678 | asdl_seq * _res = NULL; |
| 22679 | int _mark = p->mark; |
| 22680 | { // pattern _loop0_63 |
| 22681 | if (p->error_indicator) { |
| 22682 | D(p->level--); |
| 22683 | return NULL; |
| 22684 | } |
| 22685 | D(fprintf(stderr, "%*c> _gather_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "pattern _loop0_63")); |
| 22686 | expr_ty elem; |
| 22687 | asdl_seq * seq; |
| 22688 | if ( |
| 22689 | (elem = pattern_rule(p)) // pattern |
| 22690 | && |
| 22691 | (seq = _loop0_63_rule(p)) // _loop0_63 |
| 22692 | ) |
| 22693 | { |
| 22694 | D(fprintf(stderr, "%*c+ _gather_62[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "pattern _loop0_63")); |
| 22695 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 22696 | goto done; |
| 22697 | } |
| 22698 | p->mark = _mark; |
| 22699 | D(fprintf(stderr, "%*c%s _gather_62[%d-%d]: %s failed!\n", p->level, ' ', |
| 22700 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "pattern _loop0_63")); |
| 22701 | } |
| 22702 | _res = NULL; |
| 22703 | done: |
| 22704 | D(p->level--); |
| 22705 | return _res; |
| 22706 | } |
| 22707 | |
| 22708 | // _loop0_65: ',' keyword_pattern |
| 22709 | static asdl_seq * |
| 22710 | _loop0_65_rule(Parser *p) |
| 22711 | { |
| 22712 | D(p->level++); |
| 22713 | if (p->error_indicator) { |
| 22714 | D(p->level--); |
| 22715 | return NULL; |
| 22716 | } |
| 22717 | void *_res = NULL; |
| 22718 | int _mark = p->mark; |
| 22719 | int _start_mark = p->mark; |
| 22720 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 22721 | if (!_children) { |
| 22722 | p->error_indicator = 1; |
| 22723 | PyErr_NoMemory(); |
| 22724 | D(p->level--); |
| 22725 | return NULL; |
| 22726 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 22727 | Py_ssize_t _children_capacity = 1; |
| 22728 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22729 | { // ',' keyword_pattern |
| 22730 | if (p->error_indicator) { |
| 22731 | D(p->level--); |
| 22732 | return NULL; |
| 22733 | } |
| 22734 | D(fprintf(stderr, "%*c> _loop0_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' keyword_pattern")); |
| 22735 | Token * _literal; |
| 22736 | keyword_ty elem; |
| 22737 | while ( |
| 22738 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 22739 | && |
| 22740 | (elem = keyword_pattern_rule(p)) // keyword_pattern |
| 22741 | ) |
| 22742 | { |
| 22743 | _res = elem; |
| 22744 | if (_res == NULL && PyErr_Occurred()) { |
| 22745 | p->error_indicator = 1; |
| 22746 | PyMem_Free(_children); |
| 22747 | D(p->level--); |
| 22748 | return NULL; |
| 22749 | } |
| 22750 | if (_n == _children_capacity) { |
| 22751 | _children_capacity *= 2; |
| 22752 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 22753 | if (!_new_children) { |
| 22754 | p->error_indicator = 1; |
| 22755 | PyErr_NoMemory(); |
| 22756 | D(p->level--); |
| 22757 | return NULL; |
| 22758 | } |
| 22759 | _children = _new_children; |
| 22760 | } |
| 22761 | _children[_n++] = _res; |
| 22762 | _mark = p->mark; |
| 22763 | } |
| 22764 | p->mark = _mark; |
| 22765 | D(fprintf(stderr, "%*c%s _loop0_65[%d-%d]: %s failed!\n", p->level, ' ', |
| 22766 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' keyword_pattern")); |
| 22767 | } |
| 22768 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 22769 | if (!_seq) { |
| 22770 | PyMem_Free(_children); |
| 22771 | p->error_indicator = 1; |
| 22772 | PyErr_NoMemory(); |
| 22773 | D(p->level--); |
| 22774 | return NULL; |
| 22775 | } |
| 22776 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 22777 | PyMem_Free(_children); |
| 22778 | _PyPegen_insert_memo(p, _start_mark, _loop0_65_type, _seq); |
| 22779 | D(p->level--); |
| 22780 | return _seq; |
| 22781 | } |
| 22782 | |
| 22783 | // _gather_64: keyword_pattern _loop0_65 |
| 22784 | static asdl_seq * |
| 22785 | _gather_64_rule(Parser *p) |
| 22786 | { |
| 22787 | D(p->level++); |
| 22788 | if (p->error_indicator) { |
| 22789 | D(p->level--); |
| 22790 | return NULL; |
| 22791 | } |
| 22792 | asdl_seq * _res = NULL; |
| 22793 | int _mark = p->mark; |
| 22794 | { // keyword_pattern _loop0_65 |
| 22795 | if (p->error_indicator) { |
| 22796 | D(p->level--); |
| 22797 | return NULL; |
| 22798 | } |
| 22799 | D(fprintf(stderr, "%*c> _gather_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_65")); |
| 22800 | keyword_ty elem; |
| 22801 | asdl_seq * seq; |
| 22802 | if ( |
| 22803 | (elem = keyword_pattern_rule(p)) // keyword_pattern |
| 22804 | && |
| 22805 | (seq = _loop0_65_rule(p)) // _loop0_65 |
| 22806 | ) |
| 22807 | { |
| 22808 | D(fprintf(stderr, "%*c+ _gather_64[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "keyword_pattern _loop0_65")); |
| 22809 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 22810 | goto done; |
| 22811 | } |
| 22812 | p->mark = _mark; |
| 22813 | D(fprintf(stderr, "%*c%s _gather_64[%d-%d]: %s failed!\n", p->level, ' ', |
| 22814 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "keyword_pattern _loop0_65")); |
| 22815 | } |
| 22816 | _res = NULL; |
| 22817 | done: |
| 22818 | D(p->level--); |
| 22819 | return _res; |
| 22820 | } |
| 22821 | |
| 22822 | // _tmp_66: 'from' expression |
| 22823 | static void * |
| 22824 | _tmp_66_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22825 | { |
| 22826 | D(p->level++); |
| 22827 | if (p->error_indicator) { |
| 22828 | D(p->level--); |
| 22829 | return NULL; |
| 22830 | } |
| 22831 | void * _res = NULL; |
| 22832 | int _mark = p->mark; |
| 22833 | { // 'from' expression |
| 22834 | if (p->error_indicator) { |
| 22835 | D(p->level--); |
| 22836 | return NULL; |
| 22837 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22838 | D(fprintf(stderr, "%*c> _tmp_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22839 | Token * _keyword; |
| 22840 | expr_ty z; |
| 22841 | if ( |
| 22842 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
| 22843 | && |
| 22844 | (z = expression_rule(p)) // expression |
| 22845 | ) |
| 22846 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22847 | D(fprintf(stderr, "%*c+ _tmp_66[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22848 | _res = z; |
| 22849 | if (_res == NULL && PyErr_Occurred()) { |
| 22850 | p->error_indicator = 1; |
| 22851 | D(p->level--); |
| 22852 | return NULL; |
| 22853 | } |
| 22854 | goto done; |
| 22855 | } |
| 22856 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22857 | D(fprintf(stderr, "%*c%s _tmp_66[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 22858 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22859 | } |
| 22860 | _res = NULL; |
| 22861 | done: |
| 22862 | D(p->level--); |
| 22863 | return _res; |
| 22864 | } |
| 22865 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22866 | // _tmp_67: '->' expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22867 | static void * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22868 | _tmp_67_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22869 | { |
| 22870 | D(p->level++); |
| 22871 | if (p->error_indicator) { |
| 22872 | D(p->level--); |
| 22873 | return NULL; |
| 22874 | } |
| 22875 | void * _res = NULL; |
| 22876 | int _mark = p->mark; |
| 22877 | { // '->' expression |
| 22878 | if (p->error_indicator) { |
| 22879 | D(p->level--); |
| 22880 | return NULL; |
| 22881 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22882 | D(fprintf(stderr, "%*c> _tmp_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22883 | Token * _literal; |
| 22884 | expr_ty z; |
| 22885 | if ( |
| 22886 | (_literal = _PyPegen_expect_token(p, 51)) // token='->' |
| 22887 | && |
| 22888 | (z = expression_rule(p)) // expression |
| 22889 | ) |
| 22890 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22891 | D(fprintf(stderr, "%*c+ _tmp_67[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22892 | _res = z; |
| 22893 | if (_res == NULL && PyErr_Occurred()) { |
| 22894 | p->error_indicator = 1; |
| 22895 | D(p->level--); |
| 22896 | return NULL; |
| 22897 | } |
| 22898 | goto done; |
| 22899 | } |
| 22900 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22901 | D(fprintf(stderr, "%*c%s _tmp_67[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22902 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); |
| 22903 | } |
| 22904 | _res = NULL; |
| 22905 | done: |
| 22906 | D(p->level--); |
| 22907 | return _res; |
| 22908 | } |
| 22909 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22910 | // _tmp_68: '->' expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22911 | static void * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22912 | _tmp_68_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22913 | { |
| 22914 | D(p->level++); |
| 22915 | if (p->error_indicator) { |
| 22916 | D(p->level--); |
| 22917 | return NULL; |
| 22918 | } |
| 22919 | void * _res = NULL; |
| 22920 | int _mark = p->mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 22921 | { // '->' expression |
| 22922 | if (p->error_indicator) { |
| 22923 | D(p->level--); |
| 22924 | return NULL; |
| 22925 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22926 | D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 22927 | Token * _literal; |
| 22928 | expr_ty z; |
| 22929 | if ( |
| 22930 | (_literal = _PyPegen_expect_token(p, 51)) // token='->' |
| 22931 | && |
| 22932 | (z = expression_rule(p)) // expression |
| 22933 | ) |
| 22934 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22935 | D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 22936 | _res = z; |
| 22937 | if (_res == NULL && PyErr_Occurred()) { |
| 22938 | p->error_indicator = 1; |
| 22939 | D(p->level--); |
| 22940 | return NULL; |
| 22941 | } |
| 22942 | goto done; |
| 22943 | } |
| 22944 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22945 | D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 22946 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); |
| 22947 | } |
| 22948 | _res = NULL; |
| 22949 | done: |
| 22950 | D(p->level--); |
| 22951 | return _res; |
| 22952 | } |
| 22953 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22954 | // _tmp_69: NEWLINE INDENT |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 22955 | static void * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22956 | _tmp_69_rule(Parser *p) |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 22957 | { |
| 22958 | D(p->level++); |
| 22959 | if (p->error_indicator) { |
| 22960 | D(p->level--); |
| 22961 | return NULL; |
| 22962 | } |
| 22963 | void * _res = NULL; |
| 22964 | int _mark = p->mark; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22965 | { // NEWLINE INDENT |
| 22966 | if (p->error_indicator) { |
| 22967 | D(p->level--); |
| 22968 | return NULL; |
| 22969 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22970 | D(fprintf(stderr, "%*c> _tmp_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22971 | Token * indent_var; |
| 22972 | Token * newline_var; |
| 22973 | if ( |
| 22974 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 22975 | && |
| 22976 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
| 22977 | ) |
| 22978 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22979 | D(fprintf(stderr, "%*c+ _tmp_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22980 | _res = _PyPegen_dummy_name(p, newline_var, indent_var); |
| 22981 | goto done; |
| 22982 | } |
| 22983 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22984 | D(fprintf(stderr, "%*c%s _tmp_69[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22985 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); |
| 22986 | } |
| 22987 | _res = NULL; |
| 22988 | done: |
| 22989 | D(p->level--); |
| 22990 | return _res; |
| 22991 | } |
| 22992 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22993 | // _loop0_70: param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22994 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 22995 | _loop0_70_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 22996 | { |
| 22997 | D(p->level++); |
| 22998 | if (p->error_indicator) { |
| 22999 | D(p->level--); |
| 23000 | return NULL; |
| 23001 | } |
| 23002 | void *_res = NULL; |
| 23003 | int _mark = p->mark; |
| 23004 | int _start_mark = p->mark; |
| 23005 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23006 | if (!_children) { |
| 23007 | p->error_indicator = 1; |
| 23008 | PyErr_NoMemory(); |
| 23009 | D(p->level--); |
| 23010 | return NULL; |
| 23011 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23012 | Py_ssize_t _children_capacity = 1; |
| 23013 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23014 | { // param_no_default |
| 23015 | if (p->error_indicator) { |
| 23016 | D(p->level--); |
| 23017 | return NULL; |
| 23018 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23019 | D(fprintf(stderr, "%*c> _loop0_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23020 | arg_ty param_no_default_var; |
| 23021 | while ( |
| 23022 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
| 23023 | ) |
| 23024 | { |
| 23025 | _res = param_no_default_var; |
| 23026 | if (_n == _children_capacity) { |
| 23027 | _children_capacity *= 2; |
| 23028 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23029 | if (!_new_children) { |
| 23030 | p->error_indicator = 1; |
| 23031 | PyErr_NoMemory(); |
| 23032 | D(p->level--); |
| 23033 | return NULL; |
| 23034 | } |
| 23035 | _children = _new_children; |
| 23036 | } |
| 23037 | _children[_n++] = _res; |
| 23038 | _mark = p->mark; |
| 23039 | } |
| 23040 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23041 | D(fprintf(stderr, "%*c%s _loop0_70[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23042 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23043 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23044 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23045 | if (!_seq) { |
| 23046 | PyMem_Free(_children); |
| 23047 | p->error_indicator = 1; |
| 23048 | PyErr_NoMemory(); |
| 23049 | D(p->level--); |
| 23050 | return NULL; |
| 23051 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23052 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23053 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23054 | _PyPegen_insert_memo(p, _start_mark, _loop0_70_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23055 | D(p->level--); |
| 23056 | return _seq; |
| 23057 | } |
| 23058 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23059 | // _loop0_71: param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23060 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23061 | _loop0_71_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23062 | { |
| 23063 | D(p->level++); |
| 23064 | if (p->error_indicator) { |
| 23065 | D(p->level--); |
| 23066 | return NULL; |
| 23067 | } |
| 23068 | void *_res = NULL; |
| 23069 | int _mark = p->mark; |
| 23070 | int _start_mark = p->mark; |
| 23071 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23072 | if (!_children) { |
| 23073 | p->error_indicator = 1; |
| 23074 | PyErr_NoMemory(); |
| 23075 | D(p->level--); |
| 23076 | return NULL; |
| 23077 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23078 | Py_ssize_t _children_capacity = 1; |
| 23079 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23080 | { // param_with_default |
| 23081 | if (p->error_indicator) { |
| 23082 | D(p->level--); |
| 23083 | return NULL; |
| 23084 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23085 | D(fprintf(stderr, "%*c> _loop0_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23086 | NameDefaultPair* param_with_default_var; |
| 23087 | while ( |
| 23088 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
| 23089 | ) |
| 23090 | { |
| 23091 | _res = param_with_default_var; |
| 23092 | if (_n == _children_capacity) { |
| 23093 | _children_capacity *= 2; |
| 23094 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23095 | if (!_new_children) { |
| 23096 | p->error_indicator = 1; |
| 23097 | PyErr_NoMemory(); |
| 23098 | D(p->level--); |
| 23099 | return NULL; |
| 23100 | } |
| 23101 | _children = _new_children; |
| 23102 | } |
| 23103 | _children[_n++] = _res; |
| 23104 | _mark = p->mark; |
| 23105 | } |
| 23106 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23107 | D(fprintf(stderr, "%*c%s _loop0_71[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23108 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); |
| 23109 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23110 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23111 | if (!_seq) { |
| 23112 | PyMem_Free(_children); |
| 23113 | p->error_indicator = 1; |
| 23114 | PyErr_NoMemory(); |
| 23115 | D(p->level--); |
| 23116 | return NULL; |
| 23117 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23118 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23119 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23120 | _PyPegen_insert_memo(p, _start_mark, _loop0_71_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23121 | D(p->level--); |
| 23122 | return _seq; |
| 23123 | } |
| 23124 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23125 | // _loop0_72: param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23126 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23127 | _loop0_72_rule(Parser *p) |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23128 | { |
| 23129 | D(p->level++); |
| 23130 | if (p->error_indicator) { |
| 23131 | D(p->level--); |
| 23132 | return NULL; |
| 23133 | } |
| 23134 | void *_res = NULL; |
| 23135 | int _mark = p->mark; |
| 23136 | int _start_mark = p->mark; |
| 23137 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23138 | if (!_children) { |
| 23139 | p->error_indicator = 1; |
| 23140 | PyErr_NoMemory(); |
| 23141 | D(p->level--); |
| 23142 | return NULL; |
| 23143 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23144 | Py_ssize_t _children_capacity = 1; |
| 23145 | Py_ssize_t _n = 0; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23146 | { // param_with_default |
| 23147 | if (p->error_indicator) { |
| 23148 | D(p->level--); |
| 23149 | return NULL; |
| 23150 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23151 | D(fprintf(stderr, "%*c> _loop0_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23152 | NameDefaultPair* param_with_default_var; |
| 23153 | while ( |
| 23154 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
| 23155 | ) |
| 23156 | { |
| 23157 | _res = param_with_default_var; |
| 23158 | if (_n == _children_capacity) { |
| 23159 | _children_capacity *= 2; |
| 23160 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23161 | if (!_new_children) { |
| 23162 | p->error_indicator = 1; |
| 23163 | PyErr_NoMemory(); |
| 23164 | D(p->level--); |
| 23165 | return NULL; |
| 23166 | } |
| 23167 | _children = _new_children; |
| 23168 | } |
| 23169 | _children[_n++] = _res; |
| 23170 | _mark = p->mark; |
| 23171 | } |
| 23172 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23173 | D(fprintf(stderr, "%*c%s _loop0_72[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23174 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); |
| 23175 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23176 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23177 | if (!_seq) { |
| 23178 | PyMem_Free(_children); |
| 23179 | p->error_indicator = 1; |
| 23180 | PyErr_NoMemory(); |
| 23181 | D(p->level--); |
| 23182 | return NULL; |
| 23183 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23184 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23185 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23186 | _PyPegen_insert_memo(p, _start_mark, _loop0_72_type, _seq); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23187 | D(p->level--); |
| 23188 | return _seq; |
| 23189 | } |
| 23190 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23191 | // _loop1_73: param_no_default |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23192 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23193 | _loop1_73_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23194 | { |
| 23195 | D(p->level++); |
| 23196 | if (p->error_indicator) { |
| 23197 | D(p->level--); |
| 23198 | return NULL; |
| 23199 | } |
| 23200 | void *_res = NULL; |
| 23201 | int _mark = p->mark; |
| 23202 | int _start_mark = p->mark; |
| 23203 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23204 | if (!_children) { |
| 23205 | p->error_indicator = 1; |
| 23206 | PyErr_NoMemory(); |
| 23207 | D(p->level--); |
| 23208 | return NULL; |
| 23209 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23210 | Py_ssize_t _children_capacity = 1; |
| 23211 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23212 | { // param_no_default |
| 23213 | if (p->error_indicator) { |
| 23214 | D(p->level--); |
| 23215 | return NULL; |
| 23216 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23217 | D(fprintf(stderr, "%*c> _loop1_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23218 | arg_ty param_no_default_var; |
| 23219 | while ( |
| 23220 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
| 23221 | ) |
| 23222 | { |
| 23223 | _res = param_no_default_var; |
| 23224 | if (_n == _children_capacity) { |
| 23225 | _children_capacity *= 2; |
| 23226 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23227 | if (!_new_children) { |
| 23228 | p->error_indicator = 1; |
| 23229 | PyErr_NoMemory(); |
| 23230 | D(p->level--); |
| 23231 | return NULL; |
| 23232 | } |
| 23233 | _children = _new_children; |
| 23234 | } |
| 23235 | _children[_n++] = _res; |
| 23236 | _mark = p->mark; |
| 23237 | } |
| 23238 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23239 | D(fprintf(stderr, "%*c%s _loop1_73[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23240 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); |
| 23241 | } |
| 23242 | if (_n == 0 || p->error_indicator) { |
| 23243 | PyMem_Free(_children); |
| 23244 | D(p->level--); |
| 23245 | return NULL; |
| 23246 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23247 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23248 | if (!_seq) { |
| 23249 | PyMem_Free(_children); |
| 23250 | p->error_indicator = 1; |
| 23251 | PyErr_NoMemory(); |
| 23252 | D(p->level--); |
| 23253 | return NULL; |
| 23254 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23255 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23256 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23257 | _PyPegen_insert_memo(p, _start_mark, _loop1_73_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23258 | D(p->level--); |
| 23259 | return _seq; |
| 23260 | } |
| 23261 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23262 | // _loop0_74: param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23263 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23264 | _loop0_74_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23265 | { |
| 23266 | D(p->level++); |
| 23267 | if (p->error_indicator) { |
| 23268 | D(p->level--); |
| 23269 | return NULL; |
| 23270 | } |
| 23271 | void *_res = NULL; |
| 23272 | int _mark = p->mark; |
| 23273 | int _start_mark = p->mark; |
| 23274 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23275 | if (!_children) { |
| 23276 | p->error_indicator = 1; |
| 23277 | PyErr_NoMemory(); |
| 23278 | D(p->level--); |
| 23279 | return NULL; |
| 23280 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23281 | Py_ssize_t _children_capacity = 1; |
| 23282 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23283 | { // param_with_default |
| 23284 | if (p->error_indicator) { |
| 23285 | D(p->level--); |
| 23286 | return NULL; |
| 23287 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23288 | D(fprintf(stderr, "%*c> _loop0_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23289 | NameDefaultPair* param_with_default_var; |
| 23290 | while ( |
| 23291 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
| 23292 | ) |
| 23293 | { |
| 23294 | _res = param_with_default_var; |
| 23295 | if (_n == _children_capacity) { |
| 23296 | _children_capacity *= 2; |
| 23297 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23298 | if (!_new_children) { |
| 23299 | p->error_indicator = 1; |
| 23300 | PyErr_NoMemory(); |
| 23301 | D(p->level--); |
| 23302 | return NULL; |
| 23303 | } |
| 23304 | _children = _new_children; |
| 23305 | } |
| 23306 | _children[_n++] = _res; |
| 23307 | _mark = p->mark; |
| 23308 | } |
| 23309 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23310 | D(fprintf(stderr, "%*c%s _loop0_74[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23311 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); |
| 23312 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23313 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23314 | if (!_seq) { |
| 23315 | PyMem_Free(_children); |
| 23316 | p->error_indicator = 1; |
| 23317 | PyErr_NoMemory(); |
| 23318 | D(p->level--); |
| 23319 | return NULL; |
| 23320 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23321 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23322 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23323 | _PyPegen_insert_memo(p, _start_mark, _loop0_74_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23324 | D(p->level--); |
| 23325 | return _seq; |
| 23326 | } |
| 23327 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23328 | // _loop1_75: param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23329 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23330 | _loop1_75_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23331 | { |
| 23332 | D(p->level++); |
| 23333 | if (p->error_indicator) { |
| 23334 | D(p->level--); |
| 23335 | return NULL; |
| 23336 | } |
| 23337 | void *_res = NULL; |
| 23338 | int _mark = p->mark; |
| 23339 | int _start_mark = p->mark; |
| 23340 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23341 | if (!_children) { |
| 23342 | p->error_indicator = 1; |
| 23343 | PyErr_NoMemory(); |
| 23344 | D(p->level--); |
| 23345 | return NULL; |
| 23346 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23347 | Py_ssize_t _children_capacity = 1; |
| 23348 | Py_ssize_t _n = 0; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23349 | { // param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23350 | if (p->error_indicator) { |
| 23351 | D(p->level--); |
| 23352 | return NULL; |
| 23353 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23354 | D(fprintf(stderr, "%*c> _loop1_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23355 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23356 | while ( |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23357 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23358 | ) |
| 23359 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23360 | _res = param_with_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23361 | if (_n == _children_capacity) { |
| 23362 | _children_capacity *= 2; |
| 23363 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23364 | if (!_new_children) { |
| 23365 | p->error_indicator = 1; |
| 23366 | PyErr_NoMemory(); |
| 23367 | D(p->level--); |
| 23368 | return NULL; |
| 23369 | } |
| 23370 | _children = _new_children; |
| 23371 | } |
| 23372 | _children[_n++] = _res; |
| 23373 | _mark = p->mark; |
| 23374 | } |
| 23375 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23376 | D(fprintf(stderr, "%*c%s _loop1_75[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23377 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23378 | } |
| 23379 | if (_n == 0 || p->error_indicator) { |
| 23380 | PyMem_Free(_children); |
| 23381 | D(p->level--); |
| 23382 | return NULL; |
| 23383 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23384 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23385 | if (!_seq) { |
| 23386 | PyMem_Free(_children); |
| 23387 | p->error_indicator = 1; |
| 23388 | PyErr_NoMemory(); |
| 23389 | D(p->level--); |
| 23390 | return NULL; |
| 23391 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23392 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23393 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23394 | _PyPegen_insert_memo(p, _start_mark, _loop1_75_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23395 | D(p->level--); |
| 23396 | return _seq; |
| 23397 | } |
| 23398 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23399 | // _loop1_76: param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23400 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23401 | _loop1_76_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23402 | { |
| 23403 | D(p->level++); |
| 23404 | if (p->error_indicator) { |
| 23405 | D(p->level--); |
| 23406 | return NULL; |
| 23407 | } |
| 23408 | void *_res = NULL; |
| 23409 | int _mark = p->mark; |
| 23410 | int _start_mark = p->mark; |
| 23411 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23412 | if (!_children) { |
| 23413 | p->error_indicator = 1; |
| 23414 | PyErr_NoMemory(); |
| 23415 | D(p->level--); |
| 23416 | return NULL; |
| 23417 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23418 | Py_ssize_t _children_capacity = 1; |
| 23419 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23420 | { // param_no_default |
| 23421 | if (p->error_indicator) { |
| 23422 | D(p->level--); |
| 23423 | return NULL; |
| 23424 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23425 | D(fprintf(stderr, "%*c> _loop1_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23426 | arg_ty param_no_default_var; |
| 23427 | while ( |
| 23428 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
| 23429 | ) |
| 23430 | { |
| 23431 | _res = param_no_default_var; |
| 23432 | if (_n == _children_capacity) { |
| 23433 | _children_capacity *= 2; |
| 23434 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23435 | if (!_new_children) { |
| 23436 | p->error_indicator = 1; |
| 23437 | PyErr_NoMemory(); |
| 23438 | D(p->level--); |
| 23439 | return NULL; |
| 23440 | } |
| 23441 | _children = _new_children; |
| 23442 | } |
| 23443 | _children[_n++] = _res; |
| 23444 | _mark = p->mark; |
| 23445 | } |
| 23446 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23447 | D(fprintf(stderr, "%*c%s _loop1_76[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23448 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); |
| 23449 | } |
| 23450 | if (_n == 0 || p->error_indicator) { |
| 23451 | PyMem_Free(_children); |
| 23452 | D(p->level--); |
| 23453 | return NULL; |
| 23454 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23455 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23456 | if (!_seq) { |
| 23457 | PyMem_Free(_children); |
| 23458 | p->error_indicator = 1; |
| 23459 | PyErr_NoMemory(); |
| 23460 | D(p->level--); |
| 23461 | return NULL; |
| 23462 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23463 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23464 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23465 | _PyPegen_insert_memo(p, _start_mark, _loop1_76_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23466 | D(p->level--); |
| 23467 | return _seq; |
| 23468 | } |
| 23469 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23470 | // _loop1_77: param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23471 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23472 | _loop1_77_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23473 | { |
| 23474 | D(p->level++); |
| 23475 | if (p->error_indicator) { |
| 23476 | D(p->level--); |
| 23477 | return NULL; |
| 23478 | } |
| 23479 | void *_res = NULL; |
| 23480 | int _mark = p->mark; |
| 23481 | int _start_mark = p->mark; |
| 23482 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23483 | if (!_children) { |
| 23484 | p->error_indicator = 1; |
| 23485 | PyErr_NoMemory(); |
| 23486 | D(p->level--); |
| 23487 | return NULL; |
| 23488 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23489 | Py_ssize_t _children_capacity = 1; |
| 23490 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23491 | { // param_no_default |
| 23492 | if (p->error_indicator) { |
| 23493 | D(p->level--); |
| 23494 | return NULL; |
| 23495 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23496 | D(fprintf(stderr, "%*c> _loop1_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23497 | arg_ty param_no_default_var; |
| 23498 | while ( |
| 23499 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
| 23500 | ) |
| 23501 | { |
| 23502 | _res = param_no_default_var; |
| 23503 | if (_n == _children_capacity) { |
| 23504 | _children_capacity *= 2; |
| 23505 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23506 | if (!_new_children) { |
| 23507 | p->error_indicator = 1; |
| 23508 | PyErr_NoMemory(); |
| 23509 | D(p->level--); |
| 23510 | return NULL; |
| 23511 | } |
| 23512 | _children = _new_children; |
| 23513 | } |
| 23514 | _children[_n++] = _res; |
| 23515 | _mark = p->mark; |
| 23516 | } |
| 23517 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23518 | D(fprintf(stderr, "%*c%s _loop1_77[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23519 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); |
| 23520 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23521 | if (_n == 0 || p->error_indicator) { |
| 23522 | PyMem_Free(_children); |
| 23523 | D(p->level--); |
| 23524 | return NULL; |
| 23525 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23526 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23527 | if (!_seq) { |
| 23528 | PyMem_Free(_children); |
| 23529 | p->error_indicator = 1; |
| 23530 | PyErr_NoMemory(); |
| 23531 | D(p->level--); |
| 23532 | return NULL; |
| 23533 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23534 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23535 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23536 | _PyPegen_insert_memo(p, _start_mark, _loop1_77_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23537 | D(p->level--); |
| 23538 | return _seq; |
| 23539 | } |
| 23540 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23541 | // _loop0_78: param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23542 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23543 | _loop0_78_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23544 | { |
| 23545 | D(p->level++); |
| 23546 | if (p->error_indicator) { |
| 23547 | D(p->level--); |
| 23548 | return NULL; |
| 23549 | } |
| 23550 | void *_res = NULL; |
| 23551 | int _mark = p->mark; |
| 23552 | int _start_mark = p->mark; |
| 23553 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23554 | if (!_children) { |
| 23555 | p->error_indicator = 1; |
| 23556 | PyErr_NoMemory(); |
| 23557 | D(p->level--); |
| 23558 | return NULL; |
| 23559 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23560 | Py_ssize_t _children_capacity = 1; |
| 23561 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23562 | { // param_no_default |
| 23563 | if (p->error_indicator) { |
| 23564 | D(p->level--); |
| 23565 | return NULL; |
| 23566 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23567 | D(fprintf(stderr, "%*c> _loop0_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23568 | arg_ty param_no_default_var; |
| 23569 | while ( |
| 23570 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
| 23571 | ) |
| 23572 | { |
| 23573 | _res = param_no_default_var; |
| 23574 | if (_n == _children_capacity) { |
| 23575 | _children_capacity *= 2; |
| 23576 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23577 | if (!_new_children) { |
| 23578 | p->error_indicator = 1; |
| 23579 | PyErr_NoMemory(); |
| 23580 | D(p->level--); |
| 23581 | return NULL; |
| 23582 | } |
| 23583 | _children = _new_children; |
| 23584 | } |
| 23585 | _children[_n++] = _res; |
| 23586 | _mark = p->mark; |
| 23587 | } |
| 23588 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23589 | D(fprintf(stderr, "%*c%s _loop0_78[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23590 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); |
| 23591 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23592 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23593 | if (!_seq) { |
| 23594 | PyMem_Free(_children); |
| 23595 | p->error_indicator = 1; |
| 23596 | PyErr_NoMemory(); |
| 23597 | D(p->level--); |
| 23598 | return NULL; |
| 23599 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23600 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23601 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23602 | _PyPegen_insert_memo(p, _start_mark, _loop0_78_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23603 | D(p->level--); |
| 23604 | return _seq; |
| 23605 | } |
| 23606 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23607 | // _loop1_79: param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23608 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23609 | _loop1_79_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23610 | { |
| 23611 | D(p->level++); |
| 23612 | if (p->error_indicator) { |
| 23613 | D(p->level--); |
| 23614 | return NULL; |
| 23615 | } |
| 23616 | void *_res = NULL; |
| 23617 | int _mark = p->mark; |
| 23618 | int _start_mark = p->mark; |
| 23619 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23620 | if (!_children) { |
| 23621 | p->error_indicator = 1; |
| 23622 | PyErr_NoMemory(); |
| 23623 | D(p->level--); |
| 23624 | return NULL; |
| 23625 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23626 | Py_ssize_t _children_capacity = 1; |
| 23627 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23628 | { // param_with_default |
| 23629 | if (p->error_indicator) { |
| 23630 | D(p->level--); |
| 23631 | return NULL; |
| 23632 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23633 | D(fprintf(stderr, "%*c> _loop1_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23634 | NameDefaultPair* param_with_default_var; |
| 23635 | while ( |
| 23636 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
| 23637 | ) |
| 23638 | { |
| 23639 | _res = param_with_default_var; |
| 23640 | if (_n == _children_capacity) { |
| 23641 | _children_capacity *= 2; |
| 23642 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23643 | if (!_new_children) { |
| 23644 | p->error_indicator = 1; |
| 23645 | PyErr_NoMemory(); |
| 23646 | D(p->level--); |
| 23647 | return NULL; |
| 23648 | } |
| 23649 | _children = _new_children; |
| 23650 | } |
| 23651 | _children[_n++] = _res; |
| 23652 | _mark = p->mark; |
| 23653 | } |
| 23654 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23655 | D(fprintf(stderr, "%*c%s _loop1_79[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23656 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); |
| 23657 | } |
| 23658 | if (_n == 0 || p->error_indicator) { |
| 23659 | PyMem_Free(_children); |
| 23660 | D(p->level--); |
| 23661 | return NULL; |
| 23662 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23663 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23664 | if (!_seq) { |
| 23665 | PyMem_Free(_children); |
| 23666 | p->error_indicator = 1; |
| 23667 | PyErr_NoMemory(); |
| 23668 | D(p->level--); |
| 23669 | return NULL; |
| 23670 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23671 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23672 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23673 | _PyPegen_insert_memo(p, _start_mark, _loop1_79_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23674 | D(p->level--); |
| 23675 | return _seq; |
| 23676 | } |
| 23677 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23678 | // _loop0_80: param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23679 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23680 | _loop0_80_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23681 | { |
| 23682 | D(p->level++); |
| 23683 | if (p->error_indicator) { |
| 23684 | D(p->level--); |
| 23685 | return NULL; |
| 23686 | } |
| 23687 | void *_res = NULL; |
| 23688 | int _mark = p->mark; |
| 23689 | int _start_mark = p->mark; |
| 23690 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23691 | if (!_children) { |
| 23692 | p->error_indicator = 1; |
| 23693 | PyErr_NoMemory(); |
| 23694 | D(p->level--); |
| 23695 | return NULL; |
| 23696 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23697 | Py_ssize_t _children_capacity = 1; |
| 23698 | Py_ssize_t _n = 0; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23699 | { // param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23700 | if (p->error_indicator) { |
| 23701 | D(p->level--); |
| 23702 | return NULL; |
| 23703 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23704 | D(fprintf(stderr, "%*c> _loop0_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23705 | arg_ty param_no_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23706 | while ( |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23707 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23708 | ) |
| 23709 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23710 | _res = param_no_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23711 | if (_n == _children_capacity) { |
| 23712 | _children_capacity *= 2; |
| 23713 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23714 | if (!_new_children) { |
| 23715 | p->error_indicator = 1; |
| 23716 | PyErr_NoMemory(); |
| 23717 | D(p->level--); |
| 23718 | return NULL; |
| 23719 | } |
| 23720 | _children = _new_children; |
| 23721 | } |
| 23722 | _children[_n++] = _res; |
| 23723 | _mark = p->mark; |
| 23724 | } |
| 23725 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23726 | D(fprintf(stderr, "%*c%s _loop0_80[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23727 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23728 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23729 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23730 | if (!_seq) { |
| 23731 | PyMem_Free(_children); |
| 23732 | p->error_indicator = 1; |
| 23733 | PyErr_NoMemory(); |
| 23734 | D(p->level--); |
| 23735 | return NULL; |
| 23736 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23737 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23738 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23739 | _PyPegen_insert_memo(p, _start_mark, _loop0_80_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23740 | D(p->level--); |
| 23741 | return _seq; |
| 23742 | } |
| 23743 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23744 | // _loop1_81: param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23745 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23746 | _loop1_81_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23747 | { |
| 23748 | D(p->level++); |
| 23749 | if (p->error_indicator) { |
| 23750 | D(p->level--); |
| 23751 | return NULL; |
| 23752 | } |
| 23753 | void *_res = NULL; |
| 23754 | int _mark = p->mark; |
| 23755 | int _start_mark = p->mark; |
| 23756 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23757 | if (!_children) { |
| 23758 | p->error_indicator = 1; |
| 23759 | PyErr_NoMemory(); |
| 23760 | D(p->level--); |
| 23761 | return NULL; |
| 23762 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23763 | Py_ssize_t _children_capacity = 1; |
| 23764 | Py_ssize_t _n = 0; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23765 | { // param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23766 | if (p->error_indicator) { |
| 23767 | D(p->level--); |
| 23768 | return NULL; |
| 23769 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23770 | D(fprintf(stderr, "%*c> _loop1_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23771 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23772 | while ( |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23773 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23774 | ) |
| 23775 | { |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23776 | _res = param_with_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23777 | if (_n == _children_capacity) { |
| 23778 | _children_capacity *= 2; |
| 23779 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23780 | if (!_new_children) { |
| 23781 | p->error_indicator = 1; |
| 23782 | PyErr_NoMemory(); |
| 23783 | D(p->level--); |
| 23784 | return NULL; |
| 23785 | } |
| 23786 | _children = _new_children; |
| 23787 | } |
| 23788 | _children[_n++] = _res; |
| 23789 | _mark = p->mark; |
| 23790 | } |
| 23791 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23792 | D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23793 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23794 | } |
| 23795 | if (_n == 0 || p->error_indicator) { |
| 23796 | PyMem_Free(_children); |
| 23797 | D(p->level--); |
| 23798 | return NULL; |
| 23799 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23800 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23801 | if (!_seq) { |
| 23802 | PyMem_Free(_children); |
| 23803 | p->error_indicator = 1; |
| 23804 | PyErr_NoMemory(); |
| 23805 | D(p->level--); |
| 23806 | return NULL; |
| 23807 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23808 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23809 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23810 | _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23811 | D(p->level--); |
| 23812 | return _seq; |
| 23813 | } |
| 23814 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23815 | // _loop0_82: param_maybe_default |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23816 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23817 | _loop0_82_rule(Parser *p) |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23818 | { |
| 23819 | D(p->level++); |
| 23820 | if (p->error_indicator) { |
| 23821 | D(p->level--); |
| 23822 | return NULL; |
| 23823 | } |
| 23824 | void *_res = NULL; |
| 23825 | int _mark = p->mark; |
| 23826 | int _start_mark = p->mark; |
| 23827 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23828 | if (!_children) { |
| 23829 | p->error_indicator = 1; |
| 23830 | PyErr_NoMemory(); |
| 23831 | D(p->level--); |
| 23832 | return NULL; |
| 23833 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23834 | Py_ssize_t _children_capacity = 1; |
| 23835 | Py_ssize_t _n = 0; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23836 | { // param_maybe_default |
| 23837 | if (p->error_indicator) { |
| 23838 | D(p->level--); |
| 23839 | return NULL; |
| 23840 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23841 | D(fprintf(stderr, "%*c> _loop0_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23842 | NameDefaultPair* param_maybe_default_var; |
| 23843 | while ( |
| 23844 | (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default |
| 23845 | ) |
| 23846 | { |
| 23847 | _res = param_maybe_default_var; |
| 23848 | if (_n == _children_capacity) { |
| 23849 | _children_capacity *= 2; |
| 23850 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23851 | if (!_new_children) { |
| 23852 | p->error_indicator = 1; |
| 23853 | PyErr_NoMemory(); |
| 23854 | D(p->level--); |
| 23855 | return NULL; |
| 23856 | } |
| 23857 | _children = _new_children; |
| 23858 | } |
| 23859 | _children[_n++] = _res; |
| 23860 | _mark = p->mark; |
| 23861 | } |
| 23862 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23863 | D(fprintf(stderr, "%*c%s _loop0_82[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23864 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); |
| 23865 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23866 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23867 | if (!_seq) { |
| 23868 | PyMem_Free(_children); |
| 23869 | p->error_indicator = 1; |
| 23870 | PyErr_NoMemory(); |
| 23871 | D(p->level--); |
| 23872 | return NULL; |
| 23873 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23874 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23875 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23876 | _PyPegen_insert_memo(p, _start_mark, _loop0_82_type, _seq); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23877 | D(p->level--); |
| 23878 | return _seq; |
| 23879 | } |
| 23880 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23881 | // _loop1_83: param_maybe_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23882 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23883 | _loop1_83_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23884 | { |
| 23885 | D(p->level++); |
| 23886 | if (p->error_indicator) { |
| 23887 | D(p->level--); |
| 23888 | return NULL; |
| 23889 | } |
| 23890 | void *_res = NULL; |
| 23891 | int _mark = p->mark; |
| 23892 | int _start_mark = p->mark; |
| 23893 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23894 | if (!_children) { |
| 23895 | p->error_indicator = 1; |
| 23896 | PyErr_NoMemory(); |
| 23897 | D(p->level--); |
| 23898 | return NULL; |
| 23899 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23900 | Py_ssize_t _children_capacity = 1; |
| 23901 | Py_ssize_t _n = 0; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23902 | { // param_maybe_default |
| 23903 | if (p->error_indicator) { |
| 23904 | D(p->level--); |
| 23905 | return NULL; |
| 23906 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23907 | D(fprintf(stderr, "%*c> _loop1_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23908 | NameDefaultPair* param_maybe_default_var; |
| 23909 | while ( |
| 23910 | (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default |
| 23911 | ) |
| 23912 | { |
| 23913 | _res = param_maybe_default_var; |
| 23914 | if (_n == _children_capacity) { |
| 23915 | _children_capacity *= 2; |
| 23916 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23917 | if (!_new_children) { |
| 23918 | p->error_indicator = 1; |
| 23919 | PyErr_NoMemory(); |
| 23920 | D(p->level--); |
| 23921 | return NULL; |
| 23922 | } |
| 23923 | _children = _new_children; |
| 23924 | } |
| 23925 | _children[_n++] = _res; |
| 23926 | _mark = p->mark; |
| 23927 | } |
| 23928 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23929 | D(fprintf(stderr, "%*c%s _loop1_83[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23930 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); |
| 23931 | } |
| 23932 | if (_n == 0 || p->error_indicator) { |
| 23933 | PyMem_Free(_children); |
| 23934 | D(p->level--); |
| 23935 | return NULL; |
| 23936 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23937 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23938 | if (!_seq) { |
| 23939 | PyMem_Free(_children); |
| 23940 | p->error_indicator = 1; |
| 23941 | PyErr_NoMemory(); |
| 23942 | D(p->level--); |
| 23943 | return NULL; |
| 23944 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 23945 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23946 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23947 | _PyPegen_insert_memo(p, _start_mark, _loop1_83_type, _seq); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23948 | D(p->level--); |
| 23949 | return _seq; |
| 23950 | } |
| 23951 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23952 | // _loop1_84: ('@' named_expression NEWLINE) |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23953 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23954 | _loop1_84_rule(Parser *p) |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 23955 | { |
| 23956 | D(p->level++); |
| 23957 | if (p->error_indicator) { |
| 23958 | D(p->level--); |
| 23959 | return NULL; |
| 23960 | } |
| 23961 | void *_res = NULL; |
| 23962 | int _mark = p->mark; |
| 23963 | int _start_mark = p->mark; |
| 23964 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23965 | if (!_children) { |
| 23966 | p->error_indicator = 1; |
| 23967 | PyErr_NoMemory(); |
| 23968 | D(p->level--); |
| 23969 | return NULL; |
| 23970 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 23971 | Py_ssize_t _children_capacity = 1; |
| 23972 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23973 | { // ('@' named_expression NEWLINE) |
| 23974 | if (p->error_indicator) { |
| 23975 | D(p->level--); |
| 23976 | return NULL; |
| 23977 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 23978 | D(fprintf(stderr, "%*c> _loop1_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 23979 | void *_tmp_168_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23980 | while ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 23981 | (_tmp_168_var = _tmp_168_rule(p)) // '@' named_expression NEWLINE |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23982 | ) |
| 23983 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 23984 | _res = _tmp_168_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 23985 | if (_n == _children_capacity) { |
| 23986 | _children_capacity *= 2; |
| 23987 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23988 | if (!_new_children) { |
| 23989 | p->error_indicator = 1; |
| 23990 | PyErr_NoMemory(); |
| 23991 | D(p->level--); |
| 23992 | return NULL; |
| 23993 | } |
| 23994 | _children = _new_children; |
| 23995 | } |
| 23996 | _children[_n++] = _res; |
| 23997 | _mark = p->mark; |
| 23998 | } |
| 23999 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24000 | D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24001 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)")); |
| 24002 | } |
| 24003 | if (_n == 0 || p->error_indicator) { |
| 24004 | PyMem_Free(_children); |
| 24005 | D(p->level--); |
| 24006 | return NULL; |
| 24007 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24008 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24009 | if (!_seq) { |
| 24010 | PyMem_Free(_children); |
| 24011 | p->error_indicator = 1; |
| 24012 | PyErr_NoMemory(); |
| 24013 | D(p->level--); |
| 24014 | return NULL; |
| 24015 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24016 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24017 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24018 | _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24019 | D(p->level--); |
| 24020 | return _seq; |
| 24021 | } |
| 24022 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24023 | // _tmp_85: '(' arguments? ')' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24024 | static void * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24025 | _tmp_85_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24026 | { |
| 24027 | D(p->level++); |
| 24028 | if (p->error_indicator) { |
| 24029 | D(p->level--); |
| 24030 | return NULL; |
| 24031 | } |
| 24032 | void * _res = NULL; |
| 24033 | int _mark = p->mark; |
| 24034 | { // '(' arguments? ')' |
| 24035 | if (p->error_indicator) { |
| 24036 | D(p->level--); |
| 24037 | return NULL; |
| 24038 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24039 | D(fprintf(stderr, "%*c> _tmp_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24040 | Token * _literal; |
| 24041 | Token * _literal_1; |
| 24042 | void *z; |
| 24043 | if ( |
| 24044 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 24045 | && |
| 24046 | (z = arguments_rule(p), 1) // arguments? |
| 24047 | && |
| 24048 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
| 24049 | ) |
| 24050 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24051 | D(fprintf(stderr, "%*c+ _tmp_85[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24052 | _res = z; |
| 24053 | if (_res == NULL && PyErr_Occurred()) { |
| 24054 | p->error_indicator = 1; |
| 24055 | D(p->level--); |
| 24056 | return NULL; |
| 24057 | } |
| 24058 | goto done; |
| 24059 | } |
| 24060 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24061 | D(fprintf(stderr, "%*c%s _tmp_85[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24062 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); |
| 24063 | } |
| 24064 | _res = NULL; |
| 24065 | done: |
| 24066 | D(p->level--); |
| 24067 | return _res; |
| 24068 | } |
| 24069 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24070 | // _loop1_86: (',' star_expression) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24071 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24072 | _loop1_86_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24073 | { |
| 24074 | D(p->level++); |
| 24075 | if (p->error_indicator) { |
| 24076 | D(p->level--); |
| 24077 | return NULL; |
| 24078 | } |
| 24079 | void *_res = NULL; |
| 24080 | int _mark = p->mark; |
| 24081 | int _start_mark = p->mark; |
| 24082 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24083 | if (!_children) { |
| 24084 | p->error_indicator = 1; |
| 24085 | PyErr_NoMemory(); |
| 24086 | D(p->level--); |
| 24087 | return NULL; |
| 24088 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 24089 | Py_ssize_t _children_capacity = 1; |
| 24090 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24091 | { // (',' star_expression) |
| 24092 | if (p->error_indicator) { |
| 24093 | D(p->level--); |
| 24094 | return NULL; |
| 24095 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24096 | D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 24097 | void *_tmp_169_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24098 | while ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 24099 | (_tmp_169_var = _tmp_169_rule(p)) // ',' star_expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24100 | ) |
| 24101 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 24102 | _res = _tmp_169_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24103 | if (_n == _children_capacity) { |
| 24104 | _children_capacity *= 2; |
| 24105 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24106 | if (!_new_children) { |
| 24107 | p->error_indicator = 1; |
| 24108 | PyErr_NoMemory(); |
| 24109 | D(p->level--); |
| 24110 | return NULL; |
| 24111 | } |
| 24112 | _children = _new_children; |
| 24113 | } |
| 24114 | _children[_n++] = _res; |
| 24115 | _mark = p->mark; |
| 24116 | } |
| 24117 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24118 | D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24119 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); |
| 24120 | } |
| 24121 | if (_n == 0 || p->error_indicator) { |
| 24122 | PyMem_Free(_children); |
| 24123 | D(p->level--); |
| 24124 | return NULL; |
| 24125 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24126 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24127 | if (!_seq) { |
| 24128 | PyMem_Free(_children); |
| 24129 | p->error_indicator = 1; |
| 24130 | PyErr_NoMemory(); |
| 24131 | D(p->level--); |
| 24132 | return NULL; |
| 24133 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24134 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24135 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24136 | _PyPegen_insert_memo(p, _start_mark, _loop1_86_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24137 | D(p->level--); |
| 24138 | return _seq; |
| 24139 | } |
| 24140 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24141 | // _loop0_88: ',' star_named_expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24142 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24143 | _loop0_88_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24144 | { |
| 24145 | D(p->level++); |
| 24146 | if (p->error_indicator) { |
| 24147 | D(p->level--); |
| 24148 | return NULL; |
| 24149 | } |
| 24150 | void *_res = NULL; |
| 24151 | int _mark = p->mark; |
| 24152 | int _start_mark = p->mark; |
| 24153 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24154 | if (!_children) { |
| 24155 | p->error_indicator = 1; |
| 24156 | PyErr_NoMemory(); |
| 24157 | D(p->level--); |
| 24158 | return NULL; |
| 24159 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 24160 | Py_ssize_t _children_capacity = 1; |
| 24161 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24162 | { // ',' star_named_expression |
| 24163 | if (p->error_indicator) { |
| 24164 | D(p->level--); |
| 24165 | return NULL; |
| 24166 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24167 | D(fprintf(stderr, "%*c> _loop0_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24168 | Token * _literal; |
| 24169 | expr_ty elem; |
| 24170 | while ( |
| 24171 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 24172 | && |
| 24173 | (elem = star_named_expression_rule(p)) // star_named_expression |
| 24174 | ) |
| 24175 | { |
| 24176 | _res = elem; |
| 24177 | if (_res == NULL && PyErr_Occurred()) { |
| 24178 | p->error_indicator = 1; |
| 24179 | PyMem_Free(_children); |
| 24180 | D(p->level--); |
| 24181 | return NULL; |
| 24182 | } |
| 24183 | if (_n == _children_capacity) { |
| 24184 | _children_capacity *= 2; |
| 24185 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24186 | if (!_new_children) { |
| 24187 | p->error_indicator = 1; |
| 24188 | PyErr_NoMemory(); |
| 24189 | D(p->level--); |
| 24190 | return NULL; |
| 24191 | } |
| 24192 | _children = _new_children; |
| 24193 | } |
| 24194 | _children[_n++] = _res; |
| 24195 | _mark = p->mark; |
| 24196 | } |
| 24197 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24198 | D(fprintf(stderr, "%*c%s _loop0_88[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24199 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); |
| 24200 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24201 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24202 | if (!_seq) { |
| 24203 | PyMem_Free(_children); |
| 24204 | p->error_indicator = 1; |
| 24205 | PyErr_NoMemory(); |
| 24206 | D(p->level--); |
| 24207 | return NULL; |
| 24208 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24209 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24210 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24211 | _PyPegen_insert_memo(p, _start_mark, _loop0_88_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24212 | D(p->level--); |
| 24213 | return _seq; |
| 24214 | } |
| 24215 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24216 | // _gather_87: star_named_expression _loop0_88 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24217 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24218 | _gather_87_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24219 | { |
| 24220 | D(p->level++); |
| 24221 | if (p->error_indicator) { |
| 24222 | D(p->level--); |
| 24223 | return NULL; |
| 24224 | } |
| 24225 | asdl_seq * _res = NULL; |
| 24226 | int _mark = p->mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24227 | { // star_named_expression _loop0_88 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24228 | if (p->error_indicator) { |
| 24229 | D(p->level--); |
| 24230 | return NULL; |
| 24231 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24232 | D(fprintf(stderr, "%*c> _gather_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_88")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24233 | expr_ty elem; |
| 24234 | asdl_seq * seq; |
| 24235 | if ( |
| 24236 | (elem = star_named_expression_rule(p)) // star_named_expression |
| 24237 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24238 | (seq = _loop0_88_rule(p)) // _loop0_88 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24239 | ) |
| 24240 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24241 | D(fprintf(stderr, "%*c+ _gather_87[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_88")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24242 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 24243 | goto done; |
| 24244 | } |
| 24245 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24246 | D(fprintf(stderr, "%*c%s _gather_87[%d-%d]: %s failed!\n", p->level, ' ', |
| 24247 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_88")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24248 | } |
| 24249 | _res = NULL; |
| 24250 | done: |
| 24251 | D(p->level--); |
| 24252 | return _res; |
| 24253 | } |
| 24254 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24255 | // _loop1_89: (',' expression) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24256 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24257 | _loop1_89_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24258 | { |
| 24259 | D(p->level++); |
| 24260 | if (p->error_indicator) { |
| 24261 | D(p->level--); |
| 24262 | return NULL; |
| 24263 | } |
| 24264 | void *_res = NULL; |
| 24265 | int _mark = p->mark; |
| 24266 | int _start_mark = p->mark; |
| 24267 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24268 | if (!_children) { |
| 24269 | p->error_indicator = 1; |
| 24270 | PyErr_NoMemory(); |
| 24271 | D(p->level--); |
| 24272 | return NULL; |
| 24273 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 24274 | Py_ssize_t _children_capacity = 1; |
| 24275 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24276 | { // (',' expression) |
| 24277 | if (p->error_indicator) { |
| 24278 | D(p->level--); |
| 24279 | return NULL; |
| 24280 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24281 | D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 24282 | void *_tmp_170_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24283 | while ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 24284 | (_tmp_170_var = _tmp_170_rule(p)) // ',' expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24285 | ) |
| 24286 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 24287 | _res = _tmp_170_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24288 | if (_n == _children_capacity) { |
| 24289 | _children_capacity *= 2; |
| 24290 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24291 | if (!_new_children) { |
| 24292 | p->error_indicator = 1; |
| 24293 | PyErr_NoMemory(); |
| 24294 | D(p->level--); |
| 24295 | return NULL; |
| 24296 | } |
| 24297 | _children = _new_children; |
| 24298 | } |
| 24299 | _children[_n++] = _res; |
| 24300 | _mark = p->mark; |
| 24301 | } |
| 24302 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24303 | D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24304 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); |
| 24305 | } |
| 24306 | if (_n == 0 || p->error_indicator) { |
| 24307 | PyMem_Free(_children); |
| 24308 | D(p->level--); |
| 24309 | return NULL; |
| 24310 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24311 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24312 | if (!_seq) { |
| 24313 | PyMem_Free(_children); |
| 24314 | p->error_indicator = 1; |
| 24315 | PyErr_NoMemory(); |
| 24316 | D(p->level--); |
| 24317 | return NULL; |
| 24318 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24319 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24320 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24321 | _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24322 | D(p->level--); |
| 24323 | return _seq; |
| 24324 | } |
| 24325 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24326 | // _loop0_90: lambda_param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24327 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24328 | _loop0_90_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24329 | { |
| 24330 | D(p->level++); |
| 24331 | if (p->error_indicator) { |
| 24332 | D(p->level--); |
| 24333 | return NULL; |
| 24334 | } |
| 24335 | void *_res = NULL; |
| 24336 | int _mark = p->mark; |
| 24337 | int _start_mark = p->mark; |
| 24338 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24339 | if (!_children) { |
| 24340 | p->error_indicator = 1; |
| 24341 | PyErr_NoMemory(); |
| 24342 | D(p->level--); |
| 24343 | return NULL; |
| 24344 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 24345 | Py_ssize_t _children_capacity = 1; |
| 24346 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24347 | { // lambda_param_no_default |
| 24348 | if (p->error_indicator) { |
| 24349 | D(p->level--); |
| 24350 | return NULL; |
| 24351 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24352 | D(fprintf(stderr, "%*c> _loop0_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24353 | arg_ty lambda_param_no_default_var; |
| 24354 | while ( |
| 24355 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
| 24356 | ) |
| 24357 | { |
| 24358 | _res = lambda_param_no_default_var; |
| 24359 | if (_n == _children_capacity) { |
| 24360 | _children_capacity *= 2; |
| 24361 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24362 | if (!_new_children) { |
| 24363 | p->error_indicator = 1; |
| 24364 | PyErr_NoMemory(); |
| 24365 | D(p->level--); |
| 24366 | return NULL; |
| 24367 | } |
| 24368 | _children = _new_children; |
| 24369 | } |
| 24370 | _children[_n++] = _res; |
| 24371 | _mark = p->mark; |
| 24372 | } |
| 24373 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24374 | D(fprintf(stderr, "%*c%s _loop0_90[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 24375 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24376 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24377 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24378 | if (!_seq) { |
| 24379 | PyMem_Free(_children); |
| 24380 | p->error_indicator = 1; |
| 24381 | PyErr_NoMemory(); |
| 24382 | D(p->level--); |
| 24383 | return NULL; |
| 24384 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24385 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24386 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24387 | _PyPegen_insert_memo(p, _start_mark, _loop0_90_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24388 | D(p->level--); |
| 24389 | return _seq; |
| 24390 | } |
| 24391 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24392 | // _loop0_91: lambda_param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24393 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24394 | _loop0_91_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24395 | { |
| 24396 | D(p->level++); |
| 24397 | if (p->error_indicator) { |
| 24398 | D(p->level--); |
| 24399 | return NULL; |
| 24400 | } |
| 24401 | void *_res = NULL; |
| 24402 | int _mark = p->mark; |
| 24403 | int _start_mark = p->mark; |
| 24404 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24405 | if (!_children) { |
| 24406 | p->error_indicator = 1; |
| 24407 | PyErr_NoMemory(); |
| 24408 | D(p->level--); |
| 24409 | return NULL; |
| 24410 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 24411 | Py_ssize_t _children_capacity = 1; |
| 24412 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24413 | { // lambda_param_with_default |
| 24414 | if (p->error_indicator) { |
| 24415 | D(p->level--); |
| 24416 | return NULL; |
| 24417 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24418 | D(fprintf(stderr, "%*c> _loop0_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24419 | NameDefaultPair* lambda_param_with_default_var; |
| 24420 | while ( |
| 24421 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
| 24422 | ) |
| 24423 | { |
| 24424 | _res = lambda_param_with_default_var; |
| 24425 | if (_n == _children_capacity) { |
| 24426 | _children_capacity *= 2; |
| 24427 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24428 | if (!_new_children) { |
| 24429 | p->error_indicator = 1; |
| 24430 | PyErr_NoMemory(); |
| 24431 | D(p->level--); |
| 24432 | return NULL; |
| 24433 | } |
| 24434 | _children = _new_children; |
| 24435 | } |
| 24436 | _children[_n++] = _res; |
| 24437 | _mark = p->mark; |
| 24438 | } |
| 24439 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24440 | D(fprintf(stderr, "%*c%s _loop0_91[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24441 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); |
| 24442 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24443 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24444 | if (!_seq) { |
| 24445 | PyMem_Free(_children); |
| 24446 | p->error_indicator = 1; |
| 24447 | PyErr_NoMemory(); |
| 24448 | D(p->level--); |
| 24449 | return NULL; |
| 24450 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24451 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24452 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24453 | _PyPegen_insert_memo(p, _start_mark, _loop0_91_type, _seq); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24454 | D(p->level--); |
| 24455 | return _seq; |
| 24456 | } |
| 24457 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24458 | // _loop0_92: lambda_param_with_default |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24459 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24460 | _loop0_92_rule(Parser *p) |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24461 | { |
| 24462 | D(p->level++); |
| 24463 | if (p->error_indicator) { |
| 24464 | D(p->level--); |
| 24465 | return NULL; |
| 24466 | } |
| 24467 | void *_res = NULL; |
| 24468 | int _mark = p->mark; |
| 24469 | int _start_mark = p->mark; |
| 24470 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24471 | if (!_children) { |
| 24472 | p->error_indicator = 1; |
| 24473 | PyErr_NoMemory(); |
| 24474 | D(p->level--); |
| 24475 | return NULL; |
| 24476 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 24477 | Py_ssize_t _children_capacity = 1; |
| 24478 | Py_ssize_t _n = 0; |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24479 | { // lambda_param_with_default |
| 24480 | if (p->error_indicator) { |
| 24481 | D(p->level--); |
| 24482 | return NULL; |
| 24483 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24484 | D(fprintf(stderr, "%*c> _loop0_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24485 | NameDefaultPair* lambda_param_with_default_var; |
| 24486 | while ( |
| 24487 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
| 24488 | ) |
| 24489 | { |
| 24490 | _res = lambda_param_with_default_var; |
| 24491 | if (_n == _children_capacity) { |
| 24492 | _children_capacity *= 2; |
| 24493 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24494 | if (!_new_children) { |
| 24495 | p->error_indicator = 1; |
| 24496 | PyErr_NoMemory(); |
| 24497 | D(p->level--); |
| 24498 | return NULL; |
| 24499 | } |
| 24500 | _children = _new_children; |
| 24501 | } |
| 24502 | _children[_n++] = _res; |
| 24503 | _mark = p->mark; |
| 24504 | } |
| 24505 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24506 | D(fprintf(stderr, "%*c%s _loop0_92[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24507 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); |
| 24508 | } |
| 24509 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 24510 | if (!_seq) { |
| 24511 | PyMem_Free(_children); |
| 24512 | p->error_indicator = 1; |
| 24513 | PyErr_NoMemory(); |
| 24514 | D(p->level--); |
| 24515 | return NULL; |
| 24516 | } |
| 24517 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 24518 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24519 | _PyPegen_insert_memo(p, _start_mark, _loop0_92_type, _seq); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24520 | D(p->level--); |
| 24521 | return _seq; |
| 24522 | } |
| 24523 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24524 | // _loop1_93: lambda_param_no_default |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24525 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24526 | _loop1_93_rule(Parser *p) |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24527 | { |
| 24528 | D(p->level++); |
| 24529 | if (p->error_indicator) { |
| 24530 | D(p->level--); |
| 24531 | return NULL; |
| 24532 | } |
| 24533 | void *_res = NULL; |
| 24534 | int _mark = p->mark; |
| 24535 | int _start_mark = p->mark; |
| 24536 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24537 | if (!_children) { |
| 24538 | p->error_indicator = 1; |
| 24539 | PyErr_NoMemory(); |
| 24540 | D(p->level--); |
| 24541 | return NULL; |
| 24542 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 24543 | Py_ssize_t _children_capacity = 1; |
| 24544 | Py_ssize_t _n = 0; |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24545 | { // lambda_param_no_default |
| 24546 | if (p->error_indicator) { |
| 24547 | D(p->level--); |
| 24548 | return NULL; |
| 24549 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24550 | D(fprintf(stderr, "%*c> _loop1_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24551 | arg_ty lambda_param_no_default_var; |
| 24552 | while ( |
| 24553 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
| 24554 | ) |
| 24555 | { |
| 24556 | _res = lambda_param_no_default_var; |
| 24557 | if (_n == _children_capacity) { |
| 24558 | _children_capacity *= 2; |
| 24559 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24560 | if (!_new_children) { |
| 24561 | p->error_indicator = 1; |
| 24562 | PyErr_NoMemory(); |
| 24563 | D(p->level--); |
| 24564 | return NULL; |
| 24565 | } |
| 24566 | _children = _new_children; |
| 24567 | } |
| 24568 | _children[_n++] = _res; |
| 24569 | _mark = p->mark; |
| 24570 | } |
| 24571 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24572 | D(fprintf(stderr, "%*c%s _loop1_93[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24573 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); |
| 24574 | } |
| 24575 | if (_n == 0 || p->error_indicator) { |
| 24576 | PyMem_Free(_children); |
| 24577 | D(p->level--); |
| 24578 | return NULL; |
| 24579 | } |
| 24580 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 24581 | if (!_seq) { |
| 24582 | PyMem_Free(_children); |
| 24583 | p->error_indicator = 1; |
| 24584 | PyErr_NoMemory(); |
| 24585 | D(p->level--); |
| 24586 | return NULL; |
| 24587 | } |
| 24588 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 24589 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24590 | _PyPegen_insert_memo(p, _start_mark, _loop1_93_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24591 | D(p->level--); |
| 24592 | return _seq; |
| 24593 | } |
| 24594 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24595 | // _loop0_94: lambda_param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24596 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24597 | _loop0_94_rule(Parser *p) |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 24598 | { |
| 24599 | D(p->level++); |
| 24600 | if (p->error_indicator) { |
| 24601 | D(p->level--); |
| 24602 | return NULL; |
| 24603 | } |
| 24604 | void *_res = NULL; |
| 24605 | int _mark = p->mark; |
| 24606 | int _start_mark = p->mark; |
| 24607 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24608 | if (!_children) { |
| 24609 | p->error_indicator = 1; |
| 24610 | PyErr_NoMemory(); |
| 24611 | D(p->level--); |
| 24612 | return NULL; |
| 24613 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 24614 | Py_ssize_t _children_capacity = 1; |
| 24615 | Py_ssize_t _n = 0; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 24616 | { // lambda_param_with_default |
| 24617 | if (p->error_indicator) { |
| 24618 | D(p->level--); |
| 24619 | return NULL; |
| 24620 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24621 | D(fprintf(stderr, "%*c> _loop0_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 24622 | NameDefaultPair* lambda_param_with_default_var; |
| 24623 | while ( |
| 24624 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
| 24625 | ) |
| 24626 | { |
| 24627 | _res = lambda_param_with_default_var; |
| 24628 | if (_n == _children_capacity) { |
| 24629 | _children_capacity *= 2; |
| 24630 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24631 | if (!_new_children) { |
| 24632 | p->error_indicator = 1; |
| 24633 | PyErr_NoMemory(); |
| 24634 | D(p->level--); |
| 24635 | return NULL; |
| 24636 | } |
| 24637 | _children = _new_children; |
| 24638 | } |
| 24639 | _children[_n++] = _res; |
| 24640 | _mark = p->mark; |
| 24641 | } |
| 24642 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24643 | D(fprintf(stderr, "%*c%s _loop0_94[%d-%d]: %s failed!\n", p->level, ' ', |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 24644 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); |
| 24645 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24646 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 24647 | if (!_seq) { |
| 24648 | PyMem_Free(_children); |
| 24649 | p->error_indicator = 1; |
| 24650 | PyErr_NoMemory(); |
| 24651 | D(p->level--); |
| 24652 | return NULL; |
| 24653 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24654 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 24655 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24656 | _PyPegen_insert_memo(p, _start_mark, _loop0_94_type, _seq); |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 24657 | D(p->level--); |
| 24658 | return _seq; |
| 24659 | } |
| 24660 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24661 | // _loop1_95: lambda_param_with_default |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 24662 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24663 | _loop1_95_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24664 | { |
| 24665 | D(p->level++); |
| 24666 | if (p->error_indicator) { |
| 24667 | D(p->level--); |
| 24668 | return NULL; |
| 24669 | } |
| 24670 | void *_res = NULL; |
| 24671 | int _mark = p->mark; |
| 24672 | int _start_mark = p->mark; |
| 24673 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24674 | if (!_children) { |
| 24675 | p->error_indicator = 1; |
| 24676 | PyErr_NoMemory(); |
| 24677 | D(p->level--); |
| 24678 | return NULL; |
| 24679 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 24680 | Py_ssize_t _children_capacity = 1; |
| 24681 | Py_ssize_t _n = 0; |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24682 | { // lambda_param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24683 | if (p->error_indicator) { |
| 24684 | D(p->level--); |
| 24685 | return NULL; |
| 24686 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24687 | D(fprintf(stderr, "%*c> _loop1_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24688 | NameDefaultPair* lambda_param_with_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24689 | while ( |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24690 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24691 | ) |
| 24692 | { |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24693 | _res = lambda_param_with_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24694 | if (_n == _children_capacity) { |
| 24695 | _children_capacity *= 2; |
| 24696 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24697 | if (!_new_children) { |
| 24698 | p->error_indicator = 1; |
| 24699 | PyErr_NoMemory(); |
| 24700 | D(p->level--); |
| 24701 | return NULL; |
| 24702 | } |
| 24703 | _children = _new_children; |
| 24704 | } |
| 24705 | _children[_n++] = _res; |
| 24706 | _mark = p->mark; |
| 24707 | } |
| 24708 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24709 | D(fprintf(stderr, "%*c%s _loop1_95[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24710 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24711 | } |
| 24712 | if (_n == 0 || p->error_indicator) { |
| 24713 | PyMem_Free(_children); |
| 24714 | D(p->level--); |
| 24715 | return NULL; |
| 24716 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24717 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24718 | if (!_seq) { |
| 24719 | PyMem_Free(_children); |
| 24720 | p->error_indicator = 1; |
| 24721 | PyErr_NoMemory(); |
| 24722 | D(p->level--); |
| 24723 | return NULL; |
| 24724 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24725 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24726 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24727 | _PyPegen_insert_memo(p, _start_mark, _loop1_95_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24728 | D(p->level--); |
| 24729 | return _seq; |
| 24730 | } |
| 24731 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24732 | // _loop1_96: lambda_param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24733 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24734 | _loop1_96_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24735 | { |
| 24736 | D(p->level++); |
| 24737 | if (p->error_indicator) { |
| 24738 | D(p->level--); |
| 24739 | return NULL; |
| 24740 | } |
| 24741 | void *_res = NULL; |
| 24742 | int _mark = p->mark; |
| 24743 | int _start_mark = p->mark; |
| 24744 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24745 | if (!_children) { |
| 24746 | p->error_indicator = 1; |
| 24747 | PyErr_NoMemory(); |
| 24748 | D(p->level--); |
| 24749 | return NULL; |
| 24750 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 24751 | Py_ssize_t _children_capacity = 1; |
| 24752 | Py_ssize_t _n = 0; |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24753 | { // lambda_param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24754 | if (p->error_indicator) { |
| 24755 | D(p->level--); |
| 24756 | return NULL; |
| 24757 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24758 | D(fprintf(stderr, "%*c> _loop1_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24759 | arg_ty lambda_param_no_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24760 | while ( |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24761 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24762 | ) |
| 24763 | { |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24764 | _res = lambda_param_no_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24765 | if (_n == _children_capacity) { |
| 24766 | _children_capacity *= 2; |
| 24767 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24768 | if (!_new_children) { |
| 24769 | p->error_indicator = 1; |
| 24770 | PyErr_NoMemory(); |
| 24771 | D(p->level--); |
| 24772 | return NULL; |
| 24773 | } |
| 24774 | _children = _new_children; |
| 24775 | } |
| 24776 | _children[_n++] = _res; |
| 24777 | _mark = p->mark; |
| 24778 | } |
| 24779 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24780 | D(fprintf(stderr, "%*c%s _loop1_96[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24781 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); |
| 24782 | } |
| 24783 | if (_n == 0 || p->error_indicator) { |
| 24784 | PyMem_Free(_children); |
| 24785 | D(p->level--); |
| 24786 | return NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24787 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24788 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24789 | if (!_seq) { |
| 24790 | PyMem_Free(_children); |
| 24791 | p->error_indicator = 1; |
| 24792 | PyErr_NoMemory(); |
| 24793 | D(p->level--); |
| 24794 | return NULL; |
| 24795 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24796 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24797 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24798 | _PyPegen_insert_memo(p, _start_mark, _loop1_96_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24799 | D(p->level--); |
| 24800 | return _seq; |
| 24801 | } |
| 24802 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24803 | // _loop1_97: lambda_param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24804 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24805 | _loop1_97_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24806 | { |
| 24807 | D(p->level++); |
| 24808 | if (p->error_indicator) { |
| 24809 | D(p->level--); |
| 24810 | return NULL; |
| 24811 | } |
| 24812 | void *_res = NULL; |
| 24813 | int _mark = p->mark; |
| 24814 | int _start_mark = p->mark; |
| 24815 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24816 | if (!_children) { |
| 24817 | p->error_indicator = 1; |
| 24818 | PyErr_NoMemory(); |
| 24819 | D(p->level--); |
| 24820 | return NULL; |
| 24821 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 24822 | Py_ssize_t _children_capacity = 1; |
| 24823 | Py_ssize_t _n = 0; |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24824 | { // lambda_param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24825 | if (p->error_indicator) { |
| 24826 | D(p->level--); |
| 24827 | return NULL; |
| 24828 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24829 | D(fprintf(stderr, "%*c> _loop1_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24830 | arg_ty lambda_param_no_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24831 | while ( |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24832 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24833 | ) |
| 24834 | { |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24835 | _res = lambda_param_no_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24836 | if (_n == _children_capacity) { |
| 24837 | _children_capacity *= 2; |
| 24838 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24839 | if (!_new_children) { |
| 24840 | p->error_indicator = 1; |
| 24841 | PyErr_NoMemory(); |
| 24842 | D(p->level--); |
| 24843 | return NULL; |
| 24844 | } |
| 24845 | _children = _new_children; |
| 24846 | } |
| 24847 | _children[_n++] = _res; |
| 24848 | _mark = p->mark; |
| 24849 | } |
| 24850 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24851 | D(fprintf(stderr, "%*c%s _loop1_97[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24852 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24853 | } |
| 24854 | if (_n == 0 || p->error_indicator) { |
| 24855 | PyMem_Free(_children); |
| 24856 | D(p->level--); |
| 24857 | return NULL; |
| 24858 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24859 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24860 | if (!_seq) { |
| 24861 | PyMem_Free(_children); |
| 24862 | p->error_indicator = 1; |
| 24863 | PyErr_NoMemory(); |
| 24864 | D(p->level--); |
| 24865 | return NULL; |
| 24866 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24867 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24868 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24869 | _PyPegen_insert_memo(p, _start_mark, _loop1_97_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24870 | D(p->level--); |
| 24871 | return _seq; |
| 24872 | } |
| 24873 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24874 | // _loop0_98: lambda_param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24875 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24876 | _loop0_98_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24877 | { |
| 24878 | D(p->level++); |
| 24879 | if (p->error_indicator) { |
| 24880 | D(p->level--); |
| 24881 | return NULL; |
| 24882 | } |
| 24883 | void *_res = NULL; |
| 24884 | int _mark = p->mark; |
| 24885 | int _start_mark = p->mark; |
| 24886 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24887 | if (!_children) { |
| 24888 | p->error_indicator = 1; |
| 24889 | PyErr_NoMemory(); |
| 24890 | D(p->level--); |
| 24891 | return NULL; |
| 24892 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 24893 | Py_ssize_t _children_capacity = 1; |
| 24894 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24895 | { // lambda_param_no_default |
| 24896 | if (p->error_indicator) { |
| 24897 | D(p->level--); |
| 24898 | return NULL; |
| 24899 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24900 | D(fprintf(stderr, "%*c> _loop0_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24901 | arg_ty lambda_param_no_default_var; |
| 24902 | while ( |
| 24903 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
| 24904 | ) |
| 24905 | { |
| 24906 | _res = lambda_param_no_default_var; |
| 24907 | if (_n == _children_capacity) { |
| 24908 | _children_capacity *= 2; |
| 24909 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24910 | if (!_new_children) { |
| 24911 | p->error_indicator = 1; |
| 24912 | PyErr_NoMemory(); |
| 24913 | D(p->level--); |
| 24914 | return NULL; |
| 24915 | } |
| 24916 | _children = _new_children; |
| 24917 | } |
| 24918 | _children[_n++] = _res; |
| 24919 | _mark = p->mark; |
| 24920 | } |
| 24921 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24922 | D(fprintf(stderr, "%*c%s _loop0_98[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24923 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); |
| 24924 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24925 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24926 | if (!_seq) { |
| 24927 | PyMem_Free(_children); |
| 24928 | p->error_indicator = 1; |
| 24929 | PyErr_NoMemory(); |
| 24930 | D(p->level--); |
| 24931 | return NULL; |
| 24932 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24933 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24934 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24935 | _PyPegen_insert_memo(p, _start_mark, _loop0_98_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24936 | D(p->level--); |
| 24937 | return _seq; |
| 24938 | } |
| 24939 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24940 | // _loop1_99: lambda_param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24941 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24942 | _loop1_99_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24943 | { |
| 24944 | D(p->level++); |
| 24945 | if (p->error_indicator) { |
| 24946 | D(p->level--); |
| 24947 | return NULL; |
| 24948 | } |
| 24949 | void *_res = NULL; |
| 24950 | int _mark = p->mark; |
| 24951 | int _start_mark = p->mark; |
| 24952 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24953 | if (!_children) { |
| 24954 | p->error_indicator = 1; |
| 24955 | PyErr_NoMemory(); |
| 24956 | D(p->level--); |
| 24957 | return NULL; |
| 24958 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 24959 | Py_ssize_t _children_capacity = 1; |
| 24960 | Py_ssize_t _n = 0; |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24961 | { // lambda_param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24962 | if (p->error_indicator) { |
| 24963 | D(p->level--); |
| 24964 | return NULL; |
| 24965 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24966 | D(fprintf(stderr, "%*c> _loop1_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24967 | NameDefaultPair* lambda_param_with_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24968 | while ( |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24969 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24970 | ) |
| 24971 | { |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24972 | _res = lambda_param_with_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24973 | if (_n == _children_capacity) { |
| 24974 | _children_capacity *= 2; |
| 24975 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24976 | if (!_new_children) { |
| 24977 | p->error_indicator = 1; |
| 24978 | PyErr_NoMemory(); |
| 24979 | D(p->level--); |
| 24980 | return NULL; |
| 24981 | } |
| 24982 | _children = _new_children; |
| 24983 | } |
| 24984 | _children[_n++] = _res; |
| 24985 | _mark = p->mark; |
| 24986 | } |
| 24987 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 24988 | D(fprintf(stderr, "%*c%s _loop1_99[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 24989 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24990 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24991 | if (_n == 0 || p->error_indicator) { |
| 24992 | PyMem_Free(_children); |
| 24993 | D(p->level--); |
| 24994 | return NULL; |
| 24995 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 24996 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 24997 | if (!_seq) { |
| 24998 | PyMem_Free(_children); |
| 24999 | p->error_indicator = 1; |
| 25000 | PyErr_NoMemory(); |
| 25001 | D(p->level--); |
| 25002 | return NULL; |
| 25003 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25004 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25005 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25006 | _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25007 | D(p->level--); |
| 25008 | return _seq; |
| 25009 | } |
| 25010 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25011 | // _loop0_100: lambda_param_no_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25012 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25013 | _loop0_100_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25014 | { |
| 25015 | D(p->level++); |
| 25016 | if (p->error_indicator) { |
| 25017 | D(p->level--); |
| 25018 | return NULL; |
| 25019 | } |
| 25020 | void *_res = NULL; |
| 25021 | int _mark = p->mark; |
| 25022 | int _start_mark = p->mark; |
| 25023 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 25024 | if (!_children) { |
| 25025 | p->error_indicator = 1; |
| 25026 | PyErr_NoMemory(); |
| 25027 | D(p->level--); |
| 25028 | return NULL; |
| 25029 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 25030 | Py_ssize_t _children_capacity = 1; |
| 25031 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25032 | { // lambda_param_no_default |
| 25033 | if (p->error_indicator) { |
| 25034 | D(p->level--); |
| 25035 | return NULL; |
| 25036 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25037 | D(fprintf(stderr, "%*c> _loop0_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25038 | arg_ty lambda_param_no_default_var; |
| 25039 | while ( |
| 25040 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
| 25041 | ) |
| 25042 | { |
| 25043 | _res = lambda_param_no_default_var; |
| 25044 | if (_n == _children_capacity) { |
| 25045 | _children_capacity *= 2; |
| 25046 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 25047 | if (!_new_children) { |
| 25048 | p->error_indicator = 1; |
| 25049 | PyErr_NoMemory(); |
| 25050 | D(p->level--); |
| 25051 | return NULL; |
| 25052 | } |
| 25053 | _children = _new_children; |
| 25054 | } |
| 25055 | _children[_n++] = _res; |
| 25056 | _mark = p->mark; |
| 25057 | } |
| 25058 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25059 | D(fprintf(stderr, "%*c%s _loop0_100[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25060 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); |
| 25061 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25062 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25063 | if (!_seq) { |
| 25064 | PyMem_Free(_children); |
| 25065 | p->error_indicator = 1; |
| 25066 | PyErr_NoMemory(); |
| 25067 | D(p->level--); |
| 25068 | return NULL; |
| 25069 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25070 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25071 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25072 | _PyPegen_insert_memo(p, _start_mark, _loop0_100_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25073 | D(p->level--); |
| 25074 | return _seq; |
| 25075 | } |
| 25076 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25077 | // _loop1_101: lambda_param_with_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25078 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25079 | _loop1_101_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25080 | { |
| 25081 | D(p->level++); |
| 25082 | if (p->error_indicator) { |
| 25083 | D(p->level--); |
| 25084 | return NULL; |
| 25085 | } |
| 25086 | void *_res = NULL; |
| 25087 | int _mark = p->mark; |
| 25088 | int _start_mark = p->mark; |
| 25089 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 25090 | if (!_children) { |
| 25091 | p->error_indicator = 1; |
| 25092 | PyErr_NoMemory(); |
| 25093 | D(p->level--); |
| 25094 | return NULL; |
| 25095 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 25096 | Py_ssize_t _children_capacity = 1; |
| 25097 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25098 | { // lambda_param_with_default |
| 25099 | if (p->error_indicator) { |
| 25100 | D(p->level--); |
| 25101 | return NULL; |
| 25102 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25103 | D(fprintf(stderr, "%*c> _loop1_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25104 | NameDefaultPair* lambda_param_with_default_var; |
| 25105 | while ( |
| 25106 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
| 25107 | ) |
| 25108 | { |
| 25109 | _res = lambda_param_with_default_var; |
| 25110 | if (_n == _children_capacity) { |
| 25111 | _children_capacity *= 2; |
| 25112 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 25113 | if (!_new_children) { |
| 25114 | p->error_indicator = 1; |
| 25115 | PyErr_NoMemory(); |
| 25116 | D(p->level--); |
| 25117 | return NULL; |
| 25118 | } |
| 25119 | _children = _new_children; |
| 25120 | } |
| 25121 | _children[_n++] = _res; |
| 25122 | _mark = p->mark; |
| 25123 | } |
| 25124 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25125 | D(fprintf(stderr, "%*c%s _loop1_101[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25126 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); |
| 25127 | } |
| 25128 | if (_n == 0 || p->error_indicator) { |
| 25129 | PyMem_Free(_children); |
| 25130 | D(p->level--); |
| 25131 | return NULL; |
| 25132 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25133 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25134 | if (!_seq) { |
| 25135 | PyMem_Free(_children); |
| 25136 | p->error_indicator = 1; |
| 25137 | PyErr_NoMemory(); |
| 25138 | D(p->level--); |
| 25139 | return NULL; |
| 25140 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25141 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25142 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25143 | _PyPegen_insert_memo(p, _start_mark, _loop1_101_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25144 | D(p->level--); |
| 25145 | return _seq; |
| 25146 | } |
| 25147 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25148 | // _loop0_102: lambda_param_maybe_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25149 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25150 | _loop0_102_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25151 | { |
| 25152 | D(p->level++); |
| 25153 | if (p->error_indicator) { |
| 25154 | D(p->level--); |
| 25155 | return NULL; |
| 25156 | } |
| 25157 | void *_res = NULL; |
| 25158 | int _mark = p->mark; |
| 25159 | int _start_mark = p->mark; |
| 25160 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 25161 | if (!_children) { |
| 25162 | p->error_indicator = 1; |
| 25163 | PyErr_NoMemory(); |
| 25164 | D(p->level--); |
| 25165 | return NULL; |
| 25166 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 25167 | Py_ssize_t _children_capacity = 1; |
| 25168 | Py_ssize_t _n = 0; |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 25169 | { // lambda_param_maybe_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25170 | if (p->error_indicator) { |
| 25171 | D(p->level--); |
| 25172 | return NULL; |
| 25173 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25174 | D(fprintf(stderr, "%*c> _loop0_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 25175 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25176 | while ( |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 25177 | (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25178 | ) |
| 25179 | { |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 25180 | _res = lambda_param_maybe_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25181 | if (_n == _children_capacity) { |
| 25182 | _children_capacity *= 2; |
| 25183 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 25184 | if (!_new_children) { |
| 25185 | p->error_indicator = 1; |
| 25186 | PyErr_NoMemory(); |
| 25187 | D(p->level--); |
| 25188 | return NULL; |
| 25189 | } |
| 25190 | _children = _new_children; |
| 25191 | } |
| 25192 | _children[_n++] = _res; |
| 25193 | _mark = p->mark; |
| 25194 | } |
| 25195 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25196 | D(fprintf(stderr, "%*c%s _loop0_102[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 25197 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25198 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25199 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25200 | if (!_seq) { |
| 25201 | PyMem_Free(_children); |
| 25202 | p->error_indicator = 1; |
| 25203 | PyErr_NoMemory(); |
| 25204 | D(p->level--); |
| 25205 | return NULL; |
| 25206 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25207 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25208 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25209 | _PyPegen_insert_memo(p, _start_mark, _loop0_102_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25210 | D(p->level--); |
| 25211 | return _seq; |
| 25212 | } |
| 25213 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25214 | // _loop1_103: lambda_param_maybe_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25215 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25216 | _loop1_103_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25217 | { |
| 25218 | D(p->level++); |
| 25219 | if (p->error_indicator) { |
| 25220 | D(p->level--); |
| 25221 | return NULL; |
| 25222 | } |
| 25223 | void *_res = NULL; |
| 25224 | int _mark = p->mark; |
| 25225 | int _start_mark = p->mark; |
| 25226 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 25227 | if (!_children) { |
| 25228 | p->error_indicator = 1; |
| 25229 | PyErr_NoMemory(); |
| 25230 | D(p->level--); |
| 25231 | return NULL; |
| 25232 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 25233 | Py_ssize_t _children_capacity = 1; |
| 25234 | Py_ssize_t _n = 0; |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 25235 | { // lambda_param_maybe_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25236 | if (p->error_indicator) { |
| 25237 | D(p->level--); |
| 25238 | return NULL; |
| 25239 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25240 | D(fprintf(stderr, "%*c> _loop1_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 25241 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25242 | while ( |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 25243 | (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25244 | ) |
| 25245 | { |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 25246 | _res = lambda_param_maybe_default_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25247 | if (_n == _children_capacity) { |
| 25248 | _children_capacity *= 2; |
| 25249 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 25250 | if (!_new_children) { |
| 25251 | p->error_indicator = 1; |
| 25252 | PyErr_NoMemory(); |
| 25253 | D(p->level--); |
| 25254 | return NULL; |
| 25255 | } |
| 25256 | _children = _new_children; |
| 25257 | } |
| 25258 | _children[_n++] = _res; |
| 25259 | _mark = p->mark; |
| 25260 | } |
| 25261 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25262 | D(fprintf(stderr, "%*c%s _loop1_103[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 25263 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25264 | } |
| 25265 | if (_n == 0 || p->error_indicator) { |
| 25266 | PyMem_Free(_children); |
| 25267 | D(p->level--); |
| 25268 | return NULL; |
| 25269 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25270 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25271 | if (!_seq) { |
| 25272 | PyMem_Free(_children); |
| 25273 | p->error_indicator = 1; |
| 25274 | PyErr_NoMemory(); |
| 25275 | D(p->level--); |
| 25276 | return NULL; |
| 25277 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25278 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25279 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25280 | _PyPegen_insert_memo(p, _start_mark, _loop1_103_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25281 | D(p->level--); |
| 25282 | return _seq; |
| 25283 | } |
| 25284 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25285 | // _loop1_104: ('or' conjunction) |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 25286 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25287 | _loop1_104_rule(Parser *p) |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 25288 | { |
| 25289 | D(p->level++); |
| 25290 | if (p->error_indicator) { |
| 25291 | D(p->level--); |
| 25292 | return NULL; |
| 25293 | } |
| 25294 | void *_res = NULL; |
| 25295 | int _mark = p->mark; |
| 25296 | int _start_mark = p->mark; |
| 25297 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 25298 | if (!_children) { |
| 25299 | p->error_indicator = 1; |
| 25300 | PyErr_NoMemory(); |
| 25301 | D(p->level--); |
| 25302 | return NULL; |
| 25303 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 25304 | Py_ssize_t _children_capacity = 1; |
| 25305 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25306 | { // ('or' conjunction) |
| 25307 | if (p->error_indicator) { |
| 25308 | D(p->level--); |
| 25309 | return NULL; |
| 25310 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25311 | D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 25312 | void *_tmp_171_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25313 | while ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 25314 | (_tmp_171_var = _tmp_171_rule(p)) // 'or' conjunction |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25315 | ) |
| 25316 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 25317 | _res = _tmp_171_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25318 | if (_n == _children_capacity) { |
| 25319 | _children_capacity *= 2; |
| 25320 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 25321 | if (!_new_children) { |
| 25322 | p->error_indicator = 1; |
| 25323 | PyErr_NoMemory(); |
| 25324 | D(p->level--); |
| 25325 | return NULL; |
| 25326 | } |
| 25327 | _children = _new_children; |
| 25328 | } |
| 25329 | _children[_n++] = _res; |
| 25330 | _mark = p->mark; |
| 25331 | } |
| 25332 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25333 | D(fprintf(stderr, "%*c%s _loop1_104[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25334 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); |
| 25335 | } |
| 25336 | if (_n == 0 || p->error_indicator) { |
| 25337 | PyMem_Free(_children); |
| 25338 | D(p->level--); |
| 25339 | return NULL; |
| 25340 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25341 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25342 | if (!_seq) { |
| 25343 | PyMem_Free(_children); |
| 25344 | p->error_indicator = 1; |
| 25345 | PyErr_NoMemory(); |
| 25346 | D(p->level--); |
| 25347 | return NULL; |
| 25348 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25349 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25350 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25351 | _PyPegen_insert_memo(p, _start_mark, _loop1_104_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25352 | D(p->level--); |
| 25353 | return _seq; |
| 25354 | } |
| 25355 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25356 | // _loop1_105: ('and' inversion) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25357 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25358 | _loop1_105_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25359 | { |
| 25360 | D(p->level++); |
| 25361 | if (p->error_indicator) { |
| 25362 | D(p->level--); |
| 25363 | return NULL; |
| 25364 | } |
| 25365 | void *_res = NULL; |
| 25366 | int _mark = p->mark; |
| 25367 | int _start_mark = p->mark; |
| 25368 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 25369 | if (!_children) { |
| 25370 | p->error_indicator = 1; |
| 25371 | PyErr_NoMemory(); |
| 25372 | D(p->level--); |
| 25373 | return NULL; |
| 25374 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 25375 | Py_ssize_t _children_capacity = 1; |
| 25376 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25377 | { // ('and' inversion) |
| 25378 | if (p->error_indicator) { |
| 25379 | D(p->level--); |
| 25380 | return NULL; |
| 25381 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25382 | D(fprintf(stderr, "%*c> _loop1_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 25383 | void *_tmp_172_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25384 | while ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 25385 | (_tmp_172_var = _tmp_172_rule(p)) // 'and' inversion |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25386 | ) |
| 25387 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 25388 | _res = _tmp_172_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25389 | if (_n == _children_capacity) { |
| 25390 | _children_capacity *= 2; |
| 25391 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 25392 | if (!_new_children) { |
| 25393 | p->error_indicator = 1; |
| 25394 | PyErr_NoMemory(); |
| 25395 | D(p->level--); |
| 25396 | return NULL; |
| 25397 | } |
| 25398 | _children = _new_children; |
| 25399 | } |
| 25400 | _children[_n++] = _res; |
| 25401 | _mark = p->mark; |
| 25402 | } |
| 25403 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25404 | D(fprintf(stderr, "%*c%s _loop1_105[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25405 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); |
| 25406 | } |
| 25407 | if (_n == 0 || p->error_indicator) { |
| 25408 | PyMem_Free(_children); |
| 25409 | D(p->level--); |
| 25410 | return NULL; |
| 25411 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25412 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25413 | if (!_seq) { |
| 25414 | PyMem_Free(_children); |
| 25415 | p->error_indicator = 1; |
| 25416 | PyErr_NoMemory(); |
| 25417 | D(p->level--); |
| 25418 | return NULL; |
| 25419 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25420 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25421 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25422 | _PyPegen_insert_memo(p, _start_mark, _loop1_105_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25423 | D(p->level--); |
| 25424 | return _seq; |
| 25425 | } |
| 25426 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25427 | // _loop1_106: compare_op_bitwise_or_pair |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25428 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25429 | _loop1_106_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25430 | { |
| 25431 | D(p->level++); |
| 25432 | if (p->error_indicator) { |
| 25433 | D(p->level--); |
| 25434 | return NULL; |
| 25435 | } |
| 25436 | void *_res = NULL; |
| 25437 | int _mark = p->mark; |
| 25438 | int _start_mark = p->mark; |
| 25439 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 25440 | if (!_children) { |
| 25441 | p->error_indicator = 1; |
| 25442 | PyErr_NoMemory(); |
| 25443 | D(p->level--); |
| 25444 | return NULL; |
| 25445 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 25446 | Py_ssize_t _children_capacity = 1; |
| 25447 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25448 | { // compare_op_bitwise_or_pair |
| 25449 | if (p->error_indicator) { |
| 25450 | D(p->level--); |
| 25451 | return NULL; |
| 25452 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25453 | D(fprintf(stderr, "%*c> _loop1_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25454 | CmpopExprPair* compare_op_bitwise_or_pair_var; |
| 25455 | while ( |
| 25456 | (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair |
| 25457 | ) |
| 25458 | { |
| 25459 | _res = compare_op_bitwise_or_pair_var; |
| 25460 | if (_n == _children_capacity) { |
| 25461 | _children_capacity *= 2; |
| 25462 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 25463 | if (!_new_children) { |
| 25464 | p->error_indicator = 1; |
| 25465 | PyErr_NoMemory(); |
| 25466 | D(p->level--); |
| 25467 | return NULL; |
| 25468 | } |
| 25469 | _children = _new_children; |
| 25470 | } |
| 25471 | _children[_n++] = _res; |
| 25472 | _mark = p->mark; |
| 25473 | } |
| 25474 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25475 | D(fprintf(stderr, "%*c%s _loop1_106[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25476 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); |
| 25477 | } |
| 25478 | if (_n == 0 || p->error_indicator) { |
| 25479 | PyMem_Free(_children); |
| 25480 | D(p->level--); |
| 25481 | return NULL; |
| 25482 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25483 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25484 | if (!_seq) { |
| 25485 | PyMem_Free(_children); |
| 25486 | p->error_indicator = 1; |
| 25487 | PyErr_NoMemory(); |
| 25488 | D(p->level--); |
| 25489 | return NULL; |
| 25490 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25491 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25492 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25493 | _PyPegen_insert_memo(p, _start_mark, _loop1_106_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25494 | D(p->level--); |
| 25495 | return _seq; |
| 25496 | } |
| 25497 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25498 | // _tmp_107: '!=' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25499 | static void * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25500 | _tmp_107_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25501 | { |
| 25502 | D(p->level++); |
| 25503 | if (p->error_indicator) { |
| 25504 | D(p->level--); |
| 25505 | return NULL; |
| 25506 | } |
| 25507 | void * _res = NULL; |
| 25508 | int _mark = p->mark; |
| 25509 | { // '!=' |
| 25510 | if (p->error_indicator) { |
| 25511 | D(p->level--); |
| 25512 | return NULL; |
| 25513 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25514 | D(fprintf(stderr, "%*c> _tmp_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25515 | Token * tok; |
| 25516 | if ( |
| 25517 | (tok = _PyPegen_expect_token(p, 28)) // token='!=' |
| 25518 | ) |
| 25519 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25520 | D(fprintf(stderr, "%*c+ _tmp_107[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); |
Pablo Galindo | 06f8c33 | 2020-10-30 23:48:42 +0000 | [diff] [blame] | 25521 | _res = _PyPegen_check_barry_as_flufl ( p , tok ) ? NULL : tok; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25522 | if (_res == NULL && PyErr_Occurred()) { |
| 25523 | p->error_indicator = 1; |
| 25524 | D(p->level--); |
| 25525 | return NULL; |
| 25526 | } |
| 25527 | goto done; |
| 25528 | } |
| 25529 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25530 | D(fprintf(stderr, "%*c%s _tmp_107[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25531 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); |
| 25532 | } |
| 25533 | _res = NULL; |
| 25534 | done: |
| 25535 | D(p->level--); |
| 25536 | return _res; |
| 25537 | } |
| 25538 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25539 | // _loop0_109: ',' slice |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25540 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25541 | _loop0_109_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25542 | { |
| 25543 | D(p->level++); |
| 25544 | if (p->error_indicator) { |
| 25545 | D(p->level--); |
| 25546 | return NULL; |
| 25547 | } |
| 25548 | void *_res = NULL; |
| 25549 | int _mark = p->mark; |
| 25550 | int _start_mark = p->mark; |
| 25551 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 25552 | if (!_children) { |
| 25553 | p->error_indicator = 1; |
| 25554 | PyErr_NoMemory(); |
| 25555 | D(p->level--); |
| 25556 | return NULL; |
| 25557 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 25558 | Py_ssize_t _children_capacity = 1; |
| 25559 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25560 | { // ',' slice |
| 25561 | if (p->error_indicator) { |
| 25562 | D(p->level--); |
| 25563 | return NULL; |
| 25564 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25565 | D(fprintf(stderr, "%*c> _loop0_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25566 | Token * _literal; |
| 25567 | expr_ty elem; |
| 25568 | while ( |
| 25569 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 25570 | && |
| 25571 | (elem = slice_rule(p)) // slice |
| 25572 | ) |
| 25573 | { |
| 25574 | _res = elem; |
| 25575 | if (_res == NULL && PyErr_Occurred()) { |
| 25576 | p->error_indicator = 1; |
| 25577 | PyMem_Free(_children); |
| 25578 | D(p->level--); |
| 25579 | return NULL; |
| 25580 | } |
| 25581 | if (_n == _children_capacity) { |
| 25582 | _children_capacity *= 2; |
| 25583 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 25584 | if (!_new_children) { |
| 25585 | p->error_indicator = 1; |
| 25586 | PyErr_NoMemory(); |
| 25587 | D(p->level--); |
| 25588 | return NULL; |
| 25589 | } |
| 25590 | _children = _new_children; |
| 25591 | } |
| 25592 | _children[_n++] = _res; |
| 25593 | _mark = p->mark; |
| 25594 | } |
| 25595 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25596 | D(fprintf(stderr, "%*c%s _loop0_109[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25597 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' slice")); |
| 25598 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25599 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25600 | if (!_seq) { |
| 25601 | PyMem_Free(_children); |
| 25602 | p->error_indicator = 1; |
| 25603 | PyErr_NoMemory(); |
| 25604 | D(p->level--); |
| 25605 | return NULL; |
| 25606 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25607 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25608 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25609 | _PyPegen_insert_memo(p, _start_mark, _loop0_109_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25610 | D(p->level--); |
| 25611 | return _seq; |
| 25612 | } |
| 25613 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25614 | // _gather_108: slice _loop0_109 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25615 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25616 | _gather_108_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25617 | { |
| 25618 | D(p->level++); |
| 25619 | if (p->error_indicator) { |
| 25620 | D(p->level--); |
| 25621 | return NULL; |
| 25622 | } |
| 25623 | asdl_seq * _res = NULL; |
| 25624 | int _mark = p->mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25625 | { // slice _loop0_109 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25626 | if (p->error_indicator) { |
| 25627 | D(p->level--); |
| 25628 | return NULL; |
| 25629 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25630 | D(fprintf(stderr, "%*c> _gather_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_109")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25631 | expr_ty elem; |
| 25632 | asdl_seq * seq; |
| 25633 | if ( |
| 25634 | (elem = slice_rule(p)) // slice |
| 25635 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25636 | (seq = _loop0_109_rule(p)) // _loop0_109 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25637 | ) |
| 25638 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25639 | D(fprintf(stderr, "%*c+ _gather_108[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_109")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25640 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 25641 | goto done; |
| 25642 | } |
| 25643 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25644 | D(fprintf(stderr, "%*c%s _gather_108[%d-%d]: %s failed!\n", p->level, ' ', |
| 25645 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_109")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25646 | } |
| 25647 | _res = NULL; |
| 25648 | done: |
| 25649 | D(p->level--); |
| 25650 | return _res; |
| 25651 | } |
| 25652 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25653 | // _tmp_110: ':' expression? |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25654 | static void * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25655 | _tmp_110_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25656 | { |
| 25657 | D(p->level++); |
| 25658 | if (p->error_indicator) { |
| 25659 | D(p->level--); |
| 25660 | return NULL; |
| 25661 | } |
| 25662 | void * _res = NULL; |
| 25663 | int _mark = p->mark; |
| 25664 | { // ':' expression? |
| 25665 | if (p->error_indicator) { |
| 25666 | D(p->level--); |
| 25667 | return NULL; |
| 25668 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25669 | D(fprintf(stderr, "%*c> _tmp_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25670 | Token * _literal; |
| 25671 | void *d; |
| 25672 | if ( |
| 25673 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 25674 | && |
| 25675 | (d = expression_rule(p), 1) // expression? |
| 25676 | ) |
| 25677 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25678 | D(fprintf(stderr, "%*c+ _tmp_110[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25679 | _res = d; |
| 25680 | if (_res == NULL && PyErr_Occurred()) { |
| 25681 | p->error_indicator = 1; |
| 25682 | D(p->level--); |
| 25683 | return NULL; |
| 25684 | } |
| 25685 | goto done; |
| 25686 | } |
| 25687 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25688 | D(fprintf(stderr, "%*c%s _tmp_110[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25689 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); |
| 25690 | } |
| 25691 | _res = NULL; |
| 25692 | done: |
| 25693 | D(p->level--); |
| 25694 | return _res; |
| 25695 | } |
| 25696 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25697 | // _tmp_111: tuple | group | genexp |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25698 | static void * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25699 | _tmp_111_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25700 | { |
| 25701 | D(p->level++); |
| 25702 | if (p->error_indicator) { |
| 25703 | D(p->level--); |
| 25704 | return NULL; |
| 25705 | } |
| 25706 | void * _res = NULL; |
| 25707 | int _mark = p->mark; |
| 25708 | { // tuple |
| 25709 | if (p->error_indicator) { |
| 25710 | D(p->level--); |
| 25711 | return NULL; |
| 25712 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25713 | D(fprintf(stderr, "%*c> _tmp_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25714 | expr_ty tuple_var; |
| 25715 | if ( |
| 25716 | (tuple_var = tuple_rule(p)) // tuple |
| 25717 | ) |
| 25718 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25719 | D(fprintf(stderr, "%*c+ _tmp_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25720 | _res = tuple_var; |
| 25721 | goto done; |
| 25722 | } |
| 25723 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25724 | D(fprintf(stderr, "%*c%s _tmp_111[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25725 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); |
| 25726 | } |
| 25727 | { // group |
| 25728 | if (p->error_indicator) { |
| 25729 | D(p->level--); |
| 25730 | return NULL; |
| 25731 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25732 | D(fprintf(stderr, "%*c> _tmp_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25733 | expr_ty group_var; |
| 25734 | if ( |
| 25735 | (group_var = group_rule(p)) // group |
| 25736 | ) |
| 25737 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25738 | D(fprintf(stderr, "%*c+ _tmp_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25739 | _res = group_var; |
| 25740 | goto done; |
| 25741 | } |
| 25742 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25743 | D(fprintf(stderr, "%*c%s _tmp_111[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25744 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group")); |
| 25745 | } |
| 25746 | { // genexp |
| 25747 | if (p->error_indicator) { |
| 25748 | D(p->level--); |
| 25749 | return NULL; |
| 25750 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25751 | D(fprintf(stderr, "%*c> _tmp_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25752 | expr_ty genexp_var; |
| 25753 | if ( |
| 25754 | (genexp_var = genexp_rule(p)) // genexp |
| 25755 | ) |
| 25756 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25757 | D(fprintf(stderr, "%*c+ _tmp_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25758 | _res = genexp_var; |
| 25759 | goto done; |
| 25760 | } |
| 25761 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25762 | D(fprintf(stderr, "%*c%s _tmp_111[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25763 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); |
| 25764 | } |
| 25765 | _res = NULL; |
| 25766 | done: |
| 25767 | D(p->level--); |
| 25768 | return _res; |
| 25769 | } |
| 25770 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25771 | // _tmp_112: list | listcomp |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25772 | static void * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25773 | _tmp_112_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25774 | { |
| 25775 | D(p->level++); |
| 25776 | if (p->error_indicator) { |
| 25777 | D(p->level--); |
| 25778 | return NULL; |
| 25779 | } |
| 25780 | void * _res = NULL; |
| 25781 | int _mark = p->mark; |
| 25782 | { // list |
| 25783 | if (p->error_indicator) { |
| 25784 | D(p->level--); |
| 25785 | return NULL; |
| 25786 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25787 | D(fprintf(stderr, "%*c> _tmp_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25788 | expr_ty list_var; |
| 25789 | if ( |
| 25790 | (list_var = list_rule(p)) // list |
| 25791 | ) |
| 25792 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25793 | D(fprintf(stderr, "%*c+ _tmp_112[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25794 | _res = list_var; |
| 25795 | goto done; |
| 25796 | } |
| 25797 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25798 | D(fprintf(stderr, "%*c%s _tmp_112[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25799 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); |
| 25800 | } |
| 25801 | { // listcomp |
| 25802 | if (p->error_indicator) { |
| 25803 | D(p->level--); |
| 25804 | return NULL; |
| 25805 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25806 | D(fprintf(stderr, "%*c> _tmp_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25807 | expr_ty listcomp_var; |
| 25808 | if ( |
| 25809 | (listcomp_var = listcomp_rule(p)) // listcomp |
| 25810 | ) |
| 25811 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25812 | D(fprintf(stderr, "%*c+ _tmp_112[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25813 | _res = listcomp_var; |
| 25814 | goto done; |
| 25815 | } |
| 25816 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25817 | D(fprintf(stderr, "%*c%s _tmp_112[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25818 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp")); |
| 25819 | } |
| 25820 | _res = NULL; |
| 25821 | done: |
| 25822 | D(p->level--); |
| 25823 | return _res; |
| 25824 | } |
| 25825 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25826 | // _tmp_113: dict | set | dictcomp | setcomp |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25827 | static void * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25828 | _tmp_113_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25829 | { |
| 25830 | D(p->level++); |
| 25831 | if (p->error_indicator) { |
| 25832 | D(p->level--); |
| 25833 | return NULL; |
| 25834 | } |
| 25835 | void * _res = NULL; |
| 25836 | int _mark = p->mark; |
| 25837 | { // dict |
| 25838 | if (p->error_indicator) { |
| 25839 | D(p->level--); |
| 25840 | return NULL; |
| 25841 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25842 | D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25843 | expr_ty dict_var; |
| 25844 | if ( |
| 25845 | (dict_var = dict_rule(p)) // dict |
| 25846 | ) |
| 25847 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25848 | D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25849 | _res = dict_var; |
| 25850 | goto done; |
| 25851 | } |
| 25852 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25853 | D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25854 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict")); |
| 25855 | } |
| 25856 | { // set |
| 25857 | if (p->error_indicator) { |
| 25858 | D(p->level--); |
| 25859 | return NULL; |
| 25860 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25861 | D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25862 | expr_ty set_var; |
| 25863 | if ( |
| 25864 | (set_var = set_rule(p)) // set |
| 25865 | ) |
| 25866 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25867 | D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25868 | _res = set_var; |
| 25869 | goto done; |
| 25870 | } |
| 25871 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25872 | D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25873 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set")); |
| 25874 | } |
| 25875 | { // dictcomp |
| 25876 | if (p->error_indicator) { |
| 25877 | D(p->level--); |
| 25878 | return NULL; |
| 25879 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25880 | D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25881 | expr_ty dictcomp_var; |
| 25882 | if ( |
| 25883 | (dictcomp_var = dictcomp_rule(p)) // dictcomp |
| 25884 | ) |
| 25885 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25886 | D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25887 | _res = dictcomp_var; |
| 25888 | goto done; |
| 25889 | } |
| 25890 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25891 | D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25892 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp")); |
| 25893 | } |
| 25894 | { // setcomp |
| 25895 | if (p->error_indicator) { |
| 25896 | D(p->level--); |
| 25897 | return NULL; |
| 25898 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25899 | D(fprintf(stderr, "%*c> _tmp_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25900 | expr_ty setcomp_var; |
| 25901 | if ( |
| 25902 | (setcomp_var = setcomp_rule(p)) // setcomp |
| 25903 | ) |
| 25904 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25905 | D(fprintf(stderr, "%*c+ _tmp_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25906 | _res = setcomp_var; |
| 25907 | goto done; |
| 25908 | } |
| 25909 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25910 | D(fprintf(stderr, "%*c%s _tmp_113[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25911 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp")); |
| 25912 | } |
| 25913 | _res = NULL; |
| 25914 | done: |
| 25915 | D(p->level--); |
| 25916 | return _res; |
| 25917 | } |
| 25918 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25919 | // _loop1_114: STRING |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25920 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25921 | _loop1_114_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25922 | { |
| 25923 | D(p->level++); |
| 25924 | if (p->error_indicator) { |
| 25925 | D(p->level--); |
| 25926 | return NULL; |
| 25927 | } |
| 25928 | void *_res = NULL; |
| 25929 | int _mark = p->mark; |
| 25930 | int _start_mark = p->mark; |
| 25931 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 25932 | if (!_children) { |
| 25933 | p->error_indicator = 1; |
| 25934 | PyErr_NoMemory(); |
| 25935 | D(p->level--); |
| 25936 | return NULL; |
| 25937 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 25938 | Py_ssize_t _children_capacity = 1; |
| 25939 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25940 | { // STRING |
| 25941 | if (p->error_indicator) { |
| 25942 | D(p->level--); |
| 25943 | return NULL; |
| 25944 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25945 | D(fprintf(stderr, "%*c> _loop1_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25946 | expr_ty string_var; |
| 25947 | while ( |
| 25948 | (string_var = _PyPegen_string_token(p)) // STRING |
| 25949 | ) |
| 25950 | { |
| 25951 | _res = string_var; |
| 25952 | if (_n == _children_capacity) { |
| 25953 | _children_capacity *= 2; |
| 25954 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 25955 | if (!_new_children) { |
| 25956 | p->error_indicator = 1; |
| 25957 | PyErr_NoMemory(); |
| 25958 | D(p->level--); |
| 25959 | return NULL; |
| 25960 | } |
| 25961 | _children = _new_children; |
| 25962 | } |
| 25963 | _children[_n++] = _res; |
| 25964 | _mark = p->mark; |
| 25965 | } |
| 25966 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25967 | D(fprintf(stderr, "%*c%s _loop1_114[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25968 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); |
| 25969 | } |
| 25970 | if (_n == 0 || p->error_indicator) { |
| 25971 | PyMem_Free(_children); |
| 25972 | D(p->level--); |
| 25973 | return NULL; |
| 25974 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25975 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25976 | if (!_seq) { |
| 25977 | PyMem_Free(_children); |
| 25978 | p->error_indicator = 1; |
| 25979 | PyErr_NoMemory(); |
| 25980 | D(p->level--); |
| 25981 | return NULL; |
| 25982 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 25983 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25984 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25985 | _PyPegen_insert_memo(p, _start_mark, _loop1_114_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25986 | D(p->level--); |
| 25987 | return _seq; |
| 25988 | } |
| 25989 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25990 | // _tmp_115: star_named_expression ',' star_named_expressions? |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25991 | static void * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 25992 | _tmp_115_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 25993 | { |
| 25994 | D(p->level++); |
| 25995 | if (p->error_indicator) { |
| 25996 | D(p->level--); |
| 25997 | return NULL; |
| 25998 | } |
| 25999 | void * _res = NULL; |
| 26000 | int _mark = p->mark; |
| 26001 | { // star_named_expression ',' star_named_expressions? |
| 26002 | if (p->error_indicator) { |
| 26003 | D(p->level--); |
| 26004 | return NULL; |
| 26005 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26006 | D(fprintf(stderr, "%*c> _tmp_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26007 | Token * _literal; |
| 26008 | expr_ty y; |
| 26009 | void *z; |
| 26010 | if ( |
| 26011 | (y = star_named_expression_rule(p)) // star_named_expression |
| 26012 | && |
| 26013 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 26014 | && |
| 26015 | (z = star_named_expressions_rule(p), 1) // star_named_expressions? |
| 26016 | ) |
| 26017 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26018 | D(fprintf(stderr, "%*c+ _tmp_115[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26019 | _res = _PyPegen_seq_insert_in_front ( p , y , z ); |
| 26020 | if (_res == NULL && PyErr_Occurred()) { |
| 26021 | p->error_indicator = 1; |
| 26022 | D(p->level--); |
| 26023 | return NULL; |
| 26024 | } |
| 26025 | goto done; |
| 26026 | } |
| 26027 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26028 | D(fprintf(stderr, "%*c%s _tmp_115[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26029 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); |
| 26030 | } |
| 26031 | _res = NULL; |
| 26032 | done: |
| 26033 | D(p->level--); |
| 26034 | return _res; |
| 26035 | } |
| 26036 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26037 | // _tmp_116: yield_expr | named_expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26038 | static void * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26039 | _tmp_116_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26040 | { |
| 26041 | D(p->level++); |
| 26042 | if (p->error_indicator) { |
| 26043 | D(p->level--); |
| 26044 | return NULL; |
| 26045 | } |
| 26046 | void * _res = NULL; |
| 26047 | int _mark = p->mark; |
| 26048 | { // yield_expr |
| 26049 | if (p->error_indicator) { |
| 26050 | D(p->level--); |
| 26051 | return NULL; |
| 26052 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26053 | D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26054 | expr_ty yield_expr_var; |
| 26055 | if ( |
| 26056 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
| 26057 | ) |
| 26058 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26059 | D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26060 | _res = yield_expr_var; |
| 26061 | goto done; |
| 26062 | } |
| 26063 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26064 | D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26065 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); |
| 26066 | } |
| 26067 | { // named_expression |
| 26068 | if (p->error_indicator) { |
| 26069 | D(p->level--); |
| 26070 | return NULL; |
| 26071 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26072 | D(fprintf(stderr, "%*c> _tmp_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26073 | expr_ty named_expression_var; |
| 26074 | if ( |
| 26075 | (named_expression_var = named_expression_rule(p)) // named_expression |
| 26076 | ) |
| 26077 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26078 | D(fprintf(stderr, "%*c+ _tmp_116[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26079 | _res = named_expression_var; |
| 26080 | goto done; |
| 26081 | } |
| 26082 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26083 | D(fprintf(stderr, "%*c%s _tmp_116[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26084 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); |
| 26085 | } |
| 26086 | _res = NULL; |
| 26087 | done: |
| 26088 | D(p->level--); |
| 26089 | return _res; |
| 26090 | } |
| 26091 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26092 | // _loop0_118: ',' double_starred_kvpair |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26093 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26094 | _loop0_118_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26095 | { |
| 26096 | D(p->level++); |
| 26097 | if (p->error_indicator) { |
| 26098 | D(p->level--); |
| 26099 | return NULL; |
| 26100 | } |
| 26101 | void *_res = NULL; |
| 26102 | int _mark = p->mark; |
| 26103 | int _start_mark = p->mark; |
| 26104 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 26105 | if (!_children) { |
| 26106 | p->error_indicator = 1; |
| 26107 | PyErr_NoMemory(); |
| 26108 | D(p->level--); |
| 26109 | return NULL; |
| 26110 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 26111 | Py_ssize_t _children_capacity = 1; |
| 26112 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26113 | { // ',' double_starred_kvpair |
| 26114 | if (p->error_indicator) { |
| 26115 | D(p->level--); |
| 26116 | return NULL; |
| 26117 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26118 | D(fprintf(stderr, "%*c> _loop0_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26119 | Token * _literal; |
| 26120 | KeyValuePair* elem; |
| 26121 | while ( |
| 26122 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 26123 | && |
| 26124 | (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair |
| 26125 | ) |
| 26126 | { |
| 26127 | _res = elem; |
| 26128 | if (_res == NULL && PyErr_Occurred()) { |
| 26129 | p->error_indicator = 1; |
| 26130 | PyMem_Free(_children); |
| 26131 | D(p->level--); |
| 26132 | return NULL; |
| 26133 | } |
| 26134 | if (_n == _children_capacity) { |
| 26135 | _children_capacity *= 2; |
| 26136 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 26137 | if (!_new_children) { |
| 26138 | p->error_indicator = 1; |
| 26139 | PyErr_NoMemory(); |
| 26140 | D(p->level--); |
| 26141 | return NULL; |
| 26142 | } |
| 26143 | _children = _new_children; |
| 26144 | } |
| 26145 | _children[_n++] = _res; |
| 26146 | _mark = p->mark; |
| 26147 | } |
| 26148 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26149 | D(fprintf(stderr, "%*c%s _loop0_118[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26150 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); |
| 26151 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 26152 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26153 | if (!_seq) { |
| 26154 | PyMem_Free(_children); |
| 26155 | p->error_indicator = 1; |
| 26156 | PyErr_NoMemory(); |
| 26157 | D(p->level--); |
| 26158 | return NULL; |
| 26159 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 26160 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26161 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26162 | _PyPegen_insert_memo(p, _start_mark, _loop0_118_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26163 | D(p->level--); |
| 26164 | return _seq; |
| 26165 | } |
| 26166 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26167 | // _gather_117: double_starred_kvpair _loop0_118 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26168 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26169 | _gather_117_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26170 | { |
| 26171 | D(p->level++); |
| 26172 | if (p->error_indicator) { |
| 26173 | D(p->level--); |
| 26174 | return NULL; |
| 26175 | } |
| 26176 | asdl_seq * _res = NULL; |
| 26177 | int _mark = p->mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26178 | { // double_starred_kvpair _loop0_118 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26179 | if (p->error_indicator) { |
| 26180 | D(p->level--); |
| 26181 | return NULL; |
| 26182 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26183 | D(fprintf(stderr, "%*c> _gather_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_118")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26184 | KeyValuePair* elem; |
| 26185 | asdl_seq * seq; |
| 26186 | if ( |
| 26187 | (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair |
| 26188 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26189 | (seq = _loop0_118_rule(p)) // _loop0_118 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26190 | ) |
| 26191 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26192 | D(fprintf(stderr, "%*c+ _gather_117[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_118")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26193 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 26194 | goto done; |
| 26195 | } |
| 26196 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26197 | D(fprintf(stderr, "%*c%s _gather_117[%d-%d]: %s failed!\n", p->level, ' ', |
| 26198 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_118")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26199 | } |
| 26200 | _res = NULL; |
| 26201 | done: |
| 26202 | D(p->level--); |
| 26203 | return _res; |
| 26204 | } |
| 26205 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26206 | // _loop1_119: for_if_clause |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26207 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26208 | _loop1_119_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26209 | { |
| 26210 | D(p->level++); |
| 26211 | if (p->error_indicator) { |
| 26212 | D(p->level--); |
| 26213 | return NULL; |
| 26214 | } |
| 26215 | void *_res = NULL; |
| 26216 | int _mark = p->mark; |
| 26217 | int _start_mark = p->mark; |
| 26218 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 26219 | if (!_children) { |
| 26220 | p->error_indicator = 1; |
| 26221 | PyErr_NoMemory(); |
| 26222 | D(p->level--); |
| 26223 | return NULL; |
| 26224 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 26225 | Py_ssize_t _children_capacity = 1; |
| 26226 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26227 | { // for_if_clause |
| 26228 | if (p->error_indicator) { |
| 26229 | D(p->level--); |
| 26230 | return NULL; |
| 26231 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26232 | D(fprintf(stderr, "%*c> _loop1_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26233 | comprehension_ty for_if_clause_var; |
| 26234 | while ( |
| 26235 | (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause |
| 26236 | ) |
| 26237 | { |
| 26238 | _res = for_if_clause_var; |
| 26239 | if (_n == _children_capacity) { |
| 26240 | _children_capacity *= 2; |
| 26241 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 26242 | if (!_new_children) { |
| 26243 | p->error_indicator = 1; |
| 26244 | PyErr_NoMemory(); |
| 26245 | D(p->level--); |
| 26246 | return NULL; |
| 26247 | } |
| 26248 | _children = _new_children; |
| 26249 | } |
| 26250 | _children[_n++] = _res; |
| 26251 | _mark = p->mark; |
| 26252 | } |
| 26253 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26254 | D(fprintf(stderr, "%*c%s _loop1_119[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26255 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); |
| 26256 | } |
| 26257 | if (_n == 0 || p->error_indicator) { |
| 26258 | PyMem_Free(_children); |
| 26259 | D(p->level--); |
| 26260 | return NULL; |
| 26261 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 26262 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26263 | if (!_seq) { |
| 26264 | PyMem_Free(_children); |
| 26265 | p->error_indicator = 1; |
| 26266 | PyErr_NoMemory(); |
| 26267 | D(p->level--); |
| 26268 | return NULL; |
| 26269 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 26270 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26271 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26272 | _PyPegen_insert_memo(p, _start_mark, _loop1_119_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26273 | D(p->level--); |
| 26274 | return _seq; |
| 26275 | } |
| 26276 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26277 | // _loop0_120: ('if' disjunction) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26278 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26279 | _loop0_120_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26280 | { |
| 26281 | D(p->level++); |
| 26282 | if (p->error_indicator) { |
| 26283 | D(p->level--); |
| 26284 | return NULL; |
| 26285 | } |
| 26286 | void *_res = NULL; |
| 26287 | int _mark = p->mark; |
| 26288 | int _start_mark = p->mark; |
| 26289 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 26290 | if (!_children) { |
| 26291 | p->error_indicator = 1; |
| 26292 | PyErr_NoMemory(); |
| 26293 | D(p->level--); |
| 26294 | return NULL; |
| 26295 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 26296 | Py_ssize_t _children_capacity = 1; |
| 26297 | Py_ssize_t _n = 0; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26298 | { // ('if' disjunction) |
| 26299 | if (p->error_indicator) { |
| 26300 | D(p->level--); |
| 26301 | return NULL; |
| 26302 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26303 | D(fprintf(stderr, "%*c> _loop0_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 26304 | void *_tmp_173_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26305 | while ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 26306 | (_tmp_173_var = _tmp_173_rule(p)) // 'if' disjunction |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26307 | ) |
| 26308 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 26309 | _res = _tmp_173_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26310 | if (_n == _children_capacity) { |
| 26311 | _children_capacity *= 2; |
| 26312 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 26313 | if (!_new_children) { |
| 26314 | p->error_indicator = 1; |
| 26315 | PyErr_NoMemory(); |
| 26316 | D(p->level--); |
| 26317 | return NULL; |
| 26318 | } |
| 26319 | _children = _new_children; |
| 26320 | } |
| 26321 | _children[_n++] = _res; |
| 26322 | _mark = p->mark; |
| 26323 | } |
| 26324 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26325 | D(fprintf(stderr, "%*c%s _loop0_120[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26326 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); |
| 26327 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 26328 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26329 | if (!_seq) { |
| 26330 | PyMem_Free(_children); |
| 26331 | p->error_indicator = 1; |
| 26332 | PyErr_NoMemory(); |
| 26333 | D(p->level--); |
| 26334 | return NULL; |
| 26335 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 26336 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26337 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26338 | _PyPegen_insert_memo(p, _start_mark, _loop0_120_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26339 | D(p->level--); |
| 26340 | return _seq; |
| 26341 | } |
| 26342 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26343 | // _loop0_121: ('if' disjunction) |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26344 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26345 | _loop0_121_rule(Parser *p) |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26346 | { |
| 26347 | D(p->level++); |
| 26348 | if (p->error_indicator) { |
| 26349 | D(p->level--); |
| 26350 | return NULL; |
| 26351 | } |
| 26352 | void *_res = NULL; |
| 26353 | int _mark = p->mark; |
| 26354 | int _start_mark = p->mark; |
| 26355 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 26356 | if (!_children) { |
| 26357 | p->error_indicator = 1; |
| 26358 | PyErr_NoMemory(); |
| 26359 | D(p->level--); |
| 26360 | return NULL; |
| 26361 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 26362 | Py_ssize_t _children_capacity = 1; |
| 26363 | Py_ssize_t _n = 0; |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26364 | { // ('if' disjunction) |
| 26365 | if (p->error_indicator) { |
| 26366 | D(p->level--); |
| 26367 | return NULL; |
| 26368 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26369 | D(fprintf(stderr, "%*c> _loop0_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 26370 | void *_tmp_174_var; |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26371 | while ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 26372 | (_tmp_174_var = _tmp_174_rule(p)) // 'if' disjunction |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26373 | ) |
| 26374 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 26375 | _res = _tmp_174_var; |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26376 | if (_n == _children_capacity) { |
| 26377 | _children_capacity *= 2; |
| 26378 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 26379 | if (!_new_children) { |
| 26380 | p->error_indicator = 1; |
| 26381 | PyErr_NoMemory(); |
| 26382 | D(p->level--); |
| 26383 | return NULL; |
| 26384 | } |
| 26385 | _children = _new_children; |
| 26386 | } |
| 26387 | _children[_n++] = _res; |
| 26388 | _mark = p->mark; |
| 26389 | } |
| 26390 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26391 | D(fprintf(stderr, "%*c%s _loop0_121[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26392 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); |
| 26393 | } |
| 26394 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 26395 | if (!_seq) { |
| 26396 | PyMem_Free(_children); |
| 26397 | p->error_indicator = 1; |
| 26398 | PyErr_NoMemory(); |
| 26399 | D(p->level--); |
| 26400 | return NULL; |
| 26401 | } |
| 26402 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 26403 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26404 | _PyPegen_insert_memo(p, _start_mark, _loop0_121_type, _seq); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26405 | D(p->level--); |
| 26406 | return _seq; |
| 26407 | } |
| 26408 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26409 | // _loop0_123: ',' (starred_expression | named_expression !'=') |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 26410 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26411 | _loop0_123_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26412 | { |
| 26413 | D(p->level++); |
| 26414 | if (p->error_indicator) { |
| 26415 | D(p->level--); |
| 26416 | return NULL; |
| 26417 | } |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 26418 | void *_res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26419 | int _mark = p->mark; |
Lysandros Nikolaou | 01ece63 | 2020-06-19 02:10:43 +0300 | [diff] [blame] | 26420 | int _start_mark = p->mark; |
| 26421 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 26422 | if (!_children) { |
| 26423 | p->error_indicator = 1; |
| 26424 | PyErr_NoMemory(); |
| 26425 | D(p->level--); |
| 26426 | return NULL; |
| 26427 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 26428 | Py_ssize_t _children_capacity = 1; |
| 26429 | Py_ssize_t _n = 0; |
Pablo Galindo | 4a97b15 | 2020-09-02 17:44:19 +0100 | [diff] [blame] | 26430 | { // ',' (starred_expression | named_expression !'=') |
| 26431 | if (p->error_indicator) { |
| 26432 | D(p->level--); |
| 26433 | return NULL; |
| 26434 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26435 | D(fprintf(stderr, "%*c> _loop0_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (starred_expression | named_expression !'=')")); |
Pablo Galindo | 4a97b15 | 2020-09-02 17:44:19 +0100 | [diff] [blame] | 26436 | Token * _literal; |
| 26437 | void *elem; |
| 26438 | while ( |
| 26439 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 26440 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 26441 | (elem = _tmp_175_rule(p)) // starred_expression | named_expression !'=' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26442 | ) |
| 26443 | { |
| 26444 | _res = elem; |
| 26445 | if (_res == NULL && PyErr_Occurred()) { |
| 26446 | p->error_indicator = 1; |
| 26447 | PyMem_Free(_children); |
| 26448 | D(p->level--); |
| 26449 | return NULL; |
| 26450 | } |
| 26451 | if (_n == _children_capacity) { |
| 26452 | _children_capacity *= 2; |
| 26453 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 26454 | if (!_new_children) { |
| 26455 | p->error_indicator = 1; |
| 26456 | PyErr_NoMemory(); |
| 26457 | D(p->level--); |
| 26458 | return NULL; |
| 26459 | } |
| 26460 | _children = _new_children; |
| 26461 | } |
| 26462 | _children[_n++] = _res; |
| 26463 | _mark = p->mark; |
| 26464 | } |
| 26465 | p->mark = _mark; |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 26466 | D(fprintf(stderr, "%*c%s _loop0_123[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26467 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (starred_expression | named_expression !'=')")); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26468 | } |
| 26469 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 26470 | if (!_seq) { |
| 26471 | PyMem_Free(_children); |
| 26472 | p->error_indicator = 1; |
| 26473 | PyErr_NoMemory(); |
| 26474 | D(p->level--); |
| 26475 | return NULL; |
| 26476 | } |
| 26477 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 26478 | PyMem_Free(_children); |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 26479 | _PyPegen_insert_memo(p, _start_mark, _loop0_123_type, _seq); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26480 | D(p->level--); |
| 26481 | return _seq; |
| 26482 | } |
| 26483 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26484 | // _gather_122: (starred_expression | named_expression !'=') _loop0_123 |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26485 | static asdl_seq * |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 26486 | _gather_122_rule(Parser *p) |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26487 | { |
| 26488 | D(p->level++); |
| 26489 | if (p->error_indicator) { |
| 26490 | D(p->level--); |
| 26491 | return NULL; |
| 26492 | } |
| 26493 | asdl_seq * _res = NULL; |
| 26494 | int _mark = p->mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26495 | { // (starred_expression | named_expression !'=') _loop0_123 |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26496 | if (p->error_indicator) { |
| 26497 | D(p->level--); |
| 26498 | return NULL; |
| 26499 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26500 | D(fprintf(stderr, "%*c> _gather_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_123")); |
| 26501 | void *elem; |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26502 | asdl_seq * seq; |
| 26503 | if ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 26504 | (elem = _tmp_175_rule(p)) // starred_expression | named_expression !'=' |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26505 | && |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 26506 | (seq = _loop0_123_rule(p)) // _loop0_123 |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26507 | ) |
| 26508 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26509 | D(fprintf(stderr, "%*c+ _gather_122[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_123")); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26510 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 26511 | goto done; |
| 26512 | } |
| 26513 | p->mark = _mark; |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 26514 | D(fprintf(stderr, "%*c%s _gather_122[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26515 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(starred_expression | named_expression !'=') _loop0_123")); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26516 | } |
| 26517 | _res = NULL; |
| 26518 | done: |
| 26519 | D(p->level--); |
| 26520 | return _res; |
| 26521 | } |
| 26522 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26523 | // _tmp_124: ',' kwargs |
| 26524 | static void * |
| 26525 | _tmp_124_rule(Parser *p) |
| 26526 | { |
| 26527 | D(p->level++); |
| 26528 | if (p->error_indicator) { |
| 26529 | D(p->level--); |
| 26530 | return NULL; |
| 26531 | } |
| 26532 | void * _res = NULL; |
| 26533 | int _mark = p->mark; |
| 26534 | { // ',' kwargs |
| 26535 | if (p->error_indicator) { |
| 26536 | D(p->level--); |
| 26537 | return NULL; |
| 26538 | } |
| 26539 | D(fprintf(stderr, "%*c> _tmp_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwargs")); |
| 26540 | Token * _literal; |
| 26541 | asdl_seq* k; |
| 26542 | if ( |
| 26543 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 26544 | && |
| 26545 | (k = kwargs_rule(p)) // kwargs |
| 26546 | ) |
| 26547 | { |
| 26548 | D(fprintf(stderr, "%*c+ _tmp_124[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' kwargs")); |
| 26549 | _res = k; |
| 26550 | if (_res == NULL && PyErr_Occurred()) { |
| 26551 | p->error_indicator = 1; |
| 26552 | D(p->level--); |
| 26553 | return NULL; |
| 26554 | } |
| 26555 | goto done; |
| 26556 | } |
| 26557 | p->mark = _mark; |
| 26558 | D(fprintf(stderr, "%*c%s _tmp_124[%d-%d]: %s failed!\n", p->level, ' ', |
| 26559 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwargs")); |
| 26560 | } |
| 26561 | _res = NULL; |
| 26562 | done: |
| 26563 | D(p->level--); |
| 26564 | return _res; |
| 26565 | } |
| 26566 | |
| 26567 | // _loop0_126: ',' kwarg_or_starred |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26568 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26569 | _loop0_126_rule(Parser *p) |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26570 | { |
| 26571 | D(p->level++); |
| 26572 | if (p->error_indicator) { |
| 26573 | D(p->level--); |
| 26574 | return NULL; |
| 26575 | } |
| 26576 | void *_res = NULL; |
| 26577 | int _mark = p->mark; |
| 26578 | int _start_mark = p->mark; |
| 26579 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 26580 | if (!_children) { |
| 26581 | p->error_indicator = 1; |
| 26582 | PyErr_NoMemory(); |
| 26583 | D(p->level--); |
| 26584 | return NULL; |
| 26585 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 26586 | Py_ssize_t _children_capacity = 1; |
| 26587 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26588 | { // ',' kwarg_or_starred |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26589 | if (p->error_indicator) { |
| 26590 | D(p->level--); |
| 26591 | return NULL; |
| 26592 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26593 | D(fprintf(stderr, "%*c> _loop0_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26594 | Token * _literal; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26595 | KeywordOrStarred* elem; |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26596 | while ( |
| 26597 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 26598 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26599 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26600 | ) |
| 26601 | { |
| 26602 | _res = elem; |
| 26603 | if (_res == NULL && PyErr_Occurred()) { |
| 26604 | p->error_indicator = 1; |
| 26605 | PyMem_Free(_children); |
| 26606 | D(p->level--); |
| 26607 | return NULL; |
| 26608 | } |
| 26609 | if (_n == _children_capacity) { |
| 26610 | _children_capacity *= 2; |
| 26611 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 26612 | if (!_new_children) { |
| 26613 | p->error_indicator = 1; |
| 26614 | PyErr_NoMemory(); |
| 26615 | D(p->level--); |
| 26616 | return NULL; |
| 26617 | } |
| 26618 | _children = _new_children; |
| 26619 | } |
| 26620 | _children[_n++] = _res; |
| 26621 | _mark = p->mark; |
| 26622 | } |
| 26623 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26624 | D(fprintf(stderr, "%*c%s _loop0_126[%d-%d]: %s failed!\n", p->level, ' ', |
| 26625 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26626 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 26627 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26628 | if (!_seq) { |
| 26629 | PyMem_Free(_children); |
| 26630 | p->error_indicator = 1; |
| 26631 | PyErr_NoMemory(); |
| 26632 | D(p->level--); |
| 26633 | return NULL; |
| 26634 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 26635 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26636 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26637 | _PyPegen_insert_memo(p, _start_mark, _loop0_126_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26638 | D(p->level--); |
| 26639 | return _seq; |
| 26640 | } |
| 26641 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26642 | // _gather_125: kwarg_or_starred _loop0_126 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26643 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26644 | _gather_125_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26645 | { |
| 26646 | D(p->level++); |
| 26647 | if (p->error_indicator) { |
| 26648 | D(p->level--); |
| 26649 | return NULL; |
| 26650 | } |
| 26651 | asdl_seq * _res = NULL; |
| 26652 | int _mark = p->mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26653 | { // kwarg_or_starred _loop0_126 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26654 | if (p->error_indicator) { |
| 26655 | D(p->level--); |
| 26656 | return NULL; |
| 26657 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26658 | D(fprintf(stderr, "%*c> _gather_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_126")); |
| 26659 | KeywordOrStarred* elem; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26660 | asdl_seq * seq; |
| 26661 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26662 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26663 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26664 | (seq = _loop0_126_rule(p)) // _loop0_126 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26665 | ) |
| 26666 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26667 | D(fprintf(stderr, "%*c+ _gather_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_126")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26668 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 26669 | goto done; |
| 26670 | } |
| 26671 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26672 | D(fprintf(stderr, "%*c%s _gather_125[%d-%d]: %s failed!\n", p->level, ' ', |
| 26673 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_126")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26674 | } |
| 26675 | _res = NULL; |
| 26676 | done: |
| 26677 | D(p->level--); |
| 26678 | return _res; |
| 26679 | } |
| 26680 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26681 | // _loop0_128: ',' kwarg_or_double_starred |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26682 | static asdl_seq * |
| 26683 | _loop0_128_rule(Parser *p) |
| 26684 | { |
| 26685 | D(p->level++); |
| 26686 | if (p->error_indicator) { |
| 26687 | D(p->level--); |
| 26688 | return NULL; |
| 26689 | } |
| 26690 | void *_res = NULL; |
| 26691 | int _mark = p->mark; |
| 26692 | int _start_mark = p->mark; |
| 26693 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 26694 | if (!_children) { |
| 26695 | p->error_indicator = 1; |
| 26696 | PyErr_NoMemory(); |
| 26697 | D(p->level--); |
| 26698 | return NULL; |
| 26699 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 26700 | Py_ssize_t _children_capacity = 1; |
| 26701 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26702 | { // ',' kwarg_or_double_starred |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26703 | if (p->error_indicator) { |
| 26704 | D(p->level--); |
| 26705 | return NULL; |
| 26706 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26707 | D(fprintf(stderr, "%*c> _loop0_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); |
| 26708 | Token * _literal; |
| 26709 | KeywordOrStarred* elem; |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26710 | while ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26711 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 26712 | && |
| 26713 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26714 | ) |
| 26715 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26716 | _res = elem; |
| 26717 | if (_res == NULL && PyErr_Occurred()) { |
| 26718 | p->error_indicator = 1; |
| 26719 | PyMem_Free(_children); |
| 26720 | D(p->level--); |
| 26721 | return NULL; |
| 26722 | } |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26723 | if (_n == _children_capacity) { |
| 26724 | _children_capacity *= 2; |
| 26725 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 26726 | if (!_new_children) { |
| 26727 | p->error_indicator = 1; |
| 26728 | PyErr_NoMemory(); |
| 26729 | D(p->level--); |
| 26730 | return NULL; |
| 26731 | } |
| 26732 | _children = _new_children; |
| 26733 | } |
| 26734 | _children[_n++] = _res; |
| 26735 | _mark = p->mark; |
| 26736 | } |
| 26737 | p->mark = _mark; |
| 26738 | D(fprintf(stderr, "%*c%s _loop0_128[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26739 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 26740 | } |
| 26741 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 26742 | if (!_seq) { |
| 26743 | PyMem_Free(_children); |
| 26744 | p->error_indicator = 1; |
| 26745 | PyErr_NoMemory(); |
| 26746 | D(p->level--); |
| 26747 | return NULL; |
| 26748 | } |
| 26749 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 26750 | PyMem_Free(_children); |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 26751 | _PyPegen_insert_memo(p, _start_mark, _loop0_128_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26752 | D(p->level--); |
Lysandros Nikolaou | 4b85e60 | 2020-06-26 02:22:36 +0300 | [diff] [blame] | 26753 | return _seq; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26754 | } |
| 26755 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26756 | // _gather_127: kwarg_or_double_starred _loop0_128 |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 26757 | static asdl_seq * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26758 | _gather_127_rule(Parser *p) |
| 26759 | { |
| 26760 | D(p->level++); |
| 26761 | if (p->error_indicator) { |
| 26762 | D(p->level--); |
| 26763 | return NULL; |
| 26764 | } |
| 26765 | asdl_seq * _res = NULL; |
| 26766 | int _mark = p->mark; |
| 26767 | { // kwarg_or_double_starred _loop0_128 |
| 26768 | if (p->error_indicator) { |
| 26769 | D(p->level--); |
| 26770 | return NULL; |
| 26771 | } |
| 26772 | D(fprintf(stderr, "%*c> _gather_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_128")); |
| 26773 | KeywordOrStarred* elem; |
| 26774 | asdl_seq * seq; |
| 26775 | if ( |
| 26776 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
| 26777 | && |
| 26778 | (seq = _loop0_128_rule(p)) // _loop0_128 |
| 26779 | ) |
| 26780 | { |
| 26781 | D(fprintf(stderr, "%*c+ _gather_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_128")); |
| 26782 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 26783 | goto done; |
| 26784 | } |
| 26785 | p->mark = _mark; |
| 26786 | D(fprintf(stderr, "%*c%s _gather_127[%d-%d]: %s failed!\n", p->level, ' ', |
| 26787 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_128")); |
| 26788 | } |
| 26789 | _res = NULL; |
| 26790 | done: |
| 26791 | D(p->level--); |
| 26792 | return _res; |
| 26793 | } |
| 26794 | |
| 26795 | // _loop0_130: ',' kwarg_or_starred |
| 26796 | static asdl_seq * |
| 26797 | _loop0_130_rule(Parser *p) |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 26798 | { |
| 26799 | D(p->level++); |
| 26800 | if (p->error_indicator) { |
| 26801 | D(p->level--); |
| 26802 | return NULL; |
| 26803 | } |
| 26804 | void *_res = NULL; |
| 26805 | int _mark = p->mark; |
| 26806 | int _start_mark = p->mark; |
| 26807 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 26808 | if (!_children) { |
| 26809 | p->error_indicator = 1; |
| 26810 | PyErr_NoMemory(); |
| 26811 | D(p->level--); |
| 26812 | return NULL; |
| 26813 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 26814 | Py_ssize_t _children_capacity = 1; |
| 26815 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26816 | { // ',' kwarg_or_starred |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 26817 | if (p->error_indicator) { |
| 26818 | D(p->level--); |
| 26819 | return NULL; |
| 26820 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26821 | D(fprintf(stderr, "%*c> _loop0_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); |
| 26822 | Token * _literal; |
| 26823 | KeywordOrStarred* elem; |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 26824 | while ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26825 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 26826 | && |
| 26827 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 26828 | ) |
| 26829 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26830 | _res = elem; |
| 26831 | if (_res == NULL && PyErr_Occurred()) { |
| 26832 | p->error_indicator = 1; |
| 26833 | PyMem_Free(_children); |
| 26834 | D(p->level--); |
| 26835 | return NULL; |
| 26836 | } |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 26837 | if (_n == _children_capacity) { |
| 26838 | _children_capacity *= 2; |
| 26839 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 26840 | if (!_new_children) { |
| 26841 | p->error_indicator = 1; |
| 26842 | PyErr_NoMemory(); |
| 26843 | D(p->level--); |
| 26844 | return NULL; |
| 26845 | } |
| 26846 | _children = _new_children; |
| 26847 | } |
| 26848 | _children[_n++] = _res; |
| 26849 | _mark = p->mark; |
| 26850 | } |
| 26851 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26852 | D(fprintf(stderr, "%*c%s _loop0_130[%d-%d]: %s failed!\n", p->level, ' ', |
| 26853 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 26854 | } |
| 26855 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 26856 | if (!_seq) { |
| 26857 | PyMem_Free(_children); |
| 26858 | p->error_indicator = 1; |
| 26859 | PyErr_NoMemory(); |
| 26860 | D(p->level--); |
| 26861 | return NULL; |
| 26862 | } |
| 26863 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 26864 | PyMem_Free(_children); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26865 | _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq); |
Lysandros Nikolaou | 2ea320d | 2021-01-03 01:14:21 +0200 | [diff] [blame] | 26866 | D(p->level--); |
| 26867 | return _seq; |
| 26868 | } |
| 26869 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26870 | // _gather_129: kwarg_or_starred _loop0_130 |
| 26871 | static asdl_seq * |
| 26872 | _gather_129_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26873 | { |
| 26874 | D(p->level++); |
| 26875 | if (p->error_indicator) { |
| 26876 | D(p->level--); |
| 26877 | return NULL; |
| 26878 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26879 | asdl_seq * _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26880 | int _mark = p->mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26881 | { // kwarg_or_starred _loop0_130 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26882 | if (p->error_indicator) { |
| 26883 | D(p->level--); |
| 26884 | return NULL; |
| 26885 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26886 | D(fprintf(stderr, "%*c> _gather_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_130")); |
| 26887 | KeywordOrStarred* elem; |
| 26888 | asdl_seq * seq; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26889 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26890 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
| 26891 | && |
| 26892 | (seq = _loop0_130_rule(p)) // _loop0_130 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26893 | ) |
| 26894 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26895 | D(fprintf(stderr, "%*c+ _gather_129[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_130")); |
| 26896 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26897 | goto done; |
| 26898 | } |
| 26899 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26900 | D(fprintf(stderr, "%*c%s _gather_129[%d-%d]: %s failed!\n", p->level, ' ', |
| 26901 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_130")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26902 | } |
| 26903 | _res = NULL; |
| 26904 | done: |
| 26905 | D(p->level--); |
| 26906 | return _res; |
| 26907 | } |
| 26908 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26909 | // _loop0_132: ',' kwarg_or_double_starred |
| 26910 | static asdl_seq * |
| 26911 | _loop0_132_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26912 | { |
| 26913 | D(p->level++); |
| 26914 | if (p->error_indicator) { |
| 26915 | D(p->level--); |
| 26916 | return NULL; |
| 26917 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26918 | void *_res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26919 | int _mark = p->mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26920 | int _start_mark = p->mark; |
| 26921 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 26922 | if (!_children) { |
| 26923 | p->error_indicator = 1; |
| 26924 | PyErr_NoMemory(); |
| 26925 | D(p->level--); |
| 26926 | return NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26927 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 26928 | Py_ssize_t _children_capacity = 1; |
| 26929 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26930 | { // ',' kwarg_or_double_starred |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26931 | if (p->error_indicator) { |
| 26932 | D(p->level--); |
| 26933 | return NULL; |
| 26934 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26935 | D(fprintf(stderr, "%*c> _loop0_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26936 | Token * _literal; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26937 | KeywordOrStarred* elem; |
| 26938 | while ( |
| 26939 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 26940 | && |
| 26941 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26942 | ) |
| 26943 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26944 | _res = elem; |
| 26945 | if (_res == NULL && PyErr_Occurred()) { |
| 26946 | p->error_indicator = 1; |
| 26947 | PyMem_Free(_children); |
| 26948 | D(p->level--); |
| 26949 | return NULL; |
| 26950 | } |
| 26951 | if (_n == _children_capacity) { |
| 26952 | _children_capacity *= 2; |
| 26953 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 26954 | if (!_new_children) { |
| 26955 | p->error_indicator = 1; |
| 26956 | PyErr_NoMemory(); |
| 26957 | D(p->level--); |
| 26958 | return NULL; |
| 26959 | } |
| 26960 | _children = _new_children; |
| 26961 | } |
| 26962 | _children[_n++] = _res; |
| 26963 | _mark = p->mark; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26964 | } |
| 26965 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26966 | D(fprintf(stderr, "%*c%s _loop0_132[%d-%d]: %s failed!\n", p->level, ' ', |
| 26967 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26968 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 26969 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 26970 | if (!_seq) { |
| 26971 | PyMem_Free(_children); |
| 26972 | p->error_indicator = 1; |
| 26973 | PyErr_NoMemory(); |
| 26974 | D(p->level--); |
| 26975 | return NULL; |
| 26976 | } |
| 26977 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 26978 | PyMem_Free(_children); |
| 26979 | _PyPegen_insert_memo(p, _start_mark, _loop0_132_type, _seq); |
| 26980 | D(p->level--); |
| 26981 | return _seq; |
| 26982 | } |
| 26983 | |
| 26984 | // _gather_131: kwarg_or_double_starred _loop0_132 |
| 26985 | static asdl_seq * |
| 26986 | _gather_131_rule(Parser *p) |
| 26987 | { |
| 26988 | D(p->level++); |
| 26989 | if (p->error_indicator) { |
| 26990 | D(p->level--); |
| 26991 | return NULL; |
| 26992 | } |
| 26993 | asdl_seq * _res = NULL; |
| 26994 | int _mark = p->mark; |
| 26995 | { // kwarg_or_double_starred _loop0_132 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 26996 | if (p->error_indicator) { |
| 26997 | D(p->level--); |
| 26998 | return NULL; |
| 26999 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27000 | D(fprintf(stderr, "%*c> _gather_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_132")); |
| 27001 | KeywordOrStarred* elem; |
| 27002 | asdl_seq * seq; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27003 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27004 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
| 27005 | && |
| 27006 | (seq = _loop0_132_rule(p)) // _loop0_132 |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27007 | ) |
| 27008 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27009 | D(fprintf(stderr, "%*c+ _gather_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_132")); |
| 27010 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27011 | goto done; |
| 27012 | } |
| 27013 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27014 | D(fprintf(stderr, "%*c%s _gather_131[%d-%d]: %s failed!\n", p->level, ' ', |
| 27015 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_132")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27016 | } |
| 27017 | _res = NULL; |
| 27018 | done: |
| 27019 | D(p->level--); |
| 27020 | return _res; |
| 27021 | } |
| 27022 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27023 | // _loop0_133: (',' star_target) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27024 | static asdl_seq * |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 27025 | _loop0_133_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27026 | { |
| 27027 | D(p->level++); |
| 27028 | if (p->error_indicator) { |
| 27029 | D(p->level--); |
| 27030 | return NULL; |
| 27031 | } |
| 27032 | void *_res = NULL; |
| 27033 | int _mark = p->mark; |
| 27034 | int _start_mark = p->mark; |
| 27035 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 27036 | if (!_children) { |
| 27037 | p->error_indicator = 1; |
| 27038 | PyErr_NoMemory(); |
| 27039 | D(p->level--); |
| 27040 | return NULL; |
| 27041 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 27042 | Py_ssize_t _children_capacity = 1; |
| 27043 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27044 | { // (',' star_target) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27045 | if (p->error_indicator) { |
| 27046 | D(p->level--); |
| 27047 | return NULL; |
| 27048 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27049 | D(fprintf(stderr, "%*c> _loop0_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27050 | void *_tmp_176_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27051 | while ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27052 | (_tmp_176_var = _tmp_176_rule(p)) // ',' star_target |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27053 | ) |
| 27054 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27055 | _res = _tmp_176_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27056 | if (_n == _children_capacity) { |
| 27057 | _children_capacity *= 2; |
| 27058 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 27059 | if (!_new_children) { |
| 27060 | p->error_indicator = 1; |
| 27061 | PyErr_NoMemory(); |
| 27062 | D(p->level--); |
| 27063 | return NULL; |
| 27064 | } |
| 27065 | _children = _new_children; |
| 27066 | } |
| 27067 | _children[_n++] = _res; |
| 27068 | _mark = p->mark; |
| 27069 | } |
| 27070 | p->mark = _mark; |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 27071 | D(fprintf(stderr, "%*c%s _loop0_133[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27072 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27073 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 27074 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27075 | if (!_seq) { |
| 27076 | PyMem_Free(_children); |
| 27077 | p->error_indicator = 1; |
| 27078 | PyErr_NoMemory(); |
| 27079 | D(p->level--); |
| 27080 | return NULL; |
| 27081 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 27082 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27083 | PyMem_Free(_children); |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 27084 | _PyPegen_insert_memo(p, _start_mark, _loop0_133_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27085 | D(p->level--); |
| 27086 | return _seq; |
| 27087 | } |
| 27088 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27089 | // _loop0_135: ',' star_target |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27090 | static asdl_seq * |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 27091 | _loop0_135_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27092 | { |
| 27093 | D(p->level++); |
| 27094 | if (p->error_indicator) { |
| 27095 | D(p->level--); |
| 27096 | return NULL; |
| 27097 | } |
| 27098 | void *_res = NULL; |
| 27099 | int _mark = p->mark; |
| 27100 | int _start_mark = p->mark; |
| 27101 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 27102 | if (!_children) { |
| 27103 | p->error_indicator = 1; |
| 27104 | PyErr_NoMemory(); |
| 27105 | D(p->level--); |
| 27106 | return NULL; |
| 27107 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 27108 | Py_ssize_t _children_capacity = 1; |
| 27109 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27110 | { // ',' star_target |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27111 | if (p->error_indicator) { |
| 27112 | D(p->level--); |
| 27113 | return NULL; |
| 27114 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27115 | D(fprintf(stderr, "%*c> _loop0_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); |
| 27116 | Token * _literal; |
| 27117 | expr_ty elem; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27118 | while ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27119 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 27120 | && |
| 27121 | (elem = star_target_rule(p)) // star_target |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27122 | ) |
| 27123 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27124 | _res = elem; |
| 27125 | if (_res == NULL && PyErr_Occurred()) { |
| 27126 | p->error_indicator = 1; |
| 27127 | PyMem_Free(_children); |
| 27128 | D(p->level--); |
| 27129 | return NULL; |
| 27130 | } |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27131 | if (_n == _children_capacity) { |
| 27132 | _children_capacity *= 2; |
| 27133 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 27134 | if (!_new_children) { |
| 27135 | p->error_indicator = 1; |
| 27136 | PyErr_NoMemory(); |
| 27137 | D(p->level--); |
| 27138 | return NULL; |
| 27139 | } |
| 27140 | _children = _new_children; |
| 27141 | } |
| 27142 | _children[_n++] = _res; |
| 27143 | _mark = p->mark; |
| 27144 | } |
| 27145 | p->mark = _mark; |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 27146 | D(fprintf(stderr, "%*c%s _loop0_135[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27147 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27148 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 27149 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27150 | if (!_seq) { |
| 27151 | PyMem_Free(_children); |
| 27152 | p->error_indicator = 1; |
| 27153 | PyErr_NoMemory(); |
| 27154 | D(p->level--); |
| 27155 | return NULL; |
| 27156 | } |
Pablo Galindo | a5634c4 | 2020-09-16 19:42:00 +0100 | [diff] [blame] | 27157 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27158 | PyMem_Free(_children); |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 27159 | _PyPegen_insert_memo(p, _start_mark, _loop0_135_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27160 | D(p->level--); |
| 27161 | return _seq; |
| 27162 | } |
| 27163 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27164 | // _gather_134: star_target _loop0_135 |
| 27165 | static asdl_seq * |
| 27166 | _gather_134_rule(Parser *p) |
| 27167 | { |
| 27168 | D(p->level++); |
| 27169 | if (p->error_indicator) { |
| 27170 | D(p->level--); |
| 27171 | return NULL; |
| 27172 | } |
| 27173 | asdl_seq * _res = NULL; |
| 27174 | int _mark = p->mark; |
| 27175 | { // star_target _loop0_135 |
| 27176 | if (p->error_indicator) { |
| 27177 | D(p->level--); |
| 27178 | return NULL; |
| 27179 | } |
| 27180 | D(fprintf(stderr, "%*c> _gather_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_135")); |
| 27181 | expr_ty elem; |
| 27182 | asdl_seq * seq; |
| 27183 | if ( |
| 27184 | (elem = star_target_rule(p)) // star_target |
| 27185 | && |
| 27186 | (seq = _loop0_135_rule(p)) // _loop0_135 |
| 27187 | ) |
| 27188 | { |
| 27189 | D(fprintf(stderr, "%*c+ _gather_134[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_135")); |
| 27190 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 27191 | goto done; |
| 27192 | } |
| 27193 | p->mark = _mark; |
| 27194 | D(fprintf(stderr, "%*c%s _gather_134[%d-%d]: %s failed!\n", p->level, ' ', |
| 27195 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_135")); |
| 27196 | } |
| 27197 | _res = NULL; |
| 27198 | done: |
| 27199 | D(p->level--); |
| 27200 | return _res; |
| 27201 | } |
| 27202 | |
| 27203 | // _loop1_136: (',' star_target) |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 27204 | static asdl_seq * |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 27205 | _loop1_136_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27206 | { |
| 27207 | D(p->level++); |
| 27208 | if (p->error_indicator) { |
| 27209 | D(p->level--); |
| 27210 | return NULL; |
| 27211 | } |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 27212 | void *_res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27213 | int _mark = p->mark; |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 27214 | int _start_mark = p->mark; |
| 27215 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 27216 | if (!_children) { |
| 27217 | p->error_indicator = 1; |
| 27218 | PyErr_NoMemory(); |
| 27219 | D(p->level--); |
| 27220 | return NULL; |
| 27221 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 27222 | Py_ssize_t _children_capacity = 1; |
| 27223 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27224 | { // (',' star_target) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27225 | if (p->error_indicator) { |
| 27226 | D(p->level--); |
| 27227 | return NULL; |
| 27228 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27229 | D(fprintf(stderr, "%*c> _loop1_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27230 | void *_tmp_177_var; |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 27231 | while ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27232 | (_tmp_177_var = _tmp_177_rule(p)) // ',' star_target |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27233 | ) |
| 27234 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27235 | _res = _tmp_177_var; |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 27236 | if (_n == _children_capacity) { |
| 27237 | _children_capacity *= 2; |
| 27238 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 27239 | if (!_new_children) { |
| 27240 | p->error_indicator = 1; |
| 27241 | PyErr_NoMemory(); |
| 27242 | D(p->level--); |
| 27243 | return NULL; |
| 27244 | } |
| 27245 | _children = _new_children; |
| 27246 | } |
| 27247 | _children[_n++] = _res; |
| 27248 | _mark = p->mark; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27249 | } |
| 27250 | p->mark = _mark; |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 27251 | D(fprintf(stderr, "%*c%s _loop1_136[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27252 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27253 | } |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 27254 | if (_n == 0 || p->error_indicator) { |
| 27255 | PyMem_Free(_children); |
| 27256 | D(p->level--); |
| 27257 | return NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27258 | } |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 27259 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 27260 | if (!_seq) { |
| 27261 | PyMem_Free(_children); |
| 27262 | p->error_indicator = 1; |
| 27263 | PyErr_NoMemory(); |
| 27264 | D(p->level--); |
| 27265 | return NULL; |
| 27266 | } |
| 27267 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 27268 | PyMem_Free(_children); |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 27269 | _PyPegen_insert_memo(p, _start_mark, _loop1_136_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27270 | D(p->level--); |
Lysandros Nikolaou | 07dcd86 | 2021-01-08 00:31:25 +0200 | [diff] [blame] | 27271 | return _seq; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27272 | } |
| 27273 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27274 | // _tmp_137: !'*' star_target |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27275 | static void * |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 27276 | _tmp_137_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27277 | { |
| 27278 | D(p->level++); |
| 27279 | if (p->error_indicator) { |
| 27280 | D(p->level--); |
| 27281 | return NULL; |
| 27282 | } |
| 27283 | void * _res = NULL; |
| 27284 | int _mark = p->mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27285 | { // !'*' star_target |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27286 | if (p->error_indicator) { |
| 27287 | D(p->level--); |
| 27288 | return NULL; |
| 27289 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27290 | D(fprintf(stderr, "%*c> _tmp_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); |
| 27291 | expr_ty star_target_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27292 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27293 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27294 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27295 | (star_target_var = star_target_rule(p)) // star_target |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27296 | ) |
| 27297 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27298 | D(fprintf(stderr, "%*c+ _tmp_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); |
| 27299 | _res = star_target_var; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27300 | goto done; |
| 27301 | } |
| 27302 | p->mark = _mark; |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 27303 | D(fprintf(stderr, "%*c%s _tmp_137[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27304 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27305 | } |
| 27306 | _res = NULL; |
| 27307 | done: |
| 27308 | D(p->level--); |
| 27309 | return _res; |
| 27310 | } |
| 27311 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27312 | // _loop0_139: ',' del_target |
| 27313 | static asdl_seq * |
| 27314 | _loop0_139_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27315 | { |
| 27316 | D(p->level++); |
| 27317 | if (p->error_indicator) { |
| 27318 | D(p->level--); |
| 27319 | return NULL; |
| 27320 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27321 | void *_res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27322 | int _mark = p->mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27323 | int _start_mark = p->mark; |
| 27324 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 27325 | if (!_children) { |
| 27326 | p->error_indicator = 1; |
| 27327 | PyErr_NoMemory(); |
| 27328 | D(p->level--); |
| 27329 | return NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27330 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 27331 | Py_ssize_t _children_capacity = 1; |
| 27332 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27333 | { // ',' del_target |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27334 | if (p->error_indicator) { |
| 27335 | D(p->level--); |
| 27336 | return NULL; |
| 27337 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27338 | D(fprintf(stderr, "%*c> _loop0_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27339 | Token * _literal; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27340 | expr_ty elem; |
| 27341 | while ( |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27342 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 27343 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27344 | (elem = del_target_rule(p)) // del_target |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27345 | ) |
| 27346 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27347 | _res = elem; |
| 27348 | if (_res == NULL && PyErr_Occurred()) { |
| 27349 | p->error_indicator = 1; |
| 27350 | PyMem_Free(_children); |
| 27351 | D(p->level--); |
| 27352 | return NULL; |
| 27353 | } |
| 27354 | if (_n == _children_capacity) { |
| 27355 | _children_capacity *= 2; |
| 27356 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 27357 | if (!_new_children) { |
| 27358 | p->error_indicator = 1; |
| 27359 | PyErr_NoMemory(); |
| 27360 | D(p->level--); |
| 27361 | return NULL; |
| 27362 | } |
| 27363 | _children = _new_children; |
| 27364 | } |
| 27365 | _children[_n++] = _res; |
| 27366 | _mark = p->mark; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27367 | } |
| 27368 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27369 | D(fprintf(stderr, "%*c%s _loop0_139[%d-%d]: %s failed!\n", p->level, ' ', |
| 27370 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27371 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27372 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 27373 | if (!_seq) { |
| 27374 | PyMem_Free(_children); |
| 27375 | p->error_indicator = 1; |
| 27376 | PyErr_NoMemory(); |
| 27377 | D(p->level--); |
| 27378 | return NULL; |
| 27379 | } |
| 27380 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 27381 | PyMem_Free(_children); |
| 27382 | _PyPegen_insert_memo(p, _start_mark, _loop0_139_type, _seq); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27383 | D(p->level--); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27384 | return _seq; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27385 | } |
| 27386 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27387 | // _gather_138: del_target _loop0_139 |
| 27388 | static asdl_seq * |
| 27389 | _gather_138_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27390 | { |
| 27391 | D(p->level++); |
| 27392 | if (p->error_indicator) { |
| 27393 | D(p->level--); |
| 27394 | return NULL; |
| 27395 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27396 | asdl_seq * _res = NULL; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 27397 | int _mark = p->mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27398 | { // del_target _loop0_139 |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27399 | if (p->error_indicator) { |
| 27400 | D(p->level--); |
| 27401 | return NULL; |
| 27402 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27403 | D(fprintf(stderr, "%*c> _gather_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_139")); |
| 27404 | expr_ty elem; |
| 27405 | asdl_seq * seq; |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27406 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27407 | (elem = del_target_rule(p)) // del_target |
| 27408 | && |
| 27409 | (seq = _loop0_139_rule(p)) // _loop0_139 |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27410 | ) |
| 27411 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27412 | D(fprintf(stderr, "%*c+ _gather_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_139")); |
| 27413 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27414 | goto done; |
| 27415 | } |
| 27416 | p->mark = _mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27417 | D(fprintf(stderr, "%*c%s _gather_138[%d-%d]: %s failed!\n", p->level, ' ', |
| 27418 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_139")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27419 | } |
| 27420 | _res = NULL; |
| 27421 | done: |
| 27422 | D(p->level--); |
| 27423 | return _res; |
| 27424 | } |
| 27425 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27426 | // _loop0_141: ',' target |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27427 | static asdl_seq * |
| 27428 | _loop0_141_rule(Parser *p) |
| 27429 | { |
| 27430 | D(p->level++); |
| 27431 | if (p->error_indicator) { |
| 27432 | D(p->level--); |
| 27433 | return NULL; |
| 27434 | } |
| 27435 | void *_res = NULL; |
| 27436 | int _mark = p->mark; |
| 27437 | int _start_mark = p->mark; |
| 27438 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 27439 | if (!_children) { |
| 27440 | p->error_indicator = 1; |
| 27441 | PyErr_NoMemory(); |
| 27442 | D(p->level--); |
| 27443 | return NULL; |
| 27444 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 27445 | Py_ssize_t _children_capacity = 1; |
| 27446 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27447 | { // ',' target |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27448 | if (p->error_indicator) { |
| 27449 | D(p->level--); |
| 27450 | return NULL; |
| 27451 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27452 | D(fprintf(stderr, "%*c> _loop0_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27453 | Token * _literal; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27454 | expr_ty elem; |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27455 | while ( |
| 27456 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 27457 | && |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27458 | (elem = target_rule(p)) // target |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27459 | ) |
| 27460 | { |
| 27461 | _res = elem; |
| 27462 | if (_res == NULL && PyErr_Occurred()) { |
| 27463 | p->error_indicator = 1; |
| 27464 | PyMem_Free(_children); |
| 27465 | D(p->level--); |
| 27466 | return NULL; |
| 27467 | } |
| 27468 | if (_n == _children_capacity) { |
| 27469 | _children_capacity *= 2; |
| 27470 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 27471 | if (!_new_children) { |
| 27472 | p->error_indicator = 1; |
| 27473 | PyErr_NoMemory(); |
| 27474 | D(p->level--); |
| 27475 | return NULL; |
| 27476 | } |
| 27477 | _children = _new_children; |
| 27478 | } |
| 27479 | _children[_n++] = _res; |
| 27480 | _mark = p->mark; |
| 27481 | } |
| 27482 | p->mark = _mark; |
| 27483 | D(fprintf(stderr, "%*c%s _loop0_141[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27484 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' target")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27485 | } |
| 27486 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 27487 | if (!_seq) { |
| 27488 | PyMem_Free(_children); |
| 27489 | p->error_indicator = 1; |
| 27490 | PyErr_NoMemory(); |
| 27491 | D(p->level--); |
| 27492 | return NULL; |
| 27493 | } |
| 27494 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 27495 | PyMem_Free(_children); |
| 27496 | _PyPegen_insert_memo(p, _start_mark, _loop0_141_type, _seq); |
| 27497 | D(p->level--); |
| 27498 | return _seq; |
| 27499 | } |
| 27500 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27501 | // _gather_140: target _loop0_141 |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27502 | static asdl_seq * |
| 27503 | _gather_140_rule(Parser *p) |
| 27504 | { |
| 27505 | D(p->level++); |
| 27506 | if (p->error_indicator) { |
| 27507 | D(p->level--); |
| 27508 | return NULL; |
| 27509 | } |
| 27510 | asdl_seq * _res = NULL; |
| 27511 | int _mark = p->mark; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27512 | { // target _loop0_141 |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27513 | if (p->error_indicator) { |
| 27514 | D(p->level--); |
| 27515 | return NULL; |
| 27516 | } |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27517 | D(fprintf(stderr, "%*c> _gather_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_141")); |
| 27518 | expr_ty elem; |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27519 | asdl_seq * seq; |
| 27520 | if ( |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27521 | (elem = target_rule(p)) // target |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27522 | && |
| 27523 | (seq = _loop0_141_rule(p)) // _loop0_141 |
| 27524 | ) |
| 27525 | { |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27526 | D(fprintf(stderr, "%*c+ _gather_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_141")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27527 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 27528 | goto done; |
| 27529 | } |
| 27530 | p->mark = _mark; |
| 27531 | D(fprintf(stderr, "%*c%s _gather_140[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27532 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_141")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27533 | } |
| 27534 | _res = NULL; |
| 27535 | done: |
| 27536 | D(p->level--); |
| 27537 | return _res; |
| 27538 | } |
| 27539 | |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27540 | // _tmp_142: args | expression for_if_clauses |
| 27541 | static void * |
| 27542 | _tmp_142_rule(Parser *p) |
| 27543 | { |
| 27544 | D(p->level++); |
| 27545 | if (p->error_indicator) { |
| 27546 | D(p->level--); |
| 27547 | return NULL; |
| 27548 | } |
| 27549 | void * _res = NULL; |
| 27550 | int _mark = p->mark; |
| 27551 | { // args |
| 27552 | if (p->error_indicator) { |
| 27553 | D(p->level--); |
| 27554 | return NULL; |
| 27555 | } |
| 27556 | D(fprintf(stderr, "%*c> _tmp_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); |
| 27557 | expr_ty args_var; |
| 27558 | if ( |
| 27559 | (args_var = args_rule(p)) // args |
| 27560 | ) |
| 27561 | { |
| 27562 | D(fprintf(stderr, "%*c+ _tmp_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); |
| 27563 | _res = args_var; |
| 27564 | goto done; |
| 27565 | } |
| 27566 | p->mark = _mark; |
| 27567 | D(fprintf(stderr, "%*c%s _tmp_142[%d-%d]: %s failed!\n", p->level, ' ', |
| 27568 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); |
| 27569 | } |
| 27570 | { // expression for_if_clauses |
| 27571 | if (p->error_indicator) { |
| 27572 | D(p->level--); |
| 27573 | return NULL; |
| 27574 | } |
| 27575 | D(fprintf(stderr, "%*c> _tmp_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); |
| 27576 | expr_ty expression_var; |
| 27577 | asdl_comprehension_seq* for_if_clauses_var; |
| 27578 | if ( |
| 27579 | (expression_var = expression_rule(p)) // expression |
| 27580 | && |
| 27581 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
| 27582 | ) |
| 27583 | { |
| 27584 | D(fprintf(stderr, "%*c+ _tmp_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); |
| 27585 | _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); |
| 27586 | goto done; |
| 27587 | } |
| 27588 | p->mark = _mark; |
| 27589 | D(fprintf(stderr, "%*c%s _tmp_142[%d-%d]: %s failed!\n", p->level, ' ', |
| 27590 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); |
| 27591 | } |
| 27592 | _res = NULL; |
| 27593 | done: |
| 27594 | D(p->level--); |
| 27595 | return _res; |
| 27596 | } |
| 27597 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27598 | // _tmp_143: '=' | ':=' | ',' |
| 27599 | static void * |
| 27600 | _tmp_143_rule(Parser *p) |
| 27601 | { |
| 27602 | D(p->level++); |
| 27603 | if (p->error_indicator) { |
| 27604 | D(p->level--); |
| 27605 | return NULL; |
| 27606 | } |
| 27607 | void * _res = NULL; |
| 27608 | int _mark = p->mark; |
| 27609 | { // '=' |
| 27610 | if (p->error_indicator) { |
| 27611 | D(p->level--); |
| 27612 | return NULL; |
| 27613 | } |
| 27614 | D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); |
| 27615 | Token * _literal; |
| 27616 | if ( |
| 27617 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 27618 | ) |
| 27619 | { |
| 27620 | D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); |
| 27621 | _res = _literal; |
| 27622 | goto done; |
| 27623 | } |
| 27624 | p->mark = _mark; |
| 27625 | D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ', |
| 27626 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); |
| 27627 | } |
| 27628 | { // ':=' |
| 27629 | if (p->error_indicator) { |
| 27630 | D(p->level--); |
| 27631 | return NULL; |
| 27632 | } |
| 27633 | D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':='")); |
| 27634 | Token * _literal; |
| 27635 | if ( |
| 27636 | (_literal = _PyPegen_expect_token(p, 53)) // token=':=' |
| 27637 | ) |
| 27638 | { |
| 27639 | D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':='")); |
| 27640 | _res = _literal; |
| 27641 | goto done; |
| 27642 | } |
| 27643 | p->mark = _mark; |
| 27644 | D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ', |
| 27645 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':='")); |
| 27646 | } |
| 27647 | { // ',' |
| 27648 | if (p->error_indicator) { |
| 27649 | D(p->level--); |
| 27650 | return NULL; |
| 27651 | } |
| 27652 | D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); |
| 27653 | Token * _literal; |
| 27654 | if ( |
| 27655 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 27656 | ) |
| 27657 | { |
| 27658 | D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); |
| 27659 | _res = _literal; |
| 27660 | goto done; |
| 27661 | } |
| 27662 | p->mark = _mark; |
| 27663 | D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ', |
| 27664 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); |
| 27665 | } |
| 27666 | _res = NULL; |
| 27667 | done: |
| 27668 | D(p->level--); |
| 27669 | return _res; |
| 27670 | } |
| 27671 | |
| 27672 | // _tmp_144: list | tuple | genexp | 'True' | 'None' | 'False' |
| 27673 | static void * |
| 27674 | _tmp_144_rule(Parser *p) |
| 27675 | { |
| 27676 | D(p->level++); |
| 27677 | if (p->error_indicator) { |
| 27678 | D(p->level--); |
| 27679 | return NULL; |
| 27680 | } |
| 27681 | void * _res = NULL; |
| 27682 | int _mark = p->mark; |
| 27683 | { // list |
| 27684 | if (p->error_indicator) { |
| 27685 | D(p->level--); |
| 27686 | return NULL; |
| 27687 | } |
| 27688 | D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); |
| 27689 | expr_ty list_var; |
| 27690 | if ( |
| 27691 | (list_var = list_rule(p)) // list |
| 27692 | ) |
| 27693 | { |
| 27694 | D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); |
| 27695 | _res = list_var; |
| 27696 | goto done; |
| 27697 | } |
| 27698 | p->mark = _mark; |
| 27699 | D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', |
| 27700 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); |
| 27701 | } |
| 27702 | { // tuple |
| 27703 | if (p->error_indicator) { |
| 27704 | D(p->level--); |
| 27705 | return NULL; |
| 27706 | } |
| 27707 | D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); |
| 27708 | expr_ty tuple_var; |
| 27709 | if ( |
| 27710 | (tuple_var = tuple_rule(p)) // tuple |
| 27711 | ) |
| 27712 | { |
| 27713 | D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); |
| 27714 | _res = tuple_var; |
| 27715 | goto done; |
| 27716 | } |
| 27717 | p->mark = _mark; |
| 27718 | D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', |
| 27719 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); |
| 27720 | } |
| 27721 | { // genexp |
| 27722 | if (p->error_indicator) { |
| 27723 | D(p->level--); |
| 27724 | return NULL; |
| 27725 | } |
| 27726 | D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); |
| 27727 | expr_ty genexp_var; |
| 27728 | if ( |
| 27729 | (genexp_var = genexp_rule(p)) // genexp |
| 27730 | ) |
| 27731 | { |
| 27732 | D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); |
| 27733 | _res = genexp_var; |
| 27734 | goto done; |
| 27735 | } |
| 27736 | p->mark = _mark; |
| 27737 | D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', |
| 27738 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); |
| 27739 | } |
| 27740 | { // 'True' |
| 27741 | if (p->error_indicator) { |
| 27742 | D(p->level--); |
| 27743 | return NULL; |
| 27744 | } |
| 27745 | D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); |
| 27746 | Token * _keyword; |
| 27747 | if ( |
| 27748 | (_keyword = _PyPegen_expect_token(p, 524)) // token='True' |
| 27749 | ) |
| 27750 | { |
| 27751 | D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); |
| 27752 | _res = _keyword; |
| 27753 | goto done; |
| 27754 | } |
| 27755 | p->mark = _mark; |
| 27756 | D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', |
| 27757 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); |
| 27758 | } |
| 27759 | { // 'None' |
| 27760 | if (p->error_indicator) { |
| 27761 | D(p->level--); |
| 27762 | return NULL; |
| 27763 | } |
| 27764 | D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); |
| 27765 | Token * _keyword; |
| 27766 | if ( |
| 27767 | (_keyword = _PyPegen_expect_token(p, 523)) // token='None' |
| 27768 | ) |
| 27769 | { |
| 27770 | D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); |
| 27771 | _res = _keyword; |
| 27772 | goto done; |
| 27773 | } |
| 27774 | p->mark = _mark; |
| 27775 | D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', |
| 27776 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); |
| 27777 | } |
| 27778 | { // 'False' |
| 27779 | if (p->error_indicator) { |
| 27780 | D(p->level--); |
| 27781 | return NULL; |
| 27782 | } |
| 27783 | D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); |
| 27784 | Token * _keyword; |
| 27785 | if ( |
| 27786 | (_keyword = _PyPegen_expect_token(p, 525)) // token='False' |
| 27787 | ) |
| 27788 | { |
| 27789 | D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); |
| 27790 | _res = _keyword; |
| 27791 | goto done; |
| 27792 | } |
| 27793 | p->mark = _mark; |
| 27794 | D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', |
| 27795 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); |
| 27796 | } |
| 27797 | _res = NULL; |
| 27798 | done: |
| 27799 | D(p->level--); |
| 27800 | return _res; |
| 27801 | } |
| 27802 | |
| 27803 | // _tmp_145: '=' | ':=' | ',' |
| 27804 | static void * |
| 27805 | _tmp_145_rule(Parser *p) |
| 27806 | { |
| 27807 | D(p->level++); |
| 27808 | if (p->error_indicator) { |
| 27809 | D(p->level--); |
| 27810 | return NULL; |
| 27811 | } |
| 27812 | void * _res = NULL; |
| 27813 | int _mark = p->mark; |
| 27814 | { // '=' |
| 27815 | if (p->error_indicator) { |
| 27816 | D(p->level--); |
| 27817 | return NULL; |
| 27818 | } |
| 27819 | D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'='")); |
| 27820 | Token * _literal; |
| 27821 | if ( |
| 27822 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 27823 | ) |
| 27824 | { |
| 27825 | D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'='")); |
| 27826 | _res = _literal; |
| 27827 | goto done; |
| 27828 | } |
| 27829 | p->mark = _mark; |
| 27830 | D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', |
| 27831 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'='")); |
| 27832 | } |
| 27833 | { // ':=' |
| 27834 | if (p->error_indicator) { |
| 27835 | D(p->level--); |
| 27836 | return NULL; |
| 27837 | } |
| 27838 | D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':='")); |
| 27839 | Token * _literal; |
| 27840 | if ( |
| 27841 | (_literal = _PyPegen_expect_token(p, 53)) // token=':=' |
| 27842 | ) |
| 27843 | { |
| 27844 | D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':='")); |
| 27845 | _res = _literal; |
| 27846 | goto done; |
| 27847 | } |
| 27848 | p->mark = _mark; |
| 27849 | D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', |
| 27850 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':='")); |
| 27851 | } |
| 27852 | { // ',' |
| 27853 | if (p->error_indicator) { |
| 27854 | D(p->level--); |
| 27855 | return NULL; |
| 27856 | } |
| 27857 | D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); |
| 27858 | Token * _literal; |
| 27859 | if ( |
| 27860 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 27861 | ) |
| 27862 | { |
| 27863 | D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); |
| 27864 | _res = _literal; |
| 27865 | goto done; |
| 27866 | } |
| 27867 | p->mark = _mark; |
| 27868 | D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', |
| 27869 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); |
| 27870 | } |
| 27871 | _res = NULL; |
| 27872 | done: |
| 27873 | D(p->level--); |
| 27874 | return _res; |
| 27875 | } |
| 27876 | |
| 27877 | // _loop0_146: star_named_expressions |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27878 | static asdl_seq * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27879 | _loop0_146_rule(Parser *p) |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27880 | { |
| 27881 | D(p->level++); |
| 27882 | if (p->error_indicator) { |
| 27883 | D(p->level--); |
| 27884 | return NULL; |
| 27885 | } |
| 27886 | void *_res = NULL; |
| 27887 | int _mark = p->mark; |
| 27888 | int _start_mark = p->mark; |
| 27889 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 27890 | if (!_children) { |
| 27891 | p->error_indicator = 1; |
| 27892 | PyErr_NoMemory(); |
| 27893 | D(p->level--); |
| 27894 | return NULL; |
| 27895 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 27896 | Py_ssize_t _children_capacity = 1; |
| 27897 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27898 | { // star_named_expressions |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 27899 | if (p->error_indicator) { |
| 27900 | D(p->level--); |
| 27901 | return NULL; |
| 27902 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27903 | D(fprintf(stderr, "%*c> _loop0_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27904 | asdl_expr_seq* star_named_expressions_var; |
| 27905 | while ( |
| 27906 | (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions |
| 27907 | ) |
| 27908 | { |
| 27909 | _res = star_named_expressions_var; |
| 27910 | if (_n == _children_capacity) { |
| 27911 | _children_capacity *= 2; |
| 27912 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 27913 | if (!_new_children) { |
| 27914 | p->error_indicator = 1; |
| 27915 | PyErr_NoMemory(); |
| 27916 | D(p->level--); |
| 27917 | return NULL; |
| 27918 | } |
| 27919 | _children = _new_children; |
| 27920 | } |
| 27921 | _children[_n++] = _res; |
| 27922 | _mark = p->mark; |
| 27923 | } |
| 27924 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27925 | D(fprintf(stderr, "%*c%s _loop0_146[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27926 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); |
| 27927 | } |
| 27928 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 27929 | if (!_seq) { |
| 27930 | PyMem_Free(_children); |
| 27931 | p->error_indicator = 1; |
| 27932 | PyErr_NoMemory(); |
| 27933 | D(p->level--); |
| 27934 | return NULL; |
| 27935 | } |
| 27936 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 27937 | PyMem_Free(_children); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27938 | _PyPegen_insert_memo(p, _start_mark, _loop0_146_type, _seq); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27939 | D(p->level--); |
| 27940 | return _seq; |
| 27941 | } |
| 27942 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27943 | // _loop0_147: (star_targets '=') |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27944 | static asdl_seq * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27945 | _loop0_147_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27946 | { |
| 27947 | D(p->level++); |
| 27948 | if (p->error_indicator) { |
| 27949 | D(p->level--); |
| 27950 | return NULL; |
| 27951 | } |
| 27952 | void *_res = NULL; |
| 27953 | int _mark = p->mark; |
| 27954 | int _start_mark = p->mark; |
| 27955 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 27956 | if (!_children) { |
| 27957 | p->error_indicator = 1; |
| 27958 | PyErr_NoMemory(); |
| 27959 | D(p->level--); |
| 27960 | return NULL; |
| 27961 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 27962 | Py_ssize_t _children_capacity = 1; |
| 27963 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27964 | { // (star_targets '=') |
| 27965 | if (p->error_indicator) { |
| 27966 | D(p->level--); |
| 27967 | return NULL; |
| 27968 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27969 | D(fprintf(stderr, "%*c> _loop0_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); |
| 27970 | void *_tmp_178_var; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27971 | while ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27972 | (_tmp_178_var = _tmp_178_rule(p)) // star_targets '=' |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27973 | ) |
| 27974 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27975 | _res = _tmp_178_var; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27976 | if (_n == _children_capacity) { |
| 27977 | _children_capacity *= 2; |
| 27978 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 27979 | if (!_new_children) { |
| 27980 | p->error_indicator = 1; |
| 27981 | PyErr_NoMemory(); |
| 27982 | D(p->level--); |
| 27983 | return NULL; |
| 27984 | } |
| 27985 | _children = _new_children; |
| 27986 | } |
| 27987 | _children[_n++] = _res; |
| 27988 | _mark = p->mark; |
| 27989 | } |
| 27990 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 27991 | D(fprintf(stderr, "%*c%s _loop0_147[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 27992 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); |
| 27993 | } |
| 27994 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 27995 | if (!_seq) { |
| 27996 | PyMem_Free(_children); |
| 27997 | p->error_indicator = 1; |
| 27998 | PyErr_NoMemory(); |
| 27999 | D(p->level--); |
| 28000 | return NULL; |
| 28001 | } |
| 28002 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 28003 | PyMem_Free(_children); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28004 | _PyPegen_insert_memo(p, _start_mark, _loop0_147_type, _seq); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28005 | D(p->level--); |
| 28006 | return _seq; |
| 28007 | } |
| 28008 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28009 | // _loop0_148: (star_targets '=') |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28010 | static asdl_seq * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28011 | _loop0_148_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28012 | { |
| 28013 | D(p->level++); |
| 28014 | if (p->error_indicator) { |
| 28015 | D(p->level--); |
| 28016 | return NULL; |
| 28017 | } |
| 28018 | void *_res = NULL; |
| 28019 | int _mark = p->mark; |
| 28020 | int _start_mark = p->mark; |
| 28021 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 28022 | if (!_children) { |
| 28023 | p->error_indicator = 1; |
| 28024 | PyErr_NoMemory(); |
| 28025 | D(p->level--); |
| 28026 | return NULL; |
| 28027 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 28028 | Py_ssize_t _children_capacity = 1; |
| 28029 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28030 | { // (star_targets '=') |
| 28031 | if (p->error_indicator) { |
| 28032 | D(p->level--); |
| 28033 | return NULL; |
| 28034 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28035 | D(fprintf(stderr, "%*c> _loop0_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); |
| 28036 | void *_tmp_179_var; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28037 | while ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28038 | (_tmp_179_var = _tmp_179_rule(p)) // star_targets '=' |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28039 | ) |
| 28040 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28041 | _res = _tmp_179_var; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28042 | if (_n == _children_capacity) { |
| 28043 | _children_capacity *= 2; |
| 28044 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 28045 | if (!_new_children) { |
| 28046 | p->error_indicator = 1; |
| 28047 | PyErr_NoMemory(); |
| 28048 | D(p->level--); |
| 28049 | return NULL; |
| 28050 | } |
| 28051 | _children = _new_children; |
| 28052 | } |
| 28053 | _children[_n++] = _res; |
| 28054 | _mark = p->mark; |
| 28055 | } |
| 28056 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28057 | D(fprintf(stderr, "%*c%s _loop0_148[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28058 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); |
| 28059 | } |
| 28060 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 28061 | if (!_seq) { |
| 28062 | PyMem_Free(_children); |
| 28063 | p->error_indicator = 1; |
| 28064 | PyErr_NoMemory(); |
| 28065 | D(p->level--); |
| 28066 | return NULL; |
| 28067 | } |
| 28068 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 28069 | PyMem_Free(_children); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28070 | _PyPegen_insert_memo(p, _start_mark, _loop0_148_type, _seq); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28071 | D(p->level--); |
| 28072 | return _seq; |
| 28073 | } |
| 28074 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28075 | // _tmp_149: yield_expr | star_expressions |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28076 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28077 | _tmp_149_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28078 | { |
| 28079 | D(p->level++); |
| 28080 | if (p->error_indicator) { |
| 28081 | D(p->level--); |
| 28082 | return NULL; |
| 28083 | } |
| 28084 | void * _res = NULL; |
| 28085 | int _mark = p->mark; |
| 28086 | { // yield_expr |
| 28087 | if (p->error_indicator) { |
| 28088 | D(p->level--); |
| 28089 | return NULL; |
| 28090 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28091 | D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28092 | expr_ty yield_expr_var; |
| 28093 | if ( |
| 28094 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
| 28095 | ) |
| 28096 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28097 | D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28098 | _res = yield_expr_var; |
| 28099 | goto done; |
| 28100 | } |
| 28101 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28102 | D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28103 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); |
| 28104 | } |
| 28105 | { // star_expressions |
| 28106 | if (p->error_indicator) { |
| 28107 | D(p->level--); |
| 28108 | return NULL; |
| 28109 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28110 | D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28111 | expr_ty star_expressions_var; |
| 28112 | if ( |
| 28113 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
| 28114 | ) |
| 28115 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28116 | D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28117 | _res = star_expressions_var; |
| 28118 | goto done; |
| 28119 | } |
| 28120 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28121 | D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28122 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); |
| 28123 | } |
| 28124 | _res = NULL; |
| 28125 | done: |
| 28126 | D(p->level--); |
| 28127 | return _res; |
| 28128 | } |
| 28129 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28130 | // _tmp_150: '[' | '(' | '{' |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28131 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28132 | _tmp_150_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28133 | { |
| 28134 | D(p->level++); |
| 28135 | if (p->error_indicator) { |
| 28136 | D(p->level--); |
| 28137 | return NULL; |
| 28138 | } |
| 28139 | void * _res = NULL; |
| 28140 | int _mark = p->mark; |
| 28141 | { // '[' |
| 28142 | if (p->error_indicator) { |
| 28143 | D(p->level--); |
| 28144 | return NULL; |
| 28145 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28146 | D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28147 | Token * _literal; |
| 28148 | if ( |
| 28149 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 28150 | ) |
| 28151 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28152 | D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28153 | _res = _literal; |
| 28154 | goto done; |
| 28155 | } |
| 28156 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28157 | D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28158 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); |
| 28159 | } |
| 28160 | { // '(' |
| 28161 | if (p->error_indicator) { |
| 28162 | D(p->level--); |
| 28163 | return NULL; |
| 28164 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28165 | D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28166 | Token * _literal; |
| 28167 | if ( |
| 28168 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
| 28169 | ) |
| 28170 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28171 | D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28172 | _res = _literal; |
| 28173 | goto done; |
| 28174 | } |
| 28175 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28176 | D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28177 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); |
| 28178 | } |
| 28179 | { // '{' |
| 28180 | if (p->error_indicator) { |
| 28181 | D(p->level--); |
| 28182 | return NULL; |
| 28183 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28184 | D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28185 | Token * _literal; |
| 28186 | if ( |
| 28187 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
| 28188 | ) |
| 28189 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28190 | D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28191 | _res = _literal; |
| 28192 | goto done; |
| 28193 | } |
| 28194 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28195 | D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28196 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); |
| 28197 | } |
| 28198 | _res = NULL; |
| 28199 | done: |
| 28200 | D(p->level--); |
| 28201 | return _res; |
| 28202 | } |
| 28203 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28204 | // _tmp_151: '[' | '{' |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28205 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28206 | _tmp_151_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28207 | { |
| 28208 | D(p->level++); |
| 28209 | if (p->error_indicator) { |
| 28210 | D(p->level--); |
| 28211 | return NULL; |
| 28212 | } |
| 28213 | void * _res = NULL; |
| 28214 | int _mark = p->mark; |
| 28215 | { // '[' |
| 28216 | if (p->error_indicator) { |
| 28217 | D(p->level--); |
| 28218 | return NULL; |
| 28219 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28220 | D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28221 | Token * _literal; |
| 28222 | if ( |
| 28223 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
| 28224 | ) |
| 28225 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28226 | D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28227 | _res = _literal; |
| 28228 | goto done; |
| 28229 | } |
| 28230 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28231 | D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28232 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); |
| 28233 | } |
| 28234 | { // '{' |
| 28235 | if (p->error_indicator) { |
| 28236 | D(p->level--); |
| 28237 | return NULL; |
| 28238 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28239 | D(fprintf(stderr, "%*c> _tmp_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28240 | Token * _literal; |
| 28241 | if ( |
| 28242 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
| 28243 | ) |
| 28244 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28245 | D(fprintf(stderr, "%*c+ _tmp_151[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28246 | _res = _literal; |
| 28247 | goto done; |
| 28248 | } |
| 28249 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28250 | D(fprintf(stderr, "%*c%s _tmp_151[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28251 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); |
| 28252 | } |
| 28253 | _res = NULL; |
| 28254 | done: |
| 28255 | D(p->level--); |
| 28256 | return _res; |
| 28257 | } |
| 28258 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28259 | // _loop0_152: param_no_default |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28260 | static asdl_seq * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28261 | _loop0_152_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28262 | { |
| 28263 | D(p->level++); |
| 28264 | if (p->error_indicator) { |
| 28265 | D(p->level--); |
| 28266 | return NULL; |
| 28267 | } |
| 28268 | void *_res = NULL; |
| 28269 | int _mark = p->mark; |
| 28270 | int _start_mark = p->mark; |
| 28271 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 28272 | if (!_children) { |
| 28273 | p->error_indicator = 1; |
| 28274 | PyErr_NoMemory(); |
| 28275 | D(p->level--); |
| 28276 | return NULL; |
| 28277 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 28278 | Py_ssize_t _children_capacity = 1; |
| 28279 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28280 | { // param_no_default |
| 28281 | if (p->error_indicator) { |
| 28282 | D(p->level--); |
| 28283 | return NULL; |
| 28284 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28285 | D(fprintf(stderr, "%*c> _loop0_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28286 | arg_ty param_no_default_var; |
| 28287 | while ( |
| 28288 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
| 28289 | ) |
| 28290 | { |
| 28291 | _res = param_no_default_var; |
| 28292 | if (_n == _children_capacity) { |
| 28293 | _children_capacity *= 2; |
| 28294 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 28295 | if (!_new_children) { |
| 28296 | p->error_indicator = 1; |
| 28297 | PyErr_NoMemory(); |
| 28298 | D(p->level--); |
| 28299 | return NULL; |
| 28300 | } |
| 28301 | _children = _new_children; |
| 28302 | } |
| 28303 | _children[_n++] = _res; |
| 28304 | _mark = p->mark; |
| 28305 | } |
| 28306 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28307 | D(fprintf(stderr, "%*c%s _loop0_152[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28308 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); |
| 28309 | } |
| 28310 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 28311 | if (!_seq) { |
| 28312 | PyMem_Free(_children); |
| 28313 | p->error_indicator = 1; |
| 28314 | PyErr_NoMemory(); |
| 28315 | D(p->level--); |
| 28316 | return NULL; |
| 28317 | } |
| 28318 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 28319 | PyMem_Free(_children); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28320 | _PyPegen_insert_memo(p, _start_mark, _loop0_152_type, _seq); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28321 | D(p->level--); |
| 28322 | return _seq; |
| 28323 | } |
| 28324 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28325 | // _loop1_153: param_with_default |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28326 | static asdl_seq * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28327 | _loop1_153_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28328 | { |
| 28329 | D(p->level++); |
| 28330 | if (p->error_indicator) { |
| 28331 | D(p->level--); |
| 28332 | return NULL; |
| 28333 | } |
| 28334 | void *_res = NULL; |
| 28335 | int _mark = p->mark; |
| 28336 | int _start_mark = p->mark; |
| 28337 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 28338 | if (!_children) { |
| 28339 | p->error_indicator = 1; |
| 28340 | PyErr_NoMemory(); |
| 28341 | D(p->level--); |
| 28342 | return NULL; |
| 28343 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 28344 | Py_ssize_t _children_capacity = 1; |
| 28345 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28346 | { // param_with_default |
| 28347 | if (p->error_indicator) { |
| 28348 | D(p->level--); |
| 28349 | return NULL; |
| 28350 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28351 | D(fprintf(stderr, "%*c> _loop1_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28352 | NameDefaultPair* param_with_default_var; |
| 28353 | while ( |
| 28354 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
| 28355 | ) |
| 28356 | { |
| 28357 | _res = param_with_default_var; |
| 28358 | if (_n == _children_capacity) { |
| 28359 | _children_capacity *= 2; |
| 28360 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 28361 | if (!_new_children) { |
| 28362 | p->error_indicator = 1; |
| 28363 | PyErr_NoMemory(); |
| 28364 | D(p->level--); |
| 28365 | return NULL; |
| 28366 | } |
| 28367 | _children = _new_children; |
| 28368 | } |
| 28369 | _children[_n++] = _res; |
| 28370 | _mark = p->mark; |
| 28371 | } |
| 28372 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28373 | D(fprintf(stderr, "%*c%s _loop1_153[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28374 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); |
| 28375 | } |
| 28376 | if (_n == 0 || p->error_indicator) { |
| 28377 | PyMem_Free(_children); |
| 28378 | D(p->level--); |
| 28379 | return NULL; |
| 28380 | } |
| 28381 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 28382 | if (!_seq) { |
| 28383 | PyMem_Free(_children); |
| 28384 | p->error_indicator = 1; |
| 28385 | PyErr_NoMemory(); |
| 28386 | D(p->level--); |
| 28387 | return NULL; |
| 28388 | } |
| 28389 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 28390 | PyMem_Free(_children); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28391 | _PyPegen_insert_memo(p, _start_mark, _loop1_153_type, _seq); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28392 | D(p->level--); |
| 28393 | return _seq; |
| 28394 | } |
| 28395 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28396 | // _loop0_154: lambda_param_no_default |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28397 | static asdl_seq * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28398 | _loop0_154_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28399 | { |
| 28400 | D(p->level++); |
| 28401 | if (p->error_indicator) { |
| 28402 | D(p->level--); |
| 28403 | return NULL; |
| 28404 | } |
| 28405 | void *_res = NULL; |
| 28406 | int _mark = p->mark; |
| 28407 | int _start_mark = p->mark; |
| 28408 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 28409 | if (!_children) { |
| 28410 | p->error_indicator = 1; |
| 28411 | PyErr_NoMemory(); |
| 28412 | D(p->level--); |
| 28413 | return NULL; |
| 28414 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 28415 | Py_ssize_t _children_capacity = 1; |
| 28416 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28417 | { // lambda_param_no_default |
| 28418 | if (p->error_indicator) { |
| 28419 | D(p->level--); |
| 28420 | return NULL; |
| 28421 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28422 | D(fprintf(stderr, "%*c> _loop0_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28423 | arg_ty lambda_param_no_default_var; |
| 28424 | while ( |
| 28425 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
| 28426 | ) |
| 28427 | { |
| 28428 | _res = lambda_param_no_default_var; |
| 28429 | if (_n == _children_capacity) { |
| 28430 | _children_capacity *= 2; |
| 28431 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 28432 | if (!_new_children) { |
| 28433 | p->error_indicator = 1; |
| 28434 | PyErr_NoMemory(); |
| 28435 | D(p->level--); |
| 28436 | return NULL; |
| 28437 | } |
| 28438 | _children = _new_children; |
| 28439 | } |
| 28440 | _children[_n++] = _res; |
| 28441 | _mark = p->mark; |
| 28442 | } |
| 28443 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28444 | D(fprintf(stderr, "%*c%s _loop0_154[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28445 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); |
| 28446 | } |
| 28447 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 28448 | if (!_seq) { |
| 28449 | PyMem_Free(_children); |
| 28450 | p->error_indicator = 1; |
| 28451 | PyErr_NoMemory(); |
| 28452 | D(p->level--); |
| 28453 | return NULL; |
| 28454 | } |
| 28455 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 28456 | PyMem_Free(_children); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28457 | _PyPegen_insert_memo(p, _start_mark, _loop0_154_type, _seq); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28458 | D(p->level--); |
| 28459 | return _seq; |
| 28460 | } |
| 28461 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28462 | // _loop1_155: lambda_param_with_default |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28463 | static asdl_seq * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28464 | _loop1_155_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28465 | { |
| 28466 | D(p->level++); |
| 28467 | if (p->error_indicator) { |
| 28468 | D(p->level--); |
| 28469 | return NULL; |
| 28470 | } |
| 28471 | void *_res = NULL; |
| 28472 | int _mark = p->mark; |
| 28473 | int _start_mark = p->mark; |
| 28474 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 28475 | if (!_children) { |
| 28476 | p->error_indicator = 1; |
| 28477 | PyErr_NoMemory(); |
| 28478 | D(p->level--); |
| 28479 | return NULL; |
| 28480 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 28481 | Py_ssize_t _children_capacity = 1; |
| 28482 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28483 | { // lambda_param_with_default |
| 28484 | if (p->error_indicator) { |
| 28485 | D(p->level--); |
| 28486 | return NULL; |
| 28487 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28488 | D(fprintf(stderr, "%*c> _loop1_155[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28489 | NameDefaultPair* lambda_param_with_default_var; |
| 28490 | while ( |
| 28491 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
| 28492 | ) |
| 28493 | { |
| 28494 | _res = lambda_param_with_default_var; |
| 28495 | if (_n == _children_capacity) { |
| 28496 | _children_capacity *= 2; |
| 28497 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 28498 | if (!_new_children) { |
| 28499 | p->error_indicator = 1; |
| 28500 | PyErr_NoMemory(); |
| 28501 | D(p->level--); |
| 28502 | return NULL; |
| 28503 | } |
| 28504 | _children = _new_children; |
| 28505 | } |
| 28506 | _children[_n++] = _res; |
| 28507 | _mark = p->mark; |
| 28508 | } |
| 28509 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28510 | D(fprintf(stderr, "%*c%s _loop1_155[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28511 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); |
| 28512 | } |
| 28513 | if (_n == 0 || p->error_indicator) { |
| 28514 | PyMem_Free(_children); |
| 28515 | D(p->level--); |
| 28516 | return NULL; |
| 28517 | } |
| 28518 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 28519 | if (!_seq) { |
| 28520 | PyMem_Free(_children); |
| 28521 | p->error_indicator = 1; |
| 28522 | PyErr_NoMemory(); |
| 28523 | D(p->level--); |
| 28524 | return NULL; |
| 28525 | } |
| 28526 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 28527 | PyMem_Free(_children); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28528 | _PyPegen_insert_memo(p, _start_mark, _loop1_155_type, _seq); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28529 | D(p->level--); |
| 28530 | return _seq; |
| 28531 | } |
| 28532 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28533 | // _tmp_156: ')' | ',' (')' | '**') |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28534 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28535 | _tmp_156_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28536 | { |
| 28537 | D(p->level++); |
| 28538 | if (p->error_indicator) { |
| 28539 | D(p->level--); |
| 28540 | return NULL; |
| 28541 | } |
| 28542 | void * _res = NULL; |
| 28543 | int _mark = p->mark; |
| 28544 | { // ')' |
| 28545 | if (p->error_indicator) { |
| 28546 | D(p->level--); |
| 28547 | return NULL; |
| 28548 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28549 | D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28550 | Token * _literal; |
| 28551 | if ( |
| 28552 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
| 28553 | ) |
| 28554 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28555 | D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28556 | _res = _literal; |
| 28557 | goto done; |
| 28558 | } |
| 28559 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28560 | D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28561 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); |
| 28562 | } |
| 28563 | { // ',' (')' | '**') |
| 28564 | if (p->error_indicator) { |
| 28565 | D(p->level--); |
| 28566 | return NULL; |
| 28567 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28568 | D(fprintf(stderr, "%*c> _tmp_156[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28569 | Token * _literal; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28570 | void *_tmp_180_var; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28571 | if ( |
| 28572 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 28573 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28574 | (_tmp_180_var = _tmp_180_rule(p)) // ')' | '**' |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28575 | ) |
| 28576 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28577 | D(fprintf(stderr, "%*c+ _tmp_156[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); |
| 28578 | _res = _PyPegen_dummy_name(p, _literal, _tmp_180_var); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28579 | goto done; |
| 28580 | } |
| 28581 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28582 | D(fprintf(stderr, "%*c%s _tmp_156[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28583 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); |
| 28584 | } |
| 28585 | _res = NULL; |
| 28586 | done: |
| 28587 | D(p->level--); |
| 28588 | return _res; |
| 28589 | } |
| 28590 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28591 | // _tmp_157: ':' | ',' (':' | '**') |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28592 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28593 | _tmp_157_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28594 | { |
| 28595 | D(p->level++); |
| 28596 | if (p->error_indicator) { |
| 28597 | D(p->level--); |
| 28598 | return NULL; |
| 28599 | } |
| 28600 | void * _res = NULL; |
| 28601 | int _mark = p->mark; |
| 28602 | { // ':' |
| 28603 | if (p->error_indicator) { |
| 28604 | D(p->level--); |
| 28605 | return NULL; |
| 28606 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28607 | D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28608 | Token * _literal; |
| 28609 | if ( |
| 28610 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 28611 | ) |
| 28612 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28613 | D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28614 | _res = _literal; |
| 28615 | goto done; |
| 28616 | } |
| 28617 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28618 | D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28619 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); |
| 28620 | } |
| 28621 | { // ',' (':' | '**') |
| 28622 | if (p->error_indicator) { |
| 28623 | D(p->level--); |
| 28624 | return NULL; |
| 28625 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28626 | D(fprintf(stderr, "%*c> _tmp_157[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28627 | Token * _literal; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28628 | void *_tmp_181_var; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28629 | if ( |
| 28630 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 28631 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28632 | (_tmp_181_var = _tmp_181_rule(p)) // ':' | '**' |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28633 | ) |
| 28634 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28635 | D(fprintf(stderr, "%*c+ _tmp_157[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); |
| 28636 | _res = _PyPegen_dummy_name(p, _literal, _tmp_181_var); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28637 | goto done; |
| 28638 | } |
| 28639 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28640 | D(fprintf(stderr, "%*c%s _tmp_157[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28641 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); |
| 28642 | } |
| 28643 | _res = NULL; |
| 28644 | done: |
| 28645 | D(p->level--); |
| 28646 | return _res; |
| 28647 | } |
| 28648 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28649 | // _tmp_158: ',' | ')' | ':' |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28650 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28651 | _tmp_158_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28652 | { |
| 28653 | D(p->level++); |
| 28654 | if (p->error_indicator) { |
| 28655 | D(p->level--); |
| 28656 | return NULL; |
| 28657 | } |
| 28658 | void * _res = NULL; |
| 28659 | int _mark = p->mark; |
| 28660 | { // ',' |
| 28661 | if (p->error_indicator) { |
| 28662 | D(p->level--); |
| 28663 | return NULL; |
| 28664 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28665 | D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28666 | Token * _literal; |
| 28667 | if ( |
| 28668 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 28669 | ) |
| 28670 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28671 | D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28672 | _res = _literal; |
| 28673 | goto done; |
| 28674 | } |
| 28675 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28676 | D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28677 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); |
| 28678 | } |
| 28679 | { // ')' |
| 28680 | if (p->error_indicator) { |
| 28681 | D(p->level--); |
| 28682 | return NULL; |
| 28683 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28684 | D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28685 | Token * _literal; |
| 28686 | if ( |
| 28687 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
| 28688 | ) |
| 28689 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28690 | D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28691 | _res = _literal; |
| 28692 | goto done; |
| 28693 | } |
| 28694 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28695 | D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28696 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); |
| 28697 | } |
| 28698 | { // ':' |
| 28699 | if (p->error_indicator) { |
| 28700 | D(p->level--); |
| 28701 | return NULL; |
| 28702 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28703 | D(fprintf(stderr, "%*c> _tmp_158[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28704 | Token * _literal; |
| 28705 | if ( |
| 28706 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 28707 | ) |
| 28708 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28709 | D(fprintf(stderr, "%*c+ _tmp_158[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28710 | _res = _literal; |
| 28711 | goto done; |
| 28712 | } |
| 28713 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28714 | D(fprintf(stderr, "%*c%s _tmp_158[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28715 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); |
| 28716 | } |
| 28717 | _res = NULL; |
| 28718 | done: |
| 28719 | D(p->level--); |
| 28720 | return _res; |
| 28721 | } |
| 28722 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28723 | // _loop0_160: ',' (expression ['as' star_target]) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28724 | static asdl_seq * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28725 | _loop0_160_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28726 | { |
| 28727 | D(p->level++); |
| 28728 | if (p->error_indicator) { |
| 28729 | D(p->level--); |
| 28730 | return NULL; |
| 28731 | } |
| 28732 | void *_res = NULL; |
| 28733 | int _mark = p->mark; |
| 28734 | int _start_mark = p->mark; |
| 28735 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 28736 | if (!_children) { |
| 28737 | p->error_indicator = 1; |
| 28738 | PyErr_NoMemory(); |
| 28739 | D(p->level--); |
| 28740 | return NULL; |
| 28741 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 28742 | Py_ssize_t _children_capacity = 1; |
| 28743 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28744 | { // ',' (expression ['as' star_target]) |
| 28745 | if (p->error_indicator) { |
| 28746 | D(p->level--); |
| 28747 | return NULL; |
| 28748 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28749 | D(fprintf(stderr, "%*c> _loop0_160[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expression ['as' star_target])")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 28750 | Token * _literal; |
| 28751 | void *elem; |
| 28752 | while ( |
| 28753 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 28754 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28755 | (elem = _tmp_182_rule(p)) // expression ['as' star_target] |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 28756 | ) |
| 28757 | { |
| 28758 | _res = elem; |
| 28759 | if (_res == NULL && PyErr_Occurred()) { |
| 28760 | p->error_indicator = 1; |
| 28761 | PyMem_Free(_children); |
| 28762 | D(p->level--); |
| 28763 | return NULL; |
| 28764 | } |
| 28765 | if (_n == _children_capacity) { |
| 28766 | _children_capacity *= 2; |
| 28767 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 28768 | if (!_new_children) { |
| 28769 | p->error_indicator = 1; |
| 28770 | PyErr_NoMemory(); |
| 28771 | D(p->level--); |
| 28772 | return NULL; |
| 28773 | } |
| 28774 | _children = _new_children; |
| 28775 | } |
| 28776 | _children[_n++] = _res; |
| 28777 | _mark = p->mark; |
| 28778 | } |
| 28779 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28780 | D(fprintf(stderr, "%*c%s _loop0_160[%d-%d]: %s failed!\n", p->level, ' ', |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28781 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expression ['as' star_target])")); |
| 28782 | } |
| 28783 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 28784 | if (!_seq) { |
| 28785 | PyMem_Free(_children); |
| 28786 | p->error_indicator = 1; |
| 28787 | PyErr_NoMemory(); |
| 28788 | D(p->level--); |
| 28789 | return NULL; |
| 28790 | } |
| 28791 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 28792 | PyMem_Free(_children); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28793 | _PyPegen_insert_memo(p, _start_mark, _loop0_160_type, _seq); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28794 | D(p->level--); |
| 28795 | return _seq; |
| 28796 | } |
| 28797 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28798 | // _gather_159: (expression ['as' star_target]) _loop0_160 |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28799 | static asdl_seq * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28800 | _gather_159_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28801 | { |
| 28802 | D(p->level++); |
| 28803 | if (p->error_indicator) { |
| 28804 | D(p->level--); |
| 28805 | return NULL; |
| 28806 | } |
| 28807 | asdl_seq * _res = NULL; |
| 28808 | int _mark = p->mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28809 | { // (expression ['as' star_target]) _loop0_160 |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28810 | if (p->error_indicator) { |
| 28811 | D(p->level--); |
| 28812 | return NULL; |
| 28813 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28814 | D(fprintf(stderr, "%*c> _gather_159[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_160")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28815 | void *elem; |
| 28816 | asdl_seq * seq; |
| 28817 | if ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28818 | (elem = _tmp_182_rule(p)) // expression ['as' star_target] |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28819 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28820 | (seq = _loop0_160_rule(p)) // _loop0_160 |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28821 | ) |
| 28822 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28823 | D(fprintf(stderr, "%*c+ _gather_159[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expression ['as' star_target]) _loop0_160")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28824 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 28825 | goto done; |
| 28826 | } |
| 28827 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28828 | D(fprintf(stderr, "%*c%s _gather_159[%d-%d]: %s failed!\n", p->level, ' ', |
| 28829 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expression ['as' star_target]) _loop0_160")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28830 | } |
| 28831 | _res = NULL; |
| 28832 | done: |
| 28833 | D(p->level--); |
| 28834 | return _res; |
| 28835 | } |
| 28836 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28837 | // _loop0_162: ',' (expressions ['as' star_target]) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28838 | static asdl_seq * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28839 | _loop0_162_rule(Parser *p) |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28840 | { |
| 28841 | D(p->level++); |
| 28842 | if (p->error_indicator) { |
| 28843 | D(p->level--); |
| 28844 | return NULL; |
| 28845 | } |
| 28846 | void *_res = NULL; |
| 28847 | int _mark = p->mark; |
| 28848 | int _start_mark = p->mark; |
| 28849 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 28850 | if (!_children) { |
| 28851 | p->error_indicator = 1; |
| 28852 | PyErr_NoMemory(); |
| 28853 | D(p->level--); |
| 28854 | return NULL; |
| 28855 | } |
Jozef Grajciar | c994ffe | 2021-03-01 12:18:33 +0100 | [diff] [blame] | 28856 | Py_ssize_t _children_capacity = 1; |
| 28857 | Py_ssize_t _n = 0; |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28858 | { // ',' (expressions ['as' star_target]) |
| 28859 | if (p->error_indicator) { |
| 28860 | D(p->level--); |
| 28861 | return NULL; |
| 28862 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28863 | D(fprintf(stderr, "%*c> _loop0_162[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (expressions ['as' star_target])")); |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28864 | Token * _literal; |
| 28865 | void *elem; |
| 28866 | while ( |
| 28867 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 28868 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28869 | (elem = _tmp_183_rule(p)) // expressions ['as' star_target] |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 28870 | ) |
| 28871 | { |
| 28872 | _res = elem; |
| 28873 | if (_res == NULL && PyErr_Occurred()) { |
| 28874 | p->error_indicator = 1; |
| 28875 | PyMem_Free(_children); |
| 28876 | D(p->level--); |
| 28877 | return NULL; |
| 28878 | } |
| 28879 | if (_n == _children_capacity) { |
| 28880 | _children_capacity *= 2; |
| 28881 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 28882 | if (!_new_children) { |
| 28883 | p->error_indicator = 1; |
| 28884 | PyErr_NoMemory(); |
| 28885 | D(p->level--); |
| 28886 | return NULL; |
| 28887 | } |
| 28888 | _children = _new_children; |
| 28889 | } |
| 28890 | _children[_n++] = _res; |
| 28891 | _mark = p->mark; |
| 28892 | } |
| 28893 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28894 | D(fprintf(stderr, "%*c%s _loop0_162[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 28895 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (expressions ['as' star_target])")); |
| 28896 | } |
| 28897 | asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena); |
| 28898 | if (!_seq) { |
| 28899 | PyMem_Free(_children); |
| 28900 | p->error_indicator = 1; |
| 28901 | PyErr_NoMemory(); |
| 28902 | D(p->level--); |
| 28903 | return NULL; |
| 28904 | } |
| 28905 | for (int i = 0; i < _n; i++) asdl_seq_SET_UNTYPED(_seq, i, _children[i]); |
| 28906 | PyMem_Free(_children); |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28907 | _PyPegen_insert_memo(p, _start_mark, _loop0_162_type, _seq); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 28908 | D(p->level--); |
| 28909 | return _seq; |
| 28910 | } |
| 28911 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28912 | // _gather_161: (expressions ['as' star_target]) _loop0_162 |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 28913 | static asdl_seq * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28914 | _gather_161_rule(Parser *p) |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 28915 | { |
| 28916 | D(p->level++); |
| 28917 | if (p->error_indicator) { |
| 28918 | D(p->level--); |
| 28919 | return NULL; |
| 28920 | } |
| 28921 | asdl_seq * _res = NULL; |
| 28922 | int _mark = p->mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28923 | { // (expressions ['as' star_target]) _loop0_162 |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 28924 | if (p->error_indicator) { |
| 28925 | D(p->level--); |
| 28926 | return NULL; |
| 28927 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28928 | D(fprintf(stderr, "%*c> _gather_161[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_162")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 28929 | void *elem; |
| 28930 | asdl_seq * seq; |
| 28931 | if ( |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28932 | (elem = _tmp_183_rule(p)) // expressions ['as' star_target] |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 28933 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28934 | (seq = _loop0_162_rule(p)) // _loop0_162 |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 28935 | ) |
| 28936 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28937 | D(fprintf(stderr, "%*c+ _gather_161[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(expressions ['as' star_target]) _loop0_162")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 28938 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 28939 | goto done; |
| 28940 | } |
| 28941 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28942 | D(fprintf(stderr, "%*c%s _gather_161[%d-%d]: %s failed!\n", p->level, ' ', |
| 28943 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(expressions ['as' star_target]) _loop0_162")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 28944 | } |
| 28945 | _res = NULL; |
| 28946 | done: |
| 28947 | D(p->level--); |
| 28948 | return _res; |
| 28949 | } |
| 28950 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28951 | // _tmp_163: 'as' NAME |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 28952 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28953 | _tmp_163_rule(Parser *p) |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 28954 | { |
| 28955 | D(p->level++); |
| 28956 | if (p->error_indicator) { |
| 28957 | D(p->level--); |
| 28958 | return NULL; |
| 28959 | } |
| 28960 | void * _res = NULL; |
| 28961 | int _mark = p->mark; |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 28962 | { // 'as' NAME |
| 28963 | if (p->error_indicator) { |
| 28964 | D(p->level--); |
| 28965 | return NULL; |
| 28966 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28967 | D(fprintf(stderr, "%*c> _tmp_163[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 28968 | Token * _keyword; |
| 28969 | expr_ty name_var; |
| 28970 | if ( |
| 28971 | (_keyword = _PyPegen_expect_token(p, 520)) // token='as' |
| 28972 | && |
| 28973 | (name_var = _PyPegen_name_token(p)) // NAME |
| 28974 | ) |
| 28975 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28976 | D(fprintf(stderr, "%*c+ _tmp_163[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 28977 | _res = _PyPegen_dummy_name(p, _keyword, name_var); |
| 28978 | goto done; |
| 28979 | } |
| 28980 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28981 | D(fprintf(stderr, "%*c%s _tmp_163[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 28982 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); |
| 28983 | } |
| 28984 | _res = NULL; |
| 28985 | done: |
| 28986 | D(p->level--); |
| 28987 | return _res; |
| 28988 | } |
| 28989 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28990 | // _tmp_164: 'as' NAME |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 28991 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 28992 | _tmp_164_rule(Parser *p) |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 28993 | { |
| 28994 | D(p->level++); |
| 28995 | if (p->error_indicator) { |
| 28996 | D(p->level--); |
| 28997 | return NULL; |
| 28998 | } |
| 28999 | void * _res = NULL; |
| 29000 | int _mark = p->mark; |
| 29001 | { // 'as' NAME |
| 29002 | if (p->error_indicator) { |
| 29003 | D(p->level--); |
| 29004 | return NULL; |
| 29005 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29006 | D(fprintf(stderr, "%*c> _tmp_164[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29007 | Token * _keyword; |
| 29008 | expr_ty name_var; |
| 29009 | if ( |
| 29010 | (_keyword = _PyPegen_expect_token(p, 520)) // token='as' |
| 29011 | && |
| 29012 | (name_var = _PyPegen_name_token(p)) // NAME |
| 29013 | ) |
| 29014 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29015 | D(fprintf(stderr, "%*c+ _tmp_164[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29016 | _res = _PyPegen_dummy_name(p, _keyword, name_var); |
| 29017 | goto done; |
| 29018 | } |
| 29019 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29020 | D(fprintf(stderr, "%*c%s _tmp_164[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29021 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); |
| 29022 | } |
| 29023 | _res = NULL; |
| 29024 | done: |
| 29025 | D(p->level--); |
| 29026 | return _res; |
| 29027 | } |
| 29028 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29029 | // _tmp_165: star_targets '=' |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29030 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29031 | _tmp_165_rule(Parser *p) |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29032 | { |
| 29033 | D(p->level++); |
| 29034 | if (p->error_indicator) { |
| 29035 | D(p->level--); |
| 29036 | return NULL; |
| 29037 | } |
| 29038 | void * _res = NULL; |
| 29039 | int _mark = p->mark; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29040 | { // star_targets '=' |
| 29041 | if (p->error_indicator) { |
| 29042 | D(p->level--); |
| 29043 | return NULL; |
| 29044 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29045 | D(fprintf(stderr, "%*c> _tmp_165[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29046 | Token * _literal; |
| 29047 | expr_ty z; |
| 29048 | if ( |
| 29049 | (z = star_targets_rule(p)) // star_targets |
| 29050 | && |
| 29051 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 29052 | ) |
| 29053 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29054 | D(fprintf(stderr, "%*c+ _tmp_165[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29055 | _res = z; |
| 29056 | if (_res == NULL && PyErr_Occurred()) { |
| 29057 | p->error_indicator = 1; |
| 29058 | D(p->level--); |
| 29059 | return NULL; |
| 29060 | } |
| 29061 | goto done; |
| 29062 | } |
| 29063 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29064 | D(fprintf(stderr, "%*c%s _tmp_165[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29065 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); |
| 29066 | } |
| 29067 | _res = NULL; |
| 29068 | done: |
| 29069 | D(p->level--); |
| 29070 | return _res; |
| 29071 | } |
| 29072 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29073 | // _tmp_166: '.' | '...' |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29074 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29075 | _tmp_166_rule(Parser *p) |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29076 | { |
| 29077 | D(p->level++); |
| 29078 | if (p->error_indicator) { |
| 29079 | D(p->level--); |
| 29080 | return NULL; |
| 29081 | } |
| 29082 | void * _res = NULL; |
| 29083 | int _mark = p->mark; |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29084 | { // '.' |
| 29085 | if (p->error_indicator) { |
| 29086 | D(p->level--); |
| 29087 | return NULL; |
| 29088 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29089 | D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29090 | Token * _literal; |
| 29091 | if ( |
| 29092 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 29093 | ) |
| 29094 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29095 | D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29096 | _res = _literal; |
| 29097 | goto done; |
| 29098 | } |
| 29099 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29100 | D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29101 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); |
| 29102 | } |
| 29103 | { // '...' |
| 29104 | if (p->error_indicator) { |
| 29105 | D(p->level--); |
| 29106 | return NULL; |
| 29107 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29108 | D(fprintf(stderr, "%*c> _tmp_166[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29109 | Token * _literal; |
| 29110 | if ( |
| 29111 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
| 29112 | ) |
| 29113 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29114 | D(fprintf(stderr, "%*c+ _tmp_166[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29115 | _res = _literal; |
| 29116 | goto done; |
| 29117 | } |
| 29118 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29119 | D(fprintf(stderr, "%*c%s _tmp_166[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29120 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); |
| 29121 | } |
| 29122 | _res = NULL; |
| 29123 | done: |
| 29124 | D(p->level--); |
| 29125 | return _res; |
| 29126 | } |
| 29127 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29128 | // _tmp_167: '.' | '...' |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29129 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29130 | _tmp_167_rule(Parser *p) |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29131 | { |
| 29132 | D(p->level++); |
| 29133 | if (p->error_indicator) { |
| 29134 | D(p->level--); |
| 29135 | return NULL; |
| 29136 | } |
| 29137 | void * _res = NULL; |
| 29138 | int _mark = p->mark; |
| 29139 | { // '.' |
| 29140 | if (p->error_indicator) { |
| 29141 | D(p->level--); |
| 29142 | return NULL; |
| 29143 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29144 | D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29145 | Token * _literal; |
| 29146 | if ( |
| 29147 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 29148 | ) |
| 29149 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29150 | D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29151 | _res = _literal; |
| 29152 | goto done; |
| 29153 | } |
| 29154 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29155 | D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29156 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); |
| 29157 | } |
| 29158 | { // '...' |
| 29159 | if (p->error_indicator) { |
| 29160 | D(p->level--); |
| 29161 | return NULL; |
| 29162 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29163 | D(fprintf(stderr, "%*c> _tmp_167[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29164 | Token * _literal; |
| 29165 | if ( |
| 29166 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
| 29167 | ) |
| 29168 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29169 | D(fprintf(stderr, "%*c+ _tmp_167[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29170 | _res = _literal; |
| 29171 | goto done; |
| 29172 | } |
| 29173 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29174 | D(fprintf(stderr, "%*c%s _tmp_167[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29175 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); |
| 29176 | } |
| 29177 | _res = NULL; |
| 29178 | done: |
| 29179 | D(p->level--); |
| 29180 | return _res; |
| 29181 | } |
| 29182 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29183 | // _tmp_168: '@' named_expression NEWLINE |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29184 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29185 | _tmp_168_rule(Parser *p) |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29186 | { |
| 29187 | D(p->level++); |
| 29188 | if (p->error_indicator) { |
| 29189 | D(p->level--); |
| 29190 | return NULL; |
| 29191 | } |
| 29192 | void * _res = NULL; |
| 29193 | int _mark = p->mark; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29194 | { // '@' named_expression NEWLINE |
| 29195 | if (p->error_indicator) { |
| 29196 | D(p->level--); |
| 29197 | return NULL; |
| 29198 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29199 | D(fprintf(stderr, "%*c> _tmp_168[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29200 | Token * _literal; |
| 29201 | expr_ty f; |
| 29202 | Token * newline_var; |
| 29203 | if ( |
| 29204 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
| 29205 | && |
| 29206 | (f = named_expression_rule(p)) // named_expression |
| 29207 | && |
| 29208 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 29209 | ) |
| 29210 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29211 | D(fprintf(stderr, "%*c+ _tmp_168[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29212 | _res = f; |
| 29213 | if (_res == NULL && PyErr_Occurred()) { |
| 29214 | p->error_indicator = 1; |
| 29215 | D(p->level--); |
| 29216 | return NULL; |
| 29217 | } |
| 29218 | goto done; |
| 29219 | } |
| 29220 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29221 | D(fprintf(stderr, "%*c%s _tmp_168[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29222 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); |
| 29223 | } |
| 29224 | _res = NULL; |
| 29225 | done: |
| 29226 | D(p->level--); |
| 29227 | return _res; |
| 29228 | } |
| 29229 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29230 | // _tmp_169: ',' star_expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29231 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29232 | _tmp_169_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29233 | { |
| 29234 | D(p->level++); |
| 29235 | if (p->error_indicator) { |
| 29236 | D(p->level--); |
| 29237 | return NULL; |
| 29238 | } |
| 29239 | void * _res = NULL; |
| 29240 | int _mark = p->mark; |
| 29241 | { // ',' star_expression |
| 29242 | if (p->error_indicator) { |
| 29243 | D(p->level--); |
| 29244 | return NULL; |
| 29245 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29246 | D(fprintf(stderr, "%*c> _tmp_169[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29247 | Token * _literal; |
| 29248 | expr_ty c; |
| 29249 | if ( |
| 29250 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 29251 | && |
| 29252 | (c = star_expression_rule(p)) // star_expression |
| 29253 | ) |
| 29254 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29255 | D(fprintf(stderr, "%*c+ _tmp_169[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29256 | _res = c; |
| 29257 | if (_res == NULL && PyErr_Occurred()) { |
| 29258 | p->error_indicator = 1; |
| 29259 | D(p->level--); |
| 29260 | return NULL; |
| 29261 | } |
| 29262 | goto done; |
| 29263 | } |
| 29264 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29265 | D(fprintf(stderr, "%*c%s _tmp_169[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29266 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); |
| 29267 | } |
| 29268 | _res = NULL; |
| 29269 | done: |
| 29270 | D(p->level--); |
| 29271 | return _res; |
| 29272 | } |
| 29273 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29274 | // _tmp_170: ',' expression |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29275 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29276 | _tmp_170_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29277 | { |
| 29278 | D(p->level++); |
| 29279 | if (p->error_indicator) { |
| 29280 | D(p->level--); |
| 29281 | return NULL; |
| 29282 | } |
| 29283 | void * _res = NULL; |
| 29284 | int _mark = p->mark; |
| 29285 | { // ',' expression |
| 29286 | if (p->error_indicator) { |
| 29287 | D(p->level--); |
| 29288 | return NULL; |
| 29289 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29290 | D(fprintf(stderr, "%*c> _tmp_170[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29291 | Token * _literal; |
| 29292 | expr_ty c; |
| 29293 | if ( |
| 29294 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 29295 | && |
| 29296 | (c = expression_rule(p)) // expression |
| 29297 | ) |
| 29298 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29299 | D(fprintf(stderr, "%*c+ _tmp_170[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29300 | _res = c; |
| 29301 | if (_res == NULL && PyErr_Occurred()) { |
| 29302 | p->error_indicator = 1; |
| 29303 | D(p->level--); |
| 29304 | return NULL; |
| 29305 | } |
| 29306 | goto done; |
| 29307 | } |
| 29308 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29309 | D(fprintf(stderr, "%*c%s _tmp_170[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29310 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); |
| 29311 | } |
| 29312 | _res = NULL; |
| 29313 | done: |
| 29314 | D(p->level--); |
| 29315 | return _res; |
| 29316 | } |
| 29317 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29318 | // _tmp_171: 'or' conjunction |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29319 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29320 | _tmp_171_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29321 | { |
| 29322 | D(p->level++); |
| 29323 | if (p->error_indicator) { |
| 29324 | D(p->level--); |
| 29325 | return NULL; |
| 29326 | } |
| 29327 | void * _res = NULL; |
| 29328 | int _mark = p->mark; |
| 29329 | { // 'or' conjunction |
| 29330 | if (p->error_indicator) { |
| 29331 | D(p->level--); |
| 29332 | return NULL; |
| 29333 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29334 | D(fprintf(stderr, "%*c> _tmp_171[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29335 | Token * _keyword; |
| 29336 | expr_ty c; |
| 29337 | if ( |
| 29338 | (_keyword = _PyPegen_expect_token(p, 531)) // token='or' |
| 29339 | && |
| 29340 | (c = conjunction_rule(p)) // conjunction |
| 29341 | ) |
| 29342 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29343 | D(fprintf(stderr, "%*c+ _tmp_171[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29344 | _res = c; |
| 29345 | if (_res == NULL && PyErr_Occurred()) { |
| 29346 | p->error_indicator = 1; |
| 29347 | D(p->level--); |
| 29348 | return NULL; |
| 29349 | } |
| 29350 | goto done; |
| 29351 | } |
| 29352 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29353 | D(fprintf(stderr, "%*c%s _tmp_171[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29354 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); |
| 29355 | } |
| 29356 | _res = NULL; |
| 29357 | done: |
| 29358 | D(p->level--); |
| 29359 | return _res; |
| 29360 | } |
| 29361 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29362 | // _tmp_172: 'and' inversion |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29363 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29364 | _tmp_172_rule(Parser *p) |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29365 | { |
| 29366 | D(p->level++); |
| 29367 | if (p->error_indicator) { |
| 29368 | D(p->level--); |
| 29369 | return NULL; |
| 29370 | } |
| 29371 | void * _res = NULL; |
| 29372 | int _mark = p->mark; |
| 29373 | { // 'and' inversion |
| 29374 | if (p->error_indicator) { |
| 29375 | D(p->level--); |
| 29376 | return NULL; |
| 29377 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29378 | D(fprintf(stderr, "%*c> _tmp_172[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29379 | Token * _keyword; |
| 29380 | expr_ty c; |
| 29381 | if ( |
| 29382 | (_keyword = _PyPegen_expect_token(p, 532)) // token='and' |
| 29383 | && |
| 29384 | (c = inversion_rule(p)) // inversion |
| 29385 | ) |
| 29386 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29387 | D(fprintf(stderr, "%*c+ _tmp_172[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29388 | _res = c; |
| 29389 | if (_res == NULL && PyErr_Occurred()) { |
| 29390 | p->error_indicator = 1; |
| 29391 | D(p->level--); |
| 29392 | return NULL; |
| 29393 | } |
| 29394 | goto done; |
| 29395 | } |
| 29396 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29397 | D(fprintf(stderr, "%*c%s _tmp_172[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29398 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); |
Pablo Galindo | b0aba1f | 2020-11-17 01:17:12 +0000 | [diff] [blame] | 29399 | } |
| 29400 | _res = NULL; |
| 29401 | done: |
| 29402 | D(p->level--); |
| 29403 | return _res; |
| 29404 | } |
| 29405 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29406 | // _tmp_173: 'if' disjunction |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29407 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29408 | _tmp_173_rule(Parser *p) |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29409 | { |
| 29410 | D(p->level++); |
| 29411 | if (p->error_indicator) { |
| 29412 | D(p->level--); |
| 29413 | return NULL; |
| 29414 | } |
| 29415 | void * _res = NULL; |
| 29416 | int _mark = p->mark; |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29417 | { // 'if' disjunction |
| 29418 | if (p->error_indicator) { |
| 29419 | D(p->level--); |
| 29420 | return NULL; |
| 29421 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29422 | D(fprintf(stderr, "%*c> _tmp_173[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29423 | Token * _keyword; |
| 29424 | expr_ty z; |
| 29425 | if ( |
| 29426 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
| 29427 | && |
| 29428 | (z = disjunction_rule(p)) // disjunction |
| 29429 | ) |
| 29430 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29431 | D(fprintf(stderr, "%*c+ _tmp_173[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29432 | _res = z; |
| 29433 | if (_res == NULL && PyErr_Occurred()) { |
| 29434 | p->error_indicator = 1; |
| 29435 | D(p->level--); |
| 29436 | return NULL; |
| 29437 | } |
| 29438 | goto done; |
| 29439 | } |
| 29440 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29441 | D(fprintf(stderr, "%*c%s _tmp_173[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29442 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); |
| 29443 | } |
| 29444 | _res = NULL; |
| 29445 | done: |
| 29446 | D(p->level--); |
| 29447 | return _res; |
| 29448 | } |
| 29449 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29450 | // _tmp_174: 'if' disjunction |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29451 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29452 | _tmp_174_rule(Parser *p) |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29453 | { |
| 29454 | D(p->level++); |
| 29455 | if (p->error_indicator) { |
| 29456 | D(p->level--); |
| 29457 | return NULL; |
| 29458 | } |
| 29459 | void * _res = NULL; |
| 29460 | int _mark = p->mark; |
| 29461 | { // 'if' disjunction |
| 29462 | if (p->error_indicator) { |
| 29463 | D(p->level--); |
| 29464 | return NULL; |
| 29465 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29466 | D(fprintf(stderr, "%*c> _tmp_174[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29467 | Token * _keyword; |
| 29468 | expr_ty z; |
| 29469 | if ( |
| 29470 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
| 29471 | && |
| 29472 | (z = disjunction_rule(p)) // disjunction |
| 29473 | ) |
| 29474 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29475 | D(fprintf(stderr, "%*c+ _tmp_174[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29476 | _res = z; |
| 29477 | if (_res == NULL && PyErr_Occurred()) { |
| 29478 | p->error_indicator = 1; |
| 29479 | D(p->level--); |
| 29480 | return NULL; |
| 29481 | } |
| 29482 | goto done; |
| 29483 | } |
| 29484 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29485 | D(fprintf(stderr, "%*c%s _tmp_174[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29486 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); |
| 29487 | } |
| 29488 | _res = NULL; |
| 29489 | done: |
| 29490 | D(p->level--); |
| 29491 | return _res; |
| 29492 | } |
| 29493 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29494 | // _tmp_175: starred_expression | named_expression !'=' |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29495 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29496 | _tmp_175_rule(Parser *p) |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29497 | { |
| 29498 | D(p->level++); |
| 29499 | if (p->error_indicator) { |
| 29500 | D(p->level--); |
| 29501 | return NULL; |
| 29502 | } |
| 29503 | void * _res = NULL; |
| 29504 | int _mark = p->mark; |
Pablo Galindo | 4a97b15 | 2020-09-02 17:44:19 +0100 | [diff] [blame] | 29505 | { // starred_expression |
| 29506 | if (p->error_indicator) { |
| 29507 | D(p->level--); |
| 29508 | return NULL; |
| 29509 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29510 | D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); |
Pablo Galindo | 4a97b15 | 2020-09-02 17:44:19 +0100 | [diff] [blame] | 29511 | expr_ty starred_expression_var; |
| 29512 | if ( |
| 29513 | (starred_expression_var = starred_expression_rule(p)) // starred_expression |
| 29514 | ) |
| 29515 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29516 | D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); |
Pablo Galindo | 4a97b15 | 2020-09-02 17:44:19 +0100 | [diff] [blame] | 29517 | _res = starred_expression_var; |
| 29518 | goto done; |
| 29519 | } |
| 29520 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29521 | D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 4a97b15 | 2020-09-02 17:44:19 +0100 | [diff] [blame] | 29522 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); |
| 29523 | } |
| 29524 | { // named_expression !'=' |
| 29525 | if (p->error_indicator) { |
| 29526 | D(p->level--); |
| 29527 | return NULL; |
| 29528 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29529 | D(fprintf(stderr, "%*c> _tmp_175[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression !'='")); |
Pablo Galindo | 4a97b15 | 2020-09-02 17:44:19 +0100 | [diff] [blame] | 29530 | expr_ty named_expression_var; |
| 29531 | if ( |
| 29532 | (named_expression_var = named_expression_rule(p)) // named_expression |
| 29533 | && |
| 29534 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' |
| 29535 | ) |
| 29536 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29537 | D(fprintf(stderr, "%*c+ _tmp_175[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression !'='")); |
Pablo Galindo | 4a97b15 | 2020-09-02 17:44:19 +0100 | [diff] [blame] | 29538 | _res = named_expression_var; |
| 29539 | goto done; |
| 29540 | } |
| 29541 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29542 | D(fprintf(stderr, "%*c%s _tmp_175[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29543 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression !'='")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29544 | } |
| 29545 | _res = NULL; |
| 29546 | done: |
| 29547 | D(p->level--); |
| 29548 | return _res; |
| 29549 | } |
| 29550 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29551 | // _tmp_176: ',' star_target |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29552 | static void * |
Brandt Bucher | 145bf26 | 2021-02-26 14:51:55 -0800 | [diff] [blame] | 29553 | _tmp_176_rule(Parser *p) |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29554 | { |
| 29555 | D(p->level++); |
| 29556 | if (p->error_indicator) { |
| 29557 | D(p->level--); |
| 29558 | return NULL; |
| 29559 | } |
| 29560 | void * _res = NULL; |
| 29561 | int _mark = p->mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29562 | { // ',' star_target |
| 29563 | if (p->error_indicator) { |
| 29564 | D(p->level--); |
| 29565 | return NULL; |
| 29566 | } |
| 29567 | D(fprintf(stderr, "%*c> _tmp_176[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); |
| 29568 | Token * _literal; |
| 29569 | expr_ty c; |
| 29570 | if ( |
| 29571 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 29572 | && |
| 29573 | (c = star_target_rule(p)) // star_target |
| 29574 | ) |
| 29575 | { |
| 29576 | D(fprintf(stderr, "%*c+ _tmp_176[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); |
| 29577 | _res = c; |
| 29578 | if (_res == NULL && PyErr_Occurred()) { |
| 29579 | p->error_indicator = 1; |
| 29580 | D(p->level--); |
| 29581 | return NULL; |
| 29582 | } |
| 29583 | goto done; |
| 29584 | } |
| 29585 | p->mark = _mark; |
| 29586 | D(fprintf(stderr, "%*c%s _tmp_176[%d-%d]: %s failed!\n", p->level, ' ', |
| 29587 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); |
| 29588 | } |
| 29589 | _res = NULL; |
| 29590 | done: |
| 29591 | D(p->level--); |
| 29592 | return _res; |
| 29593 | } |
| 29594 | |
| 29595 | // _tmp_177: ',' star_target |
| 29596 | static void * |
| 29597 | _tmp_177_rule(Parser *p) |
| 29598 | { |
| 29599 | D(p->level++); |
| 29600 | if (p->error_indicator) { |
| 29601 | D(p->level--); |
| 29602 | return NULL; |
| 29603 | } |
| 29604 | void * _res = NULL; |
| 29605 | int _mark = p->mark; |
| 29606 | { // ',' star_target |
| 29607 | if (p->error_indicator) { |
| 29608 | D(p->level--); |
| 29609 | return NULL; |
| 29610 | } |
| 29611 | D(fprintf(stderr, "%*c> _tmp_177[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); |
| 29612 | Token * _literal; |
| 29613 | expr_ty c; |
| 29614 | if ( |
| 29615 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 29616 | && |
| 29617 | (c = star_target_rule(p)) // star_target |
| 29618 | ) |
| 29619 | { |
| 29620 | D(fprintf(stderr, "%*c+ _tmp_177[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); |
| 29621 | _res = c; |
| 29622 | if (_res == NULL && PyErr_Occurred()) { |
| 29623 | p->error_indicator = 1; |
| 29624 | D(p->level--); |
| 29625 | return NULL; |
| 29626 | } |
| 29627 | goto done; |
| 29628 | } |
| 29629 | p->mark = _mark; |
| 29630 | D(fprintf(stderr, "%*c%s _tmp_177[%d-%d]: %s failed!\n", p->level, ' ', |
| 29631 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); |
| 29632 | } |
| 29633 | _res = NULL; |
| 29634 | done: |
| 29635 | D(p->level--); |
| 29636 | return _res; |
| 29637 | } |
| 29638 | |
| 29639 | // _tmp_178: star_targets '=' |
| 29640 | static void * |
| 29641 | _tmp_178_rule(Parser *p) |
| 29642 | { |
| 29643 | D(p->level++); |
| 29644 | if (p->error_indicator) { |
| 29645 | D(p->level--); |
| 29646 | return NULL; |
| 29647 | } |
| 29648 | void * _res = NULL; |
| 29649 | int _mark = p->mark; |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29650 | { // star_targets '=' |
| 29651 | if (p->error_indicator) { |
| 29652 | D(p->level--); |
| 29653 | return NULL; |
| 29654 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29655 | D(fprintf(stderr, "%*c> _tmp_178[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29656 | Token * _literal; |
| 29657 | expr_ty star_targets_var; |
| 29658 | if ( |
| 29659 | (star_targets_var = star_targets_rule(p)) // star_targets |
| 29660 | && |
| 29661 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 29662 | ) |
| 29663 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29664 | D(fprintf(stderr, "%*c+ _tmp_178[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29665 | _res = _PyPegen_dummy_name(p, star_targets_var, _literal); |
| 29666 | goto done; |
| 29667 | } |
| 29668 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29669 | D(fprintf(stderr, "%*c%s _tmp_178[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29670 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); |
| 29671 | } |
| 29672 | _res = NULL; |
| 29673 | done: |
| 29674 | D(p->level--); |
| 29675 | return _res; |
| 29676 | } |
| 29677 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29678 | // _tmp_179: star_targets '=' |
Pablo Galindo | 206cbda | 2021-02-07 18:42:21 +0000 | [diff] [blame] | 29679 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29680 | _tmp_179_rule(Parser *p) |
| 29681 | { |
| 29682 | D(p->level++); |
| 29683 | if (p->error_indicator) { |
| 29684 | D(p->level--); |
| 29685 | return NULL; |
| 29686 | } |
| 29687 | void * _res = NULL; |
| 29688 | int _mark = p->mark; |
| 29689 | { // star_targets '=' |
| 29690 | if (p->error_indicator) { |
| 29691 | D(p->level--); |
| 29692 | return NULL; |
| 29693 | } |
| 29694 | D(fprintf(stderr, "%*c> _tmp_179[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); |
| 29695 | Token * _literal; |
| 29696 | expr_ty star_targets_var; |
| 29697 | if ( |
| 29698 | (star_targets_var = star_targets_rule(p)) // star_targets |
| 29699 | && |
| 29700 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 29701 | ) |
| 29702 | { |
| 29703 | D(fprintf(stderr, "%*c+ _tmp_179[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); |
| 29704 | _res = _PyPegen_dummy_name(p, star_targets_var, _literal); |
| 29705 | goto done; |
| 29706 | } |
| 29707 | p->mark = _mark; |
| 29708 | D(fprintf(stderr, "%*c%s _tmp_179[%d-%d]: %s failed!\n", p->level, ' ', |
| 29709 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); |
| 29710 | } |
| 29711 | _res = NULL; |
| 29712 | done: |
| 29713 | D(p->level--); |
| 29714 | return _res; |
| 29715 | } |
| 29716 | |
| 29717 | // _tmp_180: ')' | '**' |
| 29718 | static void * |
| 29719 | _tmp_180_rule(Parser *p) |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29720 | { |
| 29721 | D(p->level++); |
| 29722 | if (p->error_indicator) { |
| 29723 | D(p->level--); |
| 29724 | return NULL; |
| 29725 | } |
| 29726 | void * _res = NULL; |
| 29727 | int _mark = p->mark; |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29728 | { // ')' |
| 29729 | if (p->error_indicator) { |
| 29730 | D(p->level--); |
| 29731 | return NULL; |
| 29732 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29733 | D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29734 | Token * _literal; |
| 29735 | if ( |
| 29736 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
| 29737 | ) |
| 29738 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29739 | D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29740 | _res = _literal; |
| 29741 | goto done; |
| 29742 | } |
| 29743 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29744 | D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29745 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29746 | } |
| 29747 | { // '**' |
| 29748 | if (p->error_indicator) { |
| 29749 | D(p->level--); |
| 29750 | return NULL; |
| 29751 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29752 | D(fprintf(stderr, "%*c> _tmp_180[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29753 | Token * _literal; |
| 29754 | if ( |
| 29755 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
| 29756 | ) |
| 29757 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29758 | D(fprintf(stderr, "%*c+ _tmp_180[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29759 | _res = _literal; |
| 29760 | goto done; |
| 29761 | } |
| 29762 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29763 | D(fprintf(stderr, "%*c%s _tmp_180[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29764 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); |
| 29765 | } |
| 29766 | _res = NULL; |
| 29767 | done: |
| 29768 | D(p->level--); |
| 29769 | return _res; |
| 29770 | } |
| 29771 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29772 | // _tmp_181: ':' | '**' |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29773 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29774 | _tmp_181_rule(Parser *p) |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29775 | { |
| 29776 | D(p->level++); |
| 29777 | if (p->error_indicator) { |
| 29778 | D(p->level--); |
| 29779 | return NULL; |
| 29780 | } |
| 29781 | void * _res = NULL; |
| 29782 | int _mark = p->mark; |
| 29783 | { // ':' |
| 29784 | if (p->error_indicator) { |
| 29785 | D(p->level--); |
| 29786 | return NULL; |
| 29787 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29788 | D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29789 | Token * _literal; |
| 29790 | if ( |
| 29791 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
| 29792 | ) |
| 29793 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29794 | D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29795 | _res = _literal; |
| 29796 | goto done; |
| 29797 | } |
| 29798 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29799 | D(fprintf(stderr, "%*c%s _tmp_181[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29800 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); |
| 29801 | } |
| 29802 | { // '**' |
| 29803 | if (p->error_indicator) { |
| 29804 | D(p->level--); |
| 29805 | return NULL; |
| 29806 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29807 | D(fprintf(stderr, "%*c> _tmp_181[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29808 | Token * _literal; |
| 29809 | if ( |
| 29810 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
| 29811 | ) |
| 29812 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29813 | D(fprintf(stderr, "%*c+ _tmp_181[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29814 | _res = _literal; |
| 29815 | goto done; |
| 29816 | } |
| 29817 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29818 | D(fprintf(stderr, "%*c%s _tmp_181[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 835f14f | 2021-01-31 22:52:56 +0000 | [diff] [blame] | 29819 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); |
| 29820 | } |
| 29821 | _res = NULL; |
| 29822 | done: |
| 29823 | D(p->level--); |
| 29824 | return _res; |
| 29825 | } |
| 29826 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29827 | // _tmp_182: expression ['as' star_target] |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29828 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29829 | _tmp_182_rule(Parser *p) |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29830 | { |
| 29831 | D(p->level++); |
| 29832 | if (p->error_indicator) { |
| 29833 | D(p->level--); |
| 29834 | return NULL; |
| 29835 | } |
| 29836 | void * _res = NULL; |
| 29837 | int _mark = p->mark; |
| 29838 | { // expression ['as' star_target] |
| 29839 | if (p->error_indicator) { |
| 29840 | D(p->level--); |
| 29841 | return NULL; |
| 29842 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29843 | D(fprintf(stderr, "%*c> _tmp_182[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29844 | void *_opt_var; |
| 29845 | UNUSED(_opt_var); // Silence compiler warnings |
| 29846 | expr_ty expression_var; |
| 29847 | if ( |
| 29848 | (expression_var = expression_rule(p)) // expression |
| 29849 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29850 | (_opt_var = _tmp_184_rule(p), 1) // ['as' star_target] |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29851 | ) |
| 29852 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29853 | D(fprintf(stderr, "%*c+ _tmp_182[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' star_target]")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29854 | _res = _PyPegen_dummy_name(p, expression_var, _opt_var); |
| 29855 | goto done; |
| 29856 | } |
| 29857 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29858 | D(fprintf(stderr, "%*c%s _tmp_182[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29859 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' star_target]")); |
| 29860 | } |
| 29861 | _res = NULL; |
| 29862 | done: |
| 29863 | D(p->level--); |
| 29864 | return _res; |
| 29865 | } |
| 29866 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29867 | // _tmp_183: expressions ['as' star_target] |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29868 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29869 | _tmp_183_rule(Parser *p) |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29870 | { |
| 29871 | D(p->level++); |
| 29872 | if (p->error_indicator) { |
| 29873 | D(p->level--); |
| 29874 | return NULL; |
| 29875 | } |
| 29876 | void * _res = NULL; |
| 29877 | int _mark = p->mark; |
| 29878 | { // expressions ['as' star_target] |
| 29879 | if (p->error_indicator) { |
| 29880 | D(p->level--); |
| 29881 | return NULL; |
| 29882 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29883 | D(fprintf(stderr, "%*c> _tmp_183[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29884 | void *_opt_var; |
| 29885 | UNUSED(_opt_var); // Silence compiler warnings |
| 29886 | expr_ty expressions_var; |
| 29887 | if ( |
| 29888 | (expressions_var = expressions_rule(p)) // expressions |
| 29889 | && |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29890 | (_opt_var = _tmp_185_rule(p), 1) // ['as' star_target] |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29891 | ) |
| 29892 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29893 | D(fprintf(stderr, "%*c+ _tmp_183[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions ['as' star_target]")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29894 | _res = _PyPegen_dummy_name(p, expressions_var, _opt_var); |
| 29895 | goto done; |
| 29896 | } |
| 29897 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29898 | D(fprintf(stderr, "%*c%s _tmp_183[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29899 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expressions ['as' star_target]")); |
| 29900 | } |
| 29901 | _res = NULL; |
| 29902 | done: |
| 29903 | D(p->level--); |
| 29904 | return _res; |
| 29905 | } |
| 29906 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29907 | // _tmp_184: 'as' star_target |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29908 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29909 | _tmp_184_rule(Parser *p) |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29910 | { |
| 29911 | D(p->level++); |
| 29912 | if (p->error_indicator) { |
| 29913 | D(p->level--); |
| 29914 | return NULL; |
| 29915 | } |
| 29916 | void * _res = NULL; |
| 29917 | int _mark = p->mark; |
| 29918 | { // 'as' star_target |
| 29919 | if (p->error_indicator) { |
| 29920 | D(p->level--); |
| 29921 | return NULL; |
| 29922 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29923 | D(fprintf(stderr, "%*c> _tmp_184[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29924 | Token * _keyword; |
| 29925 | expr_ty star_target_var; |
| 29926 | if ( |
| 29927 | (_keyword = _PyPegen_expect_token(p, 520)) // token='as' |
| 29928 | && |
| 29929 | (star_target_var = star_target_rule(p)) // star_target |
| 29930 | ) |
| 29931 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29932 | D(fprintf(stderr, "%*c+ _tmp_184[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29933 | _res = _PyPegen_dummy_name(p, _keyword, star_target_var); |
| 29934 | goto done; |
| 29935 | } |
| 29936 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29937 | D(fprintf(stderr, "%*c%s _tmp_184[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29938 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' star_target")); |
| 29939 | } |
| 29940 | _res = NULL; |
| 29941 | done: |
| 29942 | D(p->level--); |
| 29943 | return _res; |
| 29944 | } |
| 29945 | |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29946 | // _tmp_185: 'as' star_target |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29947 | static void * |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29948 | _tmp_185_rule(Parser *p) |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29949 | { |
| 29950 | D(p->level++); |
| 29951 | if (p->error_indicator) { |
| 29952 | D(p->level--); |
| 29953 | return NULL; |
| 29954 | } |
| 29955 | void * _res = NULL; |
| 29956 | int _mark = p->mark; |
| 29957 | { // 'as' star_target |
| 29958 | if (p->error_indicator) { |
| 29959 | D(p->level--); |
| 29960 | return NULL; |
| 29961 | } |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29962 | D(fprintf(stderr, "%*c> _tmp_185[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' star_target")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29963 | Token * _keyword; |
| 29964 | expr_ty star_target_var; |
| 29965 | if ( |
| 29966 | (_keyword = _PyPegen_expect_token(p, 520)) // token='as' |
| 29967 | && |
| 29968 | (star_target_var = star_target_rule(p)) // star_target |
| 29969 | ) |
| 29970 | { |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29971 | D(fprintf(stderr, "%*c+ _tmp_185[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' star_target")); |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29972 | _res = _PyPegen_dummy_name(p, _keyword, star_target_var); |
| 29973 | goto done; |
| 29974 | } |
| 29975 | p->mark = _mark; |
Pablo Galindo | b86ed8e | 2021-04-12 16:59:30 +0100 | [diff] [blame] | 29976 | D(fprintf(stderr, "%*c%s _tmp_185[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 58fb156 | 2021-02-02 19:54:22 +0000 | [diff] [blame] | 29977 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' star_target")); |
| 29978 | } |
| 29979 | _res = NULL; |
| 29980 | done: |
| 29981 | D(p->level--); |
| 29982 | return _res; |
| 29983 | } |
| 29984 | |
Pablo Galindo | 1ed83ad | 2020-06-11 17:30:46 +0100 | [diff] [blame] | 29985 | void * |
| 29986 | _PyPegen_parse(Parser *p) |
| 29987 | { |
| 29988 | // Initialize keywords |
| 29989 | p->keywords = reserved_keywords; |
| 29990 | p->n_keyword_lists = n_keyword_lists; |
| 29991 | |
| 29992 | // Run parser |
| 29993 | void *result = NULL; |
| 29994 | if (p->start_rule == Py_file_input) { |
| 29995 | result = file_rule(p); |
| 29996 | } else if (p->start_rule == Py_single_input) { |
| 29997 | result = interactive_rule(p); |
| 29998 | } else if (p->start_rule == Py_eval_input) { |
| 29999 | result = eval_rule(p); |
| 30000 | } else if (p->start_rule == Py_func_type_input) { |
| 30001 | result = func_type_rule(p); |
| 30002 | } else if (p->start_rule == Py_fstring_input) { |
| 30003 | result = fstring_rule(p); |
| 30004 | } |
| 30005 | |
| 30006 | return result; |
| 30007 | } |
| 30008 | |
| 30009 | // The end |