Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1 | // @generated by pegen.py from ./Grammar/python.gram |
| 2 | #include "pegen.h" |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3 | |
Pablo Galindo | deb4355 | 2020-05-25 20:17:12 +0100 | [diff] [blame] | 4 | #if defined(Py_DEBUG) && defined(Py_BUILD_CORE) |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5 | extern int Py_DebugFlag; |
| 6 | #define D(x) if (Py_DebugFlag) x; |
| 7 | #else |
| 8 | #define D(x) |
| 9 | #endif |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10 | static const int n_keyword_lists = 15; |
| 11 | static KeywordToken *reserved_keywords[] = { |
| 12 | NULL, |
| 13 | NULL, |
| 14 | (KeywordToken[]) { |
| 15 | {"if", 510}, |
| 16 | {"in", 518}, |
| 17 | {"is", 526}, |
| 18 | {"as", 531}, |
| 19 | {"or", 532}, |
| 20 | {NULL, -1}, |
| 21 | }, |
| 22 | (KeywordToken[]) { |
| 23 | {"del", 503}, |
| 24 | {"try", 511}, |
| 25 | {"for", 517}, |
| 26 | {"def", 522}, |
| 27 | {"not", 525}, |
| 28 | {"and", 533}, |
| 29 | {NULL, -1}, |
| 30 | }, |
| 31 | (KeywordToken[]) { |
| 32 | {"pass", 502}, |
| 33 | {"from", 514}, |
| 34 | {"elif", 515}, |
| 35 | {"else", 516}, |
| 36 | {"with", 519}, |
| 37 | {"True", 527}, |
| 38 | {"None", 529}, |
| 39 | {NULL, -1}, |
| 40 | }, |
| 41 | (KeywordToken[]) { |
| 42 | {"raise", 501}, |
| 43 | {"yield", 504}, |
| 44 | {"break", 506}, |
| 45 | {"while", 512}, |
| 46 | {"class", 523}, |
| 47 | {"False", 528}, |
| 48 | {NULL, -1}, |
| 49 | }, |
| 50 | (KeywordToken[]) { |
| 51 | {"return", 500}, |
| 52 | {"assert", 505}, |
| 53 | {"global", 508}, |
| 54 | {"import", 513}, |
| 55 | {"except", 520}, |
| 56 | {"lambda", 524}, |
| 57 | {NULL, -1}, |
| 58 | }, |
| 59 | (KeywordToken[]) { |
| 60 | {"finally", 521}, |
| 61 | {NULL, -1}, |
| 62 | }, |
| 63 | (KeywordToken[]) { |
| 64 | {"continue", 507}, |
| 65 | {"nonlocal", 509}, |
| 66 | {NULL, -1}, |
| 67 | }, |
| 68 | NULL, |
| 69 | NULL, |
| 70 | NULL, |
| 71 | NULL, |
| 72 | NULL, |
| 73 | (KeywordToken[]) { |
| 74 | {"__new_parser__", 530}, |
| 75 | {NULL, -1}, |
| 76 | }, |
| 77 | }; |
| 78 | #define file_type 1000 |
| 79 | #define interactive_type 1001 |
| 80 | #define eval_type 1002 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 81 | #define func_type_type 1003 |
| 82 | #define fstring_type 1004 |
| 83 | #define type_expressions_type 1005 |
| 84 | #define statements_type 1006 |
| 85 | #define statement_type 1007 |
| 86 | #define statement_newline_type 1008 |
| 87 | #define simple_stmt_type 1009 |
| 88 | #define small_stmt_type 1010 |
| 89 | #define compound_stmt_type 1011 |
| 90 | #define assignment_type 1012 |
| 91 | #define augassign_type 1013 |
| 92 | #define global_stmt_type 1014 |
| 93 | #define nonlocal_stmt_type 1015 |
| 94 | #define yield_stmt_type 1016 |
| 95 | #define assert_stmt_type 1017 |
| 96 | #define del_stmt_type 1018 |
| 97 | #define import_stmt_type 1019 |
| 98 | #define import_name_type 1020 |
| 99 | #define import_from_type 1021 |
| 100 | #define import_from_targets_type 1022 |
| 101 | #define import_from_as_names_type 1023 |
| 102 | #define import_from_as_name_type 1024 |
| 103 | #define dotted_as_names_type 1025 |
| 104 | #define dotted_as_name_type 1026 |
| 105 | #define dotted_name_type 1027 // Left-recursive |
| 106 | #define if_stmt_type 1028 |
| 107 | #define elif_stmt_type 1029 |
| 108 | #define else_block_type 1030 |
| 109 | #define while_stmt_type 1031 |
| 110 | #define for_stmt_type 1032 |
| 111 | #define with_stmt_type 1033 |
| 112 | #define with_item_type 1034 |
| 113 | #define try_stmt_type 1035 |
| 114 | #define except_block_type 1036 |
| 115 | #define finally_block_type 1037 |
| 116 | #define return_stmt_type 1038 |
| 117 | #define raise_stmt_type 1039 |
| 118 | #define function_def_type 1040 |
| 119 | #define function_def_raw_type 1041 |
| 120 | #define func_type_comment_type 1042 |
| 121 | #define params_type 1043 |
| 122 | #define parameters_type 1044 |
| 123 | #define slash_no_default_type 1045 |
| 124 | #define slash_with_default_type 1046 |
| 125 | #define star_etc_type 1047 |
| 126 | #define kwds_type 1048 |
| 127 | #define param_no_default_type 1049 |
| 128 | #define param_with_default_type 1050 |
| 129 | #define param_maybe_default_type 1051 |
| 130 | #define param_type 1052 |
| 131 | #define annotation_type 1053 |
| 132 | #define default_type 1054 |
| 133 | #define decorators_type 1055 |
| 134 | #define class_def_type 1056 |
| 135 | #define class_def_raw_type 1057 |
| 136 | #define block_type 1058 |
| 137 | #define expressions_list_type 1059 |
| 138 | #define star_expressions_type 1060 |
| 139 | #define star_expression_type 1061 |
| 140 | #define star_named_expressions_type 1062 |
| 141 | #define star_named_expression_type 1063 |
| 142 | #define named_expression_type 1064 |
| 143 | #define annotated_rhs_type 1065 |
| 144 | #define expressions_type 1066 |
| 145 | #define expression_type 1067 |
| 146 | #define lambdef_type 1068 |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 147 | #define lambda_params_type 1069 |
| 148 | #define lambda_parameters_type 1070 |
| 149 | #define lambda_slash_no_default_type 1071 |
| 150 | #define lambda_slash_with_default_type 1072 |
| 151 | #define lambda_star_etc_type 1073 |
| 152 | #define lambda_kwds_type 1074 |
| 153 | #define lambda_param_no_default_type 1075 |
| 154 | #define lambda_param_with_default_type 1076 |
| 155 | #define lambda_param_maybe_default_type 1077 |
| 156 | #define lambda_param_type 1078 |
| 157 | #define disjunction_type 1079 |
| 158 | #define conjunction_type 1080 |
| 159 | #define inversion_type 1081 |
| 160 | #define comparison_type 1082 |
| 161 | #define compare_op_bitwise_or_pair_type 1083 |
| 162 | #define eq_bitwise_or_type 1084 |
| 163 | #define noteq_bitwise_or_type 1085 |
| 164 | #define lte_bitwise_or_type 1086 |
| 165 | #define lt_bitwise_or_type 1087 |
| 166 | #define gte_bitwise_or_type 1088 |
| 167 | #define gt_bitwise_or_type 1089 |
| 168 | #define notin_bitwise_or_type 1090 |
| 169 | #define in_bitwise_or_type 1091 |
| 170 | #define isnot_bitwise_or_type 1092 |
| 171 | #define is_bitwise_or_type 1093 |
| 172 | #define bitwise_or_type 1094 // Left-recursive |
| 173 | #define bitwise_xor_type 1095 // Left-recursive |
| 174 | #define bitwise_and_type 1096 // Left-recursive |
| 175 | #define shift_expr_type 1097 // Left-recursive |
| 176 | #define sum_type 1098 // Left-recursive |
| 177 | #define term_type 1099 // Left-recursive |
| 178 | #define factor_type 1100 |
| 179 | #define power_type 1101 |
| 180 | #define await_primary_type 1102 |
| 181 | #define primary_type 1103 // Left-recursive |
| 182 | #define slices_type 1104 |
| 183 | #define slice_type 1105 |
| 184 | #define atom_type 1106 |
| 185 | #define strings_type 1107 |
| 186 | #define list_type 1108 |
| 187 | #define listcomp_type 1109 |
| 188 | #define tuple_type 1110 |
| 189 | #define group_type 1111 |
| 190 | #define genexp_type 1112 |
| 191 | #define set_type 1113 |
| 192 | #define setcomp_type 1114 |
| 193 | #define dict_type 1115 |
| 194 | #define dictcomp_type 1116 |
| 195 | #define double_starred_kvpairs_type 1117 |
| 196 | #define double_starred_kvpair_type 1118 |
| 197 | #define kvpair_type 1119 |
| 198 | #define for_if_clauses_type 1120 |
| 199 | #define for_if_clause_type 1121 |
| 200 | #define yield_expr_type 1122 |
| 201 | #define arguments_type 1123 |
| 202 | #define args_type 1124 |
| 203 | #define kwargs_type 1125 |
| 204 | #define starred_expression_type 1126 |
| 205 | #define kwarg_or_starred_type 1127 |
| 206 | #define kwarg_or_double_starred_type 1128 |
| 207 | #define star_targets_type 1129 |
| 208 | #define star_targets_seq_type 1130 |
| 209 | #define star_target_type 1131 |
| 210 | #define star_atom_type 1132 |
| 211 | #define single_target_type 1133 |
| 212 | #define single_subscript_attribute_target_type 1134 |
| 213 | #define del_targets_type 1135 |
| 214 | #define del_target_type 1136 |
| 215 | #define del_t_atom_type 1137 |
| 216 | #define del_target_end_type 1138 |
| 217 | #define targets_type 1139 |
| 218 | #define target_type 1140 |
| 219 | #define t_primary_type 1141 // Left-recursive |
| 220 | #define t_lookahead_type 1142 |
| 221 | #define t_atom_type 1143 |
| 222 | #define incorrect_arguments_type 1144 |
| 223 | #define invalid_kwarg_type 1145 |
| 224 | #define invalid_named_expression_type 1146 |
| 225 | #define invalid_assignment_type 1147 |
| 226 | #define invalid_block_type 1148 |
| 227 | #define invalid_comprehension_type 1149 |
| 228 | #define invalid_dict_comprehension_type 1150 |
| 229 | #define invalid_parameters_type 1151 |
| 230 | #define invalid_lambda_parameters_type 1152 |
| 231 | #define invalid_star_etc_type 1153 |
| 232 | #define invalid_lambda_star_etc_type 1154 |
| 233 | #define invalid_double_type_comments_type 1155 |
| 234 | #define invalid_del_target_type 1156 |
| 235 | #define invalid_import_from_targets_type 1157 |
| 236 | #define _loop0_1_type 1158 |
| 237 | #define _loop0_2_type 1159 |
| 238 | #define _loop0_4_type 1160 |
| 239 | #define _gather_3_type 1161 |
| 240 | #define _loop0_6_type 1162 |
| 241 | #define _gather_5_type 1163 |
| 242 | #define _loop0_8_type 1164 |
| 243 | #define _gather_7_type 1165 |
| 244 | #define _loop0_10_type 1166 |
| 245 | #define _gather_9_type 1167 |
| 246 | #define _loop1_11_type 1168 |
| 247 | #define _loop0_13_type 1169 |
| 248 | #define _gather_12_type 1170 |
| 249 | #define _tmp_14_type 1171 |
| 250 | #define _tmp_15_type 1172 |
| 251 | #define _tmp_16_type 1173 |
| 252 | #define _tmp_17_type 1174 |
| 253 | #define _tmp_18_type 1175 |
| 254 | #define _tmp_19_type 1176 |
| 255 | #define _tmp_20_type 1177 |
| 256 | #define _tmp_21_type 1178 |
| 257 | #define _loop1_22_type 1179 |
| 258 | #define _tmp_23_type 1180 |
| 259 | #define _tmp_24_type 1181 |
| 260 | #define _loop0_26_type 1182 |
| 261 | #define _gather_25_type 1183 |
| 262 | #define _loop0_28_type 1184 |
| 263 | #define _gather_27_type 1185 |
| 264 | #define _tmp_29_type 1186 |
| 265 | #define _loop0_30_type 1187 |
| 266 | #define _loop1_31_type 1188 |
| 267 | #define _loop0_33_type 1189 |
| 268 | #define _gather_32_type 1190 |
| 269 | #define _tmp_34_type 1191 |
| 270 | #define _loop0_36_type 1192 |
| 271 | #define _gather_35_type 1193 |
| 272 | #define _tmp_37_type 1194 |
| 273 | #define _loop0_39_type 1195 |
| 274 | #define _gather_38_type 1196 |
| 275 | #define _loop0_41_type 1197 |
| 276 | #define _gather_40_type 1198 |
| 277 | #define _loop0_43_type 1199 |
| 278 | #define _gather_42_type 1200 |
| 279 | #define _loop0_45_type 1201 |
| 280 | #define _gather_44_type 1202 |
| 281 | #define _tmp_46_type 1203 |
| 282 | #define _loop1_47_type 1204 |
| 283 | #define _tmp_48_type 1205 |
| 284 | #define _tmp_49_type 1206 |
| 285 | #define _tmp_50_type 1207 |
| 286 | #define _tmp_51_type 1208 |
| 287 | #define _tmp_52_type 1209 |
| 288 | #define _loop0_53_type 1210 |
| 289 | #define _loop0_54_type 1211 |
| 290 | #define _loop0_55_type 1212 |
| 291 | #define _loop1_56_type 1213 |
| 292 | #define _loop0_57_type 1214 |
| 293 | #define _loop1_58_type 1215 |
| 294 | #define _loop1_59_type 1216 |
| 295 | #define _loop1_60_type 1217 |
| 296 | #define _loop0_61_type 1218 |
| 297 | #define _loop1_62_type 1219 |
| 298 | #define _loop0_63_type 1220 |
| 299 | #define _loop1_64_type 1221 |
| 300 | #define _loop0_65_type 1222 |
| 301 | #define _loop1_66_type 1223 |
| 302 | #define _loop1_67_type 1224 |
| 303 | #define _tmp_68_type 1225 |
| 304 | #define _loop0_70_type 1226 |
| 305 | #define _gather_69_type 1227 |
| 306 | #define _loop1_71_type 1228 |
| 307 | #define _loop0_73_type 1229 |
| 308 | #define _gather_72_type 1230 |
| 309 | #define _loop1_74_type 1231 |
| 310 | #define _loop0_75_type 1232 |
| 311 | #define _loop0_76_type 1233 |
| 312 | #define _loop0_77_type 1234 |
| 313 | #define _loop1_78_type 1235 |
| 314 | #define _loop0_79_type 1236 |
| 315 | #define _loop1_80_type 1237 |
| 316 | #define _loop1_81_type 1238 |
| 317 | #define _loop1_82_type 1239 |
| 318 | #define _loop0_83_type 1240 |
| 319 | #define _loop1_84_type 1241 |
| 320 | #define _loop0_85_type 1242 |
| 321 | #define _loop1_86_type 1243 |
| 322 | #define _loop0_87_type 1244 |
| 323 | #define _loop1_88_type 1245 |
| 324 | #define _loop1_89_type 1246 |
| 325 | #define _loop1_90_type 1247 |
| 326 | #define _loop1_91_type 1248 |
| 327 | #define _tmp_92_type 1249 |
| 328 | #define _loop0_94_type 1250 |
| 329 | #define _gather_93_type 1251 |
| 330 | #define _tmp_95_type 1252 |
| 331 | #define _tmp_96_type 1253 |
| 332 | #define _tmp_97_type 1254 |
| 333 | #define _tmp_98_type 1255 |
| 334 | #define _loop1_99_type 1256 |
| 335 | #define _tmp_100_type 1257 |
| 336 | #define _tmp_101_type 1258 |
| 337 | #define _loop0_103_type 1259 |
| 338 | #define _gather_102_type 1260 |
| 339 | #define _loop1_104_type 1261 |
| 340 | #define _loop0_105_type 1262 |
| 341 | #define _loop0_106_type 1263 |
| 342 | #define _tmp_107_type 1264 |
| 343 | #define _tmp_108_type 1265 |
| 344 | #define _loop0_110_type 1266 |
| 345 | #define _gather_109_type 1267 |
| 346 | #define _loop0_112_type 1268 |
| 347 | #define _gather_111_type 1269 |
| 348 | #define _loop0_114_type 1270 |
| 349 | #define _gather_113_type 1271 |
| 350 | #define _loop0_116_type 1272 |
| 351 | #define _gather_115_type 1273 |
| 352 | #define _loop0_117_type 1274 |
| 353 | #define _loop0_119_type 1275 |
| 354 | #define _gather_118_type 1276 |
| 355 | #define _tmp_120_type 1277 |
| 356 | #define _loop0_122_type 1278 |
| 357 | #define _gather_121_type 1279 |
| 358 | #define _loop0_124_type 1280 |
| 359 | #define _gather_123_type 1281 |
| 360 | #define _tmp_125_type 1282 |
| 361 | #define _loop0_126_type 1283 |
| 362 | #define _tmp_127_type 1284 |
| 363 | #define _loop0_128_type 1285 |
| 364 | #define _loop0_129_type 1286 |
| 365 | #define _tmp_130_type 1287 |
| 366 | #define _tmp_131_type 1288 |
| 367 | #define _loop0_132_type 1289 |
| 368 | #define _tmp_133_type 1290 |
| 369 | #define _loop0_134_type 1291 |
| 370 | #define _tmp_135_type 1292 |
| 371 | #define _tmp_136_type 1293 |
| 372 | #define _tmp_137_type 1294 |
| 373 | #define _tmp_138_type 1295 |
| 374 | #define _tmp_139_type 1296 |
| 375 | #define _tmp_140_type 1297 |
| 376 | #define _tmp_141_type 1298 |
| 377 | #define _tmp_142_type 1299 |
| 378 | #define _tmp_143_type 1300 |
| 379 | #define _tmp_144_type 1301 |
| 380 | #define _tmp_145_type 1302 |
| 381 | #define _tmp_146_type 1303 |
| 382 | #define _tmp_147_type 1304 |
| 383 | #define _tmp_148_type 1305 |
| 384 | #define _tmp_149_type 1306 |
| 385 | #define _tmp_150_type 1307 |
| 386 | #define _loop1_151_type 1308 |
| 387 | #define _loop1_152_type 1309 |
| 388 | #define _tmp_153_type 1310 |
| 389 | #define _tmp_154_type 1311 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 390 | |
| 391 | static mod_ty file_rule(Parser *p); |
| 392 | static mod_ty interactive_rule(Parser *p); |
| 393 | static mod_ty eval_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 394 | static mod_ty func_type_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 395 | static expr_ty fstring_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 396 | static asdl_seq* type_expressions_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 397 | static asdl_seq* statements_rule(Parser *p); |
| 398 | static asdl_seq* statement_rule(Parser *p); |
| 399 | static asdl_seq* statement_newline_rule(Parser *p); |
| 400 | static asdl_seq* simple_stmt_rule(Parser *p); |
| 401 | static stmt_ty small_stmt_rule(Parser *p); |
| 402 | static stmt_ty compound_stmt_rule(Parser *p); |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 403 | static stmt_ty assignment_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 404 | static AugOperator* augassign_rule(Parser *p); |
| 405 | static stmt_ty global_stmt_rule(Parser *p); |
| 406 | static stmt_ty nonlocal_stmt_rule(Parser *p); |
| 407 | static stmt_ty yield_stmt_rule(Parser *p); |
| 408 | static stmt_ty assert_stmt_rule(Parser *p); |
| 409 | static stmt_ty del_stmt_rule(Parser *p); |
| 410 | static stmt_ty import_stmt_rule(Parser *p); |
| 411 | static stmt_ty import_name_rule(Parser *p); |
| 412 | static stmt_ty import_from_rule(Parser *p); |
| 413 | static asdl_seq* import_from_targets_rule(Parser *p); |
| 414 | static asdl_seq* import_from_as_names_rule(Parser *p); |
| 415 | static alias_ty import_from_as_name_rule(Parser *p); |
| 416 | static asdl_seq* dotted_as_names_rule(Parser *p); |
| 417 | static alias_ty dotted_as_name_rule(Parser *p); |
| 418 | static expr_ty dotted_name_rule(Parser *p); |
| 419 | static stmt_ty if_stmt_rule(Parser *p); |
| 420 | static stmt_ty elif_stmt_rule(Parser *p); |
| 421 | static asdl_seq* else_block_rule(Parser *p); |
| 422 | static stmt_ty while_stmt_rule(Parser *p); |
| 423 | static stmt_ty for_stmt_rule(Parser *p); |
| 424 | static stmt_ty with_stmt_rule(Parser *p); |
| 425 | static withitem_ty with_item_rule(Parser *p); |
| 426 | static stmt_ty try_stmt_rule(Parser *p); |
| 427 | static excepthandler_ty except_block_rule(Parser *p); |
| 428 | static asdl_seq* finally_block_rule(Parser *p); |
| 429 | static stmt_ty return_stmt_rule(Parser *p); |
| 430 | static stmt_ty raise_stmt_rule(Parser *p); |
| 431 | static stmt_ty function_def_rule(Parser *p); |
| 432 | static stmt_ty function_def_raw_rule(Parser *p); |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 433 | static Token* func_type_comment_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 434 | static arguments_ty params_rule(Parser *p); |
| 435 | static arguments_ty parameters_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 436 | static asdl_seq* slash_no_default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 437 | static SlashWithDefault* slash_with_default_rule(Parser *p); |
| 438 | static StarEtc* star_etc_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 439 | static arg_ty kwds_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 440 | static arg_ty param_no_default_rule(Parser *p); |
| 441 | static NameDefaultPair* param_with_default_rule(Parser *p); |
| 442 | static NameDefaultPair* param_maybe_default_rule(Parser *p); |
| 443 | static arg_ty param_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 444 | static expr_ty annotation_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 445 | static expr_ty default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 446 | static asdl_seq* decorators_rule(Parser *p); |
| 447 | static stmt_ty class_def_rule(Parser *p); |
| 448 | static stmt_ty class_def_raw_rule(Parser *p); |
| 449 | static asdl_seq* block_rule(Parser *p); |
| 450 | static asdl_seq* expressions_list_rule(Parser *p); |
| 451 | static expr_ty star_expressions_rule(Parser *p); |
| 452 | static expr_ty star_expression_rule(Parser *p); |
| 453 | static asdl_seq* star_named_expressions_rule(Parser *p); |
| 454 | static expr_ty star_named_expression_rule(Parser *p); |
| 455 | static expr_ty named_expression_rule(Parser *p); |
| 456 | static expr_ty annotated_rhs_rule(Parser *p); |
| 457 | static expr_ty expressions_rule(Parser *p); |
| 458 | static expr_ty expression_rule(Parser *p); |
| 459 | static expr_ty lambdef_rule(Parser *p); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 460 | static arguments_ty lambda_params_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 461 | static arguments_ty lambda_parameters_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 462 | static asdl_seq* lambda_slash_no_default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 463 | static SlashWithDefault* lambda_slash_with_default_rule(Parser *p); |
| 464 | static StarEtc* lambda_star_etc_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 465 | static arg_ty lambda_kwds_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 466 | static arg_ty lambda_param_no_default_rule(Parser *p); |
| 467 | static NameDefaultPair* lambda_param_with_default_rule(Parser *p); |
| 468 | static NameDefaultPair* lambda_param_maybe_default_rule(Parser *p); |
| 469 | static arg_ty lambda_param_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 470 | static expr_ty disjunction_rule(Parser *p); |
| 471 | static expr_ty conjunction_rule(Parser *p); |
| 472 | static expr_ty inversion_rule(Parser *p); |
| 473 | static expr_ty comparison_rule(Parser *p); |
| 474 | static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p); |
| 475 | static CmpopExprPair* eq_bitwise_or_rule(Parser *p); |
| 476 | static CmpopExprPair* noteq_bitwise_or_rule(Parser *p); |
| 477 | static CmpopExprPair* lte_bitwise_or_rule(Parser *p); |
| 478 | static CmpopExprPair* lt_bitwise_or_rule(Parser *p); |
| 479 | static CmpopExprPair* gte_bitwise_or_rule(Parser *p); |
| 480 | static CmpopExprPair* gt_bitwise_or_rule(Parser *p); |
| 481 | static CmpopExprPair* notin_bitwise_or_rule(Parser *p); |
| 482 | static CmpopExprPair* in_bitwise_or_rule(Parser *p); |
| 483 | static CmpopExprPair* isnot_bitwise_or_rule(Parser *p); |
| 484 | static CmpopExprPair* is_bitwise_or_rule(Parser *p); |
| 485 | static expr_ty bitwise_or_rule(Parser *p); |
| 486 | static expr_ty bitwise_xor_rule(Parser *p); |
| 487 | static expr_ty bitwise_and_rule(Parser *p); |
| 488 | static expr_ty shift_expr_rule(Parser *p); |
| 489 | static expr_ty sum_rule(Parser *p); |
| 490 | static expr_ty term_rule(Parser *p); |
| 491 | static expr_ty factor_rule(Parser *p); |
| 492 | static expr_ty power_rule(Parser *p); |
| 493 | static expr_ty await_primary_rule(Parser *p); |
| 494 | static expr_ty primary_rule(Parser *p); |
| 495 | static expr_ty slices_rule(Parser *p); |
| 496 | static expr_ty slice_rule(Parser *p); |
| 497 | static expr_ty atom_rule(Parser *p); |
| 498 | static expr_ty strings_rule(Parser *p); |
| 499 | static expr_ty list_rule(Parser *p); |
| 500 | static expr_ty listcomp_rule(Parser *p); |
| 501 | static expr_ty tuple_rule(Parser *p); |
| 502 | static expr_ty group_rule(Parser *p); |
| 503 | static expr_ty genexp_rule(Parser *p); |
| 504 | static expr_ty set_rule(Parser *p); |
| 505 | static expr_ty setcomp_rule(Parser *p); |
| 506 | static expr_ty dict_rule(Parser *p); |
| 507 | static expr_ty dictcomp_rule(Parser *p); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 508 | static asdl_seq* double_starred_kvpairs_rule(Parser *p); |
| 509 | static KeyValuePair* double_starred_kvpair_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 510 | static KeyValuePair* kvpair_rule(Parser *p); |
| 511 | static asdl_seq* for_if_clauses_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 512 | static comprehension_ty for_if_clause_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 513 | static expr_ty yield_expr_rule(Parser *p); |
| 514 | static expr_ty arguments_rule(Parser *p); |
| 515 | static expr_ty args_rule(Parser *p); |
| 516 | static asdl_seq* kwargs_rule(Parser *p); |
| 517 | static expr_ty starred_expression_rule(Parser *p); |
| 518 | static KeywordOrStarred* kwarg_or_starred_rule(Parser *p); |
| 519 | static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p); |
| 520 | static expr_ty star_targets_rule(Parser *p); |
| 521 | static asdl_seq* star_targets_seq_rule(Parser *p); |
| 522 | static expr_ty star_target_rule(Parser *p); |
| 523 | static expr_ty star_atom_rule(Parser *p); |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 524 | static expr_ty single_target_rule(Parser *p); |
| 525 | static expr_ty single_subscript_attribute_target_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 526 | static asdl_seq* del_targets_rule(Parser *p); |
| 527 | static expr_ty del_target_rule(Parser *p); |
| 528 | static expr_ty del_t_atom_rule(Parser *p); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 529 | static void *del_target_end_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 530 | static asdl_seq* targets_rule(Parser *p); |
| 531 | static expr_ty target_rule(Parser *p); |
| 532 | static expr_ty t_primary_rule(Parser *p); |
| 533 | static void *t_lookahead_rule(Parser *p); |
| 534 | static expr_ty t_atom_rule(Parser *p); |
| 535 | static void *incorrect_arguments_rule(Parser *p); |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 536 | static void *invalid_kwarg_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 537 | static void *invalid_named_expression_rule(Parser *p); |
| 538 | static void *invalid_assignment_rule(Parser *p); |
| 539 | static void *invalid_block_rule(Parser *p); |
| 540 | static void *invalid_comprehension_rule(Parser *p); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 541 | static void *invalid_dict_comprehension_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 542 | static void *invalid_parameters_rule(Parser *p); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 543 | static void *invalid_lambda_parameters_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 544 | static void *invalid_star_etc_rule(Parser *p); |
| 545 | static void *invalid_lambda_star_etc_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 546 | static void *invalid_double_type_comments_rule(Parser *p); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 547 | static void *invalid_del_target_rule(Parser *p); |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 548 | static void *invalid_import_from_targets_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 549 | static asdl_seq *_loop0_1_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 550 | static asdl_seq *_loop0_2_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 551 | static asdl_seq *_loop0_4_rule(Parser *p); |
| 552 | static asdl_seq *_gather_3_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 553 | static asdl_seq *_loop0_6_rule(Parser *p); |
| 554 | static asdl_seq *_gather_5_rule(Parser *p); |
| 555 | static asdl_seq *_loop0_8_rule(Parser *p); |
| 556 | static asdl_seq *_gather_7_rule(Parser *p); |
| 557 | static asdl_seq *_loop0_10_rule(Parser *p); |
| 558 | static asdl_seq *_gather_9_rule(Parser *p); |
| 559 | static asdl_seq *_loop1_11_rule(Parser *p); |
| 560 | static asdl_seq *_loop0_13_rule(Parser *p); |
| 561 | static asdl_seq *_gather_12_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 562 | static void *_tmp_14_rule(Parser *p); |
| 563 | static void *_tmp_15_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 564 | static void *_tmp_16_rule(Parser *p); |
| 565 | static void *_tmp_17_rule(Parser *p); |
| 566 | static void *_tmp_18_rule(Parser *p); |
| 567 | static void *_tmp_19_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 568 | static void *_tmp_20_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 569 | static void *_tmp_21_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 570 | static asdl_seq *_loop1_22_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 571 | static void *_tmp_23_rule(Parser *p); |
| 572 | static void *_tmp_24_rule(Parser *p); |
| 573 | static asdl_seq *_loop0_26_rule(Parser *p); |
| 574 | static asdl_seq *_gather_25_rule(Parser *p); |
| 575 | static asdl_seq *_loop0_28_rule(Parser *p); |
| 576 | static asdl_seq *_gather_27_rule(Parser *p); |
| 577 | static void *_tmp_29_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 578 | static asdl_seq *_loop0_30_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 579 | static asdl_seq *_loop1_31_rule(Parser *p); |
| 580 | static asdl_seq *_loop0_33_rule(Parser *p); |
| 581 | static asdl_seq *_gather_32_rule(Parser *p); |
| 582 | static void *_tmp_34_rule(Parser *p); |
| 583 | static asdl_seq *_loop0_36_rule(Parser *p); |
| 584 | static asdl_seq *_gather_35_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 585 | static void *_tmp_37_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 586 | static asdl_seq *_loop0_39_rule(Parser *p); |
| 587 | static asdl_seq *_gather_38_rule(Parser *p); |
| 588 | static asdl_seq *_loop0_41_rule(Parser *p); |
| 589 | static asdl_seq *_gather_40_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 590 | static asdl_seq *_loop0_43_rule(Parser *p); |
| 591 | static asdl_seq *_gather_42_rule(Parser *p); |
| 592 | static asdl_seq *_loop0_45_rule(Parser *p); |
| 593 | static asdl_seq *_gather_44_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 594 | static void *_tmp_46_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 595 | static asdl_seq *_loop1_47_rule(Parser *p); |
| 596 | static void *_tmp_48_rule(Parser *p); |
| 597 | static void *_tmp_49_rule(Parser *p); |
| 598 | static void *_tmp_50_rule(Parser *p); |
| 599 | static void *_tmp_51_rule(Parser *p); |
| 600 | static void *_tmp_52_rule(Parser *p); |
| 601 | static asdl_seq *_loop0_53_rule(Parser *p); |
| 602 | static asdl_seq *_loop0_54_rule(Parser *p); |
| 603 | static asdl_seq *_loop0_55_rule(Parser *p); |
| 604 | static asdl_seq *_loop1_56_rule(Parser *p); |
| 605 | static asdl_seq *_loop0_57_rule(Parser *p); |
| 606 | static asdl_seq *_loop1_58_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 607 | static asdl_seq *_loop1_59_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 608 | static asdl_seq *_loop1_60_rule(Parser *p); |
| 609 | static asdl_seq *_loop0_61_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 610 | static asdl_seq *_loop1_62_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 611 | static asdl_seq *_loop0_63_rule(Parser *p); |
| 612 | static asdl_seq *_loop1_64_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 613 | static asdl_seq *_loop0_65_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 614 | static asdl_seq *_loop1_66_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 615 | static asdl_seq *_loop1_67_rule(Parser *p); |
| 616 | static void *_tmp_68_rule(Parser *p); |
| 617 | static asdl_seq *_loop0_70_rule(Parser *p); |
| 618 | static asdl_seq *_gather_69_rule(Parser *p); |
| 619 | static asdl_seq *_loop1_71_rule(Parser *p); |
| 620 | static asdl_seq *_loop0_73_rule(Parser *p); |
| 621 | static asdl_seq *_gather_72_rule(Parser *p); |
| 622 | static asdl_seq *_loop1_74_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 623 | static asdl_seq *_loop0_75_rule(Parser *p); |
| 624 | static asdl_seq *_loop0_76_rule(Parser *p); |
| 625 | static asdl_seq *_loop0_77_rule(Parser *p); |
| 626 | static asdl_seq *_loop1_78_rule(Parser *p); |
| 627 | static asdl_seq *_loop0_79_rule(Parser *p); |
| 628 | static asdl_seq *_loop1_80_rule(Parser *p); |
| 629 | static asdl_seq *_loop1_81_rule(Parser *p); |
| 630 | static asdl_seq *_loop1_82_rule(Parser *p); |
| 631 | static asdl_seq *_loop0_83_rule(Parser *p); |
| 632 | static asdl_seq *_loop1_84_rule(Parser *p); |
| 633 | static asdl_seq *_loop0_85_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 634 | static asdl_seq *_loop1_86_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 635 | static asdl_seq *_loop0_87_rule(Parser *p); |
| 636 | static asdl_seq *_loop1_88_rule(Parser *p); |
| 637 | static asdl_seq *_loop1_89_rule(Parser *p); |
| 638 | static asdl_seq *_loop1_90_rule(Parser *p); |
| 639 | static asdl_seq *_loop1_91_rule(Parser *p); |
| 640 | static void *_tmp_92_rule(Parser *p); |
| 641 | static asdl_seq *_loop0_94_rule(Parser *p); |
| 642 | static asdl_seq *_gather_93_rule(Parser *p); |
| 643 | static void *_tmp_95_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 644 | static void *_tmp_96_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 645 | static void *_tmp_97_rule(Parser *p); |
| 646 | static void *_tmp_98_rule(Parser *p); |
| 647 | static asdl_seq *_loop1_99_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 648 | static void *_tmp_100_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 649 | static void *_tmp_101_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 650 | static asdl_seq *_loop0_103_rule(Parser *p); |
| 651 | static asdl_seq *_gather_102_rule(Parser *p); |
| 652 | static asdl_seq *_loop1_104_rule(Parser *p); |
| 653 | static asdl_seq *_loop0_105_rule(Parser *p); |
| 654 | static asdl_seq *_loop0_106_rule(Parser *p); |
| 655 | static void *_tmp_107_rule(Parser *p); |
| 656 | static void *_tmp_108_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 657 | static asdl_seq *_loop0_110_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 658 | static asdl_seq *_gather_109_rule(Parser *p); |
| 659 | static asdl_seq *_loop0_112_rule(Parser *p); |
| 660 | static asdl_seq *_gather_111_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 661 | static asdl_seq *_loop0_114_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 662 | static asdl_seq *_gather_113_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 663 | static asdl_seq *_loop0_116_rule(Parser *p); |
| 664 | static asdl_seq *_gather_115_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 665 | static asdl_seq *_loop0_117_rule(Parser *p); |
| 666 | static asdl_seq *_loop0_119_rule(Parser *p); |
| 667 | static asdl_seq *_gather_118_rule(Parser *p); |
| 668 | static void *_tmp_120_rule(Parser *p); |
| 669 | static asdl_seq *_loop0_122_rule(Parser *p); |
| 670 | static asdl_seq *_gather_121_rule(Parser *p); |
| 671 | static asdl_seq *_loop0_124_rule(Parser *p); |
| 672 | static asdl_seq *_gather_123_rule(Parser *p); |
| 673 | static void *_tmp_125_rule(Parser *p); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 674 | static asdl_seq *_loop0_126_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 675 | static void *_tmp_127_rule(Parser *p); |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 676 | static asdl_seq *_loop0_128_rule(Parser *p); |
| 677 | static asdl_seq *_loop0_129_rule(Parser *p); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 678 | static void *_tmp_130_rule(Parser *p); |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 679 | static void *_tmp_131_rule(Parser *p); |
| 680 | static asdl_seq *_loop0_132_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 681 | static void *_tmp_133_rule(Parser *p); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 682 | static asdl_seq *_loop0_134_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 683 | static void *_tmp_135_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 684 | static void *_tmp_136_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 685 | static void *_tmp_137_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 686 | static void *_tmp_138_rule(Parser *p); |
| 687 | static void *_tmp_139_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 688 | static void *_tmp_140_rule(Parser *p); |
| 689 | static void *_tmp_141_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 690 | static void *_tmp_142_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 691 | static void *_tmp_143_rule(Parser *p); |
| 692 | static void *_tmp_144_rule(Parser *p); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 693 | static void *_tmp_145_rule(Parser *p); |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 694 | static void *_tmp_146_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 695 | static void *_tmp_147_rule(Parser *p); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 696 | static void *_tmp_148_rule(Parser *p); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 697 | static void *_tmp_149_rule(Parser *p); |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 698 | static void *_tmp_150_rule(Parser *p); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 699 | static asdl_seq *_loop1_151_rule(Parser *p); |
| 700 | static asdl_seq *_loop1_152_rule(Parser *p); |
| 701 | static void *_tmp_153_rule(Parser *p); |
| 702 | static void *_tmp_154_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 703 | |
| 704 | |
| 705 | // file: statements? $ |
| 706 | static mod_ty |
| 707 | file_rule(Parser *p) |
| 708 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 709 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 710 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 711 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 712 | return NULL; |
| 713 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 714 | mod_ty _res = NULL; |
| 715 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 716 | { // statements? $ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 717 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 718 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 719 | return NULL; |
| 720 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 721 | D(fprintf(stderr, "%*c> file[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statements? $")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 722 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 723 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 724 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 725 | (a = statements_rule(p), 1) // statements? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 726 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 727 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 728 | ) |
| 729 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 730 | D(fprintf(stderr, "%*c+ file[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "statements? $")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 731 | _res = _PyPegen_make_module ( p , a ); |
| 732 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 733 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 734 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 735 | return NULL; |
| 736 | } |
| 737 | goto done; |
| 738 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 739 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 740 | D(fprintf(stderr, "%*c%s file[%d-%d]: %s failed!\n", p->level, ' ', |
| 741 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statements? $")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 742 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 743 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 744 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 745 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 746 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 747 | } |
| 748 | |
| 749 | // interactive: statement_newline |
| 750 | static mod_ty |
| 751 | interactive_rule(Parser *p) |
| 752 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 753 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 754 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 755 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 756 | return NULL; |
| 757 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 758 | mod_ty _res = NULL; |
| 759 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 760 | { // statement_newline |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 761 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 762 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 763 | return NULL; |
| 764 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 765 | D(fprintf(stderr, "%*c> interactive[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement_newline")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 766 | asdl_seq* a; |
| 767 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 768 | (a = statement_newline_rule(p)) // statement_newline |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 769 | ) |
| 770 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 771 | D(fprintf(stderr, "%*c+ interactive[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "statement_newline")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 772 | _res = Interactive ( a , p -> arena ); |
| 773 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 774 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 775 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 776 | return NULL; |
| 777 | } |
| 778 | goto done; |
| 779 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 780 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 781 | D(fprintf(stderr, "%*c%s interactive[%d-%d]: %s failed!\n", p->level, ' ', |
| 782 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement_newline")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 783 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 784 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 785 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 786 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 787 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 788 | } |
| 789 | |
| 790 | // eval: expressions NEWLINE* $ |
| 791 | static mod_ty |
| 792 | eval_rule(Parser *p) |
| 793 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 794 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 795 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 796 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 797 | return NULL; |
| 798 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 799 | mod_ty _res = NULL; |
| 800 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 801 | { // expressions NEWLINE* $ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 802 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 803 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 804 | return NULL; |
| 805 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 806 | D(fprintf(stderr, "%*c> eval[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expressions NEWLINE* $")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 807 | asdl_seq * _loop0_1_var; |
| 808 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 809 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 810 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 811 | (a = expressions_rule(p)) // expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 812 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 813 | (_loop0_1_var = _loop0_1_rule(p)) // NEWLINE* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 814 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 815 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 816 | ) |
| 817 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 818 | D(fprintf(stderr, "%*c+ eval[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expressions NEWLINE* $")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 819 | _res = Expression ( a , p -> arena ); |
| 820 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 821 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 822 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 823 | return NULL; |
| 824 | } |
| 825 | goto done; |
| 826 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 827 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 828 | D(fprintf(stderr, "%*c%s eval[%d-%d]: %s failed!\n", p->level, ' ', |
| 829 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expressions NEWLINE* $")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 830 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 831 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 832 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 833 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 834 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 835 | } |
| 836 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 837 | // func_type: '(' type_expressions? ')' '->' expression NEWLINE* $ |
| 838 | static mod_ty |
| 839 | func_type_rule(Parser *p) |
| 840 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 841 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 842 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 843 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 844 | return NULL; |
| 845 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 846 | mod_ty _res = NULL; |
| 847 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 848 | { // '(' type_expressions? ')' '->' expression NEWLINE* $ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 849 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 850 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 851 | return NULL; |
| 852 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 853 | D(fprintf(stderr, "%*c> func_type[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' type_expressions? ')' '->' expression NEWLINE* $")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 854 | Token * _literal; |
| 855 | Token * _literal_1; |
| 856 | Token * _literal_2; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 857 | asdl_seq * _loop0_2_var; |
| 858 | void *a; |
| 859 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 860 | Token * endmarker_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 861 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 862 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 863 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 864 | (a = type_expressions_rule(p), 1) // type_expressions? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 865 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 866 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 867 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 868 | (_literal_2 = _PyPegen_expect_token(p, 51)) // token='->' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 869 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 870 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 871 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 872 | (_loop0_2_var = _loop0_2_rule(p)) // NEWLINE* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 873 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 874 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 875 | ) |
| 876 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 877 | D(fprintf(stderr, "%*c+ func_type[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' type_expressions? ')' '->' expression NEWLINE* $")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 878 | _res = FunctionType ( a , b , p -> arena ); |
| 879 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 880 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 881 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 882 | return NULL; |
| 883 | } |
| 884 | goto done; |
| 885 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 886 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 887 | D(fprintf(stderr, "%*c%s func_type[%d-%d]: %s failed!\n", p->level, ' ', |
| 888 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' type_expressions? ')' '->' expression NEWLINE* $")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 889 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 890 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 891 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 892 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 893 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 894 | } |
| 895 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 896 | // fstring: star_expressions |
| 897 | static expr_ty |
| 898 | fstring_rule(Parser *p) |
| 899 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 900 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 901 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 902 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 903 | return NULL; |
| 904 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 905 | expr_ty _res = NULL; |
| 906 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 907 | { // star_expressions |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 908 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 909 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 910 | return NULL; |
| 911 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 912 | D(fprintf(stderr, "%*c> fstring[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 913 | expr_ty star_expressions_var; |
| 914 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 915 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 916 | ) |
| 917 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 918 | D(fprintf(stderr, "%*c+ fstring[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 919 | _res = star_expressions_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 920 | goto done; |
| 921 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 922 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 923 | D(fprintf(stderr, "%*c%s fstring[%d-%d]: %s failed!\n", p->level, ' ', |
| 924 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 925 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 926 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 927 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 928 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 929 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 930 | } |
| 931 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 932 | // type_expressions: |
| 933 | // | ','.expression+ ',' '*' expression ',' '**' expression |
| 934 | // | ','.expression+ ',' '*' expression |
| 935 | // | ','.expression+ ',' '**' expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 936 | // | '*' expression ',' '**' expression |
| 937 | // | '*' expression |
| 938 | // | '**' expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 939 | // | ','.expression+ |
| 940 | static asdl_seq* |
| 941 | type_expressions_rule(Parser *p) |
| 942 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 943 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 944 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 945 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 946 | return NULL; |
| 947 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 948 | asdl_seq* _res = NULL; |
| 949 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 950 | { // ','.expression+ ',' '*' expression ',' '**' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 951 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 952 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 953 | return NULL; |
| 954 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 955 | D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 956 | Token * _literal; |
| 957 | Token * _literal_1; |
| 958 | Token * _literal_2; |
| 959 | Token * _literal_3; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 960 | asdl_seq * a; |
| 961 | expr_ty b; |
| 962 | expr_ty c; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 963 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 964 | (a = _gather_3_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 965 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 966 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 967 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 968 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 969 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 970 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 971 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 972 | (_literal_2 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 973 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 974 | (_literal_3 = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 975 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 976 | (c = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 977 | ) |
| 978 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 979 | D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 980 | _res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_seq_append_to_end ( p , a , b ) ) , c ); |
| 981 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 982 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 983 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 984 | return NULL; |
| 985 | } |
| 986 | goto done; |
| 987 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 988 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 989 | D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 990 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '*' expression ',' '**' expression")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 991 | } |
| 992 | { // ','.expression+ ',' '*' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 993 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 994 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 995 | return NULL; |
| 996 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 997 | D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 998 | Token * _literal; |
| 999 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1000 | asdl_seq * a; |
| 1001 | expr_ty b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1002 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1003 | (a = _gather_5_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1004 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1005 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1006 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1007 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1008 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1009 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1010 | ) |
| 1011 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1012 | D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '*' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1013 | _res = _PyPegen_seq_append_to_end ( p , a , b ); |
| 1014 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1015 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1016 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1017 | return NULL; |
| 1018 | } |
| 1019 | goto done; |
| 1020 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1021 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1022 | D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 1023 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '*' expression")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1024 | } |
| 1025 | { // ','.expression+ ',' '**' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1026 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1027 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1028 | return NULL; |
| 1029 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1030 | D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '**' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1031 | Token * _literal; |
| 1032 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1033 | asdl_seq * a; |
| 1034 | expr_ty b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1035 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1036 | (a = _gather_7_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1037 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1038 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1039 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1040 | (_literal_1 = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1041 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1042 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1043 | ) |
| 1044 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1045 | D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+ ',' '**' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1046 | _res = _PyPegen_seq_append_to_end ( p , a , b ); |
| 1047 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1048 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1049 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1050 | return NULL; |
| 1051 | } |
| 1052 | goto done; |
| 1053 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1054 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1055 | D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 1056 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+ ',' '**' expression")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1057 | } |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1058 | { // '*' expression ',' '**' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1059 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1060 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1061 | return NULL; |
| 1062 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1063 | D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression ',' '**' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1064 | Token * _literal; |
| 1065 | Token * _literal_1; |
| 1066 | Token * _literal_2; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1067 | expr_ty a; |
| 1068 | expr_ty b; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1069 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1070 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1071 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1072 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1073 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1074 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1075 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1076 | (_literal_2 = _PyPegen_expect_token(p, 35)) // token='**' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1077 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1078 | (b = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1079 | ) |
| 1080 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1081 | D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression ',' '**' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1082 | _res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_singleton_seq ( p , a ) ) , b ); |
| 1083 | if (_res == NULL && PyErr_Occurred()) { |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1084 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1085 | D(p->level--); |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1086 | return NULL; |
| 1087 | } |
| 1088 | goto done; |
| 1089 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1090 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1091 | D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 1092 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression ',' '**' expression")); |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1093 | } |
| 1094 | { // '*' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1095 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1096 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1097 | return NULL; |
| 1098 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1099 | D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1100 | Token * _literal; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1101 | expr_ty a; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1102 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1103 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1104 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1105 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1106 | ) |
| 1107 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1108 | D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1109 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1110 | if (_res == NULL && PyErr_Occurred()) { |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1111 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1112 | D(p->level--); |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1113 | return NULL; |
| 1114 | } |
| 1115 | goto done; |
| 1116 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1117 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1118 | D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 1119 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression")); |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1120 | } |
| 1121 | { // '**' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1122 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1123 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1124 | return NULL; |
| 1125 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1126 | D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1127 | Token * _literal; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1128 | expr_ty a; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1129 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1130 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1131 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1132 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1133 | ) |
| 1134 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1135 | D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1136 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1137 | if (_res == NULL && PyErr_Occurred()) { |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1138 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1139 | D(p->level--); |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1140 | return NULL; |
| 1141 | } |
| 1142 | goto done; |
| 1143 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1144 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1145 | D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 1146 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' expression")); |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1147 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1148 | { // ','.expression+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1149 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1150 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1151 | return NULL; |
| 1152 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1153 | D(fprintf(stderr, "%*c> type_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.expression+")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1154 | asdl_seq * _gather_9_var; |
| 1155 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1156 | (_gather_9_var = _gather_9_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1157 | ) |
| 1158 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1159 | D(fprintf(stderr, "%*c+ type_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.expression+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1160 | _res = _gather_9_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1161 | goto done; |
| 1162 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1163 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1164 | D(fprintf(stderr, "%*c%s type_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 1165 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.expression+")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1166 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1167 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1168 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1169 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1170 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1171 | } |
| 1172 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1173 | // statements: statement+ |
| 1174 | static asdl_seq* |
| 1175 | statements_rule(Parser *p) |
| 1176 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1177 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1178 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1179 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1180 | return NULL; |
| 1181 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1182 | asdl_seq* _res = NULL; |
| 1183 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1184 | { // statement+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1185 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1186 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1187 | return NULL; |
| 1188 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1189 | D(fprintf(stderr, "%*c> statements[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1190 | asdl_seq * a; |
| 1191 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1192 | (a = _loop1_11_rule(p)) // statement+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1193 | ) |
| 1194 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1195 | D(fprintf(stderr, "%*c+ statements[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "statement+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1196 | _res = _PyPegen_seq_flatten ( p , a ); |
| 1197 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1198 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1199 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1200 | return NULL; |
| 1201 | } |
| 1202 | goto done; |
| 1203 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1204 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1205 | D(fprintf(stderr, "%*c%s statements[%d-%d]: %s failed!\n", p->level, ' ', |
| 1206 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1207 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1208 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1209 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1210 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1211 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1212 | } |
| 1213 | |
| 1214 | // statement: compound_stmt | simple_stmt |
| 1215 | static asdl_seq* |
| 1216 | statement_rule(Parser *p) |
| 1217 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1218 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1219 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1220 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1221 | return NULL; |
| 1222 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1223 | asdl_seq* _res = NULL; |
| 1224 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1225 | { // compound_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1226 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1227 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1228 | return NULL; |
| 1229 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1230 | D(fprintf(stderr, "%*c> statement[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compound_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1231 | stmt_ty a; |
| 1232 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1233 | (a = compound_stmt_rule(p)) // compound_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1234 | ) |
| 1235 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1236 | D(fprintf(stderr, "%*c+ statement[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "compound_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1237 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1238 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1239 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1240 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1241 | return NULL; |
| 1242 | } |
| 1243 | goto done; |
| 1244 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1245 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1246 | D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ', |
| 1247 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1248 | } |
| 1249 | { // simple_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1250 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1251 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1252 | return NULL; |
| 1253 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1254 | D(fprintf(stderr, "%*c> statement[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1255 | asdl_seq* simple_stmt_var; |
| 1256 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1257 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1258 | ) |
| 1259 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1260 | D(fprintf(stderr, "%*c+ statement[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1261 | _res = simple_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1262 | goto done; |
| 1263 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1264 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1265 | D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ', |
| 1266 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1267 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1268 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1269 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1270 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1271 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1272 | } |
| 1273 | |
| 1274 | // statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $ |
| 1275 | static asdl_seq* |
| 1276 | statement_newline_rule(Parser *p) |
| 1277 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1278 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1279 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1280 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1281 | return NULL; |
| 1282 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1283 | asdl_seq* _res = NULL; |
| 1284 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1285 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1286 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1287 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1288 | return NULL; |
| 1289 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1290 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1291 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1292 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1293 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1294 | { // compound_stmt NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1295 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1296 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1297 | return NULL; |
| 1298 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1299 | D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compound_stmt NEWLINE")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1300 | stmt_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1301 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1302 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1303 | (a = compound_stmt_rule(p)) // compound_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1304 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1305 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1306 | ) |
| 1307 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1308 | D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "compound_stmt NEWLINE")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1309 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1310 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1311 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1312 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1313 | return NULL; |
| 1314 | } |
| 1315 | goto done; |
| 1316 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1317 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1318 | D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ', |
| 1319 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt NEWLINE")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1320 | } |
| 1321 | { // simple_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1322 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1323 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1324 | return NULL; |
| 1325 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1326 | D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1327 | asdl_seq* simple_stmt_var; |
| 1328 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1329 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1330 | ) |
| 1331 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1332 | D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1333 | _res = simple_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1334 | goto done; |
| 1335 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1336 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1337 | D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ', |
| 1338 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1339 | } |
| 1340 | { // NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1341 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1342 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1343 | return NULL; |
| 1344 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1345 | D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1346 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1347 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1348 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1349 | ) |
| 1350 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1351 | D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1352 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1353 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1354 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1355 | return NULL; |
| 1356 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1357 | int _end_lineno = _token->end_lineno; |
| 1358 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1359 | int _end_col_offset = _token->end_col_offset; |
| 1360 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1361 | _res = _PyPegen_singleton_seq ( p , CHECK ( _Py_Pass ( EXTRA ) ) ); |
| 1362 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1363 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1364 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1365 | return NULL; |
| 1366 | } |
| 1367 | goto done; |
| 1368 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1369 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1370 | D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ', |
| 1371 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1372 | } |
| 1373 | { // $ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1374 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1375 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1376 | return NULL; |
| 1377 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1378 | D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "$")); |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1379 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1380 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1381 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1382 | ) |
| 1383 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1384 | D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "$")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1385 | _res = _PyPegen_interactive_exit ( p ); |
| 1386 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1387 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1388 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1389 | return NULL; |
| 1390 | } |
| 1391 | goto done; |
| 1392 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1393 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1394 | D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ', |
| 1395 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "$")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1396 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1397 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1398 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1399 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1400 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1401 | } |
| 1402 | |
| 1403 | // simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE |
| 1404 | static asdl_seq* |
| 1405 | simple_stmt_rule(Parser *p) |
| 1406 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1407 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1408 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1409 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1410 | return NULL; |
| 1411 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1412 | asdl_seq* _res = NULL; |
| 1413 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1414 | { // small_stmt !';' NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1415 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1416 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1417 | return NULL; |
| 1418 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1419 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "small_stmt !';' NEWLINE")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1420 | stmt_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1421 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1422 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1423 | (a = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1424 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1425 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1426 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1427 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1428 | ) |
| 1429 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1430 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "small_stmt !';' NEWLINE")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1431 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1432 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1433 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1434 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1435 | return NULL; |
| 1436 | } |
| 1437 | goto done; |
| 1438 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1439 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1440 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1441 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "small_stmt !';' NEWLINE")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1442 | } |
| 1443 | { // ';'.small_stmt+ ';'? NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1444 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1445 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1446 | return NULL; |
| 1447 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1448 | D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1449 | void *_opt_var; |
| 1450 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1451 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1452 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1453 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1454 | (a = _gather_12_rule(p)) // ';'.small_stmt+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1455 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1456 | (_opt_var = _PyPegen_expect_token(p, 13), 1) // ';'? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1457 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1458 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1459 | ) |
| 1460 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1461 | D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1462 | _res = a; |
| 1463 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1464 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1465 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1466 | return NULL; |
| 1467 | } |
| 1468 | goto done; |
| 1469 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1470 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1471 | D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1472 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1473 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1474 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1475 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1476 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1477 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1478 | } |
| 1479 | |
| 1480 | // small_stmt: |
| 1481 | // | assignment |
| 1482 | // | star_expressions |
| 1483 | // | &'return' return_stmt |
| 1484 | // | &('import' | 'from') import_stmt |
| 1485 | // | &'raise' raise_stmt |
| 1486 | // | 'pass' |
| 1487 | // | &'del' del_stmt |
| 1488 | // | &'yield' yield_stmt |
| 1489 | // | &'assert' assert_stmt |
| 1490 | // | 'break' |
| 1491 | // | 'continue' |
| 1492 | // | &'global' global_stmt |
| 1493 | // | &'nonlocal' nonlocal_stmt |
| 1494 | static stmt_ty |
| 1495 | small_stmt_rule(Parser *p) |
| 1496 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1497 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1498 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1499 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1500 | return NULL; |
| 1501 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1502 | stmt_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1503 | if (_PyPegen_is_memoized(p, small_stmt_type, &_res)) { |
| 1504 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1505 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1506 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1507 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1508 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1509 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1510 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1511 | return NULL; |
| 1512 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1513 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1514 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1515 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1516 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1517 | { // assignment |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1518 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1519 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1520 | return NULL; |
| 1521 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1522 | D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment")); |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 1523 | stmt_ty assignment_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1524 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1525 | (assignment_var = assignment_rule(p)) // assignment |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1526 | ) |
| 1527 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1528 | D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1529 | _res = assignment_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1530 | goto done; |
| 1531 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1532 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1533 | D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1534 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1535 | } |
| 1536 | { // star_expressions |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1537 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1538 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1539 | return NULL; |
| 1540 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1541 | D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1542 | expr_ty e; |
| 1543 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1544 | (e = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1545 | ) |
| 1546 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1547 | D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1548 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1549 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1550 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1551 | return NULL; |
| 1552 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1553 | int _end_lineno = _token->end_lineno; |
| 1554 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1555 | int _end_col_offset = _token->end_col_offset; |
| 1556 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1557 | _res = _Py_Expr ( e , EXTRA ); |
| 1558 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1559 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1560 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1561 | return NULL; |
| 1562 | } |
| 1563 | goto done; |
| 1564 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1565 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1566 | D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1567 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1568 | } |
| 1569 | { // &'return' return_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1570 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1571 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1572 | return NULL; |
| 1573 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1574 | D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1575 | stmt_ty return_stmt_var; |
| 1576 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1577 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1578 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1579 | (return_stmt_var = return_stmt_rule(p)) // return_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1580 | ) |
| 1581 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1582 | D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1583 | _res = return_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1584 | goto done; |
| 1585 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1586 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1587 | D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1588 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'return' return_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1589 | } |
| 1590 | { // &('import' | 'from') import_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1591 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1592 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1593 | return NULL; |
| 1594 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1595 | D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1596 | stmt_ty import_stmt_var; |
| 1597 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1598 | _PyPegen_lookahead(1, _tmp_14_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1599 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1600 | (import_stmt_var = import_stmt_rule(p)) // import_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1601 | ) |
| 1602 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1603 | D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1604 | _res = import_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1605 | goto done; |
| 1606 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1607 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1608 | D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1609 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('import' | 'from') import_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1610 | } |
| 1611 | { // &'raise' raise_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1612 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1613 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1614 | return NULL; |
| 1615 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1616 | D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1617 | stmt_ty raise_stmt_var; |
| 1618 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1619 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1620 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1621 | (raise_stmt_var = raise_stmt_rule(p)) // raise_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1622 | ) |
| 1623 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1624 | D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1625 | _res = raise_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1626 | goto done; |
| 1627 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1628 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1629 | D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1630 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'raise' raise_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1631 | } |
| 1632 | { // 'pass' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1633 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1634 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1635 | return NULL; |
| 1636 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1637 | D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'pass'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1638 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1639 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1640 | (_keyword = _PyPegen_expect_token(p, 502)) // token='pass' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1641 | ) |
| 1642 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1643 | D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'pass'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1644 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1645 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1646 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1647 | return NULL; |
| 1648 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1649 | int _end_lineno = _token->end_lineno; |
| 1650 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1651 | int _end_col_offset = _token->end_col_offset; |
| 1652 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1653 | _res = _Py_Pass ( EXTRA ); |
| 1654 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1655 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1656 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1657 | return NULL; |
| 1658 | } |
| 1659 | goto done; |
| 1660 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1661 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1662 | D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1663 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'pass'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1664 | } |
| 1665 | { // &'del' del_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1666 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1667 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1668 | return NULL; |
| 1669 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1670 | D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1671 | stmt_ty del_stmt_var; |
| 1672 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1673 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) // token='del' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1674 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1675 | (del_stmt_var = del_stmt_rule(p)) // del_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1676 | ) |
| 1677 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1678 | D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1679 | _res = del_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1680 | goto done; |
| 1681 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1682 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1683 | D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1684 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'del' del_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1685 | } |
| 1686 | { // &'yield' yield_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1687 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1688 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1689 | return NULL; |
| 1690 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1691 | D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1692 | stmt_ty yield_stmt_var; |
| 1693 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1694 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1695 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1696 | (yield_stmt_var = yield_stmt_rule(p)) // yield_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1697 | ) |
| 1698 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1699 | D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1700 | _res = yield_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1701 | goto done; |
| 1702 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1703 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1704 | D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1705 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'yield' yield_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1706 | } |
| 1707 | { // &'assert' assert_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1708 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1709 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1710 | return NULL; |
| 1711 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1712 | D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1713 | stmt_ty assert_stmt_var; |
| 1714 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1715 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) // token='assert' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1716 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1717 | (assert_stmt_var = assert_stmt_rule(p)) // assert_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1718 | ) |
| 1719 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1720 | D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1721 | _res = assert_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1722 | goto done; |
| 1723 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1724 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1725 | D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1726 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'assert' assert_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1727 | } |
| 1728 | { // 'break' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1729 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1730 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1731 | return NULL; |
| 1732 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1733 | D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'break'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1734 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1735 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1736 | (_keyword = _PyPegen_expect_token(p, 506)) // token='break' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1737 | ) |
| 1738 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1739 | D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'break'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1740 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1741 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1742 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1743 | return NULL; |
| 1744 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1745 | int _end_lineno = _token->end_lineno; |
| 1746 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1747 | int _end_col_offset = _token->end_col_offset; |
| 1748 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1749 | _res = _Py_Break ( EXTRA ); |
| 1750 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1751 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1752 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1753 | return NULL; |
| 1754 | } |
| 1755 | goto done; |
| 1756 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1757 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1758 | D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1759 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'break'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1760 | } |
| 1761 | { // 'continue' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1762 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1763 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1764 | return NULL; |
| 1765 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1766 | D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'continue'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1767 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1768 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1769 | (_keyword = _PyPegen_expect_token(p, 507)) // token='continue' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1770 | ) |
| 1771 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1772 | D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'continue'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1773 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1774 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1775 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1776 | return NULL; |
| 1777 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1778 | int _end_lineno = _token->end_lineno; |
| 1779 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1780 | int _end_col_offset = _token->end_col_offset; |
| 1781 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1782 | _res = _Py_Continue ( EXTRA ); |
| 1783 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1784 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1785 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1786 | return NULL; |
| 1787 | } |
| 1788 | goto done; |
| 1789 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1790 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1791 | D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1792 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'continue'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1793 | } |
| 1794 | { // &'global' global_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1795 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1796 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1797 | return NULL; |
| 1798 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1799 | D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1800 | stmt_ty global_stmt_var; |
| 1801 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1802 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1803 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1804 | (global_stmt_var = global_stmt_rule(p)) // global_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1805 | ) |
| 1806 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1807 | D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1808 | _res = global_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1809 | goto done; |
| 1810 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1811 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1812 | D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1813 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'global' global_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1814 | } |
| 1815 | { // &'nonlocal' nonlocal_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1816 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1817 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1818 | return NULL; |
| 1819 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1820 | D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1821 | stmt_ty nonlocal_stmt_var; |
| 1822 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1823 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1824 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1825 | (nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1826 | ) |
| 1827 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1828 | D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1829 | _res = nonlocal_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1830 | goto done; |
| 1831 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1832 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1833 | D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1834 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'nonlocal' nonlocal_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1835 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1836 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1837 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1838 | _PyPegen_insert_memo(p, _mark, small_stmt_type, _res); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1839 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1840 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1841 | } |
| 1842 | |
| 1843 | // compound_stmt: |
| 1844 | // | &('def' | '@' | ASYNC) function_def |
| 1845 | // | &'if' if_stmt |
| 1846 | // | &('class' | '@') class_def |
| 1847 | // | &('with' | ASYNC) with_stmt |
| 1848 | // | &('for' | ASYNC) for_stmt |
| 1849 | // | &'try' try_stmt |
| 1850 | // | &'while' while_stmt |
| 1851 | static stmt_ty |
| 1852 | compound_stmt_rule(Parser *p) |
| 1853 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1854 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1855 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1856 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1857 | return NULL; |
| 1858 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1859 | stmt_ty _res = NULL; |
| 1860 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1861 | { // &('def' | '@' | ASYNC) function_def |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1862 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1863 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1864 | return NULL; |
| 1865 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1866 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('def' | '@' | ASYNC) function_def")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1867 | stmt_ty function_def_var; |
| 1868 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1869 | _PyPegen_lookahead(1, _tmp_15_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1870 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1871 | (function_def_var = function_def_rule(p)) // function_def |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1872 | ) |
| 1873 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1874 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('def' | '@' | ASYNC) function_def")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1875 | _res = function_def_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1876 | goto done; |
| 1877 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1878 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1879 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1880 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('def' | '@' | ASYNC) function_def")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1881 | } |
| 1882 | { // &'if' if_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1883 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1884 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1885 | return NULL; |
| 1886 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1887 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'if' if_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1888 | stmt_ty if_stmt_var; |
| 1889 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1890 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 510) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1891 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1892 | (if_stmt_var = if_stmt_rule(p)) // if_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1893 | ) |
| 1894 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1895 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'if' if_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1896 | _res = if_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1897 | goto done; |
| 1898 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1899 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1900 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1901 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'if' if_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1902 | } |
| 1903 | { // &('class' | '@') class_def |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1904 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1905 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1906 | return NULL; |
| 1907 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1908 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('class' | '@') class_def")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1909 | stmt_ty class_def_var; |
| 1910 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1911 | _PyPegen_lookahead(1, _tmp_16_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1912 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1913 | (class_def_var = class_def_rule(p)) // class_def |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1914 | ) |
| 1915 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1916 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('class' | '@') class_def")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1917 | _res = class_def_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1918 | goto done; |
| 1919 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1920 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1921 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1922 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('class' | '@') class_def")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1923 | } |
| 1924 | { // &('with' | ASYNC) with_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1925 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1926 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1927 | return NULL; |
| 1928 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1929 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('with' | ASYNC) with_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1930 | stmt_ty with_stmt_var; |
| 1931 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1932 | _PyPegen_lookahead(1, _tmp_17_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1933 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1934 | (with_stmt_var = with_stmt_rule(p)) // with_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1935 | ) |
| 1936 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1937 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('with' | ASYNC) with_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1938 | _res = with_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1939 | goto done; |
| 1940 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1941 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1942 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1943 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('with' | ASYNC) with_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1944 | } |
| 1945 | { // &('for' | ASYNC) for_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1946 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1947 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1948 | return NULL; |
| 1949 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1950 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('for' | ASYNC) for_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1951 | stmt_ty for_stmt_var; |
| 1952 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1953 | _PyPegen_lookahead(1, _tmp_18_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1954 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1955 | (for_stmt_var = for_stmt_rule(p)) // for_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1956 | ) |
| 1957 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1958 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('for' | ASYNC) for_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1959 | _res = for_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1960 | goto done; |
| 1961 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1962 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1963 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1964 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('for' | ASYNC) for_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1965 | } |
| 1966 | { // &'try' try_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1967 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1968 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1969 | return NULL; |
| 1970 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1971 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'try' try_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1972 | stmt_ty try_stmt_var; |
| 1973 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1974 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 511) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1975 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1976 | (try_stmt_var = try_stmt_rule(p)) // try_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1977 | ) |
| 1978 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1979 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'try' try_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1980 | _res = try_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1981 | goto done; |
| 1982 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1983 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1984 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 1985 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'try' try_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1986 | } |
| 1987 | { // &'while' while_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1988 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1989 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1990 | return NULL; |
| 1991 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 1992 | D(fprintf(stderr, "%*c> compound_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'while' while_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1993 | stmt_ty while_stmt_var; |
| 1994 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1995 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 512) // token='while' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1996 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1997 | (while_stmt_var = while_stmt_rule(p)) // while_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1998 | ) |
| 1999 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2000 | D(fprintf(stderr, "%*c+ compound_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'while' while_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2001 | _res = while_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2002 | goto done; |
| 2003 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2004 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2005 | D(fprintf(stderr, "%*c%s compound_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2006 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'while' while_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2007 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2008 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2009 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2010 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2011 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2012 | } |
| 2013 | |
| 2014 | // assignment: |
| 2015 | // | NAME ':' expression ['=' annotated_rhs] |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 2016 | // | ('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs] |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 2017 | // | ((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT? |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 2018 | // | single_target augassign (yield_expr | star_expressions) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2019 | // | invalid_assignment |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 2020 | static stmt_ty |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2021 | assignment_rule(Parser *p) |
| 2022 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2023 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2024 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2025 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2026 | return NULL; |
| 2027 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2028 | stmt_ty _res = NULL; |
| 2029 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2030 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2031 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2032 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2033 | return NULL; |
| 2034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2035 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2036 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2037 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2038 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2039 | { // NAME ':' expression ['=' annotated_rhs] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2040 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2041 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2042 | return NULL; |
| 2043 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2044 | D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':' expression ['=' annotated_rhs]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2045 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2046 | expr_ty a; |
| 2047 | expr_ty b; |
| 2048 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2049 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2050 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2051 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2052 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2053 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2054 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2055 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2056 | (c = _tmp_19_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2057 | ) |
| 2058 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2059 | D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ':' expression ['=' annotated_rhs]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2060 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2061 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2062 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2063 | return NULL; |
| 2064 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2065 | int _end_lineno = _token->end_lineno; |
| 2066 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2067 | int _end_col_offset = _token->end_col_offset; |
| 2068 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2069 | _res = CHECK_VERSION ( 6 , "Variable annotation syntax is" , _Py_AnnAssign ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , c , 1 , EXTRA ) ); |
| 2070 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2071 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2072 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2073 | return NULL; |
| 2074 | } |
| 2075 | goto done; |
| 2076 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2077 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2078 | D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 2079 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':' expression ['=' annotated_rhs]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2080 | } |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 2081 | { // ('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2082 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2083 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2084 | return NULL; |
| 2085 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2086 | D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2087 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2088 | void *a; |
| 2089 | expr_ty b; |
| 2090 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2091 | if ( |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 2092 | (a = _tmp_20_rule(p)) // '(' single_target ')' | single_subscript_attribute_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2093 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2094 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2095 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2096 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2097 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2098 | (c = _tmp_21_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2099 | ) |
| 2100 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2101 | D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2102 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2103 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2104 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2105 | return NULL; |
| 2106 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2107 | int _end_lineno = _token->end_lineno; |
| 2108 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2109 | int _end_col_offset = _token->end_col_offset; |
| 2110 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2111 | _res = CHECK_VERSION ( 6 , "Variable annotations syntax is" , _Py_AnnAssign ( a , b , c , 0 , EXTRA ) ); |
| 2112 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2113 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2114 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2115 | return NULL; |
| 2116 | } |
| 2117 | goto done; |
| 2118 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2119 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2120 | D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 2121 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2122 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 2123 | { // ((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2124 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2125 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2126 | return NULL; |
| 2127 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 2128 | D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2129 | asdl_seq * a; |
| 2130 | void *b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2131 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2132 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2133 | (a = _loop1_22_rule(p)) // ((star_targets '='))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2134 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2135 | (b = _tmp_23_rule(p)) // yield_expr | star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2136 | && |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 2137 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 22) // token='=' |
| 2138 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2139 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2140 | ) |
| 2141 | { |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 2142 | D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2143 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2144 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2145 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2146 | return NULL; |
| 2147 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2148 | int _end_lineno = _token->end_lineno; |
| 2149 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2150 | int _end_col_offset = _token->end_col_offset; |
| 2151 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2152 | _res = _Py_Assign ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 2153 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2154 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2155 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2156 | return NULL; |
| 2157 | } |
| 2158 | goto done; |
| 2159 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2160 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2161 | D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 2162 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))+ (yield_expr | star_expressions) !'=' TYPE_COMMENT?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2163 | } |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 2164 | { // single_target augassign (yield_expr | star_expressions) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2165 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2166 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2167 | return NULL; |
| 2168 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2169 | D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_target augassign (yield_expr | star_expressions)")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2170 | expr_ty a; |
| 2171 | AugOperator* b; |
| 2172 | void *c; |
| 2173 | if ( |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 2174 | (a = single_target_rule(p)) // single_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2175 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2176 | (b = augassign_rule(p)) // augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2177 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2178 | (c = _tmp_24_rule(p)) // yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2179 | ) |
| 2180 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2181 | D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_target augassign (yield_expr | star_expressions)")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2182 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2183 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2184 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2185 | return NULL; |
| 2186 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2187 | int _end_lineno = _token->end_lineno; |
| 2188 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2189 | int _end_col_offset = _token->end_col_offset; |
| 2190 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2191 | _res = _Py_AugAssign ( a , b -> kind , c , EXTRA ); |
| 2192 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2193 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2194 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2195 | return NULL; |
| 2196 | } |
| 2197 | goto done; |
| 2198 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2199 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2200 | D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 2201 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_target augassign (yield_expr | star_expressions)")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2202 | } |
| 2203 | { // invalid_assignment |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2204 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2205 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2206 | return NULL; |
| 2207 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2208 | D(fprintf(stderr, "%*c> assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_assignment")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2209 | void *invalid_assignment_var; |
| 2210 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2211 | (invalid_assignment_var = invalid_assignment_rule(p)) // invalid_assignment |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2212 | ) |
| 2213 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2214 | D(fprintf(stderr, "%*c+ assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_assignment")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2215 | _res = invalid_assignment_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2216 | goto done; |
| 2217 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2218 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2219 | D(fprintf(stderr, "%*c%s assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 2220 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_assignment")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2221 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2222 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2223 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2224 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2225 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2226 | } |
| 2227 | |
| 2228 | // augassign: |
| 2229 | // | '+=' |
| 2230 | // | '-=' |
| 2231 | // | '*=' |
| 2232 | // | '@=' |
| 2233 | // | '/=' |
| 2234 | // | '%=' |
| 2235 | // | '&=' |
| 2236 | // | '|=' |
| 2237 | // | '^=' |
| 2238 | // | '<<=' |
| 2239 | // | '>>=' |
| 2240 | // | '**=' |
| 2241 | // | '//=' |
| 2242 | static AugOperator* |
| 2243 | augassign_rule(Parser *p) |
| 2244 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2245 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2246 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2247 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2248 | return NULL; |
| 2249 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2250 | AugOperator* _res = NULL; |
| 2251 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2252 | { // '+=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2253 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2254 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2255 | return NULL; |
| 2256 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2257 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2258 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2259 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2260 | (_literal = _PyPegen_expect_token(p, 36)) // token='+=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2261 | ) |
| 2262 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2263 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2264 | _res = _PyPegen_augoperator ( p , Add ); |
| 2265 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2266 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2267 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2268 | return NULL; |
| 2269 | } |
| 2270 | goto done; |
| 2271 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2272 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2273 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2274 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2275 | } |
| 2276 | { // '-=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2277 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2278 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2279 | return NULL; |
| 2280 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2281 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2282 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2283 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2284 | (_literal = _PyPegen_expect_token(p, 37)) // token='-=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2285 | ) |
| 2286 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2287 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2288 | _res = _PyPegen_augoperator ( p , Sub ); |
| 2289 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2290 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2291 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2292 | return NULL; |
| 2293 | } |
| 2294 | goto done; |
| 2295 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2296 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2297 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2298 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2299 | } |
| 2300 | { // '*=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2301 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2302 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2303 | return NULL; |
| 2304 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2305 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2306 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2307 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2308 | (_literal = _PyPegen_expect_token(p, 38)) // token='*=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2309 | ) |
| 2310 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2311 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2312 | _res = _PyPegen_augoperator ( p , Mult ); |
| 2313 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2314 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2315 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2316 | return NULL; |
| 2317 | } |
| 2318 | goto done; |
| 2319 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2320 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2321 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2322 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2323 | } |
| 2324 | { // '@=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2325 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2326 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2327 | return NULL; |
| 2328 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2329 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2330 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2331 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2332 | (_literal = _PyPegen_expect_token(p, 50)) // token='@=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2333 | ) |
| 2334 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2335 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2336 | _res = CHECK_VERSION ( 5 , "The '@' operator is" , _PyPegen_augoperator ( p , MatMult ) ); |
| 2337 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2338 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2339 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2340 | return NULL; |
| 2341 | } |
| 2342 | goto done; |
| 2343 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2344 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2345 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2346 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2347 | } |
| 2348 | { // '/=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2349 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2350 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2351 | return NULL; |
| 2352 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2353 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'/='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2354 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2355 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2356 | (_literal = _PyPegen_expect_token(p, 39)) // token='/=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2357 | ) |
| 2358 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2359 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'/='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2360 | _res = _PyPegen_augoperator ( p , Div ); |
| 2361 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2362 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2363 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2364 | return NULL; |
| 2365 | } |
| 2366 | goto done; |
| 2367 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2368 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2369 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2370 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'/='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2371 | } |
| 2372 | { // '%=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2373 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2374 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2375 | return NULL; |
| 2376 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2377 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'%='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2378 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2379 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2380 | (_literal = _PyPegen_expect_token(p, 40)) // token='%=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2381 | ) |
| 2382 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2383 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'%='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2384 | _res = _PyPegen_augoperator ( p , Mod ); |
| 2385 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2386 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2387 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2388 | return NULL; |
| 2389 | } |
| 2390 | goto done; |
| 2391 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2392 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2393 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2394 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'%='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2395 | } |
| 2396 | { // '&=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2397 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2398 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2399 | return NULL; |
| 2400 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2401 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'&='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2402 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2403 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2404 | (_literal = _PyPegen_expect_token(p, 41)) // token='&=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2405 | ) |
| 2406 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2407 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'&='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2408 | _res = _PyPegen_augoperator ( p , BitAnd ); |
| 2409 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2410 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2411 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2412 | return NULL; |
| 2413 | } |
| 2414 | goto done; |
| 2415 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2416 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2417 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2418 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'&='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2419 | } |
| 2420 | { // '|=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2421 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2422 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2423 | return NULL; |
| 2424 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2425 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'|='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2426 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2427 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2428 | (_literal = _PyPegen_expect_token(p, 42)) // token='|=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2429 | ) |
| 2430 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2431 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'|='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2432 | _res = _PyPegen_augoperator ( p , BitOr ); |
| 2433 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2434 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2435 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2436 | return NULL; |
| 2437 | } |
| 2438 | goto done; |
| 2439 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2440 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2441 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2442 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'|='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2443 | } |
| 2444 | { // '^=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2445 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2446 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2447 | return NULL; |
| 2448 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2449 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'^='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2450 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2451 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2452 | (_literal = _PyPegen_expect_token(p, 43)) // token='^=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2453 | ) |
| 2454 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2455 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'^='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2456 | _res = _PyPegen_augoperator ( p , BitXor ); |
| 2457 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2458 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2459 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2460 | return NULL; |
| 2461 | } |
| 2462 | goto done; |
| 2463 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2464 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2465 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2466 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'^='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2467 | } |
| 2468 | { // '<<=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2469 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2470 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2471 | return NULL; |
| 2472 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2473 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<<='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2474 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2475 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2476 | (_literal = _PyPegen_expect_token(p, 44)) // token='<<=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2477 | ) |
| 2478 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2479 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<<='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2480 | _res = _PyPegen_augoperator ( p , LShift ); |
| 2481 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2482 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2483 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2484 | return NULL; |
| 2485 | } |
| 2486 | goto done; |
| 2487 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2488 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2489 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2490 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<<='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2491 | } |
| 2492 | { // '>>=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2493 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2494 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2495 | return NULL; |
| 2496 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2497 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>>='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2498 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2499 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2500 | (_literal = _PyPegen_expect_token(p, 45)) // token='>>=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2501 | ) |
| 2502 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2503 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>>='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2504 | _res = _PyPegen_augoperator ( p , RShift ); |
| 2505 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2506 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2507 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2508 | return NULL; |
| 2509 | } |
| 2510 | goto done; |
| 2511 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2512 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2513 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2514 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>>='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2515 | } |
| 2516 | { // '**=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2517 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2518 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2519 | return NULL; |
| 2520 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2521 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2522 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2523 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2524 | (_literal = _PyPegen_expect_token(p, 46)) // token='**=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2525 | ) |
| 2526 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2527 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2528 | _res = _PyPegen_augoperator ( p , Pow ); |
| 2529 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2530 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2531 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2532 | return NULL; |
| 2533 | } |
| 2534 | goto done; |
| 2535 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2536 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2537 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2538 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2539 | } |
| 2540 | { // '//=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2541 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2542 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2543 | return NULL; |
| 2544 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2545 | D(fprintf(stderr, "%*c> augassign[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'//='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2546 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2547 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2548 | (_literal = _PyPegen_expect_token(p, 48)) // token='//=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2549 | ) |
| 2550 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2551 | D(fprintf(stderr, "%*c+ augassign[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'//='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2552 | _res = _PyPegen_augoperator ( p , FloorDiv ); |
| 2553 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2554 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2555 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2556 | return NULL; |
| 2557 | } |
| 2558 | goto done; |
| 2559 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2560 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2561 | D(fprintf(stderr, "%*c%s augassign[%d-%d]: %s failed!\n", p->level, ' ', |
| 2562 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'//='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2563 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2564 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2565 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2566 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2567 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2568 | } |
| 2569 | |
| 2570 | // global_stmt: 'global' ','.NAME+ |
| 2571 | static stmt_ty |
| 2572 | global_stmt_rule(Parser *p) |
| 2573 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2574 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2575 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2576 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2577 | return NULL; |
| 2578 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2579 | stmt_ty _res = NULL; |
| 2580 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2581 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2582 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2583 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2584 | return NULL; |
| 2585 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2586 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2587 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2588 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2589 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2590 | { // 'global' ','.NAME+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2591 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2592 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2593 | return NULL; |
| 2594 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2595 | D(fprintf(stderr, "%*c> global_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'global' ','.NAME+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2596 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2597 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2598 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2599 | (_keyword = _PyPegen_expect_token(p, 508)) // token='global' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2600 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2601 | (a = _gather_25_rule(p)) // ','.NAME+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2602 | ) |
| 2603 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2604 | D(fprintf(stderr, "%*c+ global_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'global' ','.NAME+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2605 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2606 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2607 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2608 | return NULL; |
| 2609 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2610 | int _end_lineno = _token->end_lineno; |
| 2611 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2612 | int _end_col_offset = _token->end_col_offset; |
| 2613 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2614 | _res = _Py_Global ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
| 2615 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2616 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2617 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2618 | return NULL; |
| 2619 | } |
| 2620 | goto done; |
| 2621 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2622 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2623 | D(fprintf(stderr, "%*c%s global_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2624 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'global' ','.NAME+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2625 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2626 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2627 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2628 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2629 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2630 | } |
| 2631 | |
| 2632 | // nonlocal_stmt: 'nonlocal' ','.NAME+ |
| 2633 | static stmt_ty |
| 2634 | nonlocal_stmt_rule(Parser *p) |
| 2635 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2636 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2637 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2638 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2639 | return NULL; |
| 2640 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2641 | stmt_ty _res = NULL; |
| 2642 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2643 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2644 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2645 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2646 | return NULL; |
| 2647 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2648 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2649 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2650 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2651 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2652 | { // 'nonlocal' ','.NAME+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2653 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2654 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2655 | return NULL; |
| 2656 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2657 | D(fprintf(stderr, "%*c> nonlocal_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'nonlocal' ','.NAME+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2658 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2659 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2660 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2661 | (_keyword = _PyPegen_expect_token(p, 509)) // token='nonlocal' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2662 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2663 | (a = _gather_27_rule(p)) // ','.NAME+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2664 | ) |
| 2665 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2666 | D(fprintf(stderr, "%*c+ nonlocal_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'nonlocal' ','.NAME+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2667 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2668 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2669 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2670 | return NULL; |
| 2671 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2672 | int _end_lineno = _token->end_lineno; |
| 2673 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2674 | int _end_col_offset = _token->end_col_offset; |
| 2675 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2676 | _res = _Py_Nonlocal ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
| 2677 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2678 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2679 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2680 | return NULL; |
| 2681 | } |
| 2682 | goto done; |
| 2683 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2684 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2685 | D(fprintf(stderr, "%*c%s nonlocal_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2686 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'nonlocal' ','.NAME+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2687 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2688 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2689 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2690 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2691 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2692 | } |
| 2693 | |
| 2694 | // yield_stmt: yield_expr |
| 2695 | static stmt_ty |
| 2696 | yield_stmt_rule(Parser *p) |
| 2697 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2698 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2699 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2700 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2701 | return NULL; |
| 2702 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2703 | stmt_ty _res = NULL; |
| 2704 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2705 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2706 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2707 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2708 | return NULL; |
| 2709 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2710 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2711 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2712 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2713 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2714 | { // yield_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2715 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2716 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2717 | return NULL; |
| 2718 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2719 | D(fprintf(stderr, "%*c> yield_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2720 | expr_ty y; |
| 2721 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2722 | (y = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2723 | ) |
| 2724 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2725 | D(fprintf(stderr, "%*c+ yield_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2726 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2727 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2728 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2729 | return NULL; |
| 2730 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2731 | int _end_lineno = _token->end_lineno; |
| 2732 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2733 | int _end_col_offset = _token->end_col_offset; |
| 2734 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2735 | _res = _Py_Expr ( y , EXTRA ); |
| 2736 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2737 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2738 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2739 | return NULL; |
| 2740 | } |
| 2741 | goto done; |
| 2742 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2743 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2744 | D(fprintf(stderr, "%*c%s yield_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2745 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2746 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2747 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2748 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2749 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2750 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2751 | } |
| 2752 | |
| 2753 | // assert_stmt: 'assert' expression [',' expression] |
| 2754 | static stmt_ty |
| 2755 | assert_stmt_rule(Parser *p) |
| 2756 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2757 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2758 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2759 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2760 | return NULL; |
| 2761 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2762 | stmt_ty _res = NULL; |
| 2763 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2764 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2765 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2766 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2767 | return NULL; |
| 2768 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2769 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2770 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2771 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2772 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2773 | { // 'assert' expression [',' expression] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2774 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2775 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2776 | return NULL; |
| 2777 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2778 | D(fprintf(stderr, "%*c> assert_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'assert' expression [',' expression]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2779 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2780 | expr_ty a; |
| 2781 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2782 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2783 | (_keyword = _PyPegen_expect_token(p, 505)) // token='assert' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2784 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2785 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2786 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2787 | (b = _tmp_29_rule(p), 1) // [',' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2788 | ) |
| 2789 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2790 | D(fprintf(stderr, "%*c+ assert_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'assert' expression [',' expression]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2791 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2792 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2793 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2794 | return NULL; |
| 2795 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2796 | int _end_lineno = _token->end_lineno; |
| 2797 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2798 | int _end_col_offset = _token->end_col_offset; |
| 2799 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2800 | _res = _Py_Assert ( a , b , EXTRA ); |
| 2801 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2802 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2803 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2804 | return NULL; |
| 2805 | } |
| 2806 | goto done; |
| 2807 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2808 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2809 | D(fprintf(stderr, "%*c%s assert_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2810 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'assert' expression [',' expression]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2811 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2812 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2813 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2814 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2815 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2816 | } |
| 2817 | |
| 2818 | // del_stmt: 'del' del_targets |
| 2819 | static stmt_ty |
| 2820 | del_stmt_rule(Parser *p) |
| 2821 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2822 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2823 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2824 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2825 | return NULL; |
| 2826 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2827 | stmt_ty _res = NULL; |
| 2828 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2829 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2830 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2831 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2832 | return NULL; |
| 2833 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2834 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2835 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2836 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2837 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2838 | { // 'del' del_targets |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2839 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2840 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2841 | return NULL; |
| 2842 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2843 | D(fprintf(stderr, "%*c> del_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'del' del_targets")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2844 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2845 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2846 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2847 | (_keyword = _PyPegen_expect_token(p, 503)) // token='del' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2848 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2849 | (a = del_targets_rule(p)) // del_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2850 | ) |
| 2851 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2852 | D(fprintf(stderr, "%*c+ del_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'del' del_targets")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2853 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2854 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2855 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2856 | return NULL; |
| 2857 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2858 | int _end_lineno = _token->end_lineno; |
| 2859 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2860 | int _end_col_offset = _token->end_col_offset; |
| 2861 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2862 | _res = _Py_Delete ( a , EXTRA ); |
| 2863 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2864 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2865 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2866 | return NULL; |
| 2867 | } |
| 2868 | goto done; |
| 2869 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2870 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2871 | D(fprintf(stderr, "%*c%s del_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2872 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'del' del_targets")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2873 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2874 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2875 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2876 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2877 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2878 | } |
| 2879 | |
| 2880 | // import_stmt: import_name | import_from |
| 2881 | static stmt_ty |
| 2882 | import_stmt_rule(Parser *p) |
| 2883 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2884 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2885 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2886 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2887 | return NULL; |
| 2888 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2889 | stmt_ty _res = NULL; |
| 2890 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2891 | { // import_name |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2892 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2893 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2894 | return NULL; |
| 2895 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2896 | D(fprintf(stderr, "%*c> import_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_name")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2897 | stmt_ty import_name_var; |
| 2898 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2899 | (import_name_var = import_name_rule(p)) // import_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2900 | ) |
| 2901 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2902 | D(fprintf(stderr, "%*c+ import_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_name")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2903 | _res = import_name_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2904 | goto done; |
| 2905 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2906 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2907 | D(fprintf(stderr, "%*c%s import_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2908 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_name")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2909 | } |
| 2910 | { // import_from |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2911 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2912 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2913 | return NULL; |
| 2914 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2915 | D(fprintf(stderr, "%*c> import_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2916 | stmt_ty import_from_var; |
| 2917 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2918 | (import_from_var = import_from_rule(p)) // import_from |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2919 | ) |
| 2920 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2921 | D(fprintf(stderr, "%*c+ import_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2922 | _res = import_from_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2923 | goto done; |
| 2924 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2925 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2926 | D(fprintf(stderr, "%*c%s import_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 2927 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2928 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2929 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2930 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2931 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2932 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2933 | } |
| 2934 | |
| 2935 | // import_name: 'import' dotted_as_names |
| 2936 | static stmt_ty |
| 2937 | import_name_rule(Parser *p) |
| 2938 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2939 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2940 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2941 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2942 | return NULL; |
| 2943 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2944 | stmt_ty _res = NULL; |
| 2945 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2946 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2947 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2948 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2949 | return NULL; |
| 2950 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2951 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2952 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2953 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2954 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2955 | { // 'import' dotted_as_names |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2956 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2957 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2958 | return NULL; |
| 2959 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2960 | D(fprintf(stderr, "%*c> import_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import' dotted_as_names")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2961 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2962 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2963 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2964 | (_keyword = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2965 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2966 | (a = dotted_as_names_rule(p)) // dotted_as_names |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2967 | ) |
| 2968 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2969 | D(fprintf(stderr, "%*c+ import_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import' dotted_as_names")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2970 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2971 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2972 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2973 | return NULL; |
| 2974 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2975 | int _end_lineno = _token->end_lineno; |
| 2976 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2977 | int _end_col_offset = _token->end_col_offset; |
| 2978 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2979 | _res = _Py_Import ( a , EXTRA ); |
| 2980 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2981 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2982 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2983 | return NULL; |
| 2984 | } |
| 2985 | goto done; |
| 2986 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2987 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2988 | D(fprintf(stderr, "%*c%s import_name[%d-%d]: %s failed!\n", p->level, ' ', |
| 2989 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import' dotted_as_names")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2990 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2991 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2992 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 2993 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2994 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2995 | } |
| 2996 | |
| 2997 | // import_from: |
| 2998 | // | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
| 2999 | // | 'from' (('.' | '...'))+ 'import' import_from_targets |
| 3000 | static stmt_ty |
| 3001 | import_from_rule(Parser *p) |
| 3002 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3003 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3004 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3005 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3006 | return NULL; |
| 3007 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3008 | stmt_ty _res = NULL; |
| 3009 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3010 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3011 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3012 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3013 | return NULL; |
| 3014 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3015 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3016 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3017 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3018 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3019 | { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3020 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3021 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3022 | return NULL; |
| 3023 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3024 | D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3025 | Token * _keyword; |
| 3026 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3027 | asdl_seq * a; |
| 3028 | expr_ty b; |
| 3029 | asdl_seq* c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3030 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3031 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3032 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3033 | (a = _loop0_30_rule(p)) // (('.' | '...'))* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3034 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3035 | (b = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3036 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3037 | (_keyword_1 = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3038 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3039 | (c = import_from_targets_rule(p)) // import_from_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3040 | ) |
| 3041 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3042 | D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3043 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3044 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3045 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3046 | return NULL; |
| 3047 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3048 | int _end_lineno = _token->end_lineno; |
| 3049 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3050 | int _end_col_offset = _token->end_col_offset; |
| 3051 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3052 | _res = _Py_ImportFrom ( b -> v . Name . id , c , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
| 3053 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3054 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3055 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3056 | return NULL; |
| 3057 | } |
| 3058 | goto done; |
| 3059 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3060 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3061 | D(fprintf(stderr, "%*c%s import_from[%d-%d]: %s failed!\n", p->level, ' ', |
| 3062 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' (('.' | '...'))* dotted_name 'import' import_from_targets")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3063 | } |
| 3064 | { // 'from' (('.' | '...'))+ 'import' import_from_targets |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3065 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3066 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3067 | return NULL; |
| 3068 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3069 | D(fprintf(stderr, "%*c> import_from[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3070 | Token * _keyword; |
| 3071 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3072 | asdl_seq * a; |
| 3073 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3074 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3075 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3076 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3077 | (a = _loop1_31_rule(p)) // (('.' | '...'))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3078 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3079 | (_keyword_1 = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3080 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3081 | (b = import_from_targets_rule(p)) // import_from_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3082 | ) |
| 3083 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3084 | D(fprintf(stderr, "%*c+ import_from[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3085 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3086 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3087 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3088 | return NULL; |
| 3089 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3090 | int _end_lineno = _token->end_lineno; |
| 3091 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3092 | int _end_col_offset = _token->end_col_offset; |
| 3093 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3094 | _res = _Py_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
| 3095 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3096 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3097 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3098 | return NULL; |
| 3099 | } |
| 3100 | goto done; |
| 3101 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3102 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3103 | D(fprintf(stderr, "%*c%s import_from[%d-%d]: %s failed!\n", p->level, ' ', |
| 3104 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' (('.' | '...'))+ 'import' import_from_targets")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3105 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3106 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3107 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3108 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3109 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3110 | } |
| 3111 | |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 3112 | // import_from_targets: |
| 3113 | // | '(' import_from_as_names ','? ')' |
| 3114 | // | import_from_as_names !',' |
| 3115 | // | '*' |
| 3116 | // | invalid_import_from_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3117 | static asdl_seq* |
| 3118 | import_from_targets_rule(Parser *p) |
| 3119 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3120 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3121 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3122 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3123 | return NULL; |
| 3124 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3125 | asdl_seq* _res = NULL; |
| 3126 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3127 | { // '(' import_from_as_names ','? ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3128 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3129 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3130 | return NULL; |
| 3131 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3132 | D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' import_from_as_names ','? ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3133 | Token * _literal; |
| 3134 | Token * _literal_1; |
| 3135 | void *_opt_var; |
| 3136 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3137 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3138 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3139 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3140 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3141 | (a = import_from_as_names_rule(p)) // import_from_as_names |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3142 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3143 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3144 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3145 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3146 | ) |
| 3147 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3148 | D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' import_from_as_names ','? ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3149 | _res = a; |
| 3150 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3151 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3152 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3153 | return NULL; |
| 3154 | } |
| 3155 | goto done; |
| 3156 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3157 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3158 | D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 3159 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' import_from_as_names ','? ')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3160 | } |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 3161 | { // import_from_as_names !',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3162 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3163 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3164 | return NULL; |
| 3165 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3166 | D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_names !','")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3167 | asdl_seq* import_from_as_names_var; |
| 3168 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3169 | (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 3170 | && |
| 3171 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3172 | ) |
| 3173 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3174 | D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_names !','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3175 | _res = import_from_as_names_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3176 | goto done; |
| 3177 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3178 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3179 | D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 3180 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_names !','")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3181 | } |
| 3182 | { // '*' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3183 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3184 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3185 | return NULL; |
| 3186 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3187 | D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3188 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3189 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3190 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3191 | ) |
| 3192 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3193 | D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3194 | _res = _PyPegen_singleton_seq ( p , CHECK ( _PyPegen_alias_for_star ( p ) ) ); |
| 3195 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3196 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3197 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3198 | return NULL; |
| 3199 | } |
| 3200 | goto done; |
| 3201 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3202 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3203 | D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 3204 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3205 | } |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 3206 | { // invalid_import_from_targets |
| 3207 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3208 | D(p->level--); |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 3209 | return NULL; |
| 3210 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3211 | D(fprintf(stderr, "%*c> import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_import_from_targets")); |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 3212 | void *invalid_import_from_targets_var; |
| 3213 | if ( |
| 3214 | (invalid_import_from_targets_var = invalid_import_from_targets_rule(p)) // invalid_import_from_targets |
| 3215 | ) |
| 3216 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3217 | D(fprintf(stderr, "%*c+ import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_import_from_targets")); |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 3218 | _res = invalid_import_from_targets_var; |
| 3219 | goto done; |
| 3220 | } |
| 3221 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3222 | D(fprintf(stderr, "%*c%s import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 3223 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_import_from_targets")); |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 3224 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3225 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3226 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3227 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3228 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3229 | } |
| 3230 | |
| 3231 | // import_from_as_names: ','.import_from_as_name+ |
| 3232 | static asdl_seq* |
| 3233 | import_from_as_names_rule(Parser *p) |
| 3234 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3235 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3236 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3237 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3238 | return NULL; |
| 3239 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3240 | asdl_seq* _res = NULL; |
| 3241 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3242 | { // ','.import_from_as_name+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3243 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3244 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3245 | return NULL; |
| 3246 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3247 | D(fprintf(stderr, "%*c> import_from_as_names[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.import_from_as_name+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3248 | asdl_seq * a; |
| 3249 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3250 | (a = _gather_32_rule(p)) // ','.import_from_as_name+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3251 | ) |
| 3252 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3253 | D(fprintf(stderr, "%*c+ import_from_as_names[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.import_from_as_name+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3254 | _res = a; |
| 3255 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3256 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3257 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3258 | return NULL; |
| 3259 | } |
| 3260 | goto done; |
| 3261 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3262 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3263 | D(fprintf(stderr, "%*c%s import_from_as_names[%d-%d]: %s failed!\n", p->level, ' ', |
| 3264 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.import_from_as_name+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3266 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3267 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3268 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3269 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3270 | } |
| 3271 | |
| 3272 | // import_from_as_name: NAME ['as' NAME] |
| 3273 | static alias_ty |
| 3274 | import_from_as_name_rule(Parser *p) |
| 3275 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3276 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3277 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3278 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3279 | return NULL; |
| 3280 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3281 | alias_ty _res = NULL; |
| 3282 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3283 | { // NAME ['as' NAME] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3284 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3285 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3286 | return NULL; |
| 3287 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3288 | D(fprintf(stderr, "%*c> import_from_as_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ['as' NAME]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3289 | expr_ty a; |
| 3290 | void *b; |
| 3291 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3292 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3293 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3294 | (b = _tmp_34_rule(p), 1) // ['as' NAME] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3295 | ) |
| 3296 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3297 | D(fprintf(stderr, "%*c+ import_from_as_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ['as' NAME]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3298 | _res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena ); |
| 3299 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3300 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3301 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3302 | return NULL; |
| 3303 | } |
| 3304 | goto done; |
| 3305 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3306 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3307 | D(fprintf(stderr, "%*c%s import_from_as_name[%d-%d]: %s failed!\n", p->level, ' ', |
| 3308 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ['as' NAME]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3309 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3310 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3311 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3312 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3313 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3314 | } |
| 3315 | |
| 3316 | // dotted_as_names: ','.dotted_as_name+ |
| 3317 | static asdl_seq* |
| 3318 | dotted_as_names_rule(Parser *p) |
| 3319 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3320 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3321 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3322 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3323 | return NULL; |
| 3324 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3325 | asdl_seq* _res = NULL; |
| 3326 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3327 | { // ','.dotted_as_name+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3328 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3329 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3330 | return NULL; |
| 3331 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3332 | D(fprintf(stderr, "%*c> dotted_as_names[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.dotted_as_name+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3333 | asdl_seq * a; |
| 3334 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3335 | (a = _gather_35_rule(p)) // ','.dotted_as_name+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3336 | ) |
| 3337 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3338 | D(fprintf(stderr, "%*c+ dotted_as_names[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.dotted_as_name+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3339 | _res = a; |
| 3340 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3341 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3342 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3343 | return NULL; |
| 3344 | } |
| 3345 | goto done; |
| 3346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3347 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3348 | D(fprintf(stderr, "%*c%s dotted_as_names[%d-%d]: %s failed!\n", p->level, ' ', |
| 3349 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.dotted_as_name+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3350 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3351 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3352 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3353 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3354 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3355 | } |
| 3356 | |
| 3357 | // dotted_as_name: dotted_name ['as' NAME] |
| 3358 | static alias_ty |
| 3359 | dotted_as_name_rule(Parser *p) |
| 3360 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3361 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3362 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3363 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3364 | return NULL; |
| 3365 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3366 | alias_ty _res = NULL; |
| 3367 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3368 | { // dotted_name ['as' NAME] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3369 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3370 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3371 | return NULL; |
| 3372 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3373 | D(fprintf(stderr, "%*c> dotted_as_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_name ['as' NAME]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3374 | expr_ty a; |
| 3375 | void *b; |
| 3376 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3377 | (a = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3378 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3379 | (b = _tmp_37_rule(p), 1) // ['as' NAME] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3380 | ) |
| 3381 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3382 | D(fprintf(stderr, "%*c+ dotted_as_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_name ['as' NAME]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3383 | _res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena ); |
| 3384 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3385 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3386 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3387 | return NULL; |
| 3388 | } |
| 3389 | goto done; |
| 3390 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3391 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3392 | D(fprintf(stderr, "%*c%s dotted_as_name[%d-%d]: %s failed!\n", p->level, ' ', |
| 3393 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_name ['as' NAME]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3394 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3395 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3396 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3397 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3398 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3399 | } |
| 3400 | |
| 3401 | // Left-recursive |
| 3402 | // dotted_name: dotted_name '.' NAME | NAME |
| 3403 | static expr_ty dotted_name_raw(Parser *); |
| 3404 | static expr_ty |
| 3405 | dotted_name_rule(Parser *p) |
| 3406 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3407 | D(p->level++); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3408 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3409 | if (_PyPegen_is_memoized(p, dotted_name_type, &_res)) { |
| 3410 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3411 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3412 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3413 | int _mark = p->mark; |
| 3414 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3415 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3416 | int tmpvar_0 = _PyPegen_update_memo(p, _mark, dotted_name_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3417 | if (tmpvar_0) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3418 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3419 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3420 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3421 | p->mark = _mark; |
| 3422 | void *_raw = dotted_name_raw(p); |
| 3423 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3424 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3425 | _resmark = p->mark; |
| 3426 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3427 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3428 | p->mark = _resmark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3429 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3430 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3431 | } |
| 3432 | static expr_ty |
| 3433 | dotted_name_raw(Parser *p) |
| 3434 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3435 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3436 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3437 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3438 | return NULL; |
| 3439 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3440 | expr_ty _res = NULL; |
| 3441 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3442 | { // dotted_name '.' NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3443 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3444 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3445 | return NULL; |
| 3446 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3447 | D(fprintf(stderr, "%*c> dotted_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_name '.' NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3448 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3449 | expr_ty a; |
| 3450 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3451 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3452 | (a = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3453 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3454 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3455 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3456 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3457 | ) |
| 3458 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3459 | D(fprintf(stderr, "%*c+ dotted_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_name '.' NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3460 | _res = _PyPegen_join_names_with_dot ( p , a , b ); |
| 3461 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3462 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3463 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3464 | return NULL; |
| 3465 | } |
| 3466 | goto done; |
| 3467 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3468 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3469 | D(fprintf(stderr, "%*c%s dotted_name[%d-%d]: %s failed!\n", p->level, ' ', |
| 3470 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_name '.' NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3471 | } |
| 3472 | { // NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3473 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3474 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3475 | return NULL; |
| 3476 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3477 | D(fprintf(stderr, "%*c> dotted_name[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3478 | expr_ty name_var; |
| 3479 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3480 | (name_var = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3481 | ) |
| 3482 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3483 | D(fprintf(stderr, "%*c+ dotted_name[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3484 | _res = name_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3485 | goto done; |
| 3486 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3487 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3488 | D(fprintf(stderr, "%*c%s dotted_name[%d-%d]: %s failed!\n", p->level, ' ', |
| 3489 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3490 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3491 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3492 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3493 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3494 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3495 | } |
| 3496 | |
| 3497 | // if_stmt: |
| 3498 | // | 'if' named_expression ':' block elif_stmt |
| 3499 | // | 'if' named_expression ':' block else_block? |
| 3500 | static stmt_ty |
| 3501 | if_stmt_rule(Parser *p) |
| 3502 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3503 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3504 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3505 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3506 | return NULL; |
| 3507 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3508 | stmt_ty _res = NULL; |
| 3509 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3510 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3511 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3512 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3513 | return NULL; |
| 3514 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3515 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3516 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3517 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3518 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3519 | { // 'if' named_expression ':' block elif_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3520 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3521 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3522 | return NULL; |
| 3523 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3524 | D(fprintf(stderr, "%*c> if_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block elif_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3525 | Token * _keyword; |
| 3526 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3527 | expr_ty a; |
| 3528 | asdl_seq* b; |
| 3529 | stmt_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3530 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3531 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3532 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3533 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3534 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3535 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3536 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3537 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3538 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3539 | (c = elif_stmt_rule(p)) // elif_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3540 | ) |
| 3541 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3542 | D(fprintf(stderr, "%*c+ if_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block elif_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3543 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3544 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3545 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3546 | return NULL; |
| 3547 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3548 | int _end_lineno = _token->end_lineno; |
| 3549 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3550 | int _end_col_offset = _token->end_col_offset; |
| 3551 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3552 | _res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
| 3553 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3554 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3555 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3556 | return NULL; |
| 3557 | } |
| 3558 | goto done; |
| 3559 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3560 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3561 | D(fprintf(stderr, "%*c%s if_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 3562 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression ':' block elif_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3563 | } |
| 3564 | { // 'if' named_expression ':' block else_block? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3565 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3566 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3567 | return NULL; |
| 3568 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3569 | D(fprintf(stderr, "%*c> if_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block else_block?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3570 | Token * _keyword; |
| 3571 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3572 | expr_ty a; |
| 3573 | asdl_seq* b; |
| 3574 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3575 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3576 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3577 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3578 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3579 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3580 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3581 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3582 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3583 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3584 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3585 | ) |
| 3586 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3587 | D(fprintf(stderr, "%*c+ if_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' named_expression ':' block else_block?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3588 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3589 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3590 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3591 | return NULL; |
| 3592 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3593 | int _end_lineno = _token->end_lineno; |
| 3594 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3595 | int _end_col_offset = _token->end_col_offset; |
| 3596 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3597 | _res = _Py_If ( a , b , c , EXTRA ); |
| 3598 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3599 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3600 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3601 | return NULL; |
| 3602 | } |
| 3603 | goto done; |
| 3604 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3605 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3606 | D(fprintf(stderr, "%*c%s if_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 3607 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' named_expression ':' block else_block?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3608 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3609 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3610 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3611 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3612 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3613 | } |
| 3614 | |
| 3615 | // elif_stmt: |
| 3616 | // | 'elif' named_expression ':' block elif_stmt |
| 3617 | // | 'elif' named_expression ':' block else_block? |
| 3618 | static stmt_ty |
| 3619 | elif_stmt_rule(Parser *p) |
| 3620 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3621 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3622 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3623 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3624 | return NULL; |
| 3625 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3626 | stmt_ty _res = NULL; |
| 3627 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3628 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3629 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3630 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3631 | return NULL; |
| 3632 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3633 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3634 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3635 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3636 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3637 | { // 'elif' named_expression ':' block elif_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3638 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3639 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3640 | return NULL; |
| 3641 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3642 | D(fprintf(stderr, "%*c> elif_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block elif_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3643 | Token * _keyword; |
| 3644 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3645 | expr_ty a; |
| 3646 | asdl_seq* b; |
| 3647 | stmt_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3648 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3649 | (_keyword = _PyPegen_expect_token(p, 515)) // token='elif' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3650 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3651 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3652 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3653 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3654 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3655 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3656 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3657 | (c = elif_stmt_rule(p)) // elif_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3658 | ) |
| 3659 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3660 | D(fprintf(stderr, "%*c+ elif_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block elif_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3661 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3662 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3663 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3664 | return NULL; |
| 3665 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3666 | int _end_lineno = _token->end_lineno; |
| 3667 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3668 | int _end_col_offset = _token->end_col_offset; |
| 3669 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3670 | _res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
| 3671 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3672 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3673 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3674 | return NULL; |
| 3675 | } |
| 3676 | goto done; |
| 3677 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3678 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3679 | D(fprintf(stderr, "%*c%s elif_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 3680 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'elif' named_expression ':' block elif_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3681 | } |
| 3682 | { // 'elif' named_expression ':' block else_block? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3683 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3684 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3685 | return NULL; |
| 3686 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3687 | D(fprintf(stderr, "%*c> elif_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block else_block?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3688 | Token * _keyword; |
| 3689 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3690 | expr_ty a; |
| 3691 | asdl_seq* b; |
| 3692 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3693 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3694 | (_keyword = _PyPegen_expect_token(p, 515)) // token='elif' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3695 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3696 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3697 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3698 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3699 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3700 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3701 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3702 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3703 | ) |
| 3704 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3705 | D(fprintf(stderr, "%*c+ elif_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'elif' named_expression ':' block else_block?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3706 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3707 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3708 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3709 | return NULL; |
| 3710 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3711 | int _end_lineno = _token->end_lineno; |
| 3712 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3713 | int _end_col_offset = _token->end_col_offset; |
| 3714 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3715 | _res = _Py_If ( a , b , c , EXTRA ); |
| 3716 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3717 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3718 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3719 | return NULL; |
| 3720 | } |
| 3721 | goto done; |
| 3722 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3723 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3724 | D(fprintf(stderr, "%*c%s elif_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 3725 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'elif' named_expression ':' block else_block?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3726 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3727 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3728 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3729 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3730 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3731 | } |
| 3732 | |
| 3733 | // else_block: 'else' ':' block |
| 3734 | static asdl_seq* |
| 3735 | else_block_rule(Parser *p) |
| 3736 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3737 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3738 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3739 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3740 | return NULL; |
| 3741 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3742 | asdl_seq* _res = NULL; |
| 3743 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3744 | { // 'else' ':' block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3745 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3746 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3747 | return NULL; |
| 3748 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3749 | D(fprintf(stderr, "%*c> else_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'else' ':' block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3750 | Token * _keyword; |
| 3751 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3752 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3753 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3754 | (_keyword = _PyPegen_expect_token(p, 516)) // token='else' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3755 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3756 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3757 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3758 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3759 | ) |
| 3760 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3761 | D(fprintf(stderr, "%*c+ else_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'else' ':' block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3762 | _res = b; |
| 3763 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3764 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3765 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3766 | return NULL; |
| 3767 | } |
| 3768 | goto done; |
| 3769 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3770 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3771 | D(fprintf(stderr, "%*c%s else_block[%d-%d]: %s failed!\n", p->level, ' ', |
| 3772 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'else' ':' block")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3773 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3774 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3775 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3776 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3777 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3778 | } |
| 3779 | |
| 3780 | // while_stmt: 'while' named_expression ':' block else_block? |
| 3781 | static stmt_ty |
| 3782 | while_stmt_rule(Parser *p) |
| 3783 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3784 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3785 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3786 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3787 | return NULL; |
| 3788 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3789 | stmt_ty _res = NULL; |
| 3790 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3791 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3792 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3793 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3794 | return NULL; |
| 3795 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3796 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3797 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3798 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3799 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3800 | { // 'while' named_expression ':' block else_block? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3801 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3802 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3803 | return NULL; |
| 3804 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3805 | D(fprintf(stderr, "%*c> while_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'while' named_expression ':' block else_block?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3806 | Token * _keyword; |
| 3807 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3808 | expr_ty a; |
| 3809 | asdl_seq* b; |
| 3810 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3811 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3812 | (_keyword = _PyPegen_expect_token(p, 512)) // token='while' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3813 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3814 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3815 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3816 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3817 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3818 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3819 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3820 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3821 | ) |
| 3822 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3823 | D(fprintf(stderr, "%*c+ while_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'while' named_expression ':' block else_block?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3824 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3825 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3826 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3827 | return NULL; |
| 3828 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3829 | int _end_lineno = _token->end_lineno; |
| 3830 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3831 | int _end_col_offset = _token->end_col_offset; |
| 3832 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3833 | _res = _Py_While ( a , b , c , EXTRA ); |
| 3834 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3835 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3836 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3837 | return NULL; |
| 3838 | } |
| 3839 | goto done; |
| 3840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3841 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3842 | D(fprintf(stderr, "%*c%s while_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 3843 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'while' named_expression ':' block else_block?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3844 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3845 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3846 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3847 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3848 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3849 | } |
| 3850 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3851 | // for_stmt: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3852 | // | 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
| 3853 | // | ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3854 | static stmt_ty |
| 3855 | for_stmt_rule(Parser *p) |
| 3856 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3857 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3858 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3859 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3860 | return NULL; |
| 3861 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3862 | stmt_ty _res = NULL; |
| 3863 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3864 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3865 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3866 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3867 | return NULL; |
| 3868 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3869 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3870 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3871 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3872 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3873 | { // 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3874 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3875 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3876 | return NULL; |
| 3877 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3878 | 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?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3879 | Token * _keyword; |
| 3880 | Token * _keyword_1; |
| 3881 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3882 | asdl_seq* b; |
| 3883 | void *el; |
| 3884 | expr_ty ex; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3885 | expr_ty t; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3886 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3887 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3888 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3889 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3890 | (t = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3891 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3892 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3893 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3894 | (ex = star_expressions_rule(p)) // star_expressions |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3895 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3896 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3897 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3898 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3899 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3900 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3901 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3902 | (el = else_block_rule(p), 1) // else_block? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3903 | ) |
| 3904 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3905 | 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 | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3906 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3907 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3908 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3909 | return NULL; |
| 3910 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3911 | int _end_lineno = _token->end_lineno; |
| 3912 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3913 | int _end_col_offset = _token->end_col_offset; |
| 3914 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3915 | _res = _Py_For ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 3916 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3917 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3918 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3919 | return NULL; |
| 3920 | } |
| 3921 | goto done; |
| 3922 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3923 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3924 | D(fprintf(stderr, "%*c%s for_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 3925 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3926 | } |
| 3927 | { // ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3928 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3929 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3930 | return NULL; |
| 3931 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3932 | 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?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3933 | Token * _keyword; |
| 3934 | Token * _keyword_1; |
| 3935 | Token * _literal; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3936 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3937 | asdl_seq* b; |
| 3938 | void *el; |
| 3939 | expr_ty ex; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3940 | expr_ty t; |
| 3941 | void *tc; |
| 3942 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3943 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3944 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3945 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3946 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3947 | (t = star_targets_rule(p)) // star_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3948 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3949 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3950 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3951 | (ex = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3952 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3953 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3954 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3955 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3956 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3957 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3958 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3959 | (el = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3960 | ) |
| 3961 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3962 | 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 | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3963 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3964 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3965 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3966 | return NULL; |
| 3967 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3968 | int _end_lineno = _token->end_lineno; |
| 3969 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3970 | int _end_col_offset = _token->end_col_offset; |
| 3971 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3972 | _res = CHECK_VERSION ( 5 , "Async for loops are" , _Py_AsyncFor ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
| 3973 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3974 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3975 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3976 | return NULL; |
| 3977 | } |
| 3978 | goto done; |
| 3979 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3980 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3981 | D(fprintf(stderr, "%*c%s for_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 3982 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3984 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3985 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3986 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3987 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3988 | } |
| 3989 | |
| 3990 | // with_stmt: |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3991 | // | 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3992 | // | 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3993 | // | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3994 | // | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3995 | static stmt_ty |
| 3996 | with_stmt_rule(Parser *p) |
| 3997 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 3998 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3999 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4000 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4001 | return NULL; |
| 4002 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4003 | stmt_ty _res = NULL; |
| 4004 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4005 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4006 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4007 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4008 | return NULL; |
| 4009 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4010 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4011 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4012 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4013 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 4014 | { // 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4015 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4016 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4017 | return NULL; |
| 4018 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4019 | D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with' '(' ','.with_item+ ','? ')' ':' block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4020 | Token * _keyword; |
| 4021 | Token * _literal; |
| 4022 | Token * _literal_1; |
| 4023 | Token * _literal_2; |
| 4024 | void *_opt_var; |
| 4025 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4026 | asdl_seq * a; |
| 4027 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4028 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4029 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4030 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4031 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4032 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4033 | (a = _gather_38_rule(p)) // ','.with_item+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4034 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4035 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 4036 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4037 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4038 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4039 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4040 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4041 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4042 | ) |
| 4043 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4044 | D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with' '(' ','.with_item+ ','? ')' ':' block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4045 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4046 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4047 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4048 | return NULL; |
| 4049 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4050 | int _end_lineno = _token->end_lineno; |
| 4051 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4052 | int _end_col_offset = _token->end_col_offset; |
| 4053 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4054 | _res = _Py_With ( a , b , NULL , EXTRA ); |
| 4055 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4056 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4057 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4058 | return NULL; |
| 4059 | } |
| 4060 | goto done; |
| 4061 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4062 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4063 | D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4064 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with' '(' ','.with_item+ ','? ')' ':' block")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4065 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4066 | { // 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4067 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4068 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4069 | return NULL; |
| 4070 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4071 | D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with' ','.with_item+ ':' TYPE_COMMENT? block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4072 | Token * _keyword; |
| 4073 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4074 | asdl_seq * a; |
| 4075 | asdl_seq* b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4076 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4077 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4078 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4079 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4080 | (a = _gather_40_rule(p)) // ','.with_item+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4081 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4082 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4083 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4084 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4085 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4086 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4087 | ) |
| 4088 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4089 | D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with' ','.with_item+ ':' TYPE_COMMENT? block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4090 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4091 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4092 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4093 | return NULL; |
| 4094 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4095 | int _end_lineno = _token->end_lineno; |
| 4096 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4097 | int _end_col_offset = _token->end_col_offset; |
| 4098 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4099 | _res = _Py_With ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 4100 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4101 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4102 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4103 | return NULL; |
| 4104 | } |
| 4105 | goto done; |
| 4106 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4107 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4108 | D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4109 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with' ','.with_item+ ':' TYPE_COMMENT? block")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4110 | } |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 4111 | { // ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4112 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4113 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4114 | return NULL; |
| 4115 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4116 | D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4117 | Token * _keyword; |
| 4118 | Token * _literal; |
| 4119 | Token * _literal_1; |
| 4120 | Token * _literal_2; |
| 4121 | void *_opt_var; |
| 4122 | UNUSED(_opt_var); // Silence compiler warnings |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4123 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4124 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4125 | asdl_seq* b; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4126 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4127 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4128 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4129 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4130 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4131 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4132 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4133 | (a = _gather_42_rule(p)) // ','.with_item+ |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4134 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4135 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 4136 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4137 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4138 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4139 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4140 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4141 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4142 | ) |
| 4143 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4144 | D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4145 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4146 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4147 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4148 | return NULL; |
| 4149 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4150 | int _end_lineno = _token->end_lineno; |
| 4151 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4152 | int _end_col_offset = _token->end_col_offset; |
| 4153 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4154 | _res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NULL , EXTRA ) ); |
| 4155 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4156 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4157 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4158 | return NULL; |
| 4159 | } |
| 4160 | goto done; |
| 4161 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4162 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4163 | D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4164 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4165 | } |
| 4166 | { // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4167 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4168 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4169 | return NULL; |
| 4170 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4171 | D(fprintf(stderr, "%*c> with_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4172 | Token * _keyword; |
| 4173 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4174 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4175 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4176 | asdl_seq* b; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4177 | void *tc; |
| 4178 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4179 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4180 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4181 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4182 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4183 | (a = _gather_44_rule(p)) // ','.with_item+ |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4184 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4185 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4186 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4187 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4188 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4189 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4190 | ) |
| 4191 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4192 | D(fprintf(stderr, "%*c+ with_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4193 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4194 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4195 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4196 | return NULL; |
| 4197 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4198 | int _end_lineno = _token->end_lineno; |
| 4199 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4200 | int _end_col_offset = _token->end_col_offset; |
| 4201 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4202 | _res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
| 4203 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4204 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4205 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4206 | return NULL; |
| 4207 | } |
| 4208 | goto done; |
| 4209 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4210 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4211 | D(fprintf(stderr, "%*c%s with_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4212 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4213 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4214 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4215 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4216 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4217 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4218 | } |
| 4219 | |
| 4220 | // with_item: expression ['as' target] |
| 4221 | static withitem_ty |
| 4222 | with_item_rule(Parser *p) |
| 4223 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4224 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4225 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4226 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4227 | return NULL; |
| 4228 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4229 | withitem_ty _res = NULL; |
| 4230 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4231 | { // expression ['as' target] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4232 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4233 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4234 | return NULL; |
| 4235 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4236 | D(fprintf(stderr, "%*c> with_item[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ['as' target]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4237 | expr_ty e; |
| 4238 | void *o; |
| 4239 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4240 | (e = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4241 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4242 | (o = _tmp_46_rule(p), 1) // ['as' target] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4243 | ) |
| 4244 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4245 | D(fprintf(stderr, "%*c+ with_item[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ['as' target]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4246 | _res = _Py_withitem ( e , o , p -> arena ); |
| 4247 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4248 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4249 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4250 | return NULL; |
| 4251 | } |
| 4252 | goto done; |
| 4253 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4254 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4255 | D(fprintf(stderr, "%*c%s with_item[%d-%d]: %s failed!\n", p->level, ' ', |
| 4256 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ['as' target]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4257 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4258 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4259 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4260 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4261 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4262 | } |
| 4263 | |
| 4264 | // try_stmt: |
| 4265 | // | 'try' ':' block finally_block |
| 4266 | // | 'try' ':' block except_block+ else_block? finally_block? |
| 4267 | static stmt_ty |
| 4268 | try_stmt_rule(Parser *p) |
| 4269 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4270 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4271 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4272 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4273 | return NULL; |
| 4274 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4275 | stmt_ty _res = NULL; |
| 4276 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4277 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4278 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4279 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4280 | return NULL; |
| 4281 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4282 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4283 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4284 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4285 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4286 | { // 'try' ':' block finally_block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4287 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4288 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4289 | return NULL; |
| 4290 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4291 | D(fprintf(stderr, "%*c> try_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'try' ':' block finally_block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4292 | Token * _keyword; |
| 4293 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4294 | asdl_seq* b; |
| 4295 | asdl_seq* f; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4296 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4297 | (_keyword = _PyPegen_expect_token(p, 511)) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4298 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4299 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4300 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4301 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4302 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4303 | (f = finally_block_rule(p)) // finally_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4304 | ) |
| 4305 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4306 | D(fprintf(stderr, "%*c+ try_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'try' ':' block finally_block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4307 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4308 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4309 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4310 | return NULL; |
| 4311 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4312 | int _end_lineno = _token->end_lineno; |
| 4313 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4314 | int _end_col_offset = _token->end_col_offset; |
| 4315 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4316 | _res = _Py_Try ( b , NULL , NULL , f , EXTRA ); |
| 4317 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4318 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4319 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4320 | return NULL; |
| 4321 | } |
| 4322 | goto done; |
| 4323 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4324 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4325 | D(fprintf(stderr, "%*c%s try_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4326 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' ':' block finally_block")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4327 | } |
| 4328 | { // 'try' ':' block except_block+ else_block? finally_block? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4329 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4330 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4331 | return NULL; |
| 4332 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4333 | 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 | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4334 | Token * _keyword; |
| 4335 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4336 | asdl_seq* b; |
| 4337 | void *el; |
| 4338 | asdl_seq * ex; |
| 4339 | void *f; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4340 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4341 | (_keyword = _PyPegen_expect_token(p, 511)) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4342 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4343 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4344 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4345 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4346 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4347 | (ex = _loop1_47_rule(p)) // except_block+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4348 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4349 | (el = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4350 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4351 | (f = finally_block_rule(p), 1) // finally_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4352 | ) |
| 4353 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4354 | 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 | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4355 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4356 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4357 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4358 | return NULL; |
| 4359 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4360 | int _end_lineno = _token->end_lineno; |
| 4361 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4362 | int _end_col_offset = _token->end_col_offset; |
| 4363 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4364 | _res = _Py_Try ( b , ex , el , f , EXTRA ); |
| 4365 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4366 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4367 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4368 | return NULL; |
| 4369 | } |
| 4370 | goto done; |
| 4371 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4372 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4373 | D(fprintf(stderr, "%*c%s try_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4374 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'try' ':' block except_block+ else_block? finally_block?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4375 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4376 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4377 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4378 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4379 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4380 | } |
| 4381 | |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 4382 | // except_block: 'except' expression ['as' NAME] ':' block | 'except' ':' block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4383 | static excepthandler_ty |
| 4384 | except_block_rule(Parser *p) |
| 4385 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4386 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4387 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4388 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4389 | return NULL; |
| 4390 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4391 | excepthandler_ty _res = NULL; |
| 4392 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4393 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4394 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4395 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4396 | return NULL; |
| 4397 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4398 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4399 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4400 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4401 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 4402 | { // 'except' expression ['as' NAME] ':' block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4403 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4404 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4405 | return NULL; |
| 4406 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4407 | D(fprintf(stderr, "%*c> except_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] ':' block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4408 | Token * _keyword; |
| 4409 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4410 | asdl_seq* b; |
| 4411 | expr_ty e; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4412 | void *t; |
| 4413 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4414 | (_keyword = _PyPegen_expect_token(p, 520)) // token='except' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4415 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4416 | (e = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4417 | && |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 4418 | (t = _tmp_48_rule(p), 1) // ['as' NAME] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4419 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4420 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4421 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4422 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4423 | ) |
| 4424 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4425 | D(fprintf(stderr, "%*c+ except_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression ['as' NAME] ':' block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4426 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4427 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4428 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4429 | return NULL; |
| 4430 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4431 | int _end_lineno = _token->end_lineno; |
| 4432 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4433 | int _end_col_offset = _token->end_col_offset; |
| 4434 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4435 | _res = _Py_ExceptHandler ( e , ( t ) ? ( ( expr_ty ) t ) -> v . Name . id : NULL , b , EXTRA ); |
| 4436 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4437 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4438 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4439 | return NULL; |
| 4440 | } |
| 4441 | goto done; |
| 4442 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4443 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4444 | D(fprintf(stderr, "%*c%s except_block[%d-%d]: %s failed!\n", p->level, ' ', |
| 4445 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' expression ['as' NAME] ':' block")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4446 | } |
| 4447 | { // 'except' ':' block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4448 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4449 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4450 | return NULL; |
| 4451 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4452 | D(fprintf(stderr, "%*c> except_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'except' ':' block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4453 | Token * _keyword; |
| 4454 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4455 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4456 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4457 | (_keyword = _PyPegen_expect_token(p, 520)) // token='except' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4458 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4459 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4460 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4461 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4462 | ) |
| 4463 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4464 | D(fprintf(stderr, "%*c+ except_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' ':' block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4465 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4466 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4467 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4468 | return NULL; |
| 4469 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4470 | int _end_lineno = _token->end_lineno; |
| 4471 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4472 | int _end_col_offset = _token->end_col_offset; |
| 4473 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4474 | _res = _Py_ExceptHandler ( NULL , NULL , b , EXTRA ); |
| 4475 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4476 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4477 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4478 | return NULL; |
| 4479 | } |
| 4480 | goto done; |
| 4481 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4482 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4483 | D(fprintf(stderr, "%*c%s except_block[%d-%d]: %s failed!\n", p->level, ' ', |
| 4484 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'except' ':' block")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4485 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4486 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4487 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4488 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4489 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4490 | } |
| 4491 | |
| 4492 | // finally_block: 'finally' ':' block |
| 4493 | static asdl_seq* |
| 4494 | finally_block_rule(Parser *p) |
| 4495 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4496 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4497 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4498 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4499 | return NULL; |
| 4500 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4501 | asdl_seq* _res = NULL; |
| 4502 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4503 | { // 'finally' ':' block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4504 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4505 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4506 | return NULL; |
| 4507 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4508 | D(fprintf(stderr, "%*c> finally_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'finally' ':' block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4509 | Token * _keyword; |
| 4510 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4511 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4512 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4513 | (_keyword = _PyPegen_expect_token(p, 521)) // token='finally' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4514 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4515 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4516 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4517 | (a = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4518 | ) |
| 4519 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4520 | D(fprintf(stderr, "%*c+ finally_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'finally' ':' block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4521 | _res = a; |
| 4522 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4523 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4524 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4525 | return NULL; |
| 4526 | } |
| 4527 | goto done; |
| 4528 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4529 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4530 | D(fprintf(stderr, "%*c%s finally_block[%d-%d]: %s failed!\n", p->level, ' ', |
| 4531 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'finally' ':' block")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4532 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4533 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4534 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4535 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4536 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4537 | } |
| 4538 | |
| 4539 | // return_stmt: 'return' star_expressions? |
| 4540 | static stmt_ty |
| 4541 | return_stmt_rule(Parser *p) |
| 4542 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4543 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4544 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4545 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4546 | return NULL; |
| 4547 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4548 | stmt_ty _res = NULL; |
| 4549 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4550 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4551 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4552 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4553 | return NULL; |
| 4554 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4555 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4556 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4557 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4558 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4559 | { // 'return' star_expressions? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4560 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4561 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4562 | return NULL; |
| 4563 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4564 | D(fprintf(stderr, "%*c> return_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4565 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4566 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4567 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4568 | (_keyword = _PyPegen_expect_token(p, 500)) // token='return' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4569 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4570 | (a = star_expressions_rule(p), 1) // star_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4571 | ) |
| 4572 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4573 | D(fprintf(stderr, "%*c+ return_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'return' star_expressions?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4574 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4575 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4576 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4577 | return NULL; |
| 4578 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4579 | int _end_lineno = _token->end_lineno; |
| 4580 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4581 | int _end_col_offset = _token->end_col_offset; |
| 4582 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4583 | _res = _Py_Return ( a , EXTRA ); |
| 4584 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4585 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4586 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4587 | return NULL; |
| 4588 | } |
| 4589 | goto done; |
| 4590 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4591 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4592 | D(fprintf(stderr, "%*c%s return_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4593 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'return' star_expressions?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4594 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4595 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4596 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4597 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4598 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4599 | } |
| 4600 | |
| 4601 | // raise_stmt: 'raise' expression ['from' expression] | 'raise' |
| 4602 | static stmt_ty |
| 4603 | raise_stmt_rule(Parser *p) |
| 4604 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4605 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4606 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4607 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4608 | return NULL; |
| 4609 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4610 | stmt_ty _res = NULL; |
| 4611 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4612 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4613 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4614 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4615 | return NULL; |
| 4616 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4617 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4618 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4619 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4620 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4621 | { // 'raise' expression ['from' expression] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4622 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4623 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4624 | return NULL; |
| 4625 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4626 | D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4627 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4628 | expr_ty a; |
| 4629 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4630 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4631 | (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4632 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4633 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4634 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4635 | (b = _tmp_49_rule(p), 1) // ['from' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4636 | ) |
| 4637 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4638 | D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise' expression ['from' expression]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4639 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4640 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4641 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4642 | return NULL; |
| 4643 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4644 | int _end_lineno = _token->end_lineno; |
| 4645 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4646 | int _end_col_offset = _token->end_col_offset; |
| 4647 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4648 | _res = _Py_Raise ( a , b , EXTRA ); |
| 4649 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4650 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4651 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4652 | return NULL; |
| 4653 | } |
| 4654 | goto done; |
| 4655 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4656 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4657 | D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4658 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise' expression ['from' expression]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4659 | } |
| 4660 | { // 'raise' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4661 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4662 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4663 | return NULL; |
| 4664 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4665 | D(fprintf(stderr, "%*c> raise_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'raise'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4666 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4667 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4668 | (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4669 | ) |
| 4670 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4671 | D(fprintf(stderr, "%*c+ raise_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'raise'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4672 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4673 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4674 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4675 | return NULL; |
| 4676 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4677 | int _end_lineno = _token->end_lineno; |
| 4678 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4679 | int _end_col_offset = _token->end_col_offset; |
| 4680 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4681 | _res = _Py_Raise ( NULL , NULL , EXTRA ); |
| 4682 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4683 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4684 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4685 | return NULL; |
| 4686 | } |
| 4687 | goto done; |
| 4688 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4689 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4690 | D(fprintf(stderr, "%*c%s raise_stmt[%d-%d]: %s failed!\n", p->level, ' ', |
| 4691 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'raise'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4692 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4693 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4694 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4695 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4696 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4697 | } |
| 4698 | |
| 4699 | // function_def: decorators function_def_raw | function_def_raw |
| 4700 | static stmt_ty |
| 4701 | function_def_rule(Parser *p) |
| 4702 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4703 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4704 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4705 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4706 | return NULL; |
| 4707 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4708 | stmt_ty _res = NULL; |
| 4709 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4710 | { // decorators function_def_raw |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4711 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4712 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4713 | return NULL; |
| 4714 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4715 | D(fprintf(stderr, "%*c> function_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "decorators function_def_raw")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4716 | asdl_seq* d; |
| 4717 | stmt_ty f; |
| 4718 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4719 | (d = decorators_rule(p)) // decorators |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4720 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4721 | (f = function_def_raw_rule(p)) // function_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4722 | ) |
| 4723 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4724 | D(fprintf(stderr, "%*c+ function_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "decorators function_def_raw")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4725 | _res = _PyPegen_function_def_decorators ( p , d , f ); |
| 4726 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4727 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4728 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4729 | return NULL; |
| 4730 | } |
| 4731 | goto done; |
| 4732 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4733 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4734 | D(fprintf(stderr, "%*c%s function_def[%d-%d]: %s failed!\n", p->level, ' ', |
| 4735 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "decorators function_def_raw")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4736 | } |
| 4737 | { // function_def_raw |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4738 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4739 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4740 | return NULL; |
| 4741 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4742 | D(fprintf(stderr, "%*c> function_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "function_def_raw")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4743 | stmt_ty function_def_raw_var; |
| 4744 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4745 | (function_def_raw_var = function_def_raw_rule(p)) // function_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4746 | ) |
| 4747 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4748 | D(fprintf(stderr, "%*c+ function_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "function_def_raw")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4749 | _res = function_def_raw_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4750 | goto done; |
| 4751 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4752 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4753 | D(fprintf(stderr, "%*c%s function_def[%d-%d]: %s failed!\n", p->level, ' ', |
| 4754 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "function_def_raw")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4755 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4756 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4757 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4758 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4759 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4760 | } |
| 4761 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4762 | // function_def_raw: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4763 | // | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
| 4764 | // | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4765 | static stmt_ty |
| 4766 | function_def_raw_rule(Parser *p) |
| 4767 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4768 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4769 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4770 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4771 | return NULL; |
| 4772 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4773 | stmt_ty _res = NULL; |
| 4774 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4775 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4776 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4777 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4778 | return NULL; |
| 4779 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4780 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4781 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4782 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4783 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4784 | { // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4785 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4786 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4787 | return NULL; |
| 4788 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4789 | 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 | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4790 | Token * _keyword; |
| 4791 | Token * _literal; |
| 4792 | Token * _literal_1; |
| 4793 | Token * _literal_2; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4794 | void *a; |
| 4795 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4796 | expr_ty n; |
| 4797 | void *params; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4798 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4799 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4800 | (_keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4801 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4802 | (n = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4803 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4804 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4805 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4806 | (params = params_rule(p), 1) // params? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4807 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4808 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4809 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4810 | (a = _tmp_50_rule(p), 1) // ['->' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4811 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4812 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4813 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4814 | (tc = func_type_comment_rule(p), 1) // func_type_comment? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4815 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4816 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4817 | ) |
| 4818 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4819 | 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 | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4820 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4821 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4822 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4823 | return NULL; |
| 4824 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4825 | int _end_lineno = _token->end_lineno; |
| 4826 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4827 | int _end_col_offset = _token->end_col_offset; |
| 4828 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4829 | _res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 4830 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4831 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4832 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4833 | return NULL; |
| 4834 | } |
| 4835 | goto done; |
| 4836 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4837 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4838 | D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ', |
| 4839 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4840 | } |
| 4841 | { // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4842 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4843 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4844 | return NULL; |
| 4845 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4846 | 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 | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4847 | Token * _keyword; |
| 4848 | Token * _literal; |
| 4849 | Token * _literal_1; |
| 4850 | Token * _literal_2; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4851 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4852 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4853 | asdl_seq* b; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4854 | expr_ty n; |
| 4855 | void *params; |
| 4856 | void *tc; |
| 4857 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4858 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4859 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4860 | (_keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4861 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4862 | (n = _PyPegen_name_token(p)) // NAME |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4863 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4864 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4865 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4866 | (params = params_rule(p), 1) // params? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4867 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4868 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4869 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4870 | (a = _tmp_51_rule(p), 1) // ['->' expression] |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4871 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4872 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4873 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4874 | (tc = func_type_comment_rule(p), 1) // func_type_comment? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4875 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4876 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4877 | ) |
| 4878 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4879 | 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 | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4880 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4881 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4882 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4883 | return NULL; |
| 4884 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4885 | int _end_lineno = _token->end_lineno; |
| 4886 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4887 | int _end_col_offset = _token->end_col_offset; |
| 4888 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4889 | _res = CHECK_VERSION ( 5 , "Async functions are" , _Py_AsyncFunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
| 4890 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4891 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4892 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4893 | return NULL; |
| 4894 | } |
| 4895 | goto done; |
| 4896 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4897 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4898 | D(fprintf(stderr, "%*c%s function_def_raw[%d-%d]: %s failed!\n", p->level, ' ', |
| 4899 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4900 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4901 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4902 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4903 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4904 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4905 | } |
| 4906 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4907 | // func_type_comment: |
| 4908 | // | NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
| 4909 | // | invalid_double_type_comments |
| 4910 | // | TYPE_COMMENT |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 4911 | static Token* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4912 | func_type_comment_rule(Parser *p) |
| 4913 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4914 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4915 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4916 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4917 | return NULL; |
| 4918 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4919 | Token* _res = NULL; |
| 4920 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4921 | { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4922 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4923 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4924 | return NULL; |
| 4925 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4926 | D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4927 | Token * newline_var; |
| 4928 | Token * t; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4929 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4930 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4931 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4932 | (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4933 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4934 | _PyPegen_lookahead(1, _tmp_52_rule, p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4935 | ) |
| 4936 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4937 | D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4938 | _res = t; |
| 4939 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4940 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4941 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4942 | return NULL; |
| 4943 | } |
| 4944 | goto done; |
| 4945 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4946 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4947 | D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', |
| 4948 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE TYPE_COMMENT &(NEWLINE INDENT)")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4949 | } |
| 4950 | { // invalid_double_type_comments |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4951 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4952 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4953 | return NULL; |
| 4954 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4955 | D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4956 | void *invalid_double_type_comments_var; |
| 4957 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4958 | (invalid_double_type_comments_var = invalid_double_type_comments_rule(p)) // invalid_double_type_comments |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4959 | ) |
| 4960 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4961 | D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_double_type_comments")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4962 | _res = invalid_double_type_comments_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4963 | goto done; |
| 4964 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4965 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4966 | D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', |
| 4967 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_double_type_comments")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4968 | } |
| 4969 | { // TYPE_COMMENT |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4970 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4971 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4972 | return NULL; |
| 4973 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4974 | D(fprintf(stderr, "%*c> func_type_comment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT")); |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4975 | Token * type_comment_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4976 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4977 | (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4978 | ) |
| 4979 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4980 | D(fprintf(stderr, "%*c+ func_type_comment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4981 | _res = type_comment_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4982 | goto done; |
| 4983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4984 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4985 | D(fprintf(stderr, "%*c%s func_type_comment[%d-%d]: %s failed!\n", p->level, ' ', |
| 4986 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4987 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4988 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4989 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4990 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4991 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4992 | } |
| 4993 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4994 | // params: invalid_parameters | parameters |
| 4995 | static arguments_ty |
| 4996 | params_rule(Parser *p) |
| 4997 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 4998 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4999 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5000 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5001 | return NULL; |
| 5002 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5003 | arguments_ty _res = NULL; |
| 5004 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5005 | { // invalid_parameters |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5006 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5007 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5008 | return NULL; |
| 5009 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5010 | D(fprintf(stderr, "%*c> params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_parameters")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5011 | void *invalid_parameters_var; |
| 5012 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5013 | (invalid_parameters_var = invalid_parameters_rule(p)) // invalid_parameters |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5014 | ) |
| 5015 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5016 | D(fprintf(stderr, "%*c+ params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_parameters")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5017 | _res = invalid_parameters_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5018 | goto done; |
| 5019 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5020 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5021 | D(fprintf(stderr, "%*c%s params[%d-%d]: %s failed!\n", p->level, ' ', |
| 5022 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_parameters")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5023 | } |
| 5024 | { // parameters |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5025 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5026 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5027 | return NULL; |
| 5028 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5029 | D(fprintf(stderr, "%*c> params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "parameters")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5030 | arguments_ty parameters_var; |
| 5031 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5032 | (parameters_var = parameters_rule(p)) // parameters |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5033 | ) |
| 5034 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5035 | D(fprintf(stderr, "%*c+ params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "parameters")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5036 | _res = parameters_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5037 | goto done; |
| 5038 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5039 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5040 | D(fprintf(stderr, "%*c%s params[%d-%d]: %s failed!\n", p->level, ' ', |
| 5041 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "parameters")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5042 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5043 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5044 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5045 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5046 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5047 | } |
| 5048 | |
| 5049 | // parameters: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5050 | // | slash_no_default param_no_default* param_with_default* star_etc? |
| 5051 | // | slash_with_default param_with_default* star_etc? |
| 5052 | // | param_no_default+ param_with_default* star_etc? |
| 5053 | // | param_with_default+ star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5054 | // | star_etc |
| 5055 | static arguments_ty |
| 5056 | parameters_rule(Parser *p) |
| 5057 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5058 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5059 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5060 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5061 | return NULL; |
| 5062 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5063 | arguments_ty _res = NULL; |
| 5064 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5065 | { // slash_no_default param_no_default* param_with_default* star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5066 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5067 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5068 | return NULL; |
| 5069 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5070 | 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 | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5071 | asdl_seq* a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5072 | asdl_seq * b; |
| 5073 | asdl_seq * c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5074 | void *d; |
| 5075 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5076 | (a = slash_no_default_rule(p)) // slash_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5077 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5078 | (b = _loop0_53_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5079 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5080 | (c = _loop0_54_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5081 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5082 | (d = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5083 | ) |
| 5084 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5085 | 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?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5086 | _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 5087 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5088 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5089 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5090 | return NULL; |
| 5091 | } |
| 5092 | goto done; |
| 5093 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5094 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5095 | D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 5096 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_no_default param_no_default* param_with_default* star_etc?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5097 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5098 | { // slash_with_default param_with_default* star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5099 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5100 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5101 | return NULL; |
| 5102 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5103 | D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default param_with_default* star_etc?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5104 | SlashWithDefault* a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5105 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5106 | void *c; |
| 5107 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5108 | (a = slash_with_default_rule(p)) // slash_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5109 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5110 | (b = _loop0_55_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5111 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5112 | (c = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5113 | ) |
| 5114 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5115 | D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default param_with_default* star_etc?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5116 | _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 5117 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5118 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5119 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5120 | return NULL; |
| 5121 | } |
| 5122 | goto done; |
| 5123 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5124 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5125 | D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 5126 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default param_with_default* star_etc?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5127 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5128 | { // param_no_default+ param_with_default* star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5129 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5130 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5131 | return NULL; |
| 5132 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5133 | D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ param_with_default* star_etc?")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5134 | asdl_seq * a; |
| 5135 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5136 | void *c; |
| 5137 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5138 | (a = _loop1_56_rule(p)) // param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5139 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5140 | (b = _loop0_57_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5141 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5142 | (c = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5143 | ) |
| 5144 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5145 | D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ param_with_default* star_etc?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5146 | _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 5147 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5148 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5149 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5150 | return NULL; |
| 5151 | } |
| 5152 | goto done; |
| 5153 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5154 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5155 | D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 5156 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ param_with_default* star_etc?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5157 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5158 | { // param_with_default+ star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5159 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5160 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5161 | return NULL; |
| 5162 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5163 | D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+ star_etc?")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5164 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5165 | void *b; |
| 5166 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5167 | (a = _loop1_58_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5168 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5169 | (b = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5170 | ) |
| 5171 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5172 | D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+ star_etc?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5173 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 5174 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5175 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5176 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5177 | return NULL; |
| 5178 | } |
| 5179 | goto done; |
| 5180 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5181 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5182 | D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 5183 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+ star_etc?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5184 | } |
| 5185 | { // star_etc |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5186 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5187 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5188 | return NULL; |
| 5189 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5190 | D(fprintf(stderr, "%*c> parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_etc")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5191 | StarEtc* a; |
| 5192 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5193 | (a = star_etc_rule(p)) // star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5194 | ) |
| 5195 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5196 | D(fprintf(stderr, "%*c+ parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_etc")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5197 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 5198 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5199 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5200 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5201 | return NULL; |
| 5202 | } |
| 5203 | goto done; |
| 5204 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5205 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5206 | D(fprintf(stderr, "%*c%s parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 5207 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_etc")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5208 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5209 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5210 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5211 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5212 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5213 | } |
| 5214 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5215 | // slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5216 | static asdl_seq* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5217 | slash_no_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5218 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5219 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5220 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5221 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5222 | return NULL; |
| 5223 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5224 | asdl_seq* _res = NULL; |
| 5225 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5226 | { // param_no_default+ '/' ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5227 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5228 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5229 | return NULL; |
| 5230 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5231 | D(fprintf(stderr, "%*c> slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5232 | Token * _literal; |
| 5233 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5234 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5235 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5236 | (a = _loop1_59_rule(p)) // param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5237 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5238 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5239 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5240 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5241 | ) |
| 5242 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5243 | D(fprintf(stderr, "%*c+ slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5244 | _res = a; |
| 5245 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5246 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5247 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5248 | return NULL; |
| 5249 | } |
| 5250 | goto done; |
| 5251 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5252 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5253 | D(fprintf(stderr, "%*c%s slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 5254 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ '/' ','")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5255 | } |
| 5256 | { // param_no_default+ '/' &')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5257 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5258 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5259 | return NULL; |
| 5260 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5261 | D(fprintf(stderr, "%*c> slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' &')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5262 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5263 | asdl_seq * a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5264 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5265 | (a = _loop1_60_rule(p)) // param_no_default+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5266 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5267 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5268 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5269 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5270 | ) |
| 5271 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5272 | D(fprintf(stderr, "%*c+ slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default+ '/' &')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5273 | _res = a; |
| 5274 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5275 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5276 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5277 | return NULL; |
| 5278 | } |
| 5279 | goto done; |
| 5280 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5281 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5282 | D(fprintf(stderr, "%*c%s slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 5283 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default+ '/' &')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5284 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5285 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5286 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5287 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5288 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5289 | } |
| 5290 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5291 | // slash_with_default: |
| 5292 | // | param_no_default* param_with_default+ '/' ',' |
| 5293 | // | param_no_default* param_with_default+ '/' &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5294 | static SlashWithDefault* |
| 5295 | slash_with_default_rule(Parser *p) |
| 5296 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5297 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5298 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5299 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5300 | return NULL; |
| 5301 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5302 | SlashWithDefault* _res = NULL; |
| 5303 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5304 | { // param_no_default* param_with_default+ '/' ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5305 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5306 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5307 | return NULL; |
| 5308 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5309 | D(fprintf(stderr, "%*c> slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5310 | Token * _literal; |
| 5311 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5312 | asdl_seq * a; |
| 5313 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5314 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5315 | (a = _loop0_61_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5316 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5317 | (b = _loop1_62_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5318 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5319 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5320 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5321 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5322 | ) |
| 5323 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5324 | 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 | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5325 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 5326 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5327 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5328 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5329 | return NULL; |
| 5330 | } |
| 5331 | goto done; |
| 5332 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5333 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5334 | D(fprintf(stderr, "%*c%s slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 5335 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* param_with_default+ '/' ','")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5336 | } |
| 5337 | { // param_no_default* param_with_default+ '/' &')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5338 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5339 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5340 | return NULL; |
| 5341 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5342 | D(fprintf(stderr, "%*c> slash_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* param_with_default+ '/' &')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5343 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5344 | asdl_seq * a; |
| 5345 | asdl_seq * b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5346 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5347 | (a = _loop0_63_rule(p)) // param_no_default* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5348 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5349 | (b = _loop1_64_rule(p)) // param_with_default+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5350 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5351 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5352 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5353 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5354 | ) |
| 5355 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5356 | 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 | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5357 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 5358 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5359 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5360 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5361 | return NULL; |
| 5362 | } |
| 5363 | goto done; |
| 5364 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5365 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5366 | D(fprintf(stderr, "%*c%s slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 5367 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* param_with_default+ '/' &')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5368 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5369 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5370 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5371 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5372 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5373 | } |
| 5374 | |
| 5375 | // star_etc: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5376 | // | '*' param_no_default param_maybe_default* kwds? |
| 5377 | // | '*' ',' param_maybe_default+ kwds? |
| 5378 | // | kwds |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5379 | // | invalid_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5380 | static StarEtc* |
| 5381 | star_etc_rule(Parser *p) |
| 5382 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5383 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5384 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5385 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5386 | return NULL; |
| 5387 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5388 | StarEtc* _res = NULL; |
| 5389 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5390 | { // '*' param_no_default param_maybe_default* kwds? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5391 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5392 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5393 | return NULL; |
| 5394 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5395 | D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5396 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5397 | arg_ty a; |
| 5398 | asdl_seq * b; |
| 5399 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5400 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5401 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5402 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5403 | (a = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5404 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5405 | (b = _loop0_65_rule(p)) // param_maybe_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5406 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5407 | (c = kwds_rule(p), 1) // kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5408 | ) |
| 5409 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5410 | D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5411 | _res = _PyPegen_star_etc ( p , a , b , c ); |
| 5412 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5413 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5414 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5415 | return NULL; |
| 5416 | } |
| 5417 | goto done; |
| 5418 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5419 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5420 | D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 5421 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' param_no_default param_maybe_default* kwds?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5422 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5423 | { // '*' ',' param_maybe_default+ kwds? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5424 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5425 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5426 | return NULL; |
| 5427 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5428 | D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' param_maybe_default+ kwds?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5429 | Token * _literal; |
| 5430 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5431 | asdl_seq * b; |
| 5432 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5433 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5434 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5435 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5436 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5437 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5438 | (b = _loop1_66_rule(p)) // param_maybe_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5439 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5440 | (c = kwds_rule(p), 1) // kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5441 | ) |
| 5442 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5443 | D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' param_maybe_default+ kwds?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5444 | _res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 5445 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5446 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5447 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5448 | return NULL; |
| 5449 | } |
| 5450 | goto done; |
| 5451 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5452 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5453 | D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 5454 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' param_maybe_default+ kwds?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5455 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5456 | { // kwds |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5457 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5458 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5459 | return NULL; |
| 5460 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5461 | D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwds")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5462 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5463 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5464 | (a = kwds_rule(p)) // kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5465 | ) |
| 5466 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5467 | D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwds")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5468 | _res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 5469 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5470 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5471 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5472 | return NULL; |
| 5473 | } |
| 5474 | goto done; |
| 5475 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5476 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5477 | D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 5478 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwds")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5479 | } |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5480 | { // invalid_star_etc |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5481 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5482 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5483 | return NULL; |
| 5484 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5485 | D(fprintf(stderr, "%*c> star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_star_etc")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5486 | void *invalid_star_etc_var; |
| 5487 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5488 | (invalid_star_etc_var = invalid_star_etc_rule(p)) // invalid_star_etc |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5489 | ) |
| 5490 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5491 | D(fprintf(stderr, "%*c+ star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_star_etc")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5492 | _res = invalid_star_etc_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5493 | goto done; |
| 5494 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5495 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5496 | D(fprintf(stderr, "%*c%s star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 5497 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_star_etc")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5498 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5499 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5500 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5501 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5502 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5503 | } |
| 5504 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5505 | // kwds: '**' param_no_default |
| 5506 | static arg_ty |
| 5507 | kwds_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5508 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5509 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5510 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5511 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5512 | return NULL; |
| 5513 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5514 | arg_ty _res = NULL; |
| 5515 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5516 | { // '**' param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5517 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5518 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5519 | return NULL; |
| 5520 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5521 | D(fprintf(stderr, "%*c> kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' param_no_default")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5522 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5523 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5524 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5525 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5526 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5527 | (a = param_no_default_rule(p)) // param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5528 | ) |
| 5529 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5530 | D(fprintf(stderr, "%*c+ kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' param_no_default")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5531 | _res = a; |
| 5532 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5533 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5534 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5535 | return NULL; |
| 5536 | } |
| 5537 | goto done; |
| 5538 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5539 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5540 | D(fprintf(stderr, "%*c%s kwds[%d-%d]: %s failed!\n", p->level, ' ', |
| 5541 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' param_no_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5542 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5543 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5544 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5545 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5546 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5547 | } |
| 5548 | |
| 5549 | // param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')' |
| 5550 | static arg_ty |
| 5551 | param_no_default_rule(Parser *p) |
| 5552 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5553 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5554 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5555 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5556 | return NULL; |
| 5557 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5558 | arg_ty _res = NULL; |
| 5559 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5560 | { // param ',' TYPE_COMMENT? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5561 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5562 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5563 | return NULL; |
| 5564 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5565 | D(fprintf(stderr, "%*c> param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param ',' TYPE_COMMENT?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5566 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5567 | arg_ty a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5568 | void *tc; |
| 5569 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5570 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5571 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5572 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5573 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5574 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5575 | ) |
| 5576 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5577 | D(fprintf(stderr, "%*c+ param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param ',' TYPE_COMMENT?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5578 | _res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
| 5579 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5580 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5581 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5582 | return NULL; |
| 5583 | } |
| 5584 | goto done; |
| 5585 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5586 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5587 | D(fprintf(stderr, "%*c%s param_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 5588 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param ',' TYPE_COMMENT?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5589 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5590 | { // param TYPE_COMMENT? &')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5591 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5592 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5593 | return NULL; |
| 5594 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5595 | D(fprintf(stderr, "%*c> param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param TYPE_COMMENT? &')'")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5596 | arg_ty a; |
| 5597 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5598 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5599 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5600 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5601 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5602 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5603 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5604 | ) |
| 5605 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5606 | D(fprintf(stderr, "%*c+ param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param TYPE_COMMENT? &')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5607 | _res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
| 5608 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5609 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5610 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5611 | return NULL; |
| 5612 | } |
| 5613 | goto done; |
| 5614 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5615 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5616 | D(fprintf(stderr, "%*c%s param_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 5617 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param TYPE_COMMENT? &')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5618 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5619 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5620 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5621 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5622 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5623 | } |
| 5624 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5625 | // param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5626 | static NameDefaultPair* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5627 | param_with_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5628 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5629 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5630 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5631 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5632 | return NULL; |
| 5633 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5634 | NameDefaultPair* _res = NULL; |
| 5635 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5636 | { // param default ',' TYPE_COMMENT? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5637 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5638 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5639 | return NULL; |
| 5640 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5641 | D(fprintf(stderr, "%*c> param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default ',' TYPE_COMMENT?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5642 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5643 | arg_ty a; |
| 5644 | expr_ty c; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5645 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5646 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5647 | (a = param_rule(p)) // param |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5648 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5649 | (c = default_rule(p)) // default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5650 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5651 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5652 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5653 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5654 | ) |
| 5655 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5656 | D(fprintf(stderr, "%*c+ param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default ',' TYPE_COMMENT?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5657 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 5658 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5659 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5660 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5661 | return NULL; |
| 5662 | } |
| 5663 | goto done; |
| 5664 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5665 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5666 | D(fprintf(stderr, "%*c%s param_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 5667 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default ',' TYPE_COMMENT?")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5668 | } |
| 5669 | { // param default TYPE_COMMENT? &')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5670 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5671 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5672 | return NULL; |
| 5673 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5674 | D(fprintf(stderr, "%*c> param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default TYPE_COMMENT? &')'")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5675 | arg_ty a; |
| 5676 | expr_ty c; |
| 5677 | void *tc; |
| 5678 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5679 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5680 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5681 | (c = default_rule(p)) // default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5682 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5683 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5684 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5685 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5686 | ) |
| 5687 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5688 | D(fprintf(stderr, "%*c+ param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default TYPE_COMMENT? &')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5689 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 5690 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5691 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5692 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5693 | return NULL; |
| 5694 | } |
| 5695 | goto done; |
| 5696 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5697 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5698 | D(fprintf(stderr, "%*c%s param_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 5699 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default TYPE_COMMENT? &')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5700 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5701 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5702 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5703 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5704 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5705 | } |
| 5706 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5707 | // param_maybe_default: |
| 5708 | // | param default? ',' TYPE_COMMENT? |
| 5709 | // | param default? TYPE_COMMENT? &')' |
| 5710 | static NameDefaultPair* |
| 5711 | param_maybe_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5712 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5713 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5714 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5715 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5716 | return NULL; |
| 5717 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5718 | NameDefaultPair* _res = NULL; |
| 5719 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5720 | { // param default? ',' TYPE_COMMENT? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5721 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5722 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5723 | return NULL; |
| 5724 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5725 | D(fprintf(stderr, "%*c> param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default? ',' TYPE_COMMENT?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5726 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5727 | arg_ty a; |
| 5728 | void *c; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5729 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5730 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5731 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5732 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5733 | (c = default_rule(p), 1) // default? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5734 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5735 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5736 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5737 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5738 | ) |
| 5739 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5740 | D(fprintf(stderr, "%*c+ param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default? ',' TYPE_COMMENT?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5741 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 5742 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5743 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5744 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5745 | return NULL; |
| 5746 | } |
| 5747 | goto done; |
| 5748 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5749 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5750 | D(fprintf(stderr, "%*c%s param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 5751 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default? ',' TYPE_COMMENT?")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5752 | } |
| 5753 | { // param default? TYPE_COMMENT? &')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5754 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5755 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5756 | return NULL; |
| 5757 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5758 | D(fprintf(stderr, "%*c> param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param default? TYPE_COMMENT? &')'")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5759 | arg_ty a; |
| 5760 | void *c; |
| 5761 | void *tc; |
| 5762 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5763 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5764 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5765 | (c = default_rule(p), 1) // default? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5766 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5767 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5768 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5769 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5770 | ) |
| 5771 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5772 | D(fprintf(stderr, "%*c+ param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param default? TYPE_COMMENT? &')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5773 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 5774 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5775 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5776 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5777 | return NULL; |
| 5778 | } |
| 5779 | goto done; |
| 5780 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5781 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5782 | D(fprintf(stderr, "%*c%s param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 5783 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param default? TYPE_COMMENT? &')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5784 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5785 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5786 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5787 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5788 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5789 | } |
| 5790 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5791 | // param: NAME annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5792 | static arg_ty |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5793 | param_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5794 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5795 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5796 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5797 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5798 | return NULL; |
| 5799 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5800 | arg_ty _res = NULL; |
| 5801 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5802 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5803 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5804 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5805 | return NULL; |
| 5806 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5807 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5808 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5809 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5810 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5811 | { // NAME annotation? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5812 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5813 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5814 | return NULL; |
| 5815 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5816 | D(fprintf(stderr, "%*c> param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME annotation?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5817 | expr_ty a; |
| 5818 | void *b; |
| 5819 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5820 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5821 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5822 | (b = annotation_rule(p), 1) // annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5823 | ) |
| 5824 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5825 | D(fprintf(stderr, "%*c+ param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME annotation?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5826 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5827 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5828 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5829 | return NULL; |
| 5830 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5831 | int _end_lineno = _token->end_lineno; |
| 5832 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5833 | int _end_col_offset = _token->end_col_offset; |
| 5834 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5835 | _res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA ); |
| 5836 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5837 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5838 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5839 | return NULL; |
| 5840 | } |
| 5841 | goto done; |
| 5842 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5843 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5844 | D(fprintf(stderr, "%*c%s param[%d-%d]: %s failed!\n", p->level, ' ', |
| 5845 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME annotation?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5846 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5847 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5848 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5849 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5850 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5851 | } |
| 5852 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5853 | // annotation: ':' expression |
| 5854 | static expr_ty |
| 5855 | annotation_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5856 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5857 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5858 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5859 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5860 | return NULL; |
| 5861 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5862 | expr_ty _res = NULL; |
| 5863 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5864 | { // ':' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5865 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5866 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5867 | return NULL; |
| 5868 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5869 | D(fprintf(stderr, "%*c> annotation[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5870 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5871 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5872 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5873 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5874 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5875 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5876 | ) |
| 5877 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5878 | D(fprintf(stderr, "%*c+ annotation[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5879 | _res = a; |
| 5880 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5881 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5882 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5883 | return NULL; |
| 5884 | } |
| 5885 | goto done; |
| 5886 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5887 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5888 | D(fprintf(stderr, "%*c%s annotation[%d-%d]: %s failed!\n", p->level, ' ', |
| 5889 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5890 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5891 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5892 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5893 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5894 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5895 | } |
| 5896 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5897 | // default: '=' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5898 | static expr_ty |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5899 | default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5900 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5901 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5902 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5903 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5904 | return NULL; |
| 5905 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5906 | expr_ty _res = NULL; |
| 5907 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5908 | { // '=' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5909 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5910 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5911 | return NULL; |
| 5912 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5913 | D(fprintf(stderr, "%*c> default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5914 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5915 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5916 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5917 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5918 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5919 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5920 | ) |
| 5921 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5922 | D(fprintf(stderr, "%*c+ default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5923 | _res = a; |
| 5924 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5925 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5926 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 5927 | return NULL; |
| 5928 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5929 | goto done; |
| 5930 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5931 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5932 | D(fprintf(stderr, "%*c%s default[%d-%d]: %s failed!\n", p->level, ' ', |
| 5933 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5934 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5935 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5936 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5937 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5938 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5939 | } |
| 5940 | |
| 5941 | // decorators: (('@' named_expression NEWLINE))+ |
| 5942 | static asdl_seq* |
| 5943 | decorators_rule(Parser *p) |
| 5944 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5945 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5946 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5947 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5948 | return NULL; |
| 5949 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5950 | asdl_seq* _res = NULL; |
| 5951 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5952 | { // (('@' named_expression NEWLINE))+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5953 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5954 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5955 | return NULL; |
| 5956 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5957 | D(fprintf(stderr, "%*c> decorators[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5958 | asdl_seq * a; |
| 5959 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5960 | (a = _loop1_67_rule(p)) // (('@' named_expression NEWLINE))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5961 | ) |
| 5962 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5963 | D(fprintf(stderr, "%*c+ decorators[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "(('@' named_expression NEWLINE))+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5964 | _res = a; |
| 5965 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5966 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5967 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5968 | return NULL; |
| 5969 | } |
| 5970 | goto done; |
| 5971 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5972 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5973 | D(fprintf(stderr, "%*c%s decorators[%d-%d]: %s failed!\n", p->level, ' ', |
| 5974 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(('@' named_expression NEWLINE))+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5975 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5976 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5977 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5978 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5979 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5980 | } |
| 5981 | |
| 5982 | // class_def: decorators class_def_raw | class_def_raw |
| 5983 | static stmt_ty |
| 5984 | class_def_rule(Parser *p) |
| 5985 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5986 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5987 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5988 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5989 | return NULL; |
| 5990 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5991 | stmt_ty _res = NULL; |
| 5992 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5993 | { // decorators class_def_raw |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5994 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5995 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5996 | return NULL; |
| 5997 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 5998 | D(fprintf(stderr, "%*c> class_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "decorators class_def_raw")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5999 | asdl_seq* a; |
| 6000 | stmt_ty b; |
| 6001 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6002 | (a = decorators_rule(p)) // decorators |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6003 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6004 | (b = class_def_raw_rule(p)) // class_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6005 | ) |
| 6006 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6007 | D(fprintf(stderr, "%*c+ class_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "decorators class_def_raw")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6008 | _res = _PyPegen_class_def_decorators ( p , a , b ); |
| 6009 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6010 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6011 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6012 | return NULL; |
| 6013 | } |
| 6014 | goto done; |
| 6015 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6016 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6017 | D(fprintf(stderr, "%*c%s class_def[%d-%d]: %s failed!\n", p->level, ' ', |
| 6018 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "decorators class_def_raw")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6019 | } |
| 6020 | { // class_def_raw |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6021 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6022 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6023 | return NULL; |
| 6024 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6025 | D(fprintf(stderr, "%*c> class_def[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "class_def_raw")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6026 | stmt_ty class_def_raw_var; |
| 6027 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6028 | (class_def_raw_var = class_def_raw_rule(p)) // class_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6029 | ) |
| 6030 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6031 | D(fprintf(stderr, "%*c+ class_def[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "class_def_raw")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6032 | _res = class_def_raw_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6033 | goto done; |
| 6034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6035 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6036 | D(fprintf(stderr, "%*c%s class_def[%d-%d]: %s failed!\n", p->level, ' ', |
| 6037 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "class_def_raw")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6038 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6039 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6040 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6041 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6042 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6043 | } |
| 6044 | |
| 6045 | // class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block |
| 6046 | static stmt_ty |
| 6047 | class_def_raw_rule(Parser *p) |
| 6048 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6049 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6050 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6051 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6052 | return NULL; |
| 6053 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6054 | stmt_ty _res = NULL; |
| 6055 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6056 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6057 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6058 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6059 | return NULL; |
| 6060 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6061 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6062 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6063 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6064 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6065 | { // 'class' NAME ['(' arguments? ')'] ':' block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6066 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6067 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6068 | return NULL; |
| 6069 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6070 | D(fprintf(stderr, "%*c> class_def_raw[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6071 | Token * _keyword; |
| 6072 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6073 | expr_ty a; |
| 6074 | void *b; |
| 6075 | asdl_seq* c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6076 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6077 | (_keyword = _PyPegen_expect_token(p, 523)) // token='class' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6078 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6079 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6080 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6081 | (b = _tmp_68_rule(p), 1) // ['(' arguments? ')'] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6082 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6083 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6084 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6085 | (c = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6086 | ) |
| 6087 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6088 | D(fprintf(stderr, "%*c+ class_def_raw[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6089 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6090 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6091 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6092 | return NULL; |
| 6093 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6094 | int _end_lineno = _token->end_lineno; |
| 6095 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6096 | int _end_col_offset = _token->end_col_offset; |
| 6097 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6098 | _res = _Py_ClassDef ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , c , NULL , EXTRA ); |
| 6099 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6100 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6101 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6102 | return NULL; |
| 6103 | } |
| 6104 | goto done; |
| 6105 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6106 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6107 | D(fprintf(stderr, "%*c%s class_def_raw[%d-%d]: %s failed!\n", p->level, ' ', |
| 6108 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class' NAME ['(' arguments? ')'] ':' block")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6109 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6110 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6111 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6112 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6113 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6114 | } |
| 6115 | |
| 6116 | // block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block |
| 6117 | static asdl_seq* |
| 6118 | block_rule(Parser *p) |
| 6119 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6120 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6121 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6122 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6123 | return NULL; |
| 6124 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6125 | asdl_seq* _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6126 | if (_PyPegen_is_memoized(p, block_type, &_res)) { |
| 6127 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6128 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6129 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6130 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6131 | { // NEWLINE INDENT statements DEDENT |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6132 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6133 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6134 | return NULL; |
| 6135 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6136 | D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT statements DEDENT")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6137 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6138 | Token * dedent_var; |
| 6139 | Token * indent_var; |
| 6140 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6141 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6142 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6143 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6144 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6145 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6146 | (a = statements_rule(p)) // statements |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6147 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6148 | (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6149 | ) |
| 6150 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6151 | D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT statements DEDENT")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6152 | _res = a; |
| 6153 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6154 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6155 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6156 | return NULL; |
| 6157 | } |
| 6158 | goto done; |
| 6159 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6160 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6161 | D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ', |
| 6162 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT statements DEDENT")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6163 | } |
| 6164 | { // simple_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6165 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6166 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6167 | return NULL; |
| 6168 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6169 | D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6170 | asdl_seq* simple_stmt_var; |
| 6171 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6172 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6173 | ) |
| 6174 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6175 | D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6176 | _res = simple_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6177 | goto done; |
| 6178 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6179 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6180 | D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ', |
| 6181 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6182 | } |
| 6183 | { // invalid_block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6184 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6185 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6186 | return NULL; |
| 6187 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6188 | D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_block")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6189 | void *invalid_block_var; |
| 6190 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6191 | (invalid_block_var = invalid_block_rule(p)) // invalid_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6192 | ) |
| 6193 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6194 | D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_block")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6195 | _res = invalid_block_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6196 | goto done; |
| 6197 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6198 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6199 | D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ', |
| 6200 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_block")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6201 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6202 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6203 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6204 | _PyPegen_insert_memo(p, _mark, block_type, _res); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6205 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6206 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6207 | } |
| 6208 | |
| 6209 | // expressions_list: ','.star_expression+ ','? |
| 6210 | static asdl_seq* |
| 6211 | expressions_list_rule(Parser *p) |
| 6212 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6213 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6214 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6215 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6216 | return NULL; |
| 6217 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6218 | asdl_seq* _res = NULL; |
| 6219 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6220 | { // ','.star_expression+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6221 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6222 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6223 | return NULL; |
| 6224 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6225 | D(fprintf(stderr, "%*c> expressions_list[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_expression+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6226 | void *_opt_var; |
| 6227 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6228 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6229 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6230 | (a = _gather_69_rule(p)) // ','.star_expression+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6231 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6232 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6233 | ) |
| 6234 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6235 | D(fprintf(stderr, "%*c+ expressions_list[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_expression+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6236 | _res = a; |
| 6237 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6238 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6239 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6240 | return NULL; |
| 6241 | } |
| 6242 | goto done; |
| 6243 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6244 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6245 | D(fprintf(stderr, "%*c%s expressions_list[%d-%d]: %s failed!\n", p->level, ' ', |
| 6246 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_expression+ ','?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6247 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6248 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6249 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6250 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6251 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6252 | } |
| 6253 | |
| 6254 | // star_expressions: |
| 6255 | // | star_expression ((',' star_expression))+ ','? |
| 6256 | // | star_expression ',' |
| 6257 | // | star_expression |
| 6258 | static expr_ty |
| 6259 | star_expressions_rule(Parser *p) |
| 6260 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6261 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6262 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6263 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6264 | return NULL; |
| 6265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6266 | expr_ty _res = NULL; |
| 6267 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6268 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6269 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6270 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6271 | return NULL; |
| 6272 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6273 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6274 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6275 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6276 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6277 | { // star_expression ((',' star_expression))+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6278 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6279 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6280 | return NULL; |
| 6281 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6282 | D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression ((',' star_expression))+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6283 | void *_opt_var; |
| 6284 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6285 | expr_ty a; |
| 6286 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6287 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6288 | (a = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6289 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6290 | (b = _loop1_71_rule(p)) // ((',' star_expression))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6291 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6292 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6293 | ) |
| 6294 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6295 | D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression ((',' star_expression))+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6296 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6297 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6298 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6299 | return NULL; |
| 6300 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6301 | int _end_lineno = _token->end_lineno; |
| 6302 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6303 | int _end_col_offset = _token->end_col_offset; |
| 6304 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6305 | _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
| 6306 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6307 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6308 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6309 | return NULL; |
| 6310 | } |
| 6311 | goto done; |
| 6312 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6313 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6314 | D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 6315 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression ((',' star_expression))+ ','?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6316 | } |
| 6317 | { // star_expression ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6318 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6319 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6320 | return NULL; |
| 6321 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6322 | D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6323 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6324 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6325 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6326 | (a = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6327 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6328 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6329 | ) |
| 6330 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6331 | D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6332 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6333 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6334 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6335 | return NULL; |
| 6336 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6337 | int _end_lineno = _token->end_lineno; |
| 6338 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6339 | int _end_col_offset = _token->end_col_offset; |
| 6340 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6341 | _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
| 6342 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6343 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6344 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6345 | return NULL; |
| 6346 | } |
| 6347 | goto done; |
| 6348 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6349 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6350 | D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 6351 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression ','")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6352 | } |
| 6353 | { // star_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6354 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6355 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6356 | return NULL; |
| 6357 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6358 | D(fprintf(stderr, "%*c> star_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6359 | expr_ty star_expression_var; |
| 6360 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6361 | (star_expression_var = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6362 | ) |
| 6363 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6364 | D(fprintf(stderr, "%*c+ star_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6365 | _res = star_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6366 | goto done; |
| 6367 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6368 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6369 | D(fprintf(stderr, "%*c%s star_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 6370 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6371 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6372 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6373 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6374 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6375 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6376 | } |
| 6377 | |
| 6378 | // star_expression: '*' bitwise_or | expression |
| 6379 | static expr_ty |
| 6380 | star_expression_rule(Parser *p) |
| 6381 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6382 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6383 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6384 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6385 | return NULL; |
| 6386 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6387 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6388 | if (_PyPegen_is_memoized(p, star_expression_type, &_res)) { |
| 6389 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6390 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6391 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6392 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6393 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6394 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6395 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6396 | return NULL; |
| 6397 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6398 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6399 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6400 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6401 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6402 | { // '*' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6403 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6404 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6405 | return NULL; |
| 6406 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6407 | D(fprintf(stderr, "%*c> star_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6408 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6409 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6410 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6411 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6412 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6413 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6414 | ) |
| 6415 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6416 | D(fprintf(stderr, "%*c+ star_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6417 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6418 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6419 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6420 | return NULL; |
| 6421 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6422 | int _end_lineno = _token->end_lineno; |
| 6423 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6424 | int _end_col_offset = _token->end_col_offset; |
| 6425 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6426 | _res = _Py_Starred ( a , Load , EXTRA ); |
| 6427 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6428 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6429 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6430 | return NULL; |
| 6431 | } |
| 6432 | goto done; |
| 6433 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6434 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6435 | D(fprintf(stderr, "%*c%s star_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 6436 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6437 | } |
| 6438 | { // expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6439 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6440 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6441 | return NULL; |
| 6442 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6443 | D(fprintf(stderr, "%*c> star_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6444 | expr_ty expression_var; |
| 6445 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6446 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6447 | ) |
| 6448 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6449 | D(fprintf(stderr, "%*c+ star_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6450 | _res = expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6451 | goto done; |
| 6452 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6453 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6454 | D(fprintf(stderr, "%*c%s star_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 6455 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6456 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6457 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6458 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6459 | _PyPegen_insert_memo(p, _mark, star_expression_type, _res); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6460 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6461 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6462 | } |
| 6463 | |
| 6464 | // star_named_expressions: ','.star_named_expression+ ','? |
| 6465 | static asdl_seq* |
| 6466 | star_named_expressions_rule(Parser *p) |
| 6467 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6468 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6469 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6470 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6471 | return NULL; |
| 6472 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6473 | asdl_seq* _res = NULL; |
| 6474 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6475 | { // ','.star_named_expression+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6476 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6477 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6478 | return NULL; |
| 6479 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6480 | D(fprintf(stderr, "%*c> star_named_expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_named_expression+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6481 | void *_opt_var; |
| 6482 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6483 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6484 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6485 | (a = _gather_72_rule(p)) // ','.star_named_expression+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6486 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6487 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6488 | ) |
| 6489 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6490 | D(fprintf(stderr, "%*c+ star_named_expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_named_expression+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6491 | _res = a; |
| 6492 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6493 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6494 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6495 | return NULL; |
| 6496 | } |
| 6497 | goto done; |
| 6498 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6499 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6500 | D(fprintf(stderr, "%*c%s star_named_expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 6501 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_named_expression+ ','?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6502 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6503 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6504 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6505 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6506 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6507 | } |
| 6508 | |
| 6509 | // star_named_expression: '*' bitwise_or | named_expression |
| 6510 | static expr_ty |
| 6511 | star_named_expression_rule(Parser *p) |
| 6512 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6513 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6514 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6515 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6516 | return NULL; |
| 6517 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6518 | expr_ty _res = NULL; |
| 6519 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6520 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6521 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6522 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6523 | return NULL; |
| 6524 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6525 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6526 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6527 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6528 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6529 | { // '*' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6530 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6531 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6532 | return NULL; |
| 6533 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6534 | D(fprintf(stderr, "%*c> star_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6535 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6536 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6537 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6538 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6539 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6540 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6541 | ) |
| 6542 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6543 | D(fprintf(stderr, "%*c+ star_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6544 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6545 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6546 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6547 | return NULL; |
| 6548 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6549 | int _end_lineno = _token->end_lineno; |
| 6550 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6551 | int _end_col_offset = _token->end_col_offset; |
| 6552 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6553 | _res = _Py_Starred ( a , Load , EXTRA ); |
| 6554 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6555 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6556 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6557 | return NULL; |
| 6558 | } |
| 6559 | goto done; |
| 6560 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6561 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6562 | D(fprintf(stderr, "%*c%s star_named_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 6563 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6564 | } |
| 6565 | { // named_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6566 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6567 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6568 | return NULL; |
| 6569 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6570 | D(fprintf(stderr, "%*c> star_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6571 | expr_ty named_expression_var; |
| 6572 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6573 | (named_expression_var = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6574 | ) |
| 6575 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6576 | D(fprintf(stderr, "%*c+ star_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6577 | _res = named_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6578 | goto done; |
| 6579 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6580 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6581 | D(fprintf(stderr, "%*c%s star_named_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 6582 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6583 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6584 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6585 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6586 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6587 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6588 | } |
| 6589 | |
| 6590 | // named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression |
| 6591 | static expr_ty |
| 6592 | named_expression_rule(Parser *p) |
| 6593 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6594 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6595 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6596 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6597 | return NULL; |
| 6598 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6599 | expr_ty _res = NULL; |
| 6600 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6601 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6602 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6603 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6604 | return NULL; |
| 6605 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6606 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6607 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6608 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6609 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6610 | { // NAME ':=' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6611 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6612 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6613 | return NULL; |
| 6614 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6615 | D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME ':=' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6616 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6617 | expr_ty a; |
| 6618 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6619 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6620 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6621 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6622 | (_literal = _PyPegen_expect_token(p, 53)) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6623 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6624 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6625 | ) |
| 6626 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6627 | D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME ':=' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6628 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6629 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6630 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6631 | return NULL; |
| 6632 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6633 | int _end_lineno = _token->end_lineno; |
| 6634 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6635 | int _end_col_offset = _token->end_col_offset; |
| 6636 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6637 | _res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA ); |
| 6638 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6639 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6640 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6641 | return NULL; |
| 6642 | } |
| 6643 | goto done; |
| 6644 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6645 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6646 | D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 6647 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME ':=' expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6648 | } |
| 6649 | { // expression !':=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6650 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6651 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6652 | return NULL; |
| 6653 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6654 | D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression !':='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6655 | expr_ty expression_var; |
| 6656 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6657 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6658 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6659 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6660 | ) |
| 6661 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6662 | D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression !':='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6663 | _res = expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6664 | goto done; |
| 6665 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6666 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6667 | D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 6668 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression !':='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6669 | } |
| 6670 | { // invalid_named_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6671 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6672 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6673 | return NULL; |
| 6674 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6675 | D(fprintf(stderr, "%*c> named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_named_expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6676 | void *invalid_named_expression_var; |
| 6677 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6678 | (invalid_named_expression_var = invalid_named_expression_rule(p)) // invalid_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6679 | ) |
| 6680 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6681 | D(fprintf(stderr, "%*c+ named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_named_expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6682 | _res = invalid_named_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6683 | goto done; |
| 6684 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6685 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6686 | D(fprintf(stderr, "%*c%s named_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 6687 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_named_expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6688 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6689 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6690 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6691 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6692 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6693 | } |
| 6694 | |
| 6695 | // annotated_rhs: yield_expr | star_expressions |
| 6696 | static expr_ty |
| 6697 | annotated_rhs_rule(Parser *p) |
| 6698 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6699 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6700 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6701 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6702 | return NULL; |
| 6703 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6704 | expr_ty _res = NULL; |
| 6705 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6706 | { // yield_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6707 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6708 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6709 | return NULL; |
| 6710 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6711 | D(fprintf(stderr, "%*c> annotated_rhs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6712 | expr_ty yield_expr_var; |
| 6713 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6714 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6715 | ) |
| 6716 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6717 | D(fprintf(stderr, "%*c+ annotated_rhs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6718 | _res = yield_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6719 | goto done; |
| 6720 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6721 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6722 | D(fprintf(stderr, "%*c%s annotated_rhs[%d-%d]: %s failed!\n", p->level, ' ', |
| 6723 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6724 | } |
| 6725 | { // star_expressions |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6726 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6727 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6728 | return NULL; |
| 6729 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6730 | D(fprintf(stderr, "%*c> annotated_rhs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6731 | expr_ty star_expressions_var; |
| 6732 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6733 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6734 | ) |
| 6735 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6736 | D(fprintf(stderr, "%*c+ annotated_rhs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6737 | _res = star_expressions_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6738 | goto done; |
| 6739 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6740 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6741 | D(fprintf(stderr, "%*c%s annotated_rhs[%d-%d]: %s failed!\n", p->level, ' ', |
| 6742 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6743 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6744 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6745 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6746 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6747 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6748 | } |
| 6749 | |
| 6750 | // expressions: expression ((',' expression))+ ','? | expression ',' | expression |
| 6751 | static expr_ty |
| 6752 | expressions_rule(Parser *p) |
| 6753 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6754 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6755 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6756 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6757 | return NULL; |
| 6758 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6759 | expr_ty _res = NULL; |
| 6760 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6761 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6762 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6763 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6764 | return NULL; |
| 6765 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6766 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6767 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6768 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6769 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6770 | { // expression ((',' expression))+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6771 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6772 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6773 | return NULL; |
| 6774 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6775 | D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ((',' expression))+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6776 | void *_opt_var; |
| 6777 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6778 | expr_ty a; |
| 6779 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6780 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6781 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6782 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6783 | (b = _loop1_74_rule(p)) // ((',' expression))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6784 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6785 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6786 | ) |
| 6787 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6788 | D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ((',' expression))+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6789 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6790 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6791 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6792 | return NULL; |
| 6793 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6794 | int _end_lineno = _token->end_lineno; |
| 6795 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6796 | int _end_col_offset = _token->end_col_offset; |
| 6797 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6798 | _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
| 6799 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6800 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6801 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6802 | return NULL; |
| 6803 | } |
| 6804 | goto done; |
| 6805 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6806 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6807 | D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 6808 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ((',' expression))+ ','?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6809 | } |
| 6810 | { // expression ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6811 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6812 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6813 | return NULL; |
| 6814 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6815 | D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6816 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6817 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6818 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6819 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6820 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6821 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6822 | ) |
| 6823 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6824 | D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6825 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6826 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6827 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6828 | return NULL; |
| 6829 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6830 | int _end_lineno = _token->end_lineno; |
| 6831 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6832 | int _end_col_offset = _token->end_col_offset; |
| 6833 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6834 | _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
| 6835 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6836 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6837 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6838 | return NULL; |
| 6839 | } |
| 6840 | goto done; |
| 6841 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6842 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6843 | D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 6844 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ','")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6845 | } |
| 6846 | { // expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6847 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6848 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6849 | return NULL; |
| 6850 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6851 | D(fprintf(stderr, "%*c> expressions[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6852 | expr_ty expression_var; |
| 6853 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6854 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6855 | ) |
| 6856 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6857 | D(fprintf(stderr, "%*c+ expressions[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6858 | _res = expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6859 | goto done; |
| 6860 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6861 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6862 | D(fprintf(stderr, "%*c%s expressions[%d-%d]: %s failed!\n", p->level, ' ', |
| 6863 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6864 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6865 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6866 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6867 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6868 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6869 | } |
| 6870 | |
| 6871 | // expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef |
| 6872 | static expr_ty |
| 6873 | expression_rule(Parser *p) |
| 6874 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6875 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6876 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6877 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6878 | return NULL; |
| 6879 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6880 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6881 | if (_PyPegen_is_memoized(p, expression_type, &_res)) { |
| 6882 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6883 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6884 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6885 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6886 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6887 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6888 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6889 | return NULL; |
| 6890 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6891 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6892 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6893 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6894 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6895 | { // disjunction 'if' disjunction 'else' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6896 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6897 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6898 | return NULL; |
| 6899 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6900 | D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6901 | Token * _keyword; |
| 6902 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6903 | expr_ty a; |
| 6904 | expr_ty b; |
| 6905 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6906 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6907 | (a = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6908 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6909 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6910 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6911 | (b = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6912 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6913 | (_keyword_1 = _PyPegen_expect_token(p, 516)) // token='else' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6914 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6915 | (c = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6916 | ) |
| 6917 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6918 | D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6919 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6920 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6921 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6922 | return NULL; |
| 6923 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6924 | int _end_lineno = _token->end_lineno; |
| 6925 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6926 | int _end_col_offset = _token->end_col_offset; |
| 6927 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6928 | _res = _Py_IfExp ( b , a , c , EXTRA ); |
| 6929 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6930 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6931 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6932 | return NULL; |
| 6933 | } |
| 6934 | goto done; |
| 6935 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6936 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6937 | D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 6938 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction 'if' disjunction 'else' expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6939 | } |
| 6940 | { // disjunction |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6941 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6942 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6943 | return NULL; |
| 6944 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6945 | D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "disjunction")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6946 | expr_ty disjunction_var; |
| 6947 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6948 | (disjunction_var = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6949 | ) |
| 6950 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6951 | D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "disjunction")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6952 | _res = disjunction_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6953 | goto done; |
| 6954 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6955 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6956 | D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 6957 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "disjunction")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6958 | } |
| 6959 | { // lambdef |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6960 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6961 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6962 | return NULL; |
| 6963 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6964 | D(fprintf(stderr, "%*c> expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambdef")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6965 | expr_ty lambdef_var; |
| 6966 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6967 | (lambdef_var = lambdef_rule(p)) // lambdef |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6968 | ) |
| 6969 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6970 | D(fprintf(stderr, "%*c+ expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambdef")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6971 | _res = lambdef_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6972 | goto done; |
| 6973 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6974 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6975 | D(fprintf(stderr, "%*c%s expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 6976 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambdef")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6977 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6978 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6979 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6980 | _PyPegen_insert_memo(p, _mark, expression_type, _res); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6981 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6982 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6983 | } |
| 6984 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 6985 | // lambdef: 'lambda' lambda_params? ':' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6986 | static expr_ty |
| 6987 | lambdef_rule(Parser *p) |
| 6988 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6989 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6990 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6991 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6992 | return NULL; |
| 6993 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6994 | expr_ty _res = NULL; |
| 6995 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6996 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6997 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 6998 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6999 | return NULL; |
| 7000 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7001 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7002 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7003 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7004 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 7005 | { // 'lambda' lambda_params? ':' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7006 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7007 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7008 | return NULL; |
| 7009 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 7010 | D(fprintf(stderr, "%*c> lambdef[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7011 | Token * _keyword; |
| 7012 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7013 | void *a; |
| 7014 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7015 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7016 | (_keyword = _PyPegen_expect_token(p, 524)) // token='lambda' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7017 | && |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 7018 | (a = lambda_params_rule(p), 1) // lambda_params? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7019 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7020 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7021 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7022 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7023 | ) |
| 7024 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 7025 | D(fprintf(stderr, "%*c+ lambdef[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'lambda' lambda_params? ':' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7026 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7027 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7028 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7029 | return NULL; |
| 7030 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7031 | int _end_lineno = _token->end_lineno; |
| 7032 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7033 | int _end_col_offset = _token->end_col_offset; |
| 7034 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7035 | _res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA ); |
| 7036 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7037 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7038 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7039 | return NULL; |
| 7040 | } |
| 7041 | goto done; |
| 7042 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7043 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7044 | D(fprintf(stderr, "%*c%s lambdef[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 7045 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'lambda' lambda_params? ':' expression")); |
| 7046 | } |
| 7047 | _res = NULL; |
| 7048 | done: |
| 7049 | D(p->level--); |
| 7050 | return _res; |
| 7051 | } |
| 7052 | |
| 7053 | // lambda_params: invalid_lambda_parameters | lambda_parameters |
| 7054 | static arguments_ty |
| 7055 | lambda_params_rule(Parser *p) |
| 7056 | { |
| 7057 | D(p->level++); |
| 7058 | if (p->error_indicator) { |
| 7059 | D(p->level--); |
| 7060 | return NULL; |
| 7061 | } |
| 7062 | arguments_ty _res = NULL; |
| 7063 | int _mark = p->mark; |
| 7064 | { // invalid_lambda_parameters |
| 7065 | if (p->error_indicator) { |
| 7066 | D(p->level--); |
| 7067 | return NULL; |
| 7068 | } |
| 7069 | D(fprintf(stderr, "%*c> lambda_params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_lambda_parameters")); |
| 7070 | void *invalid_lambda_parameters_var; |
| 7071 | if ( |
| 7072 | (invalid_lambda_parameters_var = invalid_lambda_parameters_rule(p)) // invalid_lambda_parameters |
| 7073 | ) |
| 7074 | { |
| 7075 | D(fprintf(stderr, "%*c+ lambda_params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_lambda_parameters")); |
| 7076 | _res = invalid_lambda_parameters_var; |
| 7077 | goto done; |
| 7078 | } |
| 7079 | p->mark = _mark; |
| 7080 | D(fprintf(stderr, "%*c%s lambda_params[%d-%d]: %s failed!\n", p->level, ' ', |
| 7081 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_lambda_parameters")); |
| 7082 | } |
| 7083 | { // lambda_parameters |
| 7084 | if (p->error_indicator) { |
| 7085 | D(p->level--); |
| 7086 | return NULL; |
| 7087 | } |
| 7088 | D(fprintf(stderr, "%*c> lambda_params[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_parameters")); |
| 7089 | arguments_ty lambda_parameters_var; |
| 7090 | if ( |
| 7091 | (lambda_parameters_var = lambda_parameters_rule(p)) // lambda_parameters |
| 7092 | ) |
| 7093 | { |
| 7094 | D(fprintf(stderr, "%*c+ lambda_params[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_parameters")); |
| 7095 | _res = lambda_parameters_var; |
| 7096 | goto done; |
| 7097 | } |
| 7098 | p->mark = _mark; |
| 7099 | D(fprintf(stderr, "%*c%s lambda_params[%d-%d]: %s failed!\n", p->level, ' ', |
| 7100 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_parameters")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7101 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7102 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7103 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7104 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7105 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7106 | } |
| 7107 | |
| 7108 | // lambda_parameters: |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7109 | // | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? |
| 7110 | // | lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
| 7111 | // | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
| 7112 | // | lambda_param_with_default+ lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7113 | // | lambda_star_etc |
| 7114 | static arguments_ty |
| 7115 | lambda_parameters_rule(Parser *p) |
| 7116 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7117 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7118 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7119 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7120 | return NULL; |
| 7121 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7122 | arguments_ty _res = NULL; |
| 7123 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7124 | { // lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7125 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7126 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7127 | return NULL; |
| 7128 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7129 | 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 | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7130 | asdl_seq* a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7131 | asdl_seq * b; |
| 7132 | asdl_seq * c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7133 | void *d; |
| 7134 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7135 | (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7136 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7137 | (b = _loop0_75_rule(p)) // lambda_param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7138 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7139 | (c = _loop0_76_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7140 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7141 | (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7142 | ) |
| 7143 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7144 | 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?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7145 | _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 7146 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7147 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7148 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7149 | return NULL; |
| 7150 | } |
| 7151 | goto done; |
| 7152 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7153 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7154 | D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 7155 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7156 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7157 | { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7158 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7159 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7160 | return NULL; |
| 7161 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7162 | 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?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7163 | SlashWithDefault* a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7164 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7165 | void *c; |
| 7166 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7167 | (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7168 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7169 | (b = _loop0_77_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7170 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7171 | (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7172 | ) |
| 7173 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7174 | 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?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7175 | _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 7176 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7177 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7178 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7179 | return NULL; |
| 7180 | } |
| 7181 | goto done; |
| 7182 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7183 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7184 | D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 7185 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default lambda_param_with_default* lambda_star_etc?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7186 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7187 | { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7188 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7189 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7190 | return NULL; |
| 7191 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7192 | 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?")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7193 | asdl_seq * a; |
| 7194 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7195 | void *c; |
| 7196 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7197 | (a = _loop1_78_rule(p)) // lambda_param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7198 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7199 | (b = _loop0_79_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7200 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7201 | (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7202 | ) |
| 7203 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7204 | 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?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7205 | _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 7206 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7207 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7208 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7209 | return NULL; |
| 7210 | } |
| 7211 | goto done; |
| 7212 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7213 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7214 | D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 7215 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ lambda_param_with_default* lambda_star_etc?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7216 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7217 | { // lambda_param_with_default+ lambda_star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7218 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7219 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7220 | return NULL; |
| 7221 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7222 | D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7223 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7224 | void *b; |
| 7225 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7226 | (a = _loop1_80_rule(p)) // lambda_param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7227 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7228 | (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7229 | ) |
| 7230 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7231 | D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7232 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 7233 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7234 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7235 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7236 | return NULL; |
| 7237 | } |
| 7238 | goto done; |
| 7239 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7240 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7241 | D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 7242 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+ lambda_star_etc?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7243 | } |
| 7244 | { // lambda_star_etc |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7245 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7246 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7247 | return NULL; |
| 7248 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7249 | D(fprintf(stderr, "%*c> lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_star_etc")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7250 | StarEtc* a; |
| 7251 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7252 | (a = lambda_star_etc_rule(p)) // lambda_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7253 | ) |
| 7254 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7255 | D(fprintf(stderr, "%*c+ lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_star_etc")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7256 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 7257 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7258 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7259 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7260 | return NULL; |
| 7261 | } |
| 7262 | goto done; |
| 7263 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7264 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7265 | D(fprintf(stderr, "%*c%s lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 7266 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_star_etc")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7267 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7268 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7269 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7270 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7271 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7272 | } |
| 7273 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7274 | // lambda_slash_no_default: |
| 7275 | // | lambda_param_no_default+ '/' ',' |
| 7276 | // | lambda_param_no_default+ '/' &':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7277 | static asdl_seq* |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7278 | lambda_slash_no_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7279 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7280 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7281 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7282 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7283 | return NULL; |
| 7284 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7285 | asdl_seq* _res = NULL; |
| 7286 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7287 | { // lambda_param_no_default+ '/' ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7288 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7289 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7290 | return NULL; |
| 7291 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7292 | D(fprintf(stderr, "%*c> lambda_slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7293 | Token * _literal; |
| 7294 | Token * _literal_1; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7295 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7296 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7297 | (a = _loop1_81_rule(p)) // lambda_param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7298 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7299 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7300 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7301 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7302 | ) |
| 7303 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7304 | D(fprintf(stderr, "%*c+ lambda_slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7305 | _res = a; |
| 7306 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7307 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7308 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7309 | return NULL; |
| 7310 | } |
| 7311 | goto done; |
| 7312 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7313 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7314 | D(fprintf(stderr, "%*c%s lambda_slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 7315 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ '/' ','")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7316 | } |
| 7317 | { // lambda_param_no_default+ '/' &':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7318 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7319 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7320 | return NULL; |
| 7321 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7322 | D(fprintf(stderr, "%*c> lambda_slash_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' &':'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7323 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7324 | asdl_seq * a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7325 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7326 | (a = _loop1_82_rule(p)) // lambda_param_no_default+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7327 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7328 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7329 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7330 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7331 | ) |
| 7332 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7333 | D(fprintf(stderr, "%*c+ lambda_slash_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default+ '/' &':'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7334 | _res = a; |
| 7335 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7336 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7337 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7338 | return NULL; |
| 7339 | } |
| 7340 | goto done; |
| 7341 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7342 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7343 | D(fprintf(stderr, "%*c%s lambda_slash_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 7344 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default+ '/' &':'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7345 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7346 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7347 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7348 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7349 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7350 | } |
| 7351 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7352 | // lambda_slash_with_default: |
| 7353 | // | lambda_param_no_default* lambda_param_with_default+ '/' ',' |
| 7354 | // | lambda_param_no_default* lambda_param_with_default+ '/' &':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7355 | static SlashWithDefault* |
| 7356 | lambda_slash_with_default_rule(Parser *p) |
| 7357 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7358 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7359 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7360 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7361 | return NULL; |
| 7362 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7363 | SlashWithDefault* _res = NULL; |
| 7364 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7365 | { // lambda_param_no_default* lambda_param_with_default+ '/' ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7366 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7367 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7368 | return NULL; |
| 7369 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7370 | 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+ '/' ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7371 | Token * _literal; |
| 7372 | Token * _literal_1; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7373 | asdl_seq * a; |
| 7374 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7375 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7376 | (a = _loop0_83_rule(p)) // lambda_param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7377 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7378 | (b = _loop1_84_rule(p)) // lambda_param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7379 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7380 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7381 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7382 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7383 | ) |
| 7384 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7385 | 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 | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7386 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 7387 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7388 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7389 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7390 | return NULL; |
| 7391 | } |
| 7392 | goto done; |
| 7393 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7394 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7395 | D(fprintf(stderr, "%*c%s lambda_slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 7396 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' ','")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7397 | } |
| 7398 | { // lambda_param_no_default* lambda_param_with_default+ '/' &':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7399 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7400 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7401 | return NULL; |
| 7402 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7403 | 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+ '/' &':'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7404 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7405 | asdl_seq * a; |
| 7406 | asdl_seq * b; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7407 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7408 | (a = _loop0_85_rule(p)) // lambda_param_no_default* |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7409 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7410 | (b = _loop1_86_rule(p)) // lambda_param_with_default+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7411 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7412 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7413 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7414 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7415 | ) |
| 7416 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7417 | 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 | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7418 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 7419 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7420 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7421 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7422 | return NULL; |
| 7423 | } |
| 7424 | goto done; |
| 7425 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7426 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7427 | D(fprintf(stderr, "%*c%s lambda_slash_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 7428 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* lambda_param_with_default+ '/' &':'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7429 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7430 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7431 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7432 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7433 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7434 | } |
| 7435 | |
| 7436 | // lambda_star_etc: |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7437 | // | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
| 7438 | // | '*' ',' lambda_param_maybe_default+ lambda_kwds? |
| 7439 | // | lambda_kwds |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 7440 | // | invalid_lambda_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7441 | static StarEtc* |
| 7442 | lambda_star_etc_rule(Parser *p) |
| 7443 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7444 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7445 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7446 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7447 | return NULL; |
| 7448 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7449 | StarEtc* _res = NULL; |
| 7450 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7451 | { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7452 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7453 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7454 | return NULL; |
| 7455 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7456 | 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?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7457 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7458 | arg_ty a; |
| 7459 | asdl_seq * b; |
| 7460 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7461 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7462 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7463 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7464 | (a = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7465 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7466 | (b = _loop0_87_rule(p)) // lambda_param_maybe_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7467 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7468 | (c = lambda_kwds_rule(p), 1) // lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7469 | ) |
| 7470 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7471 | 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?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7472 | _res = _PyPegen_star_etc ( p , a , b , c ); |
| 7473 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7474 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7475 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7476 | return NULL; |
| 7477 | } |
| 7478 | goto done; |
| 7479 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7480 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7481 | D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 7482 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7483 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7484 | { // '*' ',' lambda_param_maybe_default+ lambda_kwds? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7485 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7486 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7487 | return NULL; |
| 7488 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7489 | D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7490 | Token * _literal; |
| 7491 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7492 | asdl_seq * b; |
| 7493 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7494 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7495 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7496 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7497 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7498 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7499 | (b = _loop1_88_rule(p)) // lambda_param_maybe_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7500 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7501 | (c = lambda_kwds_rule(p), 1) // lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7502 | ) |
| 7503 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7504 | D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7505 | _res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 7506 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7507 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7508 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7509 | return NULL; |
| 7510 | } |
| 7511 | goto done; |
| 7512 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7513 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7514 | D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 7515 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' lambda_param_maybe_default+ lambda_kwds?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7516 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7517 | { // lambda_kwds |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7518 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7519 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7520 | return NULL; |
| 7521 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7522 | D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_kwds")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7523 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7524 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7525 | (a = lambda_kwds_rule(p)) // lambda_kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7526 | ) |
| 7527 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7528 | D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_kwds")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7529 | _res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 7530 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7531 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7532 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7533 | return NULL; |
| 7534 | } |
| 7535 | goto done; |
| 7536 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7537 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7538 | D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 7539 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_kwds")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7540 | } |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 7541 | { // invalid_lambda_star_etc |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7542 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7543 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7544 | return NULL; |
| 7545 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7546 | D(fprintf(stderr, "%*c> lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_lambda_star_etc")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 7547 | void *invalid_lambda_star_etc_var; |
| 7548 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7549 | (invalid_lambda_star_etc_var = invalid_lambda_star_etc_rule(p)) // invalid_lambda_star_etc |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 7550 | ) |
| 7551 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7552 | D(fprintf(stderr, "%*c+ lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_lambda_star_etc")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7553 | _res = invalid_lambda_star_etc_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 7554 | goto done; |
| 7555 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7556 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7557 | D(fprintf(stderr, "%*c%s lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 7558 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_lambda_star_etc")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 7559 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7560 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7561 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7562 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7563 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7564 | } |
| 7565 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7566 | // lambda_kwds: '**' lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7567 | static arg_ty |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7568 | lambda_kwds_rule(Parser *p) |
| 7569 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7570 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7571 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7572 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7573 | return NULL; |
| 7574 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7575 | arg_ty _res = NULL; |
| 7576 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7577 | { // '**' lambda_param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7578 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7579 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7580 | return NULL; |
| 7581 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7582 | D(fprintf(stderr, "%*c> lambda_kwds[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' lambda_param_no_default")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7583 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7584 | arg_ty a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7585 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7586 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7587 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7588 | (a = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7589 | ) |
| 7590 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7591 | D(fprintf(stderr, "%*c+ lambda_kwds[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' lambda_param_no_default")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7592 | _res = a; |
| 7593 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7594 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7595 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7596 | return NULL; |
| 7597 | } |
| 7598 | goto done; |
| 7599 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7600 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7601 | D(fprintf(stderr, "%*c%s lambda_kwds[%d-%d]: %s failed!\n", p->level, ' ', |
| 7602 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' lambda_param_no_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7603 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7604 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7605 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7606 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7607 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7608 | } |
| 7609 | |
| 7610 | // lambda_param_no_default: lambda_param ',' | lambda_param &':' |
| 7611 | static arg_ty |
| 7612 | lambda_param_no_default_rule(Parser *p) |
| 7613 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7614 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7615 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7616 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7617 | return NULL; |
| 7618 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7619 | arg_ty _res = NULL; |
| 7620 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7621 | { // lambda_param ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7622 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7623 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7624 | return NULL; |
| 7625 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7626 | D(fprintf(stderr, "%*c> lambda_param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7627 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7628 | arg_ty a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7629 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7630 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7631 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7632 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7633 | ) |
| 7634 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7635 | D(fprintf(stderr, "%*c+ lambda_param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7636 | _res = a; |
| 7637 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7638 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7639 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7640 | return NULL; |
| 7641 | } |
| 7642 | goto done; |
| 7643 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7644 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7645 | D(fprintf(stderr, "%*c%s lambda_param_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 7646 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param ','")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7647 | } |
| 7648 | { // lambda_param &':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7649 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7650 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7651 | return NULL; |
| 7652 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7653 | D(fprintf(stderr, "%*c> lambda_param_no_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param &':'")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7654 | arg_ty a; |
| 7655 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7656 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7657 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7658 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7659 | ) |
| 7660 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7661 | D(fprintf(stderr, "%*c+ lambda_param_no_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param &':'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7662 | _res = a; |
| 7663 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7664 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7665 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7666 | return NULL; |
| 7667 | } |
| 7668 | goto done; |
| 7669 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7670 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7671 | D(fprintf(stderr, "%*c%s lambda_param_no_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 7672 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param &':'")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7673 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7674 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7675 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7676 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7677 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7678 | } |
| 7679 | |
| 7680 | // lambda_param_with_default: lambda_param default ',' | lambda_param default &':' |
| 7681 | static NameDefaultPair* |
| 7682 | lambda_param_with_default_rule(Parser *p) |
| 7683 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7684 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7685 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7686 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7687 | return NULL; |
| 7688 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7689 | NameDefaultPair* _res = NULL; |
| 7690 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7691 | { // lambda_param default ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7692 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7693 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7694 | return NULL; |
| 7695 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7696 | D(fprintf(stderr, "%*c> lambda_param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7697 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7698 | arg_ty a; |
| 7699 | expr_ty c; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7700 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7701 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7702 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7703 | (c = default_rule(p)) // default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7704 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7705 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7706 | ) |
| 7707 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7708 | D(fprintf(stderr, "%*c+ lambda_param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7709 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 7710 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7711 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7712 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7713 | return NULL; |
| 7714 | } |
| 7715 | goto done; |
| 7716 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7717 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7718 | D(fprintf(stderr, "%*c%s lambda_param_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 7719 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default ','")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7720 | } |
| 7721 | { // lambda_param default &':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7722 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7723 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7724 | return NULL; |
| 7725 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7726 | D(fprintf(stderr, "%*c> lambda_param_with_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default &':'")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7727 | arg_ty a; |
| 7728 | expr_ty c; |
| 7729 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7730 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7731 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7732 | (c = default_rule(p)) // default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7733 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7734 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7735 | ) |
| 7736 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7737 | D(fprintf(stderr, "%*c+ lambda_param_with_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default &':'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7738 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 7739 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7740 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7741 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7742 | return NULL; |
| 7743 | } |
| 7744 | goto done; |
| 7745 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7746 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7747 | D(fprintf(stderr, "%*c%s lambda_param_with_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 7748 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default &':'")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7749 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7750 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7751 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7752 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7753 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7754 | } |
| 7755 | |
| 7756 | // lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':' |
| 7757 | static NameDefaultPair* |
| 7758 | lambda_param_maybe_default_rule(Parser *p) |
| 7759 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7760 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7761 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7762 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7763 | return NULL; |
| 7764 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7765 | NameDefaultPair* _res = NULL; |
| 7766 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7767 | { // lambda_param default? ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7768 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7769 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7770 | return NULL; |
| 7771 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7772 | D(fprintf(stderr, "%*c> lambda_param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default? ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7773 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7774 | arg_ty a; |
| 7775 | void *c; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7776 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7777 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7778 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7779 | (c = default_rule(p), 1) // default? |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7780 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7781 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7782 | ) |
| 7783 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7784 | D(fprintf(stderr, "%*c+ lambda_param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default? ','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7785 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 7786 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7787 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7788 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7789 | return NULL; |
| 7790 | } |
| 7791 | goto done; |
| 7792 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7793 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7794 | D(fprintf(stderr, "%*c%s lambda_param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 7795 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default? ','")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7796 | } |
| 7797 | { // lambda_param default? &':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7798 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7799 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7800 | return NULL; |
| 7801 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7802 | D(fprintf(stderr, "%*c> lambda_param_maybe_default[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param default? &':'")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7803 | arg_ty a; |
| 7804 | void *c; |
| 7805 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7806 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7807 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7808 | (c = default_rule(p), 1) // default? |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7809 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7810 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7811 | ) |
| 7812 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7813 | D(fprintf(stderr, "%*c+ lambda_param_maybe_default[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param default? &':'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7814 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 7815 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7816 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7817 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7818 | return NULL; |
| 7819 | } |
| 7820 | goto done; |
| 7821 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7822 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7823 | D(fprintf(stderr, "%*c%s lambda_param_maybe_default[%d-%d]: %s failed!\n", p->level, ' ', |
| 7824 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param default? &':'")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7825 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7826 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7827 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7828 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7829 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7830 | } |
| 7831 | |
| 7832 | // lambda_param: NAME |
| 7833 | static arg_ty |
| 7834 | lambda_param_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7835 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7836 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7837 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7838 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7839 | return NULL; |
| 7840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7841 | arg_ty _res = NULL; |
| 7842 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7843 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7844 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7845 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7846 | return NULL; |
| 7847 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7848 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7849 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7850 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7851 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7852 | { // NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7853 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7854 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7855 | return NULL; |
| 7856 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7857 | D(fprintf(stderr, "%*c> lambda_param[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7858 | expr_ty a; |
| 7859 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7860 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7861 | ) |
| 7862 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7863 | D(fprintf(stderr, "%*c+ lambda_param[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7864 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7865 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7866 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7867 | return NULL; |
| 7868 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7869 | int _end_lineno = _token->end_lineno; |
| 7870 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7871 | int _end_col_offset = _token->end_col_offset; |
| 7872 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7873 | _res = _Py_arg ( a -> v . Name . id , NULL , NULL , EXTRA ); |
| 7874 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7875 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7876 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7877 | return NULL; |
| 7878 | } |
| 7879 | goto done; |
| 7880 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7881 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7882 | D(fprintf(stderr, "%*c%s lambda_param[%d-%d]: %s failed!\n", p->level, ' ', |
| 7883 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7884 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7885 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7886 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7887 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7888 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7889 | } |
| 7890 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7891 | // disjunction: conjunction (('or' conjunction))+ | conjunction |
| 7892 | static expr_ty |
| 7893 | disjunction_rule(Parser *p) |
| 7894 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7895 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7896 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7897 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7898 | return NULL; |
| 7899 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7900 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7901 | if (_PyPegen_is_memoized(p, disjunction_type, &_res)) { |
| 7902 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7903 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7904 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7905 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7906 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7907 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7908 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7909 | return NULL; |
| 7910 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7911 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7912 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7913 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7914 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7915 | { // conjunction (('or' conjunction))+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7916 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7917 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7918 | return NULL; |
| 7919 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7920 | D(fprintf(stderr, "%*c> disjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7921 | expr_ty a; |
| 7922 | asdl_seq * b; |
| 7923 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7924 | (a = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7925 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7926 | (b = _loop1_89_rule(p)) // (('or' conjunction))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7927 | ) |
| 7928 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7929 | D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction (('or' conjunction))+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7930 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7931 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7932 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7933 | return NULL; |
| 7934 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7935 | int _end_lineno = _token->end_lineno; |
| 7936 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7937 | int _end_col_offset = _token->end_col_offset; |
| 7938 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7939 | _res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
| 7940 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7941 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7942 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7943 | return NULL; |
| 7944 | } |
| 7945 | goto done; |
| 7946 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7947 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7948 | D(fprintf(stderr, "%*c%s disjunction[%d-%d]: %s failed!\n", p->level, ' ', |
| 7949 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "conjunction (('or' conjunction))+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7950 | } |
| 7951 | { // conjunction |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7952 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7953 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7954 | return NULL; |
| 7955 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7956 | D(fprintf(stderr, "%*c> disjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "conjunction")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7957 | expr_ty conjunction_var; |
| 7958 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7959 | (conjunction_var = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7960 | ) |
| 7961 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7962 | D(fprintf(stderr, "%*c+ disjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "conjunction")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7963 | _res = conjunction_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7964 | goto done; |
| 7965 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7966 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7967 | D(fprintf(stderr, "%*c%s disjunction[%d-%d]: %s failed!\n", p->level, ' ', |
| 7968 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "conjunction")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7969 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7970 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7971 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7972 | _PyPegen_insert_memo(p, _mark, disjunction_type, _res); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7973 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7974 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7975 | } |
| 7976 | |
| 7977 | // conjunction: inversion (('and' inversion))+ | inversion |
| 7978 | static expr_ty |
| 7979 | conjunction_rule(Parser *p) |
| 7980 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7981 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7982 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7983 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7984 | return NULL; |
| 7985 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7986 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7987 | if (_PyPegen_is_memoized(p, conjunction_type, &_res)) { |
| 7988 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7989 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7990 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7991 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7992 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7993 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 7994 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7995 | return NULL; |
| 7996 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7997 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7998 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7999 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8000 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8001 | { // inversion (('and' inversion))+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8002 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8003 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8004 | return NULL; |
| 8005 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8006 | D(fprintf(stderr, "%*c> conjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8007 | expr_ty a; |
| 8008 | asdl_seq * b; |
| 8009 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8010 | (a = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8011 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8012 | (b = _loop1_90_rule(p)) // (('and' inversion))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8013 | ) |
| 8014 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8015 | D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion (('and' inversion))+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8016 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8017 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8018 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8019 | return NULL; |
| 8020 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8021 | int _end_lineno = _token->end_lineno; |
| 8022 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8023 | int _end_col_offset = _token->end_col_offset; |
| 8024 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8025 | _res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
| 8026 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8027 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8028 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8029 | return NULL; |
| 8030 | } |
| 8031 | goto done; |
| 8032 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8033 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8034 | D(fprintf(stderr, "%*c%s conjunction[%d-%d]: %s failed!\n", p->level, ' ', |
| 8035 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "inversion (('and' inversion))+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8036 | } |
| 8037 | { // inversion |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8038 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8039 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8040 | return NULL; |
| 8041 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8042 | D(fprintf(stderr, "%*c> conjunction[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "inversion")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8043 | expr_ty inversion_var; |
| 8044 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8045 | (inversion_var = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8046 | ) |
| 8047 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8048 | D(fprintf(stderr, "%*c+ conjunction[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "inversion")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8049 | _res = inversion_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8050 | goto done; |
| 8051 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8052 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8053 | D(fprintf(stderr, "%*c%s conjunction[%d-%d]: %s failed!\n", p->level, ' ', |
| 8054 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "inversion")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8055 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8056 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8057 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8058 | _PyPegen_insert_memo(p, _mark, conjunction_type, _res); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8059 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8060 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8061 | } |
| 8062 | |
| 8063 | // inversion: 'not' inversion | comparison |
| 8064 | static expr_ty |
| 8065 | inversion_rule(Parser *p) |
| 8066 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8067 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8068 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8069 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8070 | return NULL; |
| 8071 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8072 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8073 | if (_PyPegen_is_memoized(p, inversion_type, &_res)) { |
| 8074 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8075 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8076 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8077 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8078 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8079 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8080 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8081 | return NULL; |
| 8082 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8083 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8084 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8085 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8086 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8087 | { // 'not' inversion |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8088 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8089 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8090 | return NULL; |
| 8091 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8092 | D(fprintf(stderr, "%*c> inversion[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'not' inversion")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8093 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8094 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8095 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8096 | (_keyword = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8097 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8098 | (a = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8099 | ) |
| 8100 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8101 | D(fprintf(stderr, "%*c+ inversion[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'not' inversion")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8102 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8103 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8104 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8105 | return NULL; |
| 8106 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8107 | int _end_lineno = _token->end_lineno; |
| 8108 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8109 | int _end_col_offset = _token->end_col_offset; |
| 8110 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8111 | _res = _Py_UnaryOp ( Not , a , EXTRA ); |
| 8112 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8113 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8114 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8115 | return NULL; |
| 8116 | } |
| 8117 | goto done; |
| 8118 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8119 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8120 | D(fprintf(stderr, "%*c%s inversion[%d-%d]: %s failed!\n", p->level, ' ', |
| 8121 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'not' inversion")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8122 | } |
| 8123 | { // comparison |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8124 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8125 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8126 | return NULL; |
| 8127 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8128 | D(fprintf(stderr, "%*c> inversion[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "comparison")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8129 | expr_ty comparison_var; |
| 8130 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8131 | (comparison_var = comparison_rule(p)) // comparison |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8132 | ) |
| 8133 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8134 | D(fprintf(stderr, "%*c+ inversion[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "comparison")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8135 | _res = comparison_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8136 | goto done; |
| 8137 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8138 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8139 | D(fprintf(stderr, "%*c%s inversion[%d-%d]: %s failed!\n", p->level, ' ', |
| 8140 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "comparison")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8141 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8142 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8143 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8144 | _PyPegen_insert_memo(p, _mark, inversion_type, _res); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8145 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8146 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8147 | } |
| 8148 | |
| 8149 | // comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or |
| 8150 | static expr_ty |
| 8151 | comparison_rule(Parser *p) |
| 8152 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8153 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8154 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8155 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8156 | return NULL; |
| 8157 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8158 | expr_ty _res = NULL; |
| 8159 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8160 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8161 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8162 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8163 | return NULL; |
| 8164 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8165 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8166 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8167 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8168 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8169 | { // bitwise_or compare_op_bitwise_or_pair+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8170 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8171 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8172 | return NULL; |
| 8173 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8174 | D(fprintf(stderr, "%*c> comparison[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8175 | expr_ty a; |
| 8176 | asdl_seq * b; |
| 8177 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8178 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8179 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8180 | (b = _loop1_91_rule(p)) // compare_op_bitwise_or_pair+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8181 | ) |
| 8182 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8183 | D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8184 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8185 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8186 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8187 | return NULL; |
| 8188 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8189 | int _end_lineno = _token->end_lineno; |
| 8190 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8191 | int _end_col_offset = _token->end_col_offset; |
| 8192 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8193 | _res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA ); |
| 8194 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8195 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8196 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8197 | return NULL; |
| 8198 | } |
| 8199 | goto done; |
| 8200 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8201 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8202 | D(fprintf(stderr, "%*c%s comparison[%d-%d]: %s failed!\n", p->level, ' ', |
| 8203 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or compare_op_bitwise_or_pair+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8204 | } |
| 8205 | { // bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8206 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8207 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8208 | return NULL; |
| 8209 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8210 | D(fprintf(stderr, "%*c> comparison[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8211 | expr_ty bitwise_or_var; |
| 8212 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8213 | (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8214 | ) |
| 8215 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8216 | D(fprintf(stderr, "%*c+ comparison[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8217 | _res = bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8218 | goto done; |
| 8219 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8220 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8221 | D(fprintf(stderr, "%*c%s comparison[%d-%d]: %s failed!\n", p->level, ' ', |
| 8222 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8223 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8224 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8225 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8226 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8227 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8228 | } |
| 8229 | |
| 8230 | // compare_op_bitwise_or_pair: |
| 8231 | // | eq_bitwise_or |
| 8232 | // | noteq_bitwise_or |
| 8233 | // | lte_bitwise_or |
| 8234 | // | lt_bitwise_or |
| 8235 | // | gte_bitwise_or |
| 8236 | // | gt_bitwise_or |
| 8237 | // | notin_bitwise_or |
| 8238 | // | in_bitwise_or |
| 8239 | // | isnot_bitwise_or |
| 8240 | // | is_bitwise_or |
| 8241 | static CmpopExprPair* |
| 8242 | compare_op_bitwise_or_pair_rule(Parser *p) |
| 8243 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8244 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8245 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8246 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8247 | return NULL; |
| 8248 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8249 | CmpopExprPair* _res = NULL; |
| 8250 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8251 | { // eq_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8252 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8253 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8254 | return NULL; |
| 8255 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8256 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "eq_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8257 | CmpopExprPair* eq_bitwise_or_var; |
| 8258 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8259 | (eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8260 | ) |
| 8261 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8262 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "eq_bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8263 | _res = eq_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8264 | goto done; |
| 8265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8266 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8267 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 8268 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "eq_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8269 | } |
| 8270 | { // noteq_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8271 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8272 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8273 | return NULL; |
| 8274 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8275 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "noteq_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8276 | CmpopExprPair* noteq_bitwise_or_var; |
| 8277 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8278 | (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8279 | ) |
| 8280 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8281 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "noteq_bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8282 | _res = noteq_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8283 | goto done; |
| 8284 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8285 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8286 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 8287 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "noteq_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8288 | } |
| 8289 | { // lte_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8290 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8291 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8292 | return NULL; |
| 8293 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8294 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lte_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8295 | CmpopExprPair* lte_bitwise_or_var; |
| 8296 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8297 | (lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8298 | ) |
| 8299 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8300 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lte_bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8301 | _res = lte_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8302 | goto done; |
| 8303 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8304 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8305 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 8306 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lte_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8307 | } |
| 8308 | { // lt_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8309 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8310 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8311 | return NULL; |
| 8312 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8313 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lt_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8314 | CmpopExprPair* lt_bitwise_or_var; |
| 8315 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8316 | (lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8317 | ) |
| 8318 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8319 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lt_bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8320 | _res = lt_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8321 | goto done; |
| 8322 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8323 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8324 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 8325 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lt_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8326 | } |
| 8327 | { // gte_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8328 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8329 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8330 | return NULL; |
| 8331 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8332 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "gte_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8333 | CmpopExprPair* gte_bitwise_or_var; |
| 8334 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8335 | (gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8336 | ) |
| 8337 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8338 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "gte_bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8339 | _res = gte_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8340 | goto done; |
| 8341 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8342 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8343 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 8344 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "gte_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8345 | } |
| 8346 | { // gt_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8347 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8348 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8349 | return NULL; |
| 8350 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8351 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "gt_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8352 | CmpopExprPair* gt_bitwise_or_var; |
| 8353 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8354 | (gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8355 | ) |
| 8356 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8357 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "gt_bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8358 | _res = gt_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8359 | goto done; |
| 8360 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8361 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8362 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 8363 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "gt_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8364 | } |
| 8365 | { // notin_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8366 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8367 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8368 | return NULL; |
| 8369 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8370 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "notin_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8371 | CmpopExprPair* notin_bitwise_or_var; |
| 8372 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8373 | (notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8374 | ) |
| 8375 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8376 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "notin_bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8377 | _res = notin_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8378 | goto done; |
| 8379 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8380 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8381 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 8382 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "notin_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8383 | } |
| 8384 | { // in_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8385 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8386 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8387 | return NULL; |
| 8388 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8389 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "in_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8390 | CmpopExprPair* in_bitwise_or_var; |
| 8391 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8392 | (in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8393 | ) |
| 8394 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8395 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "in_bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8396 | _res = in_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8397 | goto done; |
| 8398 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8399 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8400 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 8401 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "in_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8402 | } |
| 8403 | { // isnot_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8404 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8405 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8406 | return NULL; |
| 8407 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8408 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "isnot_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8409 | CmpopExprPair* isnot_bitwise_or_var; |
| 8410 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8411 | (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8412 | ) |
| 8413 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8414 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "isnot_bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8415 | _res = isnot_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8416 | goto done; |
| 8417 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8418 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8419 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 8420 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "isnot_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8421 | } |
| 8422 | { // is_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8423 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8424 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8425 | return NULL; |
| 8426 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8427 | D(fprintf(stderr, "%*c> compare_op_bitwise_or_pair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "is_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8428 | CmpopExprPair* is_bitwise_or_var; |
| 8429 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8430 | (is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8431 | ) |
| 8432 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8433 | D(fprintf(stderr, "%*c+ compare_op_bitwise_or_pair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "is_bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8434 | _res = is_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8435 | goto done; |
| 8436 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8437 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8438 | D(fprintf(stderr, "%*c%s compare_op_bitwise_or_pair[%d-%d]: %s failed!\n", p->level, ' ', |
| 8439 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "is_bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8440 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8441 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8442 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8443 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8444 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8445 | } |
| 8446 | |
| 8447 | // eq_bitwise_or: '==' bitwise_or |
| 8448 | static CmpopExprPair* |
| 8449 | eq_bitwise_or_rule(Parser *p) |
| 8450 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8451 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8452 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8453 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8454 | return NULL; |
| 8455 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8456 | CmpopExprPair* _res = NULL; |
| 8457 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8458 | { // '==' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8459 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8460 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8461 | return NULL; |
| 8462 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8463 | D(fprintf(stderr, "%*c> eq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8464 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8465 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8466 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8467 | (_literal = _PyPegen_expect_token(p, 27)) // token='==' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8468 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8469 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8470 | ) |
| 8471 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8472 | D(fprintf(stderr, "%*c+ eq_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'==' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8473 | _res = _PyPegen_cmpop_expr_pair ( p , Eq , a ); |
| 8474 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8475 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8476 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8477 | return NULL; |
| 8478 | } |
| 8479 | goto done; |
| 8480 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8481 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8482 | D(fprintf(stderr, "%*c%s eq_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 8483 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'==' bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8484 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8485 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8486 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8487 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8488 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8489 | } |
| 8490 | |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8491 | // noteq_bitwise_or: ('!=') bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8492 | static CmpopExprPair* |
| 8493 | noteq_bitwise_or_rule(Parser *p) |
| 8494 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8495 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8496 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8497 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8498 | return NULL; |
| 8499 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8500 | CmpopExprPair* _res = NULL; |
| 8501 | int _mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8502 | { // ('!=') bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8503 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8504 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8505 | return NULL; |
| 8506 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8507 | D(fprintf(stderr, "%*c> noteq_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8508 | void *_tmp_92_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8509 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8510 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8511 | (_tmp_92_var = _tmp_92_rule(p)) // '!=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8512 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8513 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8514 | ) |
| 8515 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8516 | D(fprintf(stderr, "%*c+ noteq_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('!=') bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8517 | _res = _PyPegen_cmpop_expr_pair ( p , NotEq , a ); |
| 8518 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8519 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8520 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8521 | return NULL; |
| 8522 | } |
| 8523 | goto done; |
| 8524 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8525 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8526 | D(fprintf(stderr, "%*c%s noteq_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 8527 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('!=') bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8528 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8529 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8530 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8531 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8532 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8533 | } |
| 8534 | |
| 8535 | // lte_bitwise_or: '<=' bitwise_or |
| 8536 | static CmpopExprPair* |
| 8537 | lte_bitwise_or_rule(Parser *p) |
| 8538 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8539 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8540 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8541 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8542 | return NULL; |
| 8543 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8544 | CmpopExprPair* _res = NULL; |
| 8545 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8546 | { // '<=' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8547 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8548 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8549 | return NULL; |
| 8550 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8551 | D(fprintf(stderr, "%*c> lte_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8552 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8553 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8554 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8555 | (_literal = _PyPegen_expect_token(p, 29)) // token='<=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8556 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8557 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8558 | ) |
| 8559 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8560 | D(fprintf(stderr, "%*c+ lte_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<=' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8561 | _res = _PyPegen_cmpop_expr_pair ( p , LtE , a ); |
| 8562 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8563 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8564 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8565 | return NULL; |
| 8566 | } |
| 8567 | goto done; |
| 8568 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8569 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8570 | D(fprintf(stderr, "%*c%s lte_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 8571 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<=' bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8572 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8573 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8574 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8575 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8576 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8577 | } |
| 8578 | |
| 8579 | // lt_bitwise_or: '<' bitwise_or |
| 8580 | static CmpopExprPair* |
| 8581 | lt_bitwise_or_rule(Parser *p) |
| 8582 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8583 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8584 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8585 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8586 | return NULL; |
| 8587 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8588 | CmpopExprPair* _res = NULL; |
| 8589 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8590 | { // '<' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8591 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8592 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8593 | return NULL; |
| 8594 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8595 | D(fprintf(stderr, "%*c> lt_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8596 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8597 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8598 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8599 | (_literal = _PyPegen_expect_token(p, 20)) // token='<' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8600 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8601 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8602 | ) |
| 8603 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8604 | D(fprintf(stderr, "%*c+ lt_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'<' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8605 | _res = _PyPegen_cmpop_expr_pair ( p , Lt , a ); |
| 8606 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8607 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8608 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8609 | return NULL; |
| 8610 | } |
| 8611 | goto done; |
| 8612 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8613 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8614 | D(fprintf(stderr, "%*c%s lt_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 8615 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'<' bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8616 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8617 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8618 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8619 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8620 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8621 | } |
| 8622 | |
| 8623 | // gte_bitwise_or: '>=' bitwise_or |
| 8624 | static CmpopExprPair* |
| 8625 | gte_bitwise_or_rule(Parser *p) |
| 8626 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8627 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8628 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8629 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8630 | return NULL; |
| 8631 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8632 | CmpopExprPair* _res = NULL; |
| 8633 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8634 | { // '>=' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8635 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8636 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8637 | return NULL; |
| 8638 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8639 | D(fprintf(stderr, "%*c> gte_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8640 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8641 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8642 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8643 | (_literal = _PyPegen_expect_token(p, 30)) // token='>=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8644 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8645 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8646 | ) |
| 8647 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8648 | D(fprintf(stderr, "%*c+ gte_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>=' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8649 | _res = _PyPegen_cmpop_expr_pair ( p , GtE , a ); |
| 8650 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8651 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8652 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8653 | return NULL; |
| 8654 | } |
| 8655 | goto done; |
| 8656 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8657 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8658 | D(fprintf(stderr, "%*c%s gte_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 8659 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>=' bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8660 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8661 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8662 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8663 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8664 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8665 | } |
| 8666 | |
| 8667 | // gt_bitwise_or: '>' bitwise_or |
| 8668 | static CmpopExprPair* |
| 8669 | gt_bitwise_or_rule(Parser *p) |
| 8670 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8671 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8672 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8673 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8674 | return NULL; |
| 8675 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8676 | CmpopExprPair* _res = NULL; |
| 8677 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8678 | { // '>' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8679 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8680 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8681 | return NULL; |
| 8682 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8683 | D(fprintf(stderr, "%*c> gt_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8684 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8685 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8686 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8687 | (_literal = _PyPegen_expect_token(p, 21)) // token='>' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8688 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8689 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8690 | ) |
| 8691 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8692 | D(fprintf(stderr, "%*c+ gt_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'>' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8693 | _res = _PyPegen_cmpop_expr_pair ( p , Gt , a ); |
| 8694 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8695 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8696 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8697 | return NULL; |
| 8698 | } |
| 8699 | goto done; |
| 8700 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8701 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8702 | D(fprintf(stderr, "%*c%s gt_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 8703 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'>' bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8704 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8705 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8706 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8707 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8708 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8709 | } |
| 8710 | |
| 8711 | // notin_bitwise_or: 'not' 'in' bitwise_or |
| 8712 | static CmpopExprPair* |
| 8713 | notin_bitwise_or_rule(Parser *p) |
| 8714 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8715 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8716 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8717 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8718 | return NULL; |
| 8719 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8720 | CmpopExprPair* _res = NULL; |
| 8721 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8722 | { // 'not' 'in' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8723 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8724 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8725 | return NULL; |
| 8726 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8727 | D(fprintf(stderr, "%*c> notin_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8728 | Token * _keyword; |
| 8729 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8730 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8731 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8732 | (_keyword = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8733 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8734 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8735 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8736 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8737 | ) |
| 8738 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8739 | D(fprintf(stderr, "%*c+ notin_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'not' 'in' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8740 | _res = _PyPegen_cmpop_expr_pair ( p , NotIn , a ); |
| 8741 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8742 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8743 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8744 | return NULL; |
| 8745 | } |
| 8746 | goto done; |
| 8747 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8748 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8749 | D(fprintf(stderr, "%*c%s notin_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 8750 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'not' 'in' bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8751 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8752 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8753 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8754 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8755 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8756 | } |
| 8757 | |
| 8758 | // in_bitwise_or: 'in' bitwise_or |
| 8759 | static CmpopExprPair* |
| 8760 | in_bitwise_or_rule(Parser *p) |
| 8761 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8762 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8763 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8764 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8765 | return NULL; |
| 8766 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8767 | CmpopExprPair* _res = NULL; |
| 8768 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8769 | { // 'in' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8770 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8771 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8772 | return NULL; |
| 8773 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8774 | D(fprintf(stderr, "%*c> in_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8775 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8776 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8777 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8778 | (_keyword = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8779 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8780 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8781 | ) |
| 8782 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8783 | D(fprintf(stderr, "%*c+ in_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'in' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8784 | _res = _PyPegen_cmpop_expr_pair ( p , In , a ); |
| 8785 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8786 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8787 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8788 | return NULL; |
| 8789 | } |
| 8790 | goto done; |
| 8791 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8792 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8793 | D(fprintf(stderr, "%*c%s in_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 8794 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'in' bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8795 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8796 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8797 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8798 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8799 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8800 | } |
| 8801 | |
| 8802 | // isnot_bitwise_or: 'is' 'not' bitwise_or |
| 8803 | static CmpopExprPair* |
| 8804 | isnot_bitwise_or_rule(Parser *p) |
| 8805 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8806 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8807 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8808 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8809 | return NULL; |
| 8810 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8811 | CmpopExprPair* _res = NULL; |
| 8812 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8813 | { // 'is' 'not' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8814 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8815 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8816 | return NULL; |
| 8817 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8818 | D(fprintf(stderr, "%*c> isnot_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8819 | Token * _keyword; |
| 8820 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8821 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8822 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8823 | (_keyword = _PyPegen_expect_token(p, 526)) // token='is' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8824 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8825 | (_keyword_1 = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8826 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8827 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8828 | ) |
| 8829 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8830 | D(fprintf(stderr, "%*c+ isnot_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' 'not' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8831 | _res = _PyPegen_cmpop_expr_pair ( p , IsNot , a ); |
| 8832 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8833 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8834 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8835 | return NULL; |
| 8836 | } |
| 8837 | goto done; |
| 8838 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8839 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8840 | D(fprintf(stderr, "%*c%s isnot_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 8841 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' 'not' bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8842 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8843 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8844 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8845 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8846 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8847 | } |
| 8848 | |
| 8849 | // is_bitwise_or: 'is' bitwise_or |
| 8850 | static CmpopExprPair* |
| 8851 | is_bitwise_or_rule(Parser *p) |
| 8852 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8853 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8854 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8855 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8856 | return NULL; |
| 8857 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8858 | CmpopExprPair* _res = NULL; |
| 8859 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8860 | { // 'is' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8861 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8862 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8863 | return NULL; |
| 8864 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8865 | D(fprintf(stderr, "%*c> is_bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8866 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8867 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8868 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8869 | (_keyword = _PyPegen_expect_token(p, 526)) // token='is' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8870 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8871 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8872 | ) |
| 8873 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8874 | D(fprintf(stderr, "%*c+ is_bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'is' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8875 | _res = _PyPegen_cmpop_expr_pair ( p , Is , a ); |
| 8876 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8877 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8878 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8879 | return NULL; |
| 8880 | } |
| 8881 | goto done; |
| 8882 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8883 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8884 | D(fprintf(stderr, "%*c%s is_bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 8885 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'is' bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8886 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8887 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8888 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8889 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8890 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8891 | } |
| 8892 | |
| 8893 | // Left-recursive |
| 8894 | // bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor |
| 8895 | static expr_ty bitwise_or_raw(Parser *); |
| 8896 | static expr_ty |
| 8897 | bitwise_or_rule(Parser *p) |
| 8898 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8899 | D(p->level++); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8900 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8901 | if (_PyPegen_is_memoized(p, bitwise_or_type, &_res)) { |
| 8902 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8903 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8904 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8905 | int _mark = p->mark; |
| 8906 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8907 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8908 | int tmpvar_1 = _PyPegen_update_memo(p, _mark, bitwise_or_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8909 | if (tmpvar_1) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8910 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8911 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8912 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8913 | p->mark = _mark; |
| 8914 | void *_raw = bitwise_or_raw(p); |
| 8915 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8916 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8917 | _resmark = p->mark; |
| 8918 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8919 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8920 | p->mark = _resmark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8921 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8922 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8923 | } |
| 8924 | static expr_ty |
| 8925 | bitwise_or_raw(Parser *p) |
| 8926 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8927 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8928 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8929 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8930 | return NULL; |
| 8931 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8932 | expr_ty _res = NULL; |
| 8933 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8934 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8935 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8936 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8937 | return NULL; |
| 8938 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8939 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8940 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8941 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8942 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8943 | { // bitwise_or '|' bitwise_xor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8944 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8945 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8946 | return NULL; |
| 8947 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8948 | D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8949 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8950 | expr_ty a; |
| 8951 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8952 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8953 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8954 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8955 | (_literal = _PyPegen_expect_token(p, 18)) // token='|' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8956 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8957 | (b = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8958 | ) |
| 8959 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8960 | D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_or '|' bitwise_xor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8961 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8962 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8963 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8964 | return NULL; |
| 8965 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8966 | int _end_lineno = _token->end_lineno; |
| 8967 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8968 | int _end_col_offset = _token->end_col_offset; |
| 8969 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8970 | _res = _Py_BinOp ( a , BitOr , b , EXTRA ); |
| 8971 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8972 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8973 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8974 | return NULL; |
| 8975 | } |
| 8976 | goto done; |
| 8977 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8978 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8979 | D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 8980 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_or '|' bitwise_xor")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8981 | } |
| 8982 | { // bitwise_xor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8983 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8984 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8985 | return NULL; |
| 8986 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8987 | D(fprintf(stderr, "%*c> bitwise_or[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8988 | expr_ty bitwise_xor_var; |
| 8989 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8990 | (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8991 | ) |
| 8992 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8993 | D(fprintf(stderr, "%*c+ bitwise_or[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8994 | _res = bitwise_xor_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8995 | goto done; |
| 8996 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8997 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 8998 | D(fprintf(stderr, "%*c%s bitwise_or[%d-%d]: %s failed!\n", p->level, ' ', |
| 8999 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9000 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9001 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9002 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9003 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9004 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9005 | } |
| 9006 | |
| 9007 | // Left-recursive |
| 9008 | // bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and |
| 9009 | static expr_ty bitwise_xor_raw(Parser *); |
| 9010 | static expr_ty |
| 9011 | bitwise_xor_rule(Parser *p) |
| 9012 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9013 | D(p->level++); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9014 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9015 | if (_PyPegen_is_memoized(p, bitwise_xor_type, &_res)) { |
| 9016 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9017 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9018 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9019 | int _mark = p->mark; |
| 9020 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9021 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9022 | int tmpvar_2 = _PyPegen_update_memo(p, _mark, bitwise_xor_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9023 | if (tmpvar_2) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9024 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9025 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9026 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9027 | p->mark = _mark; |
| 9028 | void *_raw = bitwise_xor_raw(p); |
| 9029 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9030 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9031 | _resmark = p->mark; |
| 9032 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9033 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9034 | p->mark = _resmark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9035 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9036 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9037 | } |
| 9038 | static expr_ty |
| 9039 | bitwise_xor_raw(Parser *p) |
| 9040 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9041 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9042 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9043 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9044 | return NULL; |
| 9045 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9046 | expr_ty _res = NULL; |
| 9047 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9048 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9049 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9050 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9051 | return NULL; |
| 9052 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9053 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9054 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9055 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9056 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9057 | { // bitwise_xor '^' bitwise_and |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9058 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9059 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9060 | return NULL; |
| 9061 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9062 | D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9063 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9064 | expr_ty a; |
| 9065 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9066 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9067 | (a = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9068 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9069 | (_literal = _PyPegen_expect_token(p, 32)) // token='^' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9070 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9071 | (b = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9072 | ) |
| 9073 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9074 | D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_xor '^' bitwise_and")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9075 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9076 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9077 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9078 | return NULL; |
| 9079 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9080 | int _end_lineno = _token->end_lineno; |
| 9081 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9082 | int _end_col_offset = _token->end_col_offset; |
| 9083 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9084 | _res = _Py_BinOp ( a , BitXor , b , EXTRA ); |
| 9085 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9086 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9087 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9088 | return NULL; |
| 9089 | } |
| 9090 | goto done; |
| 9091 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9092 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9093 | D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ', |
| 9094 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_xor '^' bitwise_and")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9095 | } |
| 9096 | { // bitwise_and |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9097 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9098 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9099 | return NULL; |
| 9100 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9101 | D(fprintf(stderr, "%*c> bitwise_xor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9102 | expr_ty bitwise_and_var; |
| 9103 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9104 | (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9105 | ) |
| 9106 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9107 | D(fprintf(stderr, "%*c+ bitwise_xor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9108 | _res = bitwise_and_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9109 | goto done; |
| 9110 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9111 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9112 | D(fprintf(stderr, "%*c%s bitwise_xor[%d-%d]: %s failed!\n", p->level, ' ', |
| 9113 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9115 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9116 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9117 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9118 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9119 | } |
| 9120 | |
| 9121 | // Left-recursive |
| 9122 | // bitwise_and: bitwise_and '&' shift_expr | shift_expr |
| 9123 | static expr_ty bitwise_and_raw(Parser *); |
| 9124 | static expr_ty |
| 9125 | bitwise_and_rule(Parser *p) |
| 9126 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9127 | D(p->level++); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9128 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9129 | if (_PyPegen_is_memoized(p, bitwise_and_type, &_res)) { |
| 9130 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9131 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9132 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9133 | int _mark = p->mark; |
| 9134 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9135 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9136 | int tmpvar_3 = _PyPegen_update_memo(p, _mark, bitwise_and_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9137 | if (tmpvar_3) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9138 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9139 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9140 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9141 | p->mark = _mark; |
| 9142 | void *_raw = bitwise_and_raw(p); |
| 9143 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9144 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9145 | _resmark = p->mark; |
| 9146 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9147 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9148 | p->mark = _resmark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9149 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9150 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9151 | } |
| 9152 | static expr_ty |
| 9153 | bitwise_and_raw(Parser *p) |
| 9154 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9155 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9156 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9157 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9158 | return NULL; |
| 9159 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9160 | expr_ty _res = NULL; |
| 9161 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9162 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9163 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9164 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9165 | return NULL; |
| 9166 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9167 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9168 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9169 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9170 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9171 | { // bitwise_and '&' shift_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9172 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9173 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9174 | return NULL; |
| 9175 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9176 | D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9177 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9178 | expr_ty a; |
| 9179 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9180 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9181 | (a = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9182 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9183 | (_literal = _PyPegen_expect_token(p, 19)) // token='&' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9184 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9185 | (b = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9186 | ) |
| 9187 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9188 | D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "bitwise_and '&' shift_expr")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9189 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9190 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9191 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9192 | return NULL; |
| 9193 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9194 | int _end_lineno = _token->end_lineno; |
| 9195 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9196 | int _end_col_offset = _token->end_col_offset; |
| 9197 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9198 | _res = _Py_BinOp ( a , BitAnd , b , EXTRA ); |
| 9199 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9200 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9201 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9202 | return NULL; |
| 9203 | } |
| 9204 | goto done; |
| 9205 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9206 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9207 | D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', |
| 9208 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "bitwise_and '&' shift_expr")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9209 | } |
| 9210 | { // shift_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9211 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9212 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9213 | return NULL; |
| 9214 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9215 | D(fprintf(stderr, "%*c> bitwise_and[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9216 | expr_ty shift_expr_var; |
| 9217 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9218 | (shift_expr_var = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9219 | ) |
| 9220 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9221 | D(fprintf(stderr, "%*c+ bitwise_and[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9222 | _res = shift_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9223 | goto done; |
| 9224 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9225 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9226 | D(fprintf(stderr, "%*c%s bitwise_and[%d-%d]: %s failed!\n", p->level, ' ', |
| 9227 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9228 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9229 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9230 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9231 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9232 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9233 | } |
| 9234 | |
| 9235 | // Left-recursive |
| 9236 | // shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum |
| 9237 | static expr_ty shift_expr_raw(Parser *); |
| 9238 | static expr_ty |
| 9239 | shift_expr_rule(Parser *p) |
| 9240 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9241 | D(p->level++); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9242 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9243 | if (_PyPegen_is_memoized(p, shift_expr_type, &_res)) { |
| 9244 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9245 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9246 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9247 | int _mark = p->mark; |
| 9248 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9249 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9250 | int tmpvar_4 = _PyPegen_update_memo(p, _mark, shift_expr_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9251 | if (tmpvar_4) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9252 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9253 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9254 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9255 | p->mark = _mark; |
| 9256 | void *_raw = shift_expr_raw(p); |
| 9257 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9258 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9259 | _resmark = p->mark; |
| 9260 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9261 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9262 | p->mark = _resmark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9263 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9264 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9265 | } |
| 9266 | static expr_ty |
| 9267 | shift_expr_raw(Parser *p) |
| 9268 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9269 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9270 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9271 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9272 | return NULL; |
| 9273 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9274 | expr_ty _res = NULL; |
| 9275 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9276 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9277 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9278 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9279 | return NULL; |
| 9280 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9281 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9282 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9283 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9284 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9285 | { // shift_expr '<<' sum |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9286 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9287 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9288 | return NULL; |
| 9289 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9290 | D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9291 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9292 | expr_ty a; |
| 9293 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9294 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9295 | (a = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9296 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9297 | (_literal = _PyPegen_expect_token(p, 33)) // token='<<' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9298 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9299 | (b = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9300 | ) |
| 9301 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9302 | D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '<<' sum")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9303 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9304 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9305 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9306 | return NULL; |
| 9307 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9308 | int _end_lineno = _token->end_lineno; |
| 9309 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9310 | int _end_col_offset = _token->end_col_offset; |
| 9311 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9312 | _res = _Py_BinOp ( a , LShift , b , EXTRA ); |
| 9313 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9314 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9315 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9316 | return NULL; |
| 9317 | } |
| 9318 | goto done; |
| 9319 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9320 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9321 | D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', |
| 9322 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '<<' sum")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9323 | } |
| 9324 | { // shift_expr '>>' sum |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9325 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9326 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9327 | return NULL; |
| 9328 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9329 | D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9330 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9331 | expr_ty a; |
| 9332 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9333 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9334 | (a = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9335 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9336 | (_literal = _PyPegen_expect_token(p, 34)) // token='>>' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9337 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9338 | (b = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9339 | ) |
| 9340 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9341 | D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "shift_expr '>>' sum")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9342 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9343 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9344 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9345 | return NULL; |
| 9346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9347 | int _end_lineno = _token->end_lineno; |
| 9348 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9349 | int _end_col_offset = _token->end_col_offset; |
| 9350 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9351 | _res = _Py_BinOp ( a , RShift , b , EXTRA ); |
| 9352 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9353 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9354 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9355 | return NULL; |
| 9356 | } |
| 9357 | goto done; |
| 9358 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9359 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9360 | D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', |
| 9361 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "shift_expr '>>' sum")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9362 | } |
| 9363 | { // sum |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9364 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9365 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9366 | return NULL; |
| 9367 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9368 | D(fprintf(stderr, "%*c> shift_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9369 | expr_ty sum_var; |
| 9370 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9371 | (sum_var = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9372 | ) |
| 9373 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9374 | D(fprintf(stderr, "%*c+ shift_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9375 | _res = sum_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9376 | goto done; |
| 9377 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9378 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9379 | D(fprintf(stderr, "%*c%s shift_expr[%d-%d]: %s failed!\n", p->level, ' ', |
| 9380 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9381 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9382 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9383 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9384 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9385 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9386 | } |
| 9387 | |
| 9388 | // Left-recursive |
| 9389 | // sum: sum '+' term | sum '-' term | term |
| 9390 | static expr_ty sum_raw(Parser *); |
| 9391 | static expr_ty |
| 9392 | sum_rule(Parser *p) |
| 9393 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9394 | D(p->level++); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9395 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9396 | if (_PyPegen_is_memoized(p, sum_type, &_res)) { |
| 9397 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9398 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9399 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9400 | int _mark = p->mark; |
| 9401 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9402 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9403 | int tmpvar_5 = _PyPegen_update_memo(p, _mark, sum_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9404 | if (tmpvar_5) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9405 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9406 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9407 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9408 | p->mark = _mark; |
| 9409 | void *_raw = sum_raw(p); |
| 9410 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9411 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9412 | _resmark = p->mark; |
| 9413 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9414 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9415 | p->mark = _resmark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9416 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9417 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9418 | } |
| 9419 | static expr_ty |
| 9420 | sum_raw(Parser *p) |
| 9421 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9422 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9423 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9424 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9425 | return NULL; |
| 9426 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9427 | expr_ty _res = NULL; |
| 9428 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9429 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9430 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9431 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9432 | return NULL; |
| 9433 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9434 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9435 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9436 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9437 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9438 | { // sum '+' term |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9439 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9440 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9441 | return NULL; |
| 9442 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9443 | D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '+' term")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9444 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9445 | expr_ty a; |
| 9446 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9447 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9448 | (a = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9449 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9450 | (_literal = _PyPegen_expect_token(p, 14)) // token='+' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9451 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9452 | (b = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9453 | ) |
| 9454 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9455 | D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '+' term")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9456 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9457 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9458 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9459 | return NULL; |
| 9460 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9461 | int _end_lineno = _token->end_lineno; |
| 9462 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9463 | int _end_col_offset = _token->end_col_offset; |
| 9464 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9465 | _res = _Py_BinOp ( a , Add , b , EXTRA ); |
| 9466 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9467 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9468 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9469 | return NULL; |
| 9470 | } |
| 9471 | goto done; |
| 9472 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9473 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9474 | D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', |
| 9475 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '+' term")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9476 | } |
| 9477 | { // sum '-' term |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9478 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9479 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9480 | return NULL; |
| 9481 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9482 | D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "sum '-' term")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9483 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9484 | expr_ty a; |
| 9485 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9486 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9487 | (a = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9488 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9489 | (_literal = _PyPegen_expect_token(p, 15)) // token='-' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9490 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9491 | (b = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9492 | ) |
| 9493 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9494 | D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "sum '-' term")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9495 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9496 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9497 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9498 | return NULL; |
| 9499 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9500 | int _end_lineno = _token->end_lineno; |
| 9501 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9502 | int _end_col_offset = _token->end_col_offset; |
| 9503 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9504 | _res = _Py_BinOp ( a , Sub , b , EXTRA ); |
| 9505 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9506 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9507 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9508 | return NULL; |
| 9509 | } |
| 9510 | goto done; |
| 9511 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9512 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9513 | D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', |
| 9514 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "sum '-' term")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9515 | } |
| 9516 | { // term |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9517 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9518 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9519 | return NULL; |
| 9520 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9521 | D(fprintf(stderr, "%*c> sum[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9522 | expr_ty term_var; |
| 9523 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9524 | (term_var = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9525 | ) |
| 9526 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9527 | D(fprintf(stderr, "%*c+ sum[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9528 | _res = term_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9529 | goto done; |
| 9530 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9531 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9532 | D(fprintf(stderr, "%*c%s sum[%d-%d]: %s failed!\n", p->level, ' ', |
| 9533 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9534 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9535 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9536 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9537 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9538 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9539 | } |
| 9540 | |
| 9541 | // Left-recursive |
| 9542 | // term: |
| 9543 | // | term '*' factor |
| 9544 | // | term '/' factor |
| 9545 | // | term '//' factor |
| 9546 | // | term '%' factor |
| 9547 | // | term '@' factor |
| 9548 | // | factor |
| 9549 | static expr_ty term_raw(Parser *); |
| 9550 | static expr_ty |
| 9551 | term_rule(Parser *p) |
| 9552 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9553 | D(p->level++); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9554 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9555 | if (_PyPegen_is_memoized(p, term_type, &_res)) { |
| 9556 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9557 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9558 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9559 | int _mark = p->mark; |
| 9560 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9561 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9562 | int tmpvar_6 = _PyPegen_update_memo(p, _mark, term_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9563 | if (tmpvar_6) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9564 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9565 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9566 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9567 | p->mark = _mark; |
| 9568 | void *_raw = term_raw(p); |
| 9569 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9570 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9571 | _resmark = p->mark; |
| 9572 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9573 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9574 | p->mark = _resmark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9575 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9576 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9577 | } |
| 9578 | static expr_ty |
| 9579 | term_raw(Parser *p) |
| 9580 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9581 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9582 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9583 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9584 | return NULL; |
| 9585 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9586 | expr_ty _res = NULL; |
| 9587 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9588 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9589 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9590 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9591 | return NULL; |
| 9592 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9593 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9594 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9595 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9596 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9597 | { // term '*' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9598 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9599 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9600 | return NULL; |
| 9601 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9602 | D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '*' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9603 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9604 | expr_ty a; |
| 9605 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9606 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9607 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9608 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9609 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9610 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9611 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9612 | ) |
| 9613 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9614 | D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '*' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9615 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9616 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9617 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9618 | return NULL; |
| 9619 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9620 | int _end_lineno = _token->end_lineno; |
| 9621 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9622 | int _end_col_offset = _token->end_col_offset; |
| 9623 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9624 | _res = _Py_BinOp ( a , Mult , b , EXTRA ); |
| 9625 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9626 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9627 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9628 | return NULL; |
| 9629 | } |
| 9630 | goto done; |
| 9631 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9632 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9633 | D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', |
| 9634 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '*' factor")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9635 | } |
| 9636 | { // term '/' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9637 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9638 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9639 | return NULL; |
| 9640 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9641 | D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '/' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9642 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9643 | expr_ty a; |
| 9644 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9645 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9646 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9647 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9648 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9649 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9650 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9651 | ) |
| 9652 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9653 | D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '/' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9654 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9655 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9656 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9657 | return NULL; |
| 9658 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9659 | int _end_lineno = _token->end_lineno; |
| 9660 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9661 | int _end_col_offset = _token->end_col_offset; |
| 9662 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9663 | _res = _Py_BinOp ( a , Div , b , EXTRA ); |
| 9664 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9665 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9666 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9667 | return NULL; |
| 9668 | } |
| 9669 | goto done; |
| 9670 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9671 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9672 | D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', |
| 9673 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '/' factor")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9674 | } |
| 9675 | { // term '//' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9676 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9677 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9678 | return NULL; |
| 9679 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9680 | D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '//' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9681 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9682 | expr_ty a; |
| 9683 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9684 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9685 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9686 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9687 | (_literal = _PyPegen_expect_token(p, 47)) // token='//' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9688 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9689 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9690 | ) |
| 9691 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9692 | D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '//' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9693 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9694 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9695 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9696 | return NULL; |
| 9697 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9698 | int _end_lineno = _token->end_lineno; |
| 9699 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9700 | int _end_col_offset = _token->end_col_offset; |
| 9701 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9702 | _res = _Py_BinOp ( a , FloorDiv , b , EXTRA ); |
| 9703 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9704 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9705 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9706 | return NULL; |
| 9707 | } |
| 9708 | goto done; |
| 9709 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9710 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9711 | D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', |
| 9712 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '//' factor")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9713 | } |
| 9714 | { // term '%' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9715 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9716 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9717 | return NULL; |
| 9718 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9719 | D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '%' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9720 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9721 | expr_ty a; |
| 9722 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9723 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9724 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9725 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9726 | (_literal = _PyPegen_expect_token(p, 24)) // token='%' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9727 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9728 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9729 | ) |
| 9730 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9731 | D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '%' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9732 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9733 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9734 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9735 | return NULL; |
| 9736 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9737 | int _end_lineno = _token->end_lineno; |
| 9738 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9739 | int _end_col_offset = _token->end_col_offset; |
| 9740 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9741 | _res = _Py_BinOp ( a , Mod , b , EXTRA ); |
| 9742 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9743 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9744 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9745 | return NULL; |
| 9746 | } |
| 9747 | goto done; |
| 9748 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9749 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9750 | D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', |
| 9751 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '%' factor")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9752 | } |
| 9753 | { // term '@' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9754 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9755 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9756 | return NULL; |
| 9757 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9758 | D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "term '@' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9759 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9760 | expr_ty a; |
| 9761 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9762 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9763 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9764 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9765 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9766 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9767 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9768 | ) |
| 9769 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9770 | D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "term '@' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9771 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9772 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9773 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9774 | return NULL; |
| 9775 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9776 | int _end_lineno = _token->end_lineno; |
| 9777 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9778 | int _end_col_offset = _token->end_col_offset; |
| 9779 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9780 | _res = CHECK_VERSION ( 5 , "The '@' operator is" , _Py_BinOp ( a , MatMult , b , EXTRA ) ); |
| 9781 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9782 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9783 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9784 | return NULL; |
| 9785 | } |
| 9786 | goto done; |
| 9787 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9788 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9789 | D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', |
| 9790 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "term '@' factor")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9791 | } |
| 9792 | { // factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9793 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9794 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9795 | return NULL; |
| 9796 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9797 | D(fprintf(stderr, "%*c> term[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "factor")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9798 | expr_ty factor_var; |
| 9799 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9800 | (factor_var = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9801 | ) |
| 9802 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9803 | D(fprintf(stderr, "%*c+ term[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9804 | _res = factor_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9805 | goto done; |
| 9806 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9807 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9808 | D(fprintf(stderr, "%*c%s term[%d-%d]: %s failed!\n", p->level, ' ', |
| 9809 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "factor")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9810 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9811 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9812 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9813 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9814 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9815 | } |
| 9816 | |
| 9817 | // factor: '+' factor | '-' factor | '~' factor | power |
| 9818 | static expr_ty |
| 9819 | factor_rule(Parser *p) |
| 9820 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9821 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9822 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9823 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9824 | return NULL; |
| 9825 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9826 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9827 | if (_PyPegen_is_memoized(p, factor_type, &_res)) { |
| 9828 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9829 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9830 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9831 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9832 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9833 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9834 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9835 | return NULL; |
| 9836 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9837 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9838 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9839 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9840 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9841 | { // '+' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9842 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9843 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9844 | return NULL; |
| 9845 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9846 | D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'+' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9847 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9848 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9849 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9850 | (_literal = _PyPegen_expect_token(p, 14)) // token='+' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9851 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9852 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9853 | ) |
| 9854 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9855 | D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'+' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9856 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9857 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9858 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9859 | return NULL; |
| 9860 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9861 | int _end_lineno = _token->end_lineno; |
| 9862 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9863 | int _end_col_offset = _token->end_col_offset; |
| 9864 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9865 | _res = _Py_UnaryOp ( UAdd , a , EXTRA ); |
| 9866 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9867 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9868 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9869 | return NULL; |
| 9870 | } |
| 9871 | goto done; |
| 9872 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9873 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9874 | D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', |
| 9875 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'+' factor")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9876 | } |
| 9877 | { // '-' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9878 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9879 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9880 | return NULL; |
| 9881 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9882 | D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'-' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9883 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9884 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9885 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9886 | (_literal = _PyPegen_expect_token(p, 15)) // token='-' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9887 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9888 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9889 | ) |
| 9890 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9891 | D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'-' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9892 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9893 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9894 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9895 | return NULL; |
| 9896 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9897 | int _end_lineno = _token->end_lineno; |
| 9898 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9899 | int _end_col_offset = _token->end_col_offset; |
| 9900 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9901 | _res = _Py_UnaryOp ( USub , a , EXTRA ); |
| 9902 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9903 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9904 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9905 | return NULL; |
| 9906 | } |
| 9907 | goto done; |
| 9908 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9909 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9910 | D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', |
| 9911 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'-' factor")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9912 | } |
| 9913 | { // '~' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9914 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9915 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9916 | return NULL; |
| 9917 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9918 | D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'~' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9919 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9920 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9921 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9922 | (_literal = _PyPegen_expect_token(p, 31)) // token='~' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9923 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9924 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9925 | ) |
| 9926 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9927 | D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'~' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9928 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9929 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9930 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9931 | return NULL; |
| 9932 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9933 | int _end_lineno = _token->end_lineno; |
| 9934 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9935 | int _end_col_offset = _token->end_col_offset; |
| 9936 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9937 | _res = _Py_UnaryOp ( Invert , a , EXTRA ); |
| 9938 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9939 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9940 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9941 | return NULL; |
| 9942 | } |
| 9943 | goto done; |
| 9944 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9945 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9946 | D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', |
| 9947 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'~' factor")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9948 | } |
| 9949 | { // power |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9950 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9951 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9952 | return NULL; |
| 9953 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9954 | D(fprintf(stderr, "%*c> factor[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "power")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9955 | expr_ty power_var; |
| 9956 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9957 | (power_var = power_rule(p)) // power |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9958 | ) |
| 9959 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9960 | D(fprintf(stderr, "%*c+ factor[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "power")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9961 | _res = power_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9962 | goto done; |
| 9963 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9964 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9965 | D(fprintf(stderr, "%*c%s factor[%d-%d]: %s failed!\n", p->level, ' ', |
| 9966 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "power")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9967 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9968 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9969 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9970 | _PyPegen_insert_memo(p, _mark, factor_type, _res); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9971 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9972 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9973 | } |
| 9974 | |
| 9975 | // power: await_primary '**' factor | await_primary |
| 9976 | static expr_ty |
| 9977 | power_rule(Parser *p) |
| 9978 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9979 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9980 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9981 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9982 | return NULL; |
| 9983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9984 | expr_ty _res = NULL; |
| 9985 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9986 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9987 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9988 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9989 | return NULL; |
| 9990 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9991 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9992 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9993 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9994 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9995 | { // await_primary '**' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9996 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 9997 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9998 | return NULL; |
| 9999 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10000 | D(fprintf(stderr, "%*c> power[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "await_primary '**' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10001 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10002 | expr_ty a; |
| 10003 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10004 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10005 | (a = await_primary_rule(p)) // await_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10006 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10007 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10008 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10009 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10010 | ) |
| 10011 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10012 | D(fprintf(stderr, "%*c+ power[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "await_primary '**' factor")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10013 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10014 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10015 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10016 | return NULL; |
| 10017 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10018 | int _end_lineno = _token->end_lineno; |
| 10019 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10020 | int _end_col_offset = _token->end_col_offset; |
| 10021 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10022 | _res = _Py_BinOp ( a , Pow , b , EXTRA ); |
| 10023 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10024 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10025 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10026 | return NULL; |
| 10027 | } |
| 10028 | goto done; |
| 10029 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10030 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10031 | D(fprintf(stderr, "%*c%s power[%d-%d]: %s failed!\n", p->level, ' ', |
| 10032 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "await_primary '**' factor")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10033 | } |
| 10034 | { // await_primary |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10035 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10036 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10037 | return NULL; |
| 10038 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10039 | D(fprintf(stderr, "%*c> power[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "await_primary")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10040 | expr_ty await_primary_var; |
| 10041 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10042 | (await_primary_var = await_primary_rule(p)) // await_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10043 | ) |
| 10044 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10045 | D(fprintf(stderr, "%*c+ power[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "await_primary")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10046 | _res = await_primary_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10047 | goto done; |
| 10048 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10049 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10050 | D(fprintf(stderr, "%*c%s power[%d-%d]: %s failed!\n", p->level, ' ', |
| 10051 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "await_primary")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10052 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10053 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10054 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10055 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10056 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10057 | } |
| 10058 | |
| 10059 | // await_primary: AWAIT primary | primary |
| 10060 | static expr_ty |
| 10061 | await_primary_rule(Parser *p) |
| 10062 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10063 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10064 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10065 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10066 | return NULL; |
| 10067 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10068 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10069 | if (_PyPegen_is_memoized(p, await_primary_type, &_res)) { |
| 10070 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10071 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10072 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10073 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10074 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10075 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10076 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10077 | return NULL; |
| 10078 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10079 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10080 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10081 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10082 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10083 | { // AWAIT primary |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10084 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10085 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10086 | return NULL; |
| 10087 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10088 | D(fprintf(stderr, "%*c> await_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "AWAIT primary")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10089 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10090 | Token * await_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10091 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10092 | (await_var = _PyPegen_expect_token(p, AWAIT)) // token='AWAIT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10093 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10094 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10095 | ) |
| 10096 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10097 | D(fprintf(stderr, "%*c+ await_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "AWAIT primary")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10098 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10099 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10100 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10101 | return NULL; |
| 10102 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10103 | int _end_lineno = _token->end_lineno; |
| 10104 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10105 | int _end_col_offset = _token->end_col_offset; |
| 10106 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10107 | _res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) ); |
| 10108 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10109 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10110 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10111 | return NULL; |
| 10112 | } |
| 10113 | goto done; |
| 10114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10115 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10116 | D(fprintf(stderr, "%*c%s await_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 10117 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "AWAIT primary")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10118 | } |
| 10119 | { // primary |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10120 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10121 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10122 | return NULL; |
| 10123 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10124 | D(fprintf(stderr, "%*c> await_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10125 | expr_ty primary_var; |
| 10126 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10127 | (primary_var = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10128 | ) |
| 10129 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10130 | D(fprintf(stderr, "%*c+ await_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10131 | _res = primary_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10132 | goto done; |
| 10133 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10134 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10135 | D(fprintf(stderr, "%*c%s await_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 10136 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10137 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10138 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10139 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10140 | _PyPegen_insert_memo(p, _mark, await_primary_type, _res); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10141 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10142 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10143 | } |
| 10144 | |
| 10145 | // Left-recursive |
| 10146 | // primary: |
| 10147 | // | primary '.' NAME |
| 10148 | // | primary genexp |
| 10149 | // | primary '(' arguments? ')' |
| 10150 | // | primary '[' slices ']' |
| 10151 | // | atom |
| 10152 | static expr_ty primary_raw(Parser *); |
| 10153 | static expr_ty |
| 10154 | primary_rule(Parser *p) |
| 10155 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10156 | D(p->level++); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10157 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10158 | if (_PyPegen_is_memoized(p, primary_type, &_res)) { |
| 10159 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10160 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10161 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10162 | int _mark = p->mark; |
| 10163 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10164 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10165 | int tmpvar_7 = _PyPegen_update_memo(p, _mark, primary_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10166 | if (tmpvar_7) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10167 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10168 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10169 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10170 | p->mark = _mark; |
| 10171 | void *_raw = primary_raw(p); |
| 10172 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10173 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10174 | _resmark = p->mark; |
| 10175 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10176 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10177 | p->mark = _resmark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10178 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10179 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10180 | } |
| 10181 | static expr_ty |
| 10182 | primary_raw(Parser *p) |
| 10183 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10184 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10185 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10186 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10187 | return NULL; |
| 10188 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10189 | expr_ty _res = NULL; |
| 10190 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10191 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10192 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10193 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10194 | return NULL; |
| 10195 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10196 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10197 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10198 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10199 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10200 | { // primary '.' NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10201 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10202 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10203 | return NULL; |
| 10204 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10205 | D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '.' NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10206 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10207 | expr_ty a; |
| 10208 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10209 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10210 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10211 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10212 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10213 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10214 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10215 | ) |
| 10216 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10217 | D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '.' NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10218 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10219 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10220 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10221 | return NULL; |
| 10222 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10223 | int _end_lineno = _token->end_lineno; |
| 10224 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10225 | int _end_col_offset = _token->end_col_offset; |
| 10226 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10227 | _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
| 10228 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10229 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10230 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10231 | return NULL; |
| 10232 | } |
| 10233 | goto done; |
| 10234 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10235 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10236 | D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 10237 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '.' NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10238 | } |
| 10239 | { // primary genexp |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10240 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10241 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10242 | return NULL; |
| 10243 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10244 | D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary genexp")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10245 | expr_ty a; |
| 10246 | expr_ty b; |
| 10247 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10248 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10249 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10250 | (b = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10251 | ) |
| 10252 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10253 | D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary genexp")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10254 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10255 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10256 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10257 | return NULL; |
| 10258 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10259 | int _end_lineno = _token->end_lineno; |
| 10260 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10261 | int _end_col_offset = _token->end_col_offset; |
| 10262 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10263 | _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
| 10264 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10265 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10266 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10267 | return NULL; |
| 10268 | } |
| 10269 | goto done; |
| 10270 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10271 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10272 | D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 10273 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary genexp")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10274 | } |
| 10275 | { // primary '(' arguments? ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10276 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10277 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10278 | return NULL; |
| 10279 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10280 | D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '(' arguments? ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10281 | Token * _literal; |
| 10282 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10283 | expr_ty a; |
| 10284 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10285 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10286 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10287 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10288 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10289 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10290 | (b = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10291 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10292 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10293 | ) |
| 10294 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10295 | D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '(' arguments? ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10296 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10297 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10298 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10299 | return NULL; |
| 10300 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10301 | int _end_lineno = _token->end_lineno; |
| 10302 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10303 | int _end_col_offset = _token->end_col_offset; |
| 10304 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10305 | _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 10306 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10307 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10308 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10309 | return NULL; |
| 10310 | } |
| 10311 | goto done; |
| 10312 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10313 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10314 | D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 10315 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '(' arguments? ')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10316 | } |
| 10317 | { // primary '[' slices ']' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10318 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10319 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10320 | return NULL; |
| 10321 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10322 | D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "primary '[' slices ']'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10323 | Token * _literal; |
| 10324 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10325 | expr_ty a; |
| 10326 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10327 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10328 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10329 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10330 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10331 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10332 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10333 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10334 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10335 | ) |
| 10336 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10337 | D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "primary '[' slices ']'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10338 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10339 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10340 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10341 | return NULL; |
| 10342 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10343 | int _end_lineno = _token->end_lineno; |
| 10344 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10345 | int _end_col_offset = _token->end_col_offset; |
| 10346 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10347 | _res = _Py_Subscript ( a , b , Load , EXTRA ); |
| 10348 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10349 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10350 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10351 | return NULL; |
| 10352 | } |
| 10353 | goto done; |
| 10354 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10355 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10356 | D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 10357 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "primary '[' slices ']'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10358 | } |
| 10359 | { // atom |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10360 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10361 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10362 | return NULL; |
| 10363 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10364 | D(fprintf(stderr, "%*c> primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "atom")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10365 | expr_ty atom_var; |
| 10366 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10367 | (atom_var = atom_rule(p)) // atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10368 | ) |
| 10369 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10370 | D(fprintf(stderr, "%*c+ primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "atom")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10371 | _res = atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10372 | goto done; |
| 10373 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10374 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10375 | D(fprintf(stderr, "%*c%s primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 10376 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "atom")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10377 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10378 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10379 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10380 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10381 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10382 | } |
| 10383 | |
| 10384 | // slices: slice !',' | ','.slice+ ','? |
| 10385 | static expr_ty |
| 10386 | slices_rule(Parser *p) |
| 10387 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10388 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10389 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10390 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10391 | return NULL; |
| 10392 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10393 | expr_ty _res = NULL; |
| 10394 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10395 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10396 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10397 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10398 | return NULL; |
| 10399 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10400 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10401 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10402 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10403 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10404 | { // slice !',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10405 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10406 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10407 | return NULL; |
| 10408 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10409 | D(fprintf(stderr, "%*c> slices[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice !','")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10410 | expr_ty a; |
| 10411 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10412 | (a = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10413 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10414 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10415 | ) |
| 10416 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10417 | D(fprintf(stderr, "%*c+ slices[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice !','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10418 | _res = a; |
| 10419 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10420 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10421 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10422 | return NULL; |
| 10423 | } |
| 10424 | goto done; |
| 10425 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10426 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10427 | D(fprintf(stderr, "%*c%s slices[%d-%d]: %s failed!\n", p->level, ' ', |
| 10428 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice !','")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10429 | } |
| 10430 | { // ','.slice+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10431 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10432 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10433 | return NULL; |
| 10434 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10435 | D(fprintf(stderr, "%*c> slices[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.slice+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10436 | void *_opt_var; |
| 10437 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10438 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10439 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10440 | (a = _gather_93_rule(p)) // ','.slice+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10441 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10442 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10443 | ) |
| 10444 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10445 | D(fprintf(stderr, "%*c+ slices[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.slice+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10446 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10447 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10448 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10449 | return NULL; |
| 10450 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10451 | int _end_lineno = _token->end_lineno; |
| 10452 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10453 | int _end_col_offset = _token->end_col_offset; |
| 10454 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10455 | _res = _Py_Tuple ( a , Load , EXTRA ); |
| 10456 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10457 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10458 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10459 | return NULL; |
| 10460 | } |
| 10461 | goto done; |
| 10462 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10463 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10464 | D(fprintf(stderr, "%*c%s slices[%d-%d]: %s failed!\n", p->level, ' ', |
| 10465 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.slice+ ','?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10466 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10467 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10468 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10469 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10470 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10471 | } |
| 10472 | |
| 10473 | // slice: expression? ':' expression? [':' expression?] | expression |
| 10474 | static expr_ty |
| 10475 | slice_rule(Parser *p) |
| 10476 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10477 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10478 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10479 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10480 | return NULL; |
| 10481 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10482 | expr_ty _res = NULL; |
| 10483 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10484 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10485 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10486 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10487 | return NULL; |
| 10488 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10489 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10490 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10491 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10492 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10493 | { // expression? ':' expression? [':' expression?] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10494 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10495 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10496 | return NULL; |
| 10497 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10498 | D(fprintf(stderr, "%*c> slice[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10499 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10500 | void *a; |
| 10501 | void *b; |
| 10502 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10503 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10504 | (a = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10505 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10506 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10507 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10508 | (b = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10509 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10510 | (c = _tmp_95_rule(p), 1) // [':' expression?] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10511 | ) |
| 10512 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10513 | D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression? ':' expression? [':' expression?]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10514 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10515 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10516 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10517 | return NULL; |
| 10518 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10519 | int _end_lineno = _token->end_lineno; |
| 10520 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10521 | int _end_col_offset = _token->end_col_offset; |
| 10522 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10523 | _res = _Py_Slice ( a , b , c , EXTRA ); |
| 10524 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10525 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10526 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10527 | return NULL; |
| 10528 | } |
| 10529 | goto done; |
| 10530 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10531 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10532 | D(fprintf(stderr, "%*c%s slice[%d-%d]: %s failed!\n", p->level, ' ', |
| 10533 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression? ':' expression? [':' expression?]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10534 | } |
| 10535 | { // expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10536 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10537 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10538 | return NULL; |
| 10539 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10540 | D(fprintf(stderr, "%*c> slice[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10541 | expr_ty a; |
| 10542 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10543 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10544 | ) |
| 10545 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10546 | D(fprintf(stderr, "%*c+ slice[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10547 | _res = a; |
| 10548 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10549 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10550 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10551 | return NULL; |
| 10552 | } |
| 10553 | goto done; |
| 10554 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10555 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10556 | D(fprintf(stderr, "%*c%s slice[%d-%d]: %s failed!\n", p->level, ' ', |
| 10557 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10558 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10559 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10560 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10561 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10562 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10563 | } |
| 10564 | |
| 10565 | // atom: |
| 10566 | // | NAME |
| 10567 | // | 'True' |
| 10568 | // | 'False' |
| 10569 | // | 'None' |
| 10570 | // | '__new_parser__' |
| 10571 | // | &STRING strings |
| 10572 | // | NUMBER |
| 10573 | // | &'(' (tuple | group | genexp) |
| 10574 | // | &'[' (list | listcomp) |
| 10575 | // | &'{' (dict | set | dictcomp | setcomp) |
| 10576 | // | '...' |
| 10577 | static expr_ty |
| 10578 | atom_rule(Parser *p) |
| 10579 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10580 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10581 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10582 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10583 | return NULL; |
| 10584 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10585 | expr_ty _res = NULL; |
| 10586 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10587 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10588 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10589 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10590 | return NULL; |
| 10591 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10592 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10593 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10594 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10595 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10596 | { // NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10597 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10598 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10599 | return NULL; |
| 10600 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10601 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10602 | expr_ty name_var; |
| 10603 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10604 | (name_var = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10605 | ) |
| 10606 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10607 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10608 | _res = name_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10609 | goto done; |
| 10610 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10611 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10612 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 10613 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10614 | } |
| 10615 | { // 'True' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10616 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10617 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10618 | return NULL; |
| 10619 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10620 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'True'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10621 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10622 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10623 | (_keyword = _PyPegen_expect_token(p, 527)) // token='True' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10624 | ) |
| 10625 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10626 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'True'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10627 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10628 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10629 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10630 | return NULL; |
| 10631 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10632 | int _end_lineno = _token->end_lineno; |
| 10633 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10634 | int _end_col_offset = _token->end_col_offset; |
| 10635 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10636 | _res = _Py_Constant ( Py_True , NULL , EXTRA ); |
| 10637 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10638 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10639 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10640 | return NULL; |
| 10641 | } |
| 10642 | goto done; |
| 10643 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10644 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10645 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 10646 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'True'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10647 | } |
| 10648 | { // 'False' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10649 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10650 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10651 | return NULL; |
| 10652 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10653 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'False'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10654 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10655 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10656 | (_keyword = _PyPegen_expect_token(p, 528)) // token='False' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10657 | ) |
| 10658 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10659 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'False'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10660 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10661 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10662 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10663 | return NULL; |
| 10664 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10665 | int _end_lineno = _token->end_lineno; |
| 10666 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10667 | int _end_col_offset = _token->end_col_offset; |
| 10668 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10669 | _res = _Py_Constant ( Py_False , NULL , EXTRA ); |
| 10670 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10671 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10672 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10673 | return NULL; |
| 10674 | } |
| 10675 | goto done; |
| 10676 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10677 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10678 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 10679 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'False'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10680 | } |
| 10681 | { // 'None' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10682 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10683 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10684 | return NULL; |
| 10685 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10686 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'None'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10687 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10688 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10689 | (_keyword = _PyPegen_expect_token(p, 529)) // token='None' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10690 | ) |
| 10691 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10692 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'None'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10693 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10694 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10695 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10696 | return NULL; |
| 10697 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10698 | int _end_lineno = _token->end_lineno; |
| 10699 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10700 | int _end_col_offset = _token->end_col_offset; |
| 10701 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10702 | _res = _Py_Constant ( Py_None , NULL , EXTRA ); |
| 10703 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10704 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10705 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10706 | return NULL; |
| 10707 | } |
| 10708 | goto done; |
| 10709 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10710 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10711 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 10712 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'None'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10713 | } |
| 10714 | { // '__new_parser__' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10715 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10716 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10717 | return NULL; |
| 10718 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10719 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'__new_parser__'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10720 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10721 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10722 | (_keyword = _PyPegen_expect_token(p, 530)) // token='__new_parser__' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10723 | ) |
| 10724 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10725 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'__new_parser__'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10726 | _res = RAISE_SYNTAX_ERROR ( "You found it!" ); |
| 10727 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10728 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10729 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10730 | return NULL; |
| 10731 | } |
| 10732 | goto done; |
| 10733 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10734 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10735 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 10736 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'__new_parser__'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10737 | } |
| 10738 | { // &STRING strings |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10739 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10740 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10741 | return NULL; |
| 10742 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10743 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&STRING strings")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10744 | expr_ty strings_var; |
| 10745 | if ( |
| 10746 | _PyPegen_lookahead(1, _PyPegen_string_token, p) |
| 10747 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10748 | (strings_var = strings_rule(p)) // strings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10749 | ) |
| 10750 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10751 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&STRING strings")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10752 | _res = strings_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10753 | goto done; |
| 10754 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10755 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10756 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 10757 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&STRING strings")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10758 | } |
| 10759 | { // NUMBER |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10760 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10761 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10762 | return NULL; |
| 10763 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10764 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NUMBER")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10765 | expr_ty number_var; |
| 10766 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10767 | (number_var = _PyPegen_number_token(p)) // NUMBER |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10768 | ) |
| 10769 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10770 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NUMBER")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10771 | _res = number_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10772 | goto done; |
| 10773 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10774 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10775 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 10776 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NUMBER")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10777 | } |
| 10778 | { // &'(' (tuple | group | genexp) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10779 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10780 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10781 | return NULL; |
| 10782 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10783 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10784 | void *_tmp_96_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10785 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10786 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10787 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10788 | (_tmp_96_var = _tmp_96_rule(p)) // tuple | group | genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10789 | ) |
| 10790 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10791 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'(' (tuple | group | genexp)")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10792 | _res = _tmp_96_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10793 | goto done; |
| 10794 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10795 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10796 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 10797 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'(' (tuple | group | genexp)")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10798 | } |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 10799 | { // &'[' (list | listcomp) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10800 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10801 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10802 | return NULL; |
| 10803 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10804 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10805 | void *_tmp_97_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10806 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10807 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10808 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10809 | (_tmp_97_var = _tmp_97_rule(p)) // list | listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10810 | ) |
| 10811 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10812 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'[' (list | listcomp)")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10813 | _res = _tmp_97_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10814 | goto done; |
| 10815 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10816 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10817 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 10818 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'[' (list | listcomp)")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10819 | } |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 10820 | { // &'{' (dict | set | dictcomp | setcomp) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10821 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10822 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10823 | return NULL; |
| 10824 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10825 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10826 | void *_tmp_98_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 10827 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10828 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 10829 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10830 | (_tmp_98_var = _tmp_98_rule(p)) // dict | set | dictcomp | setcomp |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 10831 | ) |
| 10832 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10833 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10834 | _res = _tmp_98_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 10835 | goto done; |
| 10836 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10837 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10838 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 10839 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'{' (dict | set | dictcomp | setcomp)")); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 10840 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10841 | { // '...' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10842 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10843 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10844 | return NULL; |
| 10845 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10846 | D(fprintf(stderr, "%*c> atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10847 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10848 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10849 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10850 | ) |
| 10851 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10852 | D(fprintf(stderr, "%*c+ atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10853 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10854 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10855 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10856 | return NULL; |
| 10857 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10858 | int _end_lineno = _token->end_lineno; |
| 10859 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10860 | int _end_col_offset = _token->end_col_offset; |
| 10861 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10862 | _res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA ); |
| 10863 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10864 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10865 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10866 | return NULL; |
| 10867 | } |
| 10868 | goto done; |
| 10869 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10870 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10871 | D(fprintf(stderr, "%*c%s atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 10872 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10873 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10874 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10875 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10876 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10877 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10878 | } |
| 10879 | |
| 10880 | // strings: STRING+ |
| 10881 | static expr_ty |
| 10882 | strings_rule(Parser *p) |
| 10883 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10884 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10885 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10886 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10887 | return NULL; |
| 10888 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10889 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10890 | if (_PyPegen_is_memoized(p, strings_type, &_res)) { |
| 10891 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10892 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10893 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10894 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10895 | { // STRING+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10896 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10897 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10898 | return NULL; |
| 10899 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10900 | D(fprintf(stderr, "%*c> strings[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10901 | asdl_seq * a; |
| 10902 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10903 | (a = _loop1_99_rule(p)) // STRING+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10904 | ) |
| 10905 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10906 | D(fprintf(stderr, "%*c+ strings[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "STRING+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10907 | _res = _PyPegen_concatenate_strings ( p , a ); |
| 10908 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10909 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10910 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10911 | return NULL; |
| 10912 | } |
| 10913 | goto done; |
| 10914 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10915 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10916 | D(fprintf(stderr, "%*c%s strings[%d-%d]: %s failed!\n", p->level, ' ', |
| 10917 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10918 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10919 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10920 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10921 | _PyPegen_insert_memo(p, _mark, strings_type, _res); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10922 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10923 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10924 | } |
| 10925 | |
| 10926 | // list: '[' star_named_expressions? ']' |
| 10927 | static expr_ty |
| 10928 | list_rule(Parser *p) |
| 10929 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10930 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10931 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10932 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10933 | return NULL; |
| 10934 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10935 | expr_ty _res = NULL; |
| 10936 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10937 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10938 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10939 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10940 | return NULL; |
| 10941 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10942 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10943 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10944 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10945 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10946 | { // '[' star_named_expressions? ']' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10947 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10948 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10949 | return NULL; |
| 10950 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10951 | D(fprintf(stderr, "%*c> list[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' star_named_expressions? ']'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10952 | Token * _literal; |
| 10953 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10954 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10955 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10956 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10957 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10958 | (a = star_named_expressions_rule(p), 1) // star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10959 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10960 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10961 | ) |
| 10962 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10963 | D(fprintf(stderr, "%*c+ list[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' star_named_expressions? ']'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10964 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10965 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10966 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10967 | return NULL; |
| 10968 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10969 | int _end_lineno = _token->end_lineno; |
| 10970 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10971 | int _end_col_offset = _token->end_col_offset; |
| 10972 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10973 | _res = _Py_List ( a , Load , EXTRA ); |
| 10974 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10975 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10976 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10977 | return NULL; |
| 10978 | } |
| 10979 | goto done; |
| 10980 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10981 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10982 | D(fprintf(stderr, "%*c%s list[%d-%d]: %s failed!\n", p->level, ' ', |
| 10983 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' star_named_expressions? ']'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10984 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10985 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10986 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10987 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10988 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10989 | } |
| 10990 | |
| 10991 | // listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension |
| 10992 | static expr_ty |
| 10993 | listcomp_rule(Parser *p) |
| 10994 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10995 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10996 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 10997 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10998 | return NULL; |
| 10999 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11000 | expr_ty _res = NULL; |
| 11001 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11002 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 11003 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11004 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11005 | return NULL; |
| 11006 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11007 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11008 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11009 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11010 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11011 | { // '[' named_expression for_if_clauses ']' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11012 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11013 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11014 | return NULL; |
| 11015 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11016 | D(fprintf(stderr, "%*c> listcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' named_expression for_if_clauses ']'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11017 | Token * _literal; |
| 11018 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11019 | expr_ty a; |
| 11020 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11021 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11022 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11023 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11024 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11025 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11026 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11027 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11028 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11029 | ) |
| 11030 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11031 | D(fprintf(stderr, "%*c+ listcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' named_expression for_if_clauses ']'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11032 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11033 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11034 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11035 | return NULL; |
| 11036 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11037 | int _end_lineno = _token->end_lineno; |
| 11038 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11039 | int _end_col_offset = _token->end_col_offset; |
| 11040 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11041 | _res = _Py_ListComp ( a , b , EXTRA ); |
| 11042 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11043 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11044 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11045 | return NULL; |
| 11046 | } |
| 11047 | goto done; |
| 11048 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11049 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11050 | D(fprintf(stderr, "%*c%s listcomp[%d-%d]: %s failed!\n", p->level, ' ', |
| 11051 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' named_expression for_if_clauses ']'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11052 | } |
| 11053 | { // invalid_comprehension |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11054 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11055 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11056 | return NULL; |
| 11057 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11058 | D(fprintf(stderr, "%*c> listcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11059 | void *invalid_comprehension_var; |
| 11060 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11061 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11062 | ) |
| 11063 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11064 | D(fprintf(stderr, "%*c+ listcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11065 | _res = invalid_comprehension_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11066 | goto done; |
| 11067 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11068 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11069 | D(fprintf(stderr, "%*c%s listcomp[%d-%d]: %s failed!\n", p->level, ' ', |
| 11070 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11071 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11072 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11073 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11074 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11075 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11076 | } |
| 11077 | |
| 11078 | // tuple: '(' [star_named_expression ',' star_named_expressions?] ')' |
| 11079 | static expr_ty |
| 11080 | tuple_rule(Parser *p) |
| 11081 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11082 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11083 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11084 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11085 | return NULL; |
| 11086 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11087 | expr_ty _res = NULL; |
| 11088 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11089 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 11090 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11091 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11092 | return NULL; |
| 11093 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11094 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11095 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11096 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11097 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11098 | { // '(' [star_named_expression ',' star_named_expressions?] ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11099 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11100 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11101 | return NULL; |
| 11102 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11103 | D(fprintf(stderr, "%*c> tuple[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11104 | Token * _literal; |
| 11105 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11106 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11107 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11108 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11109 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11110 | (a = _tmp_100_rule(p), 1) // [star_named_expression ',' star_named_expressions?] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11111 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11112 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11113 | ) |
| 11114 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11115 | D(fprintf(stderr, "%*c+ tuple[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11116 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11117 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11118 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11119 | return NULL; |
| 11120 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11121 | int _end_lineno = _token->end_lineno; |
| 11122 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11123 | int _end_col_offset = _token->end_col_offset; |
| 11124 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11125 | _res = _Py_Tuple ( a , Load , EXTRA ); |
| 11126 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11127 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11128 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11129 | return NULL; |
| 11130 | } |
| 11131 | goto done; |
| 11132 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11133 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11134 | D(fprintf(stderr, "%*c%s tuple[%d-%d]: %s failed!\n", p->level, ' ', |
| 11135 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' [star_named_expression ',' star_named_expressions?] ')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11136 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11137 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11138 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11139 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11140 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11141 | } |
| 11142 | |
| 11143 | // group: '(' (yield_expr | named_expression) ')' |
| 11144 | static expr_ty |
| 11145 | group_rule(Parser *p) |
| 11146 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11147 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11148 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11149 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11150 | return NULL; |
| 11151 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11152 | expr_ty _res = NULL; |
| 11153 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11154 | { // '(' (yield_expr | named_expression) ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11155 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11156 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11157 | return NULL; |
| 11158 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11159 | D(fprintf(stderr, "%*c> group[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' (yield_expr | named_expression) ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11160 | Token * _literal; |
| 11161 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11162 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11163 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11164 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11165 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11166 | (a = _tmp_101_rule(p)) // yield_expr | named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11167 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11168 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11169 | ) |
| 11170 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11171 | D(fprintf(stderr, "%*c+ group[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' (yield_expr | named_expression) ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11172 | _res = a; |
| 11173 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11174 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11175 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11176 | return NULL; |
| 11177 | } |
| 11178 | goto done; |
| 11179 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11180 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11181 | D(fprintf(stderr, "%*c%s group[%d-%d]: %s failed!\n", p->level, ' ', |
| 11182 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' (yield_expr | named_expression) ')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11183 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11184 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11185 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11186 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11187 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11188 | } |
| 11189 | |
| 11190 | // genexp: '(' expression for_if_clauses ')' | invalid_comprehension |
| 11191 | static expr_ty |
| 11192 | genexp_rule(Parser *p) |
| 11193 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11194 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11195 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11196 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11197 | return NULL; |
| 11198 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11199 | expr_ty _res = NULL; |
| 11200 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11201 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 11202 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11203 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11204 | return NULL; |
| 11205 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11206 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11207 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11208 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11209 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11210 | { // '(' expression for_if_clauses ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11211 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11212 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11213 | return NULL; |
| 11214 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11215 | D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' expression for_if_clauses ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11216 | Token * _literal; |
| 11217 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11218 | expr_ty a; |
| 11219 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11220 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11221 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11222 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11223 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11224 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11225 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11226 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11227 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11228 | ) |
| 11229 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11230 | D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' expression for_if_clauses ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11231 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11232 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11233 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11234 | return NULL; |
| 11235 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11236 | int _end_lineno = _token->end_lineno; |
| 11237 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11238 | int _end_col_offset = _token->end_col_offset; |
| 11239 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11240 | _res = _Py_GeneratorExp ( a , b , EXTRA ); |
| 11241 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11242 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11243 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11244 | return NULL; |
| 11245 | } |
| 11246 | goto done; |
| 11247 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11248 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11249 | D(fprintf(stderr, "%*c%s genexp[%d-%d]: %s failed!\n", p->level, ' ', |
| 11250 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' expression for_if_clauses ')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11251 | } |
| 11252 | { // invalid_comprehension |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11253 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11254 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11255 | return NULL; |
| 11256 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11257 | D(fprintf(stderr, "%*c> genexp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11258 | void *invalid_comprehension_var; |
| 11259 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11260 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11261 | ) |
| 11262 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11263 | D(fprintf(stderr, "%*c+ genexp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11264 | _res = invalid_comprehension_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11265 | goto done; |
| 11266 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11267 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11268 | D(fprintf(stderr, "%*c%s genexp[%d-%d]: %s failed!\n", p->level, ' ', |
| 11269 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11270 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11271 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11272 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11273 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11274 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11275 | } |
| 11276 | |
| 11277 | // set: '{' expressions_list '}' |
| 11278 | static expr_ty |
| 11279 | set_rule(Parser *p) |
| 11280 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11281 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11282 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11283 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11284 | return NULL; |
| 11285 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11286 | expr_ty _res = NULL; |
| 11287 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11288 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 11289 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11290 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11291 | return NULL; |
| 11292 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11293 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11294 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11295 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11296 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11297 | { // '{' expressions_list '}' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11298 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11299 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11300 | return NULL; |
| 11301 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11302 | D(fprintf(stderr, "%*c> set[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' expressions_list '}'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11303 | Token * _literal; |
| 11304 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11305 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11306 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11307 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11308 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11309 | (a = expressions_list_rule(p)) // expressions_list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11310 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11311 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11312 | ) |
| 11313 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11314 | D(fprintf(stderr, "%*c+ set[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' expressions_list '}'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11315 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11316 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11317 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11318 | return NULL; |
| 11319 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11320 | int _end_lineno = _token->end_lineno; |
| 11321 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11322 | int _end_col_offset = _token->end_col_offset; |
| 11323 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11324 | _res = _Py_Set ( a , EXTRA ); |
| 11325 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11326 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11327 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11328 | return NULL; |
| 11329 | } |
| 11330 | goto done; |
| 11331 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11332 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11333 | D(fprintf(stderr, "%*c%s set[%d-%d]: %s failed!\n", p->level, ' ', |
| 11334 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' expressions_list '}'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11335 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11336 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11337 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11338 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11339 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11340 | } |
| 11341 | |
| 11342 | // setcomp: '{' expression for_if_clauses '}' | invalid_comprehension |
| 11343 | static expr_ty |
| 11344 | setcomp_rule(Parser *p) |
| 11345 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11346 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11347 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11348 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11349 | return NULL; |
| 11350 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11351 | expr_ty _res = NULL; |
| 11352 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11353 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 11354 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11355 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11356 | return NULL; |
| 11357 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11358 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11359 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11360 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11361 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11362 | { // '{' expression for_if_clauses '}' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11363 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11364 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11365 | return NULL; |
| 11366 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11367 | D(fprintf(stderr, "%*c> setcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' expression for_if_clauses '}'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11368 | Token * _literal; |
| 11369 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11370 | expr_ty a; |
| 11371 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11372 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11373 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11374 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11375 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11376 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11377 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11378 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11379 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11380 | ) |
| 11381 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11382 | D(fprintf(stderr, "%*c+ setcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' expression for_if_clauses '}'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11383 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11384 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11385 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11386 | return NULL; |
| 11387 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11388 | int _end_lineno = _token->end_lineno; |
| 11389 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11390 | int _end_col_offset = _token->end_col_offset; |
| 11391 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11392 | _res = _Py_SetComp ( a , b , EXTRA ); |
| 11393 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11394 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11395 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11396 | return NULL; |
| 11397 | } |
| 11398 | goto done; |
| 11399 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11400 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11401 | D(fprintf(stderr, "%*c%s setcomp[%d-%d]: %s failed!\n", p->level, ' ', |
| 11402 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' expression for_if_clauses '}'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11403 | } |
| 11404 | { // invalid_comprehension |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11405 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11406 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11407 | return NULL; |
| 11408 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11409 | D(fprintf(stderr, "%*c> setcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11410 | void *invalid_comprehension_var; |
| 11411 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11412 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11413 | ) |
| 11414 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11415 | D(fprintf(stderr, "%*c+ setcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_comprehension")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11416 | _res = invalid_comprehension_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11417 | goto done; |
| 11418 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11419 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11420 | D(fprintf(stderr, "%*c%s setcomp[%d-%d]: %s failed!\n", p->level, ' ', |
| 11421 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_comprehension")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11422 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11423 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11424 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11425 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11426 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11427 | } |
| 11428 | |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11429 | // dict: '{' double_starred_kvpairs? '}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11430 | static expr_ty |
| 11431 | dict_rule(Parser *p) |
| 11432 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11433 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11434 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11435 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11436 | return NULL; |
| 11437 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11438 | expr_ty _res = NULL; |
| 11439 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11440 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 11441 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11442 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11443 | return NULL; |
| 11444 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11445 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11446 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11447 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11448 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11449 | { // '{' double_starred_kvpairs? '}' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11450 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11451 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11452 | return NULL; |
| 11453 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11454 | D(fprintf(stderr, "%*c> dict[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' double_starred_kvpairs? '}'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11455 | Token * _literal; |
| 11456 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11457 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11458 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11459 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11460 | && |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11461 | (a = double_starred_kvpairs_rule(p), 1) // double_starred_kvpairs? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11462 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11463 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11464 | ) |
| 11465 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11466 | D(fprintf(stderr, "%*c+ dict[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' double_starred_kvpairs? '}'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11467 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11468 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11469 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11470 | return NULL; |
| 11471 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11472 | int _end_lineno = _token->end_lineno; |
| 11473 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11474 | int _end_col_offset = _token->end_col_offset; |
| 11475 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11476 | _res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA ); |
| 11477 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11478 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11479 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11480 | return NULL; |
| 11481 | } |
| 11482 | goto done; |
| 11483 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11484 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11485 | D(fprintf(stderr, "%*c%s dict[%d-%d]: %s failed!\n", p->level, ' ', |
| 11486 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' double_starred_kvpairs? '}'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11487 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11488 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11489 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11490 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11491 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11492 | } |
| 11493 | |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11494 | // dictcomp: '{' kvpair for_if_clauses '}' | invalid_dict_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11495 | static expr_ty |
| 11496 | dictcomp_rule(Parser *p) |
| 11497 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11498 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11499 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11500 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11501 | return NULL; |
| 11502 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11503 | expr_ty _res = NULL; |
| 11504 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11505 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 11506 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11507 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11508 | return NULL; |
| 11509 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11510 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11511 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11512 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11513 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11514 | { // '{' kvpair for_if_clauses '}' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11515 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11516 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11517 | return NULL; |
| 11518 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11519 | D(fprintf(stderr, "%*c> dictcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' kvpair for_if_clauses '}'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11520 | Token * _literal; |
| 11521 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11522 | KeyValuePair* a; |
| 11523 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11524 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11525 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11526 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11527 | (a = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11528 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11529 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11530 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11531 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11532 | ) |
| 11533 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11534 | D(fprintf(stderr, "%*c+ dictcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' kvpair for_if_clauses '}'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11535 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11536 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11537 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11538 | return NULL; |
| 11539 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11540 | int _end_lineno = _token->end_lineno; |
| 11541 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11542 | int _end_col_offset = _token->end_col_offset; |
| 11543 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11544 | _res = _Py_DictComp ( a -> key , a -> value , b , EXTRA ); |
| 11545 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11546 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11547 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11548 | return NULL; |
| 11549 | } |
| 11550 | goto done; |
| 11551 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11552 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11553 | D(fprintf(stderr, "%*c%s dictcomp[%d-%d]: %s failed!\n", p->level, ' ', |
| 11554 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' kvpair for_if_clauses '}'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11555 | } |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11556 | { // invalid_dict_comprehension |
| 11557 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11558 | D(p->level--); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11559 | return NULL; |
| 11560 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11561 | D(fprintf(stderr, "%*c> dictcomp[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_dict_comprehension")); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11562 | void *invalid_dict_comprehension_var; |
| 11563 | if ( |
| 11564 | (invalid_dict_comprehension_var = invalid_dict_comprehension_rule(p)) // invalid_dict_comprehension |
| 11565 | ) |
| 11566 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11567 | D(fprintf(stderr, "%*c+ dictcomp[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_dict_comprehension")); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11568 | _res = invalid_dict_comprehension_var; |
| 11569 | goto done; |
| 11570 | } |
| 11571 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11572 | D(fprintf(stderr, "%*c%s dictcomp[%d-%d]: %s failed!\n", p->level, ' ', |
| 11573 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_dict_comprehension")); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11574 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11575 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11576 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11577 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11578 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11579 | } |
| 11580 | |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11581 | // double_starred_kvpairs: ','.double_starred_kvpair+ ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11582 | static asdl_seq* |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11583 | double_starred_kvpairs_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11584 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11585 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11586 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11587 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11588 | return NULL; |
| 11589 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11590 | asdl_seq* _res = NULL; |
| 11591 | int _mark = p->mark; |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11592 | { // ','.double_starred_kvpair+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11593 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11594 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11595 | return NULL; |
| 11596 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11597 | D(fprintf(stderr, "%*c> double_starred_kvpairs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11598 | void *_opt_var; |
| 11599 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11600 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11601 | if ( |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11602 | (a = _gather_102_rule(p)) // ','.double_starred_kvpair+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11603 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11604 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11605 | ) |
| 11606 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11607 | D(fprintf(stderr, "%*c+ double_starred_kvpairs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.double_starred_kvpair+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11608 | _res = a; |
| 11609 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11610 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11611 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11612 | return NULL; |
| 11613 | } |
| 11614 | goto done; |
| 11615 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11616 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11617 | D(fprintf(stderr, "%*c%s double_starred_kvpairs[%d-%d]: %s failed!\n", p->level, ' ', |
| 11618 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.double_starred_kvpair+ ','?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11619 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11620 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11621 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11622 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11623 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11624 | } |
| 11625 | |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11626 | // double_starred_kvpair: '**' bitwise_or | kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11627 | static KeyValuePair* |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11628 | double_starred_kvpair_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11629 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11630 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11631 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11632 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11633 | return NULL; |
| 11634 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11635 | KeyValuePair* _res = NULL; |
| 11636 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11637 | { // '**' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11638 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11639 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11640 | return NULL; |
| 11641 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11642 | D(fprintf(stderr, "%*c> double_starred_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11643 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11644 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11645 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11646 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11647 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11648 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11649 | ) |
| 11650 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11651 | D(fprintf(stderr, "%*c+ double_starred_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' bitwise_or")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11652 | _res = _PyPegen_key_value_pair ( p , NULL , a ); |
| 11653 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11654 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11655 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11656 | return NULL; |
| 11657 | } |
| 11658 | goto done; |
| 11659 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11660 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11661 | D(fprintf(stderr, "%*c%s double_starred_kvpair[%d-%d]: %s failed!\n", p->level, ' ', |
| 11662 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' bitwise_or")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11663 | } |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11664 | { // kvpair |
| 11665 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11666 | D(p->level--); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11667 | return NULL; |
| 11668 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11669 | D(fprintf(stderr, "%*c> double_starred_kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kvpair")); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11670 | KeyValuePair* kvpair_var; |
| 11671 | if ( |
| 11672 | (kvpair_var = kvpair_rule(p)) // kvpair |
| 11673 | ) |
| 11674 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11675 | D(fprintf(stderr, "%*c+ double_starred_kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kvpair")); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11676 | _res = kvpair_var; |
| 11677 | goto done; |
| 11678 | } |
| 11679 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11680 | D(fprintf(stderr, "%*c%s double_starred_kvpair[%d-%d]: %s failed!\n", p->level, ' ', |
| 11681 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kvpair")); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11682 | } |
| 11683 | _res = NULL; |
| 11684 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11685 | D(p->level--); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11686 | return _res; |
| 11687 | } |
| 11688 | |
| 11689 | // kvpair: expression ':' expression |
| 11690 | static KeyValuePair* |
| 11691 | kvpair_rule(Parser *p) |
| 11692 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11693 | D(p->level++); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11694 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11695 | D(p->level--); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 11696 | return NULL; |
| 11697 | } |
| 11698 | KeyValuePair* _res = NULL; |
| 11699 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11700 | { // expression ':' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11701 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11702 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11703 | return NULL; |
| 11704 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11705 | D(fprintf(stderr, "%*c> kvpair[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11706 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11707 | expr_ty a; |
| 11708 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11709 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11710 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11711 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11712 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11713 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11714 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11715 | ) |
| 11716 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11717 | D(fprintf(stderr, "%*c+ kvpair[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11718 | _res = _PyPegen_key_value_pair ( p , a , b ); |
| 11719 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11720 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11721 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11722 | return NULL; |
| 11723 | } |
| 11724 | goto done; |
| 11725 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11726 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11727 | D(fprintf(stderr, "%*c%s kvpair[%d-%d]: %s failed!\n", p->level, ' ', |
| 11728 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11729 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11730 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11731 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11732 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11733 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11734 | } |
| 11735 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11736 | // for_if_clauses: for_if_clause+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11737 | static asdl_seq* |
| 11738 | for_if_clauses_rule(Parser *p) |
| 11739 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11740 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11741 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11742 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11743 | return NULL; |
| 11744 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11745 | asdl_seq* _res = NULL; |
| 11746 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11747 | { // for_if_clause+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11748 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11749 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11750 | return NULL; |
| 11751 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11752 | D(fprintf(stderr, "%*c> for_if_clauses[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 11753 | asdl_seq * _loop1_104_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11754 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11755 | (_loop1_104_var = _loop1_104_rule(p)) // for_if_clause+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11756 | ) |
| 11757 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11758 | D(fprintf(stderr, "%*c+ for_if_clauses[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "for_if_clause+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11759 | _res = _loop1_104_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11760 | goto done; |
| 11761 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11762 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11763 | D(fprintf(stderr, "%*c%s for_if_clauses[%d-%d]: %s failed!\n", p->level, ' ', |
| 11764 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause+")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11765 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11766 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11767 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11768 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11769 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11770 | } |
| 11771 | |
| 11772 | // for_if_clause: |
| 11773 | // | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 11774 | // | 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 11775 | static comprehension_ty |
| 11776 | for_if_clause_rule(Parser *p) |
| 11777 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11778 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11779 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11780 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11781 | return NULL; |
| 11782 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11783 | comprehension_ty _res = NULL; |
| 11784 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11785 | { // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11786 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11787 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11788 | return NULL; |
| 11789 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11790 | D(fprintf(stderr, "%*c> for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11791 | Token * _keyword; |
| 11792 | Token * _keyword_1; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11793 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11794 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11795 | expr_ty b; |
| 11796 | asdl_seq * c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11797 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11798 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11799 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11800 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11801 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11802 | (a = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11803 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11804 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11805 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11806 | (b = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11807 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11808 | (c = _loop0_105_rule(p)) // (('if' disjunction))* |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11809 | ) |
| 11810 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11811 | 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))*")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11812 | _res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) ); |
| 11813 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11814 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11815 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11816 | return NULL; |
| 11817 | } |
| 11818 | goto done; |
| 11819 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11820 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11821 | D(fprintf(stderr, "%*c%s for_if_clause[%d-%d]: %s failed!\n", p->level, ' ', |
| 11822 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))*")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11823 | } |
| 11824 | { // 'for' star_targets 'in' disjunction (('if' disjunction))* |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11825 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11826 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11827 | return NULL; |
| 11828 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11829 | D(fprintf(stderr, "%*c> for_if_clause[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11830 | Token * _keyword; |
| 11831 | Token * _keyword_1; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11832 | expr_ty a; |
| 11833 | expr_ty b; |
| 11834 | asdl_seq * c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11835 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11836 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11837 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11838 | (a = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11839 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11840 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11841 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11842 | (b = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11843 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11844 | (c = _loop0_106_rule(p)) // (('if' disjunction))* |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 11845 | ) |
| 11846 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11847 | D(fprintf(stderr, "%*c+ for_if_clause[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11848 | _res = _Py_comprehension ( a , b , c , 0 , p -> arena ); |
| 11849 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11850 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11851 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11852 | return NULL; |
| 11853 | } |
| 11854 | goto done; |
| 11855 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11856 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11857 | D(fprintf(stderr, "%*c%s for_if_clause[%d-%d]: %s failed!\n", p->level, ' ', |
| 11858 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for' star_targets 'in' disjunction (('if' disjunction))*")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11859 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11860 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11861 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11862 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11863 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11864 | } |
| 11865 | |
| 11866 | // yield_expr: 'yield' 'from' expression | 'yield' star_expressions? |
| 11867 | static expr_ty |
| 11868 | yield_expr_rule(Parser *p) |
| 11869 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11870 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11871 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11872 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11873 | return NULL; |
| 11874 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11875 | expr_ty _res = NULL; |
| 11876 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11877 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 11878 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11879 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11880 | return NULL; |
| 11881 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11882 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11883 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11884 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11885 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11886 | { // 'yield' 'from' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11887 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11888 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11889 | return NULL; |
| 11890 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11891 | D(fprintf(stderr, "%*c> yield_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'yield' 'from' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11892 | Token * _keyword; |
| 11893 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11894 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11895 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11896 | (_keyword = _PyPegen_expect_token(p, 504)) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11897 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11898 | (_keyword_1 = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11899 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11900 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11901 | ) |
| 11902 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11903 | D(fprintf(stderr, "%*c+ yield_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'yield' 'from' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11904 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11905 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11906 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11907 | return NULL; |
| 11908 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11909 | int _end_lineno = _token->end_lineno; |
| 11910 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11911 | int _end_col_offset = _token->end_col_offset; |
| 11912 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11913 | _res = _Py_YieldFrom ( a , EXTRA ); |
| 11914 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11915 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11916 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11917 | return NULL; |
| 11918 | } |
| 11919 | goto done; |
| 11920 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11921 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11922 | D(fprintf(stderr, "%*c%s yield_expr[%d-%d]: %s failed!\n", p->level, ' ', |
| 11923 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'yield' 'from' expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11924 | } |
| 11925 | { // 'yield' star_expressions? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11926 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11927 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11928 | return NULL; |
| 11929 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11930 | D(fprintf(stderr, "%*c> yield_expr[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'yield' star_expressions?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11931 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11932 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11933 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11934 | (_keyword = _PyPegen_expect_token(p, 504)) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11935 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11936 | (a = star_expressions_rule(p), 1) // star_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11937 | ) |
| 11938 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11939 | D(fprintf(stderr, "%*c+ yield_expr[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'yield' star_expressions?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11940 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11941 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11942 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11943 | return NULL; |
| 11944 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11945 | int _end_lineno = _token->end_lineno; |
| 11946 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11947 | int _end_col_offset = _token->end_col_offset; |
| 11948 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11949 | _res = _Py_Yield ( a , EXTRA ); |
| 11950 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11951 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11952 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11953 | return NULL; |
| 11954 | } |
| 11955 | goto done; |
| 11956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11957 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11958 | D(fprintf(stderr, "%*c%s yield_expr[%d-%d]: %s failed!\n", p->level, ' ', |
| 11959 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'yield' star_expressions?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11960 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11961 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11962 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11963 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11964 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11965 | } |
| 11966 | |
| 11967 | // arguments: args ','? &')' | incorrect_arguments |
| 11968 | static expr_ty |
| 11969 | arguments_rule(Parser *p) |
| 11970 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11971 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11972 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11973 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11974 | return NULL; |
| 11975 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11976 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11977 | if (_PyPegen_is_memoized(p, arguments_type, &_res)) { |
| 11978 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11979 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11980 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11981 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11982 | { // args ','? &')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11983 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11984 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11985 | return NULL; |
| 11986 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11987 | D(fprintf(stderr, "%*c> arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ','? &')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11988 | void *_opt_var; |
| 11989 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11990 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11991 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11992 | (a = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11993 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11994 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11995 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11996 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11997 | ) |
| 11998 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 11999 | D(fprintf(stderr, "%*c+ arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ','? &')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12000 | _res = a; |
| 12001 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12002 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12003 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12004 | return NULL; |
| 12005 | } |
| 12006 | goto done; |
| 12007 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12008 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12009 | D(fprintf(stderr, "%*c%s arguments[%d-%d]: %s failed!\n", p->level, ' ', |
| 12010 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ','? &')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12011 | } |
| 12012 | { // incorrect_arguments |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12013 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12014 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12015 | return NULL; |
| 12016 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12017 | D(fprintf(stderr, "%*c> arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "incorrect_arguments")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12018 | void *incorrect_arguments_var; |
| 12019 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12020 | (incorrect_arguments_var = incorrect_arguments_rule(p)) // incorrect_arguments |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12021 | ) |
| 12022 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12023 | D(fprintf(stderr, "%*c+ arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "incorrect_arguments")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12024 | _res = incorrect_arguments_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12025 | goto done; |
| 12026 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12027 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12028 | D(fprintf(stderr, "%*c%s arguments[%d-%d]: %s failed!\n", p->level, ' ', |
| 12029 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "incorrect_arguments")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12030 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12031 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12032 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12033 | _PyPegen_insert_memo(p, _mark, arguments_type, _res); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12034 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12035 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12036 | } |
| 12037 | |
| 12038 | // args: starred_expression [',' args] | kwargs | named_expression [',' args] |
| 12039 | static expr_ty |
| 12040 | args_rule(Parser *p) |
| 12041 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12042 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12043 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12044 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12045 | return NULL; |
| 12046 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12047 | expr_ty _res = NULL; |
| 12048 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12049 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 12050 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12051 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12052 | return NULL; |
| 12053 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12054 | int _start_lineno = p->tokens[_mark]->lineno; |
| 12055 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 12056 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 12057 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12058 | { // starred_expression [',' args] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12059 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12060 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12061 | return NULL; |
| 12062 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12063 | D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12064 | expr_ty a; |
| 12065 | void *b; |
| 12066 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12067 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12068 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12069 | (b = _tmp_107_rule(p), 1) // [',' args] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12070 | ) |
| 12071 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12072 | D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression [',' args]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12073 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12074 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12075 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12076 | return NULL; |
| 12077 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12078 | int _end_lineno = _token->end_lineno; |
| 12079 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12080 | int _end_col_offset = _token->end_col_offset; |
| 12081 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 12082 | _res = _Py_Call ( _PyPegen_dummy_name ( p ) , ( b ) ? CHECK ( _PyPegen_seq_insert_in_front ( p , a , ( ( expr_ty ) b ) -> v . Call . args ) ) : CHECK ( _PyPegen_singleton_seq ( p , a ) ) , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 12083 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12084 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12085 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12086 | return NULL; |
| 12087 | } |
| 12088 | goto done; |
| 12089 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12090 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12091 | D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ', |
| 12092 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression [',' args]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12093 | } |
| 12094 | { // kwargs |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12095 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12096 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12097 | return NULL; |
| 12098 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12099 | D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwargs")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12100 | asdl_seq* a; |
| 12101 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12102 | (a = kwargs_rule(p)) // kwargs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12103 | ) |
| 12104 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12105 | D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwargs")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12106 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12107 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12108 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12109 | return NULL; |
| 12110 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12111 | int _end_lineno = _token->end_lineno; |
| 12112 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12113 | int _end_col_offset = _token->end_col_offset; |
| 12114 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 12115 | _res = _Py_Call ( _PyPegen_dummy_name ( p ) , CHECK_NULL_ALLOWED ( _PyPegen_seq_extract_starred_exprs ( p , a ) ) , CHECK_NULL_ALLOWED ( _PyPegen_seq_delete_starred_exprs ( p , a ) ) , EXTRA ); |
| 12116 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12117 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12118 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12119 | return NULL; |
| 12120 | } |
| 12121 | goto done; |
| 12122 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12123 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12124 | D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ', |
| 12125 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwargs")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12126 | } |
| 12127 | { // named_expression [',' args] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12128 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12129 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12130 | return NULL; |
| 12131 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12132 | D(fprintf(stderr, "%*c> args[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12133 | expr_ty a; |
| 12134 | void *b; |
| 12135 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12136 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12137 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12138 | (b = _tmp_108_rule(p), 1) // [',' args] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12139 | ) |
| 12140 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12141 | D(fprintf(stderr, "%*c+ args[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression [',' args]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12142 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12143 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12144 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12145 | return NULL; |
| 12146 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12147 | int _end_lineno = _token->end_lineno; |
| 12148 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12149 | int _end_col_offset = _token->end_col_offset; |
| 12150 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 12151 | _res = _Py_Call ( _PyPegen_dummy_name ( p ) , ( b ) ? CHECK ( _PyPegen_seq_insert_in_front ( p , a , ( ( expr_ty ) b ) -> v . Call . args ) ) : CHECK ( _PyPegen_singleton_seq ( p , a ) ) , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 12152 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12153 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12154 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12155 | return NULL; |
| 12156 | } |
| 12157 | goto done; |
| 12158 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12159 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12160 | D(fprintf(stderr, "%*c%s args[%d-%d]: %s failed!\n", p->level, ' ', |
| 12161 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression [',' args]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12162 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12163 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12164 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12165 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12166 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12167 | } |
| 12168 | |
| 12169 | // kwargs: |
| 12170 | // | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
| 12171 | // | ','.kwarg_or_starred+ |
| 12172 | // | ','.kwarg_or_double_starred+ |
| 12173 | static asdl_seq* |
| 12174 | kwargs_rule(Parser *p) |
| 12175 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12176 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12177 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12178 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12179 | return NULL; |
| 12180 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12181 | asdl_seq* _res = NULL; |
| 12182 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12183 | { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12184 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12185 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12186 | return NULL; |
| 12187 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12188 | D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12189 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12190 | asdl_seq * a; |
| 12191 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12192 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12193 | (a = _gather_109_rule(p)) // ','.kwarg_or_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12194 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12195 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12196 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12197 | (b = _gather_111_rule(p)) // ','.kwarg_or_double_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12198 | ) |
| 12199 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12200 | D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12201 | _res = _PyPegen_join_sequences ( p , a , b ); |
| 12202 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12203 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12204 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12205 | return NULL; |
| 12206 | } |
| 12207 | goto done; |
| 12208 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12209 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12210 | D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ', |
| 12211 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12212 | } |
| 12213 | { // ','.kwarg_or_starred+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12214 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12215 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12216 | return NULL; |
| 12217 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12218 | D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 12219 | asdl_seq * _gather_113_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12220 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12221 | (_gather_113_var = _gather_113_rule(p)) // ','.kwarg_or_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12222 | ) |
| 12223 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12224 | D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_starred+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12225 | _res = _gather_113_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12226 | goto done; |
| 12227 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12228 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12229 | D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ', |
| 12230 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_starred+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12231 | } |
| 12232 | { // ','.kwarg_or_double_starred+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12233 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12234 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12235 | return NULL; |
| 12236 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12237 | D(fprintf(stderr, "%*c> kwargs[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 12238 | asdl_seq * _gather_115_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12239 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12240 | (_gather_115_var = _gather_115_rule(p)) // ','.kwarg_or_double_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12241 | ) |
| 12242 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12243 | D(fprintf(stderr, "%*c+ kwargs[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.kwarg_or_double_starred+")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12244 | _res = _gather_115_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12245 | goto done; |
| 12246 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12247 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12248 | D(fprintf(stderr, "%*c%s kwargs[%d-%d]: %s failed!\n", p->level, ' ', |
| 12249 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.kwarg_or_double_starred+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12250 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12251 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12252 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12253 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12254 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12255 | } |
| 12256 | |
| 12257 | // starred_expression: '*' expression |
| 12258 | static expr_ty |
| 12259 | starred_expression_rule(Parser *p) |
| 12260 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12261 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12262 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12263 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12264 | return NULL; |
| 12265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12266 | expr_ty _res = NULL; |
| 12267 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12268 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 12269 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12270 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12271 | return NULL; |
| 12272 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12273 | int _start_lineno = p->tokens[_mark]->lineno; |
| 12274 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 12275 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 12276 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12277 | { // '*' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12278 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12279 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12280 | return NULL; |
| 12281 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12282 | D(fprintf(stderr, "%*c> starred_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12283 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12284 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12285 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12286 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12287 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12288 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12289 | ) |
| 12290 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12291 | D(fprintf(stderr, "%*c+ starred_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12292 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12293 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12294 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12295 | return NULL; |
| 12296 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12297 | int _end_lineno = _token->end_lineno; |
| 12298 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12299 | int _end_col_offset = _token->end_col_offset; |
| 12300 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 12301 | _res = _Py_Starred ( a , Load , EXTRA ); |
| 12302 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12303 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12304 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12305 | return NULL; |
| 12306 | } |
| 12307 | goto done; |
| 12308 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12309 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12310 | D(fprintf(stderr, "%*c%s starred_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 12311 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12312 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12313 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12314 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12315 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12316 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12317 | } |
| 12318 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 12319 | // kwarg_or_starred: NAME '=' expression | starred_expression | invalid_kwarg |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12320 | static KeywordOrStarred* |
| 12321 | kwarg_or_starred_rule(Parser *p) |
| 12322 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12323 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12324 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12325 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12326 | return NULL; |
| 12327 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12328 | KeywordOrStarred* _res = NULL; |
| 12329 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12330 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 12331 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12332 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12333 | return NULL; |
| 12334 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12335 | int _start_lineno = p->tokens[_mark]->lineno; |
| 12336 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 12337 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 12338 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12339 | { // NAME '=' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12340 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12341 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12342 | return NULL; |
| 12343 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12344 | D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12345 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12346 | expr_ty a; |
| 12347 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12348 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12349 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12350 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12351 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12352 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12353 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12354 | ) |
| 12355 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12356 | D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12357 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12358 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12359 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12360 | return NULL; |
| 12361 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12362 | int _end_lineno = _token->end_lineno; |
| 12363 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12364 | int _end_col_offset = _token->end_col_offset; |
| 12365 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 12366 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
| 12367 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12368 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12369 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12370 | return NULL; |
| 12371 | } |
| 12372 | goto done; |
| 12373 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12374 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12375 | D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ', |
| 12376 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12377 | } |
| 12378 | { // starred_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12379 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12380 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12381 | return NULL; |
| 12382 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12383 | D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "starred_expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12384 | expr_ty a; |
| 12385 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12386 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12387 | ) |
| 12388 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12389 | D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "starred_expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12390 | _res = _PyPegen_keyword_or_starred ( p , a , 0 ); |
| 12391 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12392 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12393 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12394 | return NULL; |
| 12395 | } |
| 12396 | goto done; |
| 12397 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12398 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12399 | D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ', |
| 12400 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "starred_expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12401 | } |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 12402 | { // invalid_kwarg |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12403 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12404 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12405 | return NULL; |
| 12406 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12407 | D(fprintf(stderr, "%*c> kwarg_or_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 12408 | void *invalid_kwarg_var; |
| 12409 | if ( |
| 12410 | (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg |
| 12411 | ) |
| 12412 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12413 | D(fprintf(stderr, "%*c+ kwarg_or_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12414 | _res = invalid_kwarg_var; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 12415 | goto done; |
| 12416 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12417 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12418 | D(fprintf(stderr, "%*c%s kwarg_or_starred[%d-%d]: %s failed!\n", p->level, ' ', |
| 12419 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kwarg")); |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 12420 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12421 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12422 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12423 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12424 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12425 | } |
| 12426 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 12427 | // kwarg_or_double_starred: NAME '=' expression | '**' expression | invalid_kwarg |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12428 | static KeywordOrStarred* |
| 12429 | kwarg_or_double_starred_rule(Parser *p) |
| 12430 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12431 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12432 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12433 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12434 | return NULL; |
| 12435 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12436 | KeywordOrStarred* _res = NULL; |
| 12437 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12438 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 12439 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12440 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12441 | return NULL; |
| 12442 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12443 | int _start_lineno = p->tokens[_mark]->lineno; |
| 12444 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 12445 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 12446 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12447 | { // NAME '=' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12448 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12449 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12450 | return NULL; |
| 12451 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12452 | D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12453 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12454 | expr_ty a; |
| 12455 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12456 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12457 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12458 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12459 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12460 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12461 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12462 | ) |
| 12463 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12464 | D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME '=' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12465 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12466 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12467 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12468 | return NULL; |
| 12469 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12470 | int _end_lineno = _token->end_lineno; |
| 12471 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12472 | int _end_col_offset = _token->end_col_offset; |
| 12473 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 12474 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
| 12475 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12476 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12477 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12478 | return NULL; |
| 12479 | } |
| 12480 | goto done; |
| 12481 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12482 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12483 | D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ', |
| 12484 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME '=' expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12485 | } |
| 12486 | { // '**' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12487 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12488 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12489 | return NULL; |
| 12490 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12491 | D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12492 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12493 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12494 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12495 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12496 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12497 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12498 | ) |
| 12499 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12500 | D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12501 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12502 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12503 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12504 | return NULL; |
| 12505 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12506 | int _end_lineno = _token->end_lineno; |
| 12507 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12508 | int _end_col_offset = _token->end_col_offset; |
| 12509 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 12510 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 ); |
| 12511 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12512 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12513 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12514 | return NULL; |
| 12515 | } |
| 12516 | goto done; |
| 12517 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12518 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12519 | D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ', |
| 12520 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**' expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12521 | } |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 12522 | { // invalid_kwarg |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12523 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12524 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12525 | return NULL; |
| 12526 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12527 | D(fprintf(stderr, "%*c> kwarg_or_double_starred[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 12528 | void *invalid_kwarg_var; |
| 12529 | if ( |
| 12530 | (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg |
| 12531 | ) |
| 12532 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12533 | D(fprintf(stderr, "%*c+ kwarg_or_double_starred[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_kwarg")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12534 | _res = invalid_kwarg_var; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 12535 | goto done; |
| 12536 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12537 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12538 | D(fprintf(stderr, "%*c%s kwarg_or_double_starred[%d-%d]: %s failed!\n", p->level, ' ', |
| 12539 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_kwarg")); |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 12540 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12541 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12542 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12543 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12544 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12545 | } |
| 12546 | |
| 12547 | // star_targets: star_target !',' | star_target ((',' star_target))* ','? |
| 12548 | static expr_ty |
| 12549 | star_targets_rule(Parser *p) |
| 12550 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12551 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12552 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12553 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12554 | return NULL; |
| 12555 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12556 | expr_ty _res = NULL; |
| 12557 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12558 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 12559 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12560 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12561 | return NULL; |
| 12562 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12563 | int _start_lineno = p->tokens[_mark]->lineno; |
| 12564 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 12565 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 12566 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12567 | { // star_target !',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12568 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12569 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12570 | return NULL; |
| 12571 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12572 | D(fprintf(stderr, "%*c> star_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target !','")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12573 | expr_ty a; |
| 12574 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12575 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12576 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12577 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12578 | ) |
| 12579 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12580 | D(fprintf(stderr, "%*c+ star_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target !','")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12581 | _res = a; |
| 12582 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12583 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12584 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12585 | return NULL; |
| 12586 | } |
| 12587 | goto done; |
| 12588 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12589 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12590 | D(fprintf(stderr, "%*c%s star_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 12591 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target !','")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12592 | } |
| 12593 | { // star_target ((',' star_target))* ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12594 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12595 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12596 | return NULL; |
| 12597 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12598 | D(fprintf(stderr, "%*c> star_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))* ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12599 | void *_opt_var; |
| 12600 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12601 | expr_ty a; |
| 12602 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12603 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12604 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12605 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12606 | (b = _loop0_117_rule(p)) // ((',' star_target))* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12607 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12608 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12609 | ) |
| 12610 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12611 | D(fprintf(stderr, "%*c+ star_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target ((',' star_target))* ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12612 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12613 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12614 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12615 | return NULL; |
| 12616 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12617 | int _end_lineno = _token->end_lineno; |
| 12618 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12619 | int _end_col_offset = _token->end_col_offset; |
| 12620 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 12621 | _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA ); |
| 12622 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12623 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12624 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12625 | return NULL; |
| 12626 | } |
| 12627 | goto done; |
| 12628 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12629 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12630 | D(fprintf(stderr, "%*c%s star_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 12631 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target ((',' star_target))* ','?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12632 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12633 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12634 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12635 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12636 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12637 | } |
| 12638 | |
| 12639 | // star_targets_seq: ','.star_target+ ','? |
| 12640 | static asdl_seq* |
| 12641 | star_targets_seq_rule(Parser *p) |
| 12642 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12643 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12644 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12645 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12646 | return NULL; |
| 12647 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12648 | asdl_seq* _res = NULL; |
| 12649 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12650 | { // ','.star_target+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12651 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12652 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12653 | return NULL; |
| 12654 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12655 | D(fprintf(stderr, "%*c> star_targets_seq[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.star_target+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12656 | void *_opt_var; |
| 12657 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12658 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12659 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12660 | (a = _gather_118_rule(p)) // ','.star_target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12661 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12662 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12663 | ) |
| 12664 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12665 | D(fprintf(stderr, "%*c+ star_targets_seq[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.star_target+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12666 | _res = a; |
| 12667 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12668 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12669 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12670 | return NULL; |
| 12671 | } |
| 12672 | goto done; |
| 12673 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12674 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12675 | D(fprintf(stderr, "%*c%s star_targets_seq[%d-%d]: %s failed!\n", p->level, ' ', |
| 12676 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.star_target+ ','?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12677 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12678 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12679 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12680 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12681 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12682 | } |
| 12683 | |
| 12684 | // star_target: |
| 12685 | // | '*' (!'*' star_target) |
| 12686 | // | t_primary '.' NAME !t_lookahead |
| 12687 | // | t_primary '[' slices ']' !t_lookahead |
| 12688 | // | star_atom |
| 12689 | static expr_ty |
| 12690 | star_target_rule(Parser *p) |
| 12691 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12692 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12693 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12694 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12695 | return NULL; |
| 12696 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12697 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12698 | if (_PyPegen_is_memoized(p, star_target_type, &_res)) { |
| 12699 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12700 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12701 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12702 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12703 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 12704 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12705 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12706 | return NULL; |
| 12707 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 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 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12712 | { // '*' (!'*' star_target) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12713 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12714 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12715 | return NULL; |
| 12716 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12717 | D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12718 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12719 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12720 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12721 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12722 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12723 | (a = _tmp_120_rule(p)) // !'*' star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12724 | ) |
| 12725 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12726 | D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (!'*' star_target)")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12727 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12728 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12729 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12730 | return NULL; |
| 12731 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12732 | int _end_lineno = _token->end_lineno; |
| 12733 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12734 | int _end_col_offset = _token->end_col_offset; |
| 12735 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 12736 | _res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA ); |
| 12737 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12738 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12739 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12740 | return NULL; |
| 12741 | } |
| 12742 | goto done; |
| 12743 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12744 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12745 | D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 12746 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (!'*' star_target)")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12747 | } |
| 12748 | { // t_primary '.' NAME !t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12749 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12750 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12751 | return NULL; |
| 12752 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12753 | D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12754 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12755 | expr_ty a; |
| 12756 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12757 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12758 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12759 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12760 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12761 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12762 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12763 | && |
| 12764 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 12765 | ) |
| 12766 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12767 | D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12768 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12769 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12770 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12771 | return NULL; |
| 12772 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12773 | int _end_lineno = _token->end_lineno; |
| 12774 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12775 | int _end_col_offset = _token->end_col_offset; |
| 12776 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 12777 | _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 12778 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12779 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12780 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12781 | return NULL; |
| 12782 | } |
| 12783 | goto done; |
| 12784 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12785 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12786 | D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 12787 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12788 | } |
| 12789 | { // t_primary '[' slices ']' !t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12790 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12791 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12792 | return NULL; |
| 12793 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12794 | D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12795 | Token * _literal; |
| 12796 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12797 | expr_ty a; |
| 12798 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12799 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12800 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12801 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12802 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12803 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12804 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12805 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12806 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12807 | && |
| 12808 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 12809 | ) |
| 12810 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12811 | D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12812 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12813 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12814 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12815 | return NULL; |
| 12816 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12817 | int _end_lineno = _token->end_lineno; |
| 12818 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12819 | int _end_col_offset = _token->end_col_offset; |
| 12820 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 12821 | _res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 12822 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12823 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12824 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12825 | return NULL; |
| 12826 | } |
| 12827 | goto done; |
| 12828 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12829 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12830 | D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 12831 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12832 | } |
| 12833 | { // star_atom |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12834 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12835 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12836 | return NULL; |
| 12837 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12838 | D(fprintf(stderr, "%*c> star_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_atom")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12839 | expr_ty star_atom_var; |
| 12840 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12841 | (star_atom_var = star_atom_rule(p)) // star_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12842 | ) |
| 12843 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12844 | D(fprintf(stderr, "%*c+ star_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_atom")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12845 | _res = star_atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12846 | goto done; |
| 12847 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12848 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12849 | D(fprintf(stderr, "%*c%s star_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 12850 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_atom")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12851 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12852 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12853 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12854 | _PyPegen_insert_memo(p, _mark, star_target_type, _res); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12855 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12856 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12857 | } |
| 12858 | |
| 12859 | // star_atom: |
| 12860 | // | NAME |
| 12861 | // | '(' star_target ')' |
| 12862 | // | '(' star_targets_seq? ')' |
| 12863 | // | '[' star_targets_seq? ']' |
| 12864 | static expr_ty |
| 12865 | star_atom_rule(Parser *p) |
| 12866 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12867 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12868 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12869 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12870 | return NULL; |
| 12871 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12872 | expr_ty _res = NULL; |
| 12873 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12874 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 12875 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12876 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12877 | return NULL; |
| 12878 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12879 | int _start_lineno = p->tokens[_mark]->lineno; |
| 12880 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 12881 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 12882 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12883 | { // NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12884 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12885 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12886 | return NULL; |
| 12887 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12888 | D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12889 | expr_ty a; |
| 12890 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12891 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12892 | ) |
| 12893 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12894 | D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12895 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 12896 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12897 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12898 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12899 | return NULL; |
| 12900 | } |
| 12901 | goto done; |
| 12902 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12903 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12904 | D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 12905 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12906 | } |
| 12907 | { // '(' star_target ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12908 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12909 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12910 | return NULL; |
| 12911 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12912 | D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' star_target ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12913 | Token * _literal; |
| 12914 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12915 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12916 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12917 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12918 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12919 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12920 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12921 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12922 | ) |
| 12923 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12924 | D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' star_target ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12925 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 12926 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12927 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12928 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12929 | return NULL; |
| 12930 | } |
| 12931 | goto done; |
| 12932 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12933 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12934 | D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 12935 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' star_target ')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12936 | } |
| 12937 | { // '(' star_targets_seq? ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12938 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12939 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12940 | return NULL; |
| 12941 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12942 | D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' star_targets_seq? ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12943 | Token * _literal; |
| 12944 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12945 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12946 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12947 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12948 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12949 | (a = star_targets_seq_rule(p), 1) // star_targets_seq? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12950 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12951 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12952 | ) |
| 12953 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12954 | D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' star_targets_seq? ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12955 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12956 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12957 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12958 | return NULL; |
| 12959 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12960 | int _end_lineno = _token->end_lineno; |
| 12961 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 12962 | int _end_col_offset = _token->end_col_offset; |
| 12963 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 12964 | _res = _Py_Tuple ( a , Store , EXTRA ); |
| 12965 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12966 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12967 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12968 | return NULL; |
| 12969 | } |
| 12970 | goto done; |
| 12971 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12972 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12973 | D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 12974 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' star_targets_seq? ')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12975 | } |
| 12976 | { // '[' star_targets_seq? ']' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12977 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12978 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12979 | return NULL; |
| 12980 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12981 | D(fprintf(stderr, "%*c> star_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' star_targets_seq? ']'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12982 | Token * _literal; |
| 12983 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12984 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12985 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12986 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12987 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12988 | (a = star_targets_seq_rule(p), 1) // star_targets_seq? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12989 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12990 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12991 | ) |
| 12992 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12993 | D(fprintf(stderr, "%*c+ star_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' star_targets_seq? ']'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12994 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 12995 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 12996 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12997 | return NULL; |
| 12998 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12999 | int _end_lineno = _token->end_lineno; |
| 13000 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13001 | int _end_col_offset = _token->end_col_offset; |
| 13002 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 13003 | _res = _Py_List ( a , Store , EXTRA ); |
| 13004 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13005 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13006 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13007 | return NULL; |
| 13008 | } |
| 13009 | goto done; |
| 13010 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13011 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13012 | D(fprintf(stderr, "%*c%s star_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13013 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' star_targets_seq? ']'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13014 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13015 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13016 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13017 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13018 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13019 | } |
| 13020 | |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13021 | // single_target: single_subscript_attribute_target | NAME | '(' single_target ')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13022 | static expr_ty |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13023 | single_target_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13024 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13025 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13026 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13027 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13028 | return NULL; |
| 13029 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13030 | expr_ty _res = NULL; |
| 13031 | int _mark = p->mark; |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13032 | { // single_subscript_attribute_target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13033 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13034 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13035 | return NULL; |
| 13036 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13037 | D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13038 | expr_ty single_subscript_attribute_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13039 | if ( |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13040 | (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13041 | ) |
| 13042 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13043 | D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13044 | _res = single_subscript_attribute_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13045 | goto done; |
| 13046 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13047 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13048 | D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 13049 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_subscript_attribute_target")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13050 | } |
| 13051 | { // NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13052 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13053 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13054 | return NULL; |
| 13055 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13056 | D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13057 | expr_ty a; |
| 13058 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13059 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13060 | ) |
| 13061 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13062 | D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13063 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 13064 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13065 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13066 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13067 | return NULL; |
| 13068 | } |
| 13069 | goto done; |
| 13070 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13071 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13072 | D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 13073 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13074 | } |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13075 | { // '(' single_target ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13076 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13077 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13078 | return NULL; |
| 13079 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13080 | D(fprintf(stderr, "%*c> single_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13081 | Token * _literal; |
| 13082 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13083 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13084 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13085 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13086 | && |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13087 | (a = single_target_rule(p)) // single_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13088 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13089 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13090 | ) |
| 13091 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13092 | D(fprintf(stderr, "%*c+ single_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13093 | _res = a; |
| 13094 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13095 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13096 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13097 | return NULL; |
| 13098 | } |
| 13099 | goto done; |
| 13100 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13101 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13102 | D(fprintf(stderr, "%*c%s single_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 13103 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13104 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13105 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13106 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13107 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13108 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13109 | } |
| 13110 | |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13111 | // single_subscript_attribute_target: |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13112 | // | t_primary '.' NAME !t_lookahead |
| 13113 | // | t_primary '[' slices ']' !t_lookahead |
| 13114 | static expr_ty |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13115 | single_subscript_attribute_target_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13116 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13117 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13118 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13119 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13120 | return NULL; |
| 13121 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13122 | expr_ty _res = NULL; |
| 13123 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13124 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 13125 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13126 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13127 | return NULL; |
| 13128 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13129 | int _start_lineno = p->tokens[_mark]->lineno; |
| 13130 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 13131 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 13132 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13133 | { // t_primary '.' NAME !t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13134 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13135 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13136 | return NULL; |
| 13137 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13138 | D(fprintf(stderr, "%*c> single_subscript_attribute_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13139 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13140 | expr_ty a; |
| 13141 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13142 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13143 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13144 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13145 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13146 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13147 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13148 | && |
| 13149 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 13150 | ) |
| 13151 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13152 | D(fprintf(stderr, "%*c+ single_subscript_attribute_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13153 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13154 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13155 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13156 | return NULL; |
| 13157 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13158 | int _end_lineno = _token->end_lineno; |
| 13159 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13160 | int _end_col_offset = _token->end_col_offset; |
| 13161 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 13162 | _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 13163 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13164 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13165 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13166 | return NULL; |
| 13167 | } |
| 13168 | goto done; |
| 13169 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13170 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13171 | D(fprintf(stderr, "%*c%s single_subscript_attribute_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 13172 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13173 | } |
| 13174 | { // t_primary '[' slices ']' !t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13175 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13176 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13177 | return NULL; |
| 13178 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13179 | D(fprintf(stderr, "%*c> single_subscript_attribute_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13180 | Token * _literal; |
| 13181 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13182 | expr_ty a; |
| 13183 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13184 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13185 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13186 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13187 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13188 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13189 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13190 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13191 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13192 | && |
| 13193 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 13194 | ) |
| 13195 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13196 | D(fprintf(stderr, "%*c+ single_subscript_attribute_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13197 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13198 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13199 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13200 | return NULL; |
| 13201 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13202 | int _end_lineno = _token->end_lineno; |
| 13203 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13204 | int _end_col_offset = _token->end_col_offset; |
| 13205 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 13206 | _res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 13207 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13208 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13209 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13210 | return NULL; |
| 13211 | } |
| 13212 | goto done; |
| 13213 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13214 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13215 | D(fprintf(stderr, "%*c%s single_subscript_attribute_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 13216 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13217 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13218 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13219 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13220 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13221 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13222 | } |
| 13223 | |
| 13224 | // del_targets: ','.del_target+ ','? |
| 13225 | static asdl_seq* |
| 13226 | del_targets_rule(Parser *p) |
| 13227 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13228 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13229 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13230 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13231 | return NULL; |
| 13232 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13233 | asdl_seq* _res = NULL; |
| 13234 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13235 | { // ','.del_target+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13236 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13237 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13238 | return NULL; |
| 13239 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13240 | D(fprintf(stderr, "%*c> del_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13241 | void *_opt_var; |
| 13242 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13243 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13244 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13245 | (a = _gather_121_rule(p)) // ','.del_target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13246 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13247 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13248 | ) |
| 13249 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13250 | D(fprintf(stderr, "%*c+ del_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.del_target+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13251 | _res = a; |
| 13252 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13253 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13254 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13255 | return NULL; |
| 13256 | } |
| 13257 | goto done; |
| 13258 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13259 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13260 | D(fprintf(stderr, "%*c%s del_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 13261 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.del_target+ ','?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13262 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13263 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13264 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13265 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13266 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13267 | } |
| 13268 | |
| 13269 | // del_target: |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13270 | // | t_primary '.' NAME &del_target_end |
| 13271 | // | t_primary '[' slices ']' &del_target_end |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13272 | // | del_t_atom |
| 13273 | static expr_ty |
| 13274 | del_target_rule(Parser *p) |
| 13275 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13276 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13277 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13278 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13279 | return NULL; |
| 13280 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13281 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13282 | if (_PyPegen_is_memoized(p, del_target_type, &_res)) { |
| 13283 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13284 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13285 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13286 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13287 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 13288 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13289 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13290 | return NULL; |
| 13291 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13292 | int _start_lineno = p->tokens[_mark]->lineno; |
| 13293 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 13294 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 13295 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13296 | { // t_primary '.' NAME &del_target_end |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13297 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13298 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13299 | return NULL; |
| 13300 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13301 | D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &del_target_end")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13302 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13303 | expr_ty a; |
| 13304 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13305 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13306 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13307 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13308 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13309 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13310 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13311 | && |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13312 | _PyPegen_lookahead(1, del_target_end_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13313 | ) |
| 13314 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13315 | D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &del_target_end")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13316 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13317 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13318 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13319 | return NULL; |
| 13320 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13321 | int _end_lineno = _token->end_lineno; |
| 13322 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13323 | int _end_col_offset = _token->end_col_offset; |
| 13324 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 13325 | _res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA ); |
| 13326 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13327 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13328 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13329 | return NULL; |
| 13330 | } |
| 13331 | goto done; |
| 13332 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13333 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13334 | D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 13335 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME &del_target_end")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13336 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13337 | { // t_primary '[' slices ']' &del_target_end |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13338 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13339 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13340 | return NULL; |
| 13341 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13342 | D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &del_target_end")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13343 | Token * _literal; |
| 13344 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13345 | expr_ty a; |
| 13346 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13347 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13348 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13349 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13350 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13351 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13352 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13353 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13354 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13355 | && |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13356 | _PyPegen_lookahead(1, del_target_end_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13357 | ) |
| 13358 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13359 | D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &del_target_end")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13360 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13361 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13362 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13363 | return NULL; |
| 13364 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13365 | int _end_lineno = _token->end_lineno; |
| 13366 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13367 | int _end_col_offset = _token->end_col_offset; |
| 13368 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 13369 | _res = _Py_Subscript ( a , b , Del , EXTRA ); |
| 13370 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13371 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13372 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13373 | return NULL; |
| 13374 | } |
| 13375 | goto done; |
| 13376 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13377 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13378 | D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 13379 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' &del_target_end")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13380 | } |
| 13381 | { // del_t_atom |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13382 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13383 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13384 | return NULL; |
| 13385 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13386 | D(fprintf(stderr, "%*c> del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_t_atom")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13387 | expr_ty del_t_atom_var; |
| 13388 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13389 | (del_t_atom_var = del_t_atom_rule(p)) // del_t_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13390 | ) |
| 13391 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13392 | D(fprintf(stderr, "%*c+ del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_t_atom")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13393 | _res = del_t_atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13394 | goto done; |
| 13395 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13396 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13397 | D(fprintf(stderr, "%*c%s del_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 13398 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_t_atom")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13399 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13400 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13401 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13402 | _PyPegen_insert_memo(p, _mark, del_target_type, _res); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13403 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13404 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13405 | } |
| 13406 | |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13407 | // del_t_atom: |
| 13408 | // | NAME &del_target_end |
| 13409 | // | '(' del_target ')' |
| 13410 | // | '(' del_targets? ')' |
| 13411 | // | '[' del_targets? ']' |
| 13412 | // | invalid_del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13413 | static expr_ty |
| 13414 | del_t_atom_rule(Parser *p) |
| 13415 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13416 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13417 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13418 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13419 | return NULL; |
| 13420 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13421 | expr_ty _res = NULL; |
| 13422 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13423 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 13424 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13425 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13426 | return NULL; |
| 13427 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13428 | int _start_lineno = p->tokens[_mark]->lineno; |
| 13429 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 13430 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 13431 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13432 | { // NAME &del_target_end |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13433 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13434 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13435 | return NULL; |
| 13436 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13437 | D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME &del_target_end")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13438 | expr_ty a; |
| 13439 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13440 | (a = _PyPegen_name_token(p)) // NAME |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13441 | && |
| 13442 | _PyPegen_lookahead(1, del_target_end_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13443 | ) |
| 13444 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13445 | D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME &del_target_end")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13446 | _res = _PyPegen_set_expr_context ( p , a , Del ); |
| 13447 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13448 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13449 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13450 | return NULL; |
| 13451 | } |
| 13452 | goto done; |
| 13453 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13454 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13455 | D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13456 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME &del_target_end")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13457 | } |
| 13458 | { // '(' del_target ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13459 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13460 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13461 | return NULL; |
| 13462 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13463 | D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' del_target ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13464 | Token * _literal; |
| 13465 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13466 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13467 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13468 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13469 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13470 | (a = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13471 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13472 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13473 | ) |
| 13474 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13475 | D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' del_target ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13476 | _res = _PyPegen_set_expr_context ( p , a , Del ); |
| 13477 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13478 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13479 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13480 | return NULL; |
| 13481 | } |
| 13482 | goto done; |
| 13483 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13484 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13485 | D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13486 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' del_target ')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13487 | } |
| 13488 | { // '(' del_targets? ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13489 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13490 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13491 | return NULL; |
| 13492 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13493 | D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' del_targets? ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13494 | Token * _literal; |
| 13495 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13496 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13497 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13498 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13499 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13500 | (a = del_targets_rule(p), 1) // del_targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13501 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13502 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13503 | ) |
| 13504 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13505 | D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' del_targets? ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13506 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13507 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13508 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13509 | return NULL; |
| 13510 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13511 | int _end_lineno = _token->end_lineno; |
| 13512 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13513 | int _end_col_offset = _token->end_col_offset; |
| 13514 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 13515 | _res = _Py_Tuple ( a , Del , EXTRA ); |
| 13516 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13517 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13518 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13519 | return NULL; |
| 13520 | } |
| 13521 | goto done; |
| 13522 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13523 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13524 | D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13525 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' del_targets? ')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13526 | } |
| 13527 | { // '[' del_targets? ']' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13528 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13529 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13530 | return NULL; |
| 13531 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13532 | D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' del_targets? ']'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13533 | Token * _literal; |
| 13534 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13535 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13536 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13537 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13538 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13539 | (a = del_targets_rule(p), 1) // del_targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13540 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13541 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13542 | ) |
| 13543 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13544 | D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' del_targets? ']'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13545 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13546 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13547 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13548 | return NULL; |
| 13549 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13550 | int _end_lineno = _token->end_lineno; |
| 13551 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13552 | int _end_col_offset = _token->end_col_offset; |
| 13553 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 13554 | _res = _Py_List ( a , Del , EXTRA ); |
| 13555 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13556 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13557 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13558 | return NULL; |
| 13559 | } |
| 13560 | goto done; |
| 13561 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13562 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13563 | D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13564 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' del_targets? ']'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13565 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13566 | { // invalid_del_target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13567 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13568 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13569 | return NULL; |
| 13570 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13571 | D(fprintf(stderr, "%*c> del_t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "invalid_del_target")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13572 | void *invalid_del_target_var; |
| 13573 | if ( |
| 13574 | (invalid_del_target_var = invalid_del_target_rule(p)) // invalid_del_target |
| 13575 | ) |
| 13576 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13577 | D(fprintf(stderr, "%*c+ del_t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "invalid_del_target")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13578 | _res = invalid_del_target_var; |
| 13579 | goto done; |
| 13580 | } |
| 13581 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13582 | D(fprintf(stderr, "%*c%s del_t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 13583 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "invalid_del_target")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13584 | } |
| 13585 | _res = NULL; |
| 13586 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13587 | D(p->level--); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13588 | return _res; |
| 13589 | } |
| 13590 | |
| 13591 | // del_target_end: ')' | ']' | ',' | ';' | NEWLINE |
| 13592 | static void * |
| 13593 | del_target_end_rule(Parser *p) |
| 13594 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13595 | D(p->level++); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13596 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13597 | D(p->level--); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13598 | return NULL; |
| 13599 | } |
| 13600 | void * _res = NULL; |
| 13601 | int _mark = p->mark; |
| 13602 | { // ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13603 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13604 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13605 | return NULL; |
| 13606 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13607 | D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13608 | Token * _literal; |
| 13609 | if ( |
| 13610 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
| 13611 | ) |
| 13612 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13613 | D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13614 | _res = _literal; |
| 13615 | goto done; |
| 13616 | } |
| 13617 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13618 | D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ', |
| 13619 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13620 | } |
| 13621 | { // ']' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13622 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13623 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13624 | return NULL; |
| 13625 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13626 | D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "']'")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13627 | Token * _literal; |
| 13628 | if ( |
| 13629 | (_literal = _PyPegen_expect_token(p, 10)) // token=']' |
| 13630 | ) |
| 13631 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13632 | D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "']'")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13633 | _res = _literal; |
| 13634 | goto done; |
| 13635 | } |
| 13636 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13637 | D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ', |
| 13638 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "']'")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13639 | } |
| 13640 | { // ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13641 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13642 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13643 | return NULL; |
| 13644 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13645 | D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13646 | Token * _literal; |
| 13647 | if ( |
| 13648 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 13649 | ) |
| 13650 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13651 | D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13652 | _res = _literal; |
| 13653 | goto done; |
| 13654 | } |
| 13655 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13656 | D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ', |
| 13657 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13658 | } |
| 13659 | { // ';' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13660 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13661 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13662 | return NULL; |
| 13663 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13664 | D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13665 | Token * _literal; |
| 13666 | if ( |
| 13667 | (_literal = _PyPegen_expect_token(p, 13)) // token=';' |
| 13668 | ) |
| 13669 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13670 | D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13671 | _res = _literal; |
| 13672 | goto done; |
| 13673 | } |
| 13674 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13675 | D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ', |
| 13676 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13677 | } |
| 13678 | { // NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13679 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13680 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13681 | return NULL; |
| 13682 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13683 | D(fprintf(stderr, "%*c> del_target_end[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13684 | Token * newline_var; |
| 13685 | if ( |
| 13686 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 13687 | ) |
| 13688 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13689 | D(fprintf(stderr, "%*c+ del_target_end[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13690 | _res = newline_var; |
| 13691 | goto done; |
| 13692 | } |
| 13693 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13694 | D(fprintf(stderr, "%*c%s del_target_end[%d-%d]: %s failed!\n", p->level, ' ', |
| 13695 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 13696 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13697 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13698 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13699 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13700 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13701 | } |
| 13702 | |
| 13703 | // targets: ','.target+ ','? |
| 13704 | static asdl_seq* |
| 13705 | targets_rule(Parser *p) |
| 13706 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13707 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13708 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13709 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13710 | return NULL; |
| 13711 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13712 | asdl_seq* _res = NULL; |
| 13713 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13714 | { // ','.target+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13715 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13716 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13717 | return NULL; |
| 13718 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13719 | D(fprintf(stderr, "%*c> targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "','.target+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13720 | void *_opt_var; |
| 13721 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13722 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13723 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13724 | (a = _gather_123_rule(p)) // ','.target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13725 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13726 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13727 | ) |
| 13728 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13729 | D(fprintf(stderr, "%*c+ targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "','.target+ ','?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13730 | _res = a; |
| 13731 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13732 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13733 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13734 | return NULL; |
| 13735 | } |
| 13736 | goto done; |
| 13737 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13738 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13739 | D(fprintf(stderr, "%*c%s targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 13740 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "','.target+ ','?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13741 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13742 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13743 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13744 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13745 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13746 | } |
| 13747 | |
| 13748 | // target: |
| 13749 | // | t_primary '.' NAME !t_lookahead |
| 13750 | // | t_primary '[' slices ']' !t_lookahead |
| 13751 | // | t_atom |
| 13752 | static expr_ty |
| 13753 | target_rule(Parser *p) |
| 13754 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13755 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13756 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13757 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13758 | return NULL; |
| 13759 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13760 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13761 | if (_PyPegen_is_memoized(p, target_type, &_res)) { |
| 13762 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13763 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13764 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13765 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13766 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 13767 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13768 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13769 | return NULL; |
| 13770 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13771 | int _start_lineno = p->tokens[_mark]->lineno; |
| 13772 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 13773 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 13774 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13775 | { // t_primary '.' NAME !t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13776 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13777 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13778 | return NULL; |
| 13779 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13780 | D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13781 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13782 | expr_ty a; |
| 13783 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13784 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13785 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13786 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13787 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13788 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13789 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13790 | && |
| 13791 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 13792 | ) |
| 13793 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13794 | D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13795 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13796 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13797 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13798 | return NULL; |
| 13799 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13800 | int _end_lineno = _token->end_lineno; |
| 13801 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13802 | int _end_col_offset = _token->end_col_offset; |
| 13803 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 13804 | _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 13805 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13806 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13807 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13808 | return NULL; |
| 13809 | } |
| 13810 | goto done; |
| 13811 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13812 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13813 | D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ', |
| 13814 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME !t_lookahead")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13815 | } |
| 13816 | { // t_primary '[' slices ']' !t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13817 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13818 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13819 | return NULL; |
| 13820 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13821 | D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13822 | Token * _literal; |
| 13823 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13824 | expr_ty a; |
| 13825 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13826 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13827 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13828 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13829 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13830 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13831 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13832 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13833 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13834 | && |
| 13835 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 13836 | ) |
| 13837 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13838 | D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13839 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13840 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13841 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13842 | return NULL; |
| 13843 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13844 | int _end_lineno = _token->end_lineno; |
| 13845 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13846 | int _end_col_offset = _token->end_col_offset; |
| 13847 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 13848 | _res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 13849 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13850 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13851 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13852 | return NULL; |
| 13853 | } |
| 13854 | goto done; |
| 13855 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13856 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13857 | D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ', |
| 13858 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' !t_lookahead")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13859 | } |
| 13860 | { // t_atom |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13861 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13862 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13863 | return NULL; |
| 13864 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13865 | D(fprintf(stderr, "%*c> target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_atom")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13866 | expr_ty t_atom_var; |
| 13867 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13868 | (t_atom_var = t_atom_rule(p)) // t_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13869 | ) |
| 13870 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13871 | D(fprintf(stderr, "%*c+ target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_atom")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13872 | _res = t_atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13873 | goto done; |
| 13874 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13875 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13876 | D(fprintf(stderr, "%*c%s target[%d-%d]: %s failed!\n", p->level, ' ', |
| 13877 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_atom")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13878 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13879 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13880 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13881 | _PyPegen_insert_memo(p, _mark, target_type, _res); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13882 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13883 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13884 | } |
| 13885 | |
| 13886 | // Left-recursive |
| 13887 | // t_primary: |
| 13888 | // | t_primary '.' NAME &t_lookahead |
| 13889 | // | t_primary '[' slices ']' &t_lookahead |
| 13890 | // | t_primary genexp &t_lookahead |
| 13891 | // | t_primary '(' arguments? ')' &t_lookahead |
| 13892 | // | atom &t_lookahead |
| 13893 | static expr_ty t_primary_raw(Parser *); |
| 13894 | static expr_ty |
| 13895 | t_primary_rule(Parser *p) |
| 13896 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13897 | D(p->level++); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13898 | expr_ty _res = NULL; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13899 | if (_PyPegen_is_memoized(p, t_primary_type, &_res)) { |
| 13900 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13901 | return _res; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13902 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13903 | int _mark = p->mark; |
| 13904 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13905 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13906 | int tmpvar_8 = _PyPegen_update_memo(p, _mark, t_primary_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13907 | if (tmpvar_8) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13908 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13909 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13910 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13911 | p->mark = _mark; |
| 13912 | void *_raw = t_primary_raw(p); |
| 13913 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13914 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13915 | _resmark = p->mark; |
| 13916 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13917 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13918 | p->mark = _resmark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13919 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13920 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13921 | } |
| 13922 | static expr_ty |
| 13923 | t_primary_raw(Parser *p) |
| 13924 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13925 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13926 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13927 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13928 | return NULL; |
| 13929 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13930 | expr_ty _res = NULL; |
| 13931 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13932 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 13933 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13934 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13935 | return NULL; |
| 13936 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13937 | int _start_lineno = p->tokens[_mark]->lineno; |
| 13938 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 13939 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 13940 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13941 | { // t_primary '.' NAME &t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13942 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13943 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13944 | return NULL; |
| 13945 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13946 | D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13947 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13948 | expr_ty a; |
| 13949 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13950 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13951 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13952 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13953 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13954 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13955 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13956 | && |
| 13957 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 13958 | ) |
| 13959 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13960 | D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '.' NAME &t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13961 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 13962 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13963 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13964 | return NULL; |
| 13965 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13966 | int _end_lineno = _token->end_lineno; |
| 13967 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 13968 | int _end_col_offset = _token->end_col_offset; |
| 13969 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 13970 | _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
| 13971 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13972 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13973 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13974 | return NULL; |
| 13975 | } |
| 13976 | goto done; |
| 13977 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13978 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13979 | D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 13980 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '.' NAME &t_lookahead")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13981 | } |
| 13982 | { // t_primary '[' slices ']' &t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13983 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13984 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13985 | return NULL; |
| 13986 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 13987 | D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13988 | Token * _literal; |
| 13989 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13990 | expr_ty a; |
| 13991 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13992 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13993 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13994 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13995 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13996 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13997 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13998 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13999 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14000 | && |
| 14001 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 14002 | ) |
| 14003 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14004 | D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14005 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 14006 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14007 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14008 | return NULL; |
| 14009 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14010 | int _end_lineno = _token->end_lineno; |
| 14011 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 14012 | int _end_col_offset = _token->end_col_offset; |
| 14013 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 14014 | _res = _Py_Subscript ( a , b , Load , EXTRA ); |
| 14015 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14016 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14017 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14018 | return NULL; |
| 14019 | } |
| 14020 | goto done; |
| 14021 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14022 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14023 | D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 14024 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '[' slices ']' &t_lookahead")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14025 | } |
| 14026 | { // t_primary genexp &t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14027 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14028 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14029 | return NULL; |
| 14030 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14031 | D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary genexp &t_lookahead")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14032 | expr_ty a; |
| 14033 | expr_ty b; |
| 14034 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14035 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14036 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14037 | (b = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14038 | && |
| 14039 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 14040 | ) |
| 14041 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14042 | D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary genexp &t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14043 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 14044 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14045 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14046 | return NULL; |
| 14047 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14048 | int _end_lineno = _token->end_lineno; |
| 14049 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 14050 | int _end_col_offset = _token->end_col_offset; |
| 14051 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 14052 | _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
| 14053 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14054 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14055 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14056 | return NULL; |
| 14057 | } |
| 14058 | goto done; |
| 14059 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14060 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14061 | D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 14062 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary genexp &t_lookahead")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14063 | } |
| 14064 | { // t_primary '(' arguments? ')' &t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14065 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14066 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14067 | return NULL; |
| 14068 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14069 | D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14070 | Token * _literal; |
| 14071 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14072 | expr_ty a; |
| 14073 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14074 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14075 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14076 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14077 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14078 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14079 | (b = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14080 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14081 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14082 | && |
| 14083 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 14084 | ) |
| 14085 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14086 | D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14087 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 14088 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14089 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14090 | return NULL; |
| 14091 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14092 | int _end_lineno = _token->end_lineno; |
| 14093 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 14094 | int _end_col_offset = _token->end_col_offset; |
| 14095 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 14096 | _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 14097 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14098 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14099 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14100 | return NULL; |
| 14101 | } |
| 14102 | goto done; |
| 14103 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14104 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14105 | D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 14106 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "t_primary '(' arguments? ')' &t_lookahead")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14107 | } |
| 14108 | { // atom &t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14109 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14110 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14111 | return NULL; |
| 14112 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14113 | D(fprintf(stderr, "%*c> t_primary[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "atom &t_lookahead")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14114 | expr_ty a; |
| 14115 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14116 | (a = atom_rule(p)) // atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14117 | && |
| 14118 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 14119 | ) |
| 14120 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14121 | D(fprintf(stderr, "%*c+ t_primary[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "atom &t_lookahead")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14122 | _res = a; |
| 14123 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14124 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14125 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14126 | return NULL; |
| 14127 | } |
| 14128 | goto done; |
| 14129 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14130 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14131 | D(fprintf(stderr, "%*c%s t_primary[%d-%d]: %s failed!\n", p->level, ' ', |
| 14132 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "atom &t_lookahead")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14133 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14134 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14135 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14136 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14137 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14138 | } |
| 14139 | |
| 14140 | // t_lookahead: '(' | '[' | '.' |
| 14141 | static void * |
| 14142 | t_lookahead_rule(Parser *p) |
| 14143 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14144 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14145 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14146 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14147 | return NULL; |
| 14148 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14149 | void * _res = NULL; |
| 14150 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14151 | { // '(' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14152 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14153 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14154 | return NULL; |
| 14155 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14156 | D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14157 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14158 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14159 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14160 | ) |
| 14161 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14162 | D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14163 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14164 | goto done; |
| 14165 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14166 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14167 | D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ', |
| 14168 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14169 | } |
| 14170 | { // '[' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14171 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14172 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14173 | return NULL; |
| 14174 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14175 | D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14176 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14177 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14178 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14179 | ) |
| 14180 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14181 | D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14182 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14183 | goto done; |
| 14184 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14185 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14186 | D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ', |
| 14187 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14188 | } |
| 14189 | { // '.' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14190 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14191 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14192 | return NULL; |
| 14193 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14194 | D(fprintf(stderr, "%*c> t_lookahead[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14195 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14196 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14197 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14198 | ) |
| 14199 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14200 | D(fprintf(stderr, "%*c+ t_lookahead[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14201 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14202 | goto done; |
| 14203 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14204 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14205 | D(fprintf(stderr, "%*c%s t_lookahead[%d-%d]: %s failed!\n", p->level, ' ', |
| 14206 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14207 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14208 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14209 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14210 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14211 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14212 | } |
| 14213 | |
| 14214 | // t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']' |
| 14215 | static expr_ty |
| 14216 | t_atom_rule(Parser *p) |
| 14217 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14218 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14219 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14220 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14221 | return NULL; |
| 14222 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14223 | expr_ty _res = NULL; |
| 14224 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14225 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 14226 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14227 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14228 | return NULL; |
| 14229 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14230 | int _start_lineno = p->tokens[_mark]->lineno; |
| 14231 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 14232 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 14233 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14234 | { // NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14235 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14236 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14237 | return NULL; |
| 14238 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14239 | D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14240 | expr_ty a; |
| 14241 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14242 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14243 | ) |
| 14244 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14245 | D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14246 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 14247 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14248 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14249 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14250 | return NULL; |
| 14251 | } |
| 14252 | goto done; |
| 14253 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14254 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14255 | D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 14256 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14257 | } |
| 14258 | { // '(' target ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14259 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14260 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14261 | return NULL; |
| 14262 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14263 | D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' target ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14264 | Token * _literal; |
| 14265 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14266 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14267 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14268 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14269 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14270 | (a = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14271 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14272 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14273 | ) |
| 14274 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14275 | D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' target ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14276 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 14277 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14278 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14279 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14280 | return NULL; |
| 14281 | } |
| 14282 | goto done; |
| 14283 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14284 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14285 | D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 14286 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' target ')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14287 | } |
| 14288 | { // '(' targets? ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14289 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14290 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14291 | return NULL; |
| 14292 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14293 | D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' targets? ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14294 | Token * _literal; |
| 14295 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14296 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14297 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14298 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14299 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14300 | (b = targets_rule(p), 1) // targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14301 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14302 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14303 | ) |
| 14304 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14305 | D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' targets? ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14306 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 14307 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14308 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14309 | return NULL; |
| 14310 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14311 | int _end_lineno = _token->end_lineno; |
| 14312 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 14313 | int _end_col_offset = _token->end_col_offset; |
| 14314 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 14315 | _res = _Py_Tuple ( b , Store , EXTRA ); |
| 14316 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14317 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14318 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14319 | return NULL; |
| 14320 | } |
| 14321 | goto done; |
| 14322 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14323 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14324 | D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 14325 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' targets? ')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14326 | } |
| 14327 | { // '[' targets? ']' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14328 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14329 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14330 | return NULL; |
| 14331 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14332 | D(fprintf(stderr, "%*c> t_atom[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'[' targets? ']'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14333 | Token * _literal; |
| 14334 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14335 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14336 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14337 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14338 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14339 | (b = targets_rule(p), 1) // targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14340 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14341 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14342 | ) |
| 14343 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14344 | D(fprintf(stderr, "%*c+ t_atom[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'[' targets? ']'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14345 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 14346 | if (_token == NULL) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14347 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14348 | return NULL; |
| 14349 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14350 | int _end_lineno = _token->end_lineno; |
| 14351 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 14352 | int _end_col_offset = _token->end_col_offset; |
| 14353 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 14354 | _res = _Py_List ( b , Store , EXTRA ); |
| 14355 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14356 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14357 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14358 | return NULL; |
| 14359 | } |
| 14360 | goto done; |
| 14361 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14362 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14363 | D(fprintf(stderr, "%*c%s t_atom[%d-%d]: %s failed!\n", p->level, ' ', |
| 14364 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'[' targets? ']'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14365 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14366 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14367 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14368 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14369 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14370 | } |
| 14371 | |
| 14372 | // incorrect_arguments: |
| 14373 | // | args ',' '*' |
| 14374 | // | expression for_if_clauses ',' [args | expression for_if_clauses] |
Lysandros Nikolaou | ae14583 | 2020-05-22 03:56:52 +0300 | [diff] [blame] | 14375 | // | args for_if_clauses |
| 14376 | // | args ',' expression for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14377 | // | args ',' args |
| 14378 | static void * |
| 14379 | incorrect_arguments_rule(Parser *p) |
| 14380 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14381 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14382 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14383 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14384 | return NULL; |
| 14385 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14386 | void * _res = NULL; |
| 14387 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14388 | { // args ',' '*' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14389 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14390 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14391 | return NULL; |
| 14392 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14393 | D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' '*'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14394 | Token * _literal; |
| 14395 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14396 | expr_ty args_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14397 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14398 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14399 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14400 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14401 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14402 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14403 | ) |
| 14404 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14405 | D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' '*'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14406 | _res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" ); |
| 14407 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14408 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14409 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14410 | return NULL; |
| 14411 | } |
| 14412 | goto done; |
| 14413 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14414 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14415 | D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', |
| 14416 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' '*'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14417 | } |
| 14418 | { // expression for_if_clauses ',' [args | expression for_if_clauses] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14419 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14420 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14421 | return NULL; |
| 14422 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14423 | D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14424 | Token * _literal; |
| 14425 | void *_opt_var; |
| 14426 | UNUSED(_opt_var); // Silence compiler warnings |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14427 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14428 | asdl_seq* for_if_clauses_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14429 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14430 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14431 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14432 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14433 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14434 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14435 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14436 | (_opt_var = _tmp_125_rule(p), 1) // [args | expression for_if_clauses] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14437 | ) |
| 14438 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14439 | D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14440 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "Generator expression must be parenthesized" ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14441 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14442 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14443 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14444 | return NULL; |
| 14445 | } |
| 14446 | goto done; |
| 14447 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14448 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14449 | D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', |
| 14450 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses ',' [args | expression for_if_clauses]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14451 | } |
Lysandros Nikolaou | ae14583 | 2020-05-22 03:56:52 +0300 | [diff] [blame] | 14452 | { // args for_if_clauses |
| 14453 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14454 | D(p->level--); |
Lysandros Nikolaou | ae14583 | 2020-05-22 03:56:52 +0300 | [diff] [blame] | 14455 | return NULL; |
| 14456 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14457 | D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args for_if_clauses")); |
Lysandros Nikolaou | ae14583 | 2020-05-22 03:56:52 +0300 | [diff] [blame] | 14458 | expr_ty a; |
| 14459 | asdl_seq* for_if_clauses_var; |
| 14460 | if ( |
| 14461 | (a = args_rule(p)) // args |
| 14462 | && |
| 14463 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
| 14464 | ) |
| 14465 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14466 | D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args for_if_clauses")); |
Lysandros Nikolaou | ae14583 | 2020-05-22 03:56:52 +0300 | [diff] [blame] | 14467 | _res = _PyPegen_nonparen_genexp_in_call ( p , a ); |
| 14468 | if (_res == NULL && PyErr_Occurred()) { |
| 14469 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14470 | D(p->level--); |
Lysandros Nikolaou | ae14583 | 2020-05-22 03:56:52 +0300 | [diff] [blame] | 14471 | return NULL; |
| 14472 | } |
| 14473 | goto done; |
| 14474 | } |
| 14475 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14476 | D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', |
| 14477 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args for_if_clauses")); |
Lysandros Nikolaou | ae14583 | 2020-05-22 03:56:52 +0300 | [diff] [blame] | 14478 | } |
| 14479 | { // args ',' expression for_if_clauses |
| 14480 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14481 | D(p->level--); |
Lysandros Nikolaou | ae14583 | 2020-05-22 03:56:52 +0300 | [diff] [blame] | 14482 | return NULL; |
| 14483 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14484 | D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses")); |
Lysandros Nikolaou | ae14583 | 2020-05-22 03:56:52 +0300 | [diff] [blame] | 14485 | Token * _literal; |
| 14486 | expr_ty a; |
| 14487 | expr_ty args_var; |
| 14488 | asdl_seq* for_if_clauses_var; |
| 14489 | if ( |
| 14490 | (args_var = args_rule(p)) // args |
| 14491 | && |
| 14492 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 14493 | && |
| 14494 | (a = expression_rule(p)) // expression |
| 14495 | && |
| 14496 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
| 14497 | ) |
| 14498 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14499 | D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' expression for_if_clauses")); |
Lysandros Nikolaou | ae14583 | 2020-05-22 03:56:52 +0300 | [diff] [blame] | 14500 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "Generator expression must be parenthesized" ); |
| 14501 | if (_res == NULL && PyErr_Occurred()) { |
| 14502 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14503 | D(p->level--); |
Lysandros Nikolaou | ae14583 | 2020-05-22 03:56:52 +0300 | [diff] [blame] | 14504 | return NULL; |
| 14505 | } |
| 14506 | goto done; |
| 14507 | } |
| 14508 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14509 | D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', |
| 14510 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' expression for_if_clauses")); |
Lysandros Nikolaou | ae14583 | 2020-05-22 03:56:52 +0300 | [diff] [blame] | 14511 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14512 | { // args ',' args |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14513 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14514 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14515 | return NULL; |
| 14516 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14517 | D(fprintf(stderr, "%*c> incorrect_arguments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args ',' args")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14518 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14519 | expr_ty a; |
| 14520 | expr_ty args_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14521 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14522 | (a = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14523 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14524 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14525 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14526 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14527 | ) |
| 14528 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14529 | D(fprintf(stderr, "%*c+ incorrect_arguments[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args ',' args")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14530 | _res = _PyPegen_arguments_parsing_error ( p , a ); |
| 14531 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14532 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14533 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14534 | return NULL; |
| 14535 | } |
| 14536 | goto done; |
| 14537 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14538 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14539 | D(fprintf(stderr, "%*c%s incorrect_arguments[%d-%d]: %s failed!\n", p->level, ' ', |
| 14540 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args ',' args")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14541 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14542 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14543 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14544 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14545 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14546 | } |
| 14547 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 14548 | // invalid_kwarg: expression '=' |
| 14549 | static void * |
| 14550 | invalid_kwarg_rule(Parser *p) |
| 14551 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14552 | D(p->level++); |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 14553 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14554 | D(p->level--); |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 14555 | return NULL; |
| 14556 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14557 | void * _res = NULL; |
| 14558 | int _mark = p->mark; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 14559 | { // expression '=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14560 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14561 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14562 | return NULL; |
| 14563 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14564 | D(fprintf(stderr, "%*c> invalid_kwarg[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression '='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14565 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14566 | expr_ty a; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 14567 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14568 | (a = expression_rule(p)) // expression |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 14569 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14570 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 14571 | ) |
| 14572 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14573 | D(fprintf(stderr, "%*c+ invalid_kwarg[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression '='")); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14574 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "expression cannot contain assignment, perhaps you meant \"==\"?" ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14575 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 14576 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14577 | D(p->level--); |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 14578 | return NULL; |
| 14579 | } |
| 14580 | goto done; |
| 14581 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14582 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14583 | D(fprintf(stderr, "%*c%s invalid_kwarg[%d-%d]: %s failed!\n", p->level, ' ', |
| 14584 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression '='")); |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 14585 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14586 | _res = NULL; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 14587 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14588 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14589 | return _res; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 14590 | } |
| 14591 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14592 | // invalid_named_expression: expression ':=' expression |
| 14593 | static void * |
| 14594 | invalid_named_expression_rule(Parser *p) |
| 14595 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14596 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14597 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14598 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14599 | return NULL; |
| 14600 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14601 | void * _res = NULL; |
| 14602 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14603 | { // expression ':=' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14604 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14605 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14606 | return NULL; |
| 14607 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14608 | D(fprintf(stderr, "%*c> invalid_named_expression[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':=' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14609 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14610 | expr_ty a; |
| 14611 | expr_ty expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14612 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14613 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14614 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14615 | (_literal = _PyPegen_expect_token(p, 53)) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14616 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14617 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14618 | ) |
| 14619 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14620 | D(fprintf(stderr, "%*c+ invalid_named_expression[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':=' expression")); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14621 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14622 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14623 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14624 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14625 | return NULL; |
| 14626 | } |
| 14627 | goto done; |
| 14628 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14629 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14630 | D(fprintf(stderr, "%*c%s invalid_named_expression[%d-%d]: %s failed!\n", p->level, ' ', |
| 14631 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':=' expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14632 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14633 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14634 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14635 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14636 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14637 | } |
| 14638 | |
| 14639 | // invalid_assignment: |
| 14640 | // | list ':' |
| 14641 | // | tuple ':' |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14642 | // | star_named_expression ',' star_named_expressions* ':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14643 | // | expression ':' expression ['=' annotated_rhs] |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 14644 | // | ((star_targets '='))* star_expressions '=' |
| 14645 | // | ((star_targets '='))* yield_expr '=' |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 14646 | // | star_expressions augassign (yield_expr | star_expressions) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14647 | static void * |
| 14648 | invalid_assignment_rule(Parser *p) |
| 14649 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14650 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14651 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14652 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14653 | return NULL; |
| 14654 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14655 | void * _res = NULL; |
| 14656 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14657 | { // list ':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14658 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14659 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14660 | return NULL; |
| 14661 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14662 | D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list ':'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14663 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14664 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14665 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14666 | (a = list_rule(p)) // list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14667 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14668 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14669 | ) |
| 14670 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14671 | D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list ':'")); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14672 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not list) can be annotated" ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14673 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14674 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14675 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14676 | return NULL; |
| 14677 | } |
| 14678 | goto done; |
| 14679 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14680 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14681 | D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 14682 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list ':'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14683 | } |
| 14684 | { // tuple ':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14685 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14686 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14687 | return NULL; |
| 14688 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14689 | D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple ':'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14690 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14691 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14692 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14693 | (a = tuple_rule(p)) // tuple |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14694 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14695 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14696 | ) |
| 14697 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14698 | D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple ':'")); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14699 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" ); |
| 14700 | if (_res == NULL && PyErr_Occurred()) { |
| 14701 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14702 | D(p->level--); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14703 | return NULL; |
| 14704 | } |
| 14705 | goto done; |
| 14706 | } |
| 14707 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14708 | D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 14709 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple ':'")); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14710 | } |
| 14711 | { // star_named_expression ',' star_named_expressions* ':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14712 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14713 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14714 | return NULL; |
| 14715 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14716 | D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'")); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14717 | Token * _literal; |
| 14718 | Token * _literal_1; |
| 14719 | asdl_seq * _loop0_126_var; |
| 14720 | expr_ty a; |
| 14721 | if ( |
| 14722 | (a = star_named_expression_rule(p)) // star_named_expression |
| 14723 | && |
| 14724 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 14725 | && |
| 14726 | (_loop0_126_var = _loop0_126_rule(p)) // star_named_expressions* |
| 14727 | && |
| 14728 | (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' |
| 14729 | ) |
| 14730 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14731 | D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'")); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14732 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14733 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14734 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14735 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14736 | return NULL; |
| 14737 | } |
| 14738 | goto done; |
| 14739 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14740 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14741 | D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 14742 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions* ':'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14743 | } |
| 14744 | { // expression ':' expression ['=' annotated_rhs] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14745 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14746 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14747 | return NULL; |
| 14748 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14749 | D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14750 | Token * _literal; |
| 14751 | void *_opt_var; |
| 14752 | UNUSED(_opt_var); // Silence compiler warnings |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14753 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14754 | expr_ty expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14755 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14756 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14757 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14758 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14759 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14760 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14761 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14762 | (_opt_var = _tmp_127_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14763 | ) |
| 14764 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14765 | D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression ':' expression ['=' annotated_rhs]")); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14766 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "illegal target for annotation" ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14767 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14768 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14769 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14770 | return NULL; |
| 14771 | } |
| 14772 | goto done; |
| 14773 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14774 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14775 | D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 14776 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression ':' expression ['=' annotated_rhs]")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14777 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 14778 | { // ((star_targets '='))* star_expressions '=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14779 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14780 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14781 | return NULL; |
| 14782 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 14783 | D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='")); |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 14784 | Token * _literal; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 14785 | asdl_seq * _loop0_128_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14786 | expr_ty a; |
| 14787 | if ( |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 14788 | (_loop0_128_var = _loop0_128_rule(p)) // ((star_targets '='))* |
| 14789 | && |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 14790 | (a = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14791 | && |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 14792 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 14793 | ) |
| 14794 | { |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 14795 | D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* star_expressions '='")); |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 14796 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( _PyPegen_get_invalid_target ( a ) , "cannot assign to %s" , _PyPegen_get_expr_name ( _PyPegen_get_invalid_target ( a ) ) ); |
| 14797 | if (_res == NULL && PyErr_Occurred()) { |
| 14798 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14799 | D(p->level--); |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 14800 | return NULL; |
| 14801 | } |
| 14802 | goto done; |
| 14803 | } |
| 14804 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14805 | D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 14806 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))* star_expressions '='")); |
| 14807 | } |
| 14808 | { // ((star_targets '='))* yield_expr '=' |
| 14809 | if (p->error_indicator) { |
| 14810 | D(p->level--); |
| 14811 | return NULL; |
| 14812 | } |
| 14813 | D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='")); |
| 14814 | Token * _literal; |
| 14815 | asdl_seq * _loop0_129_var; |
| 14816 | expr_ty a; |
| 14817 | if ( |
| 14818 | (_loop0_129_var = _loop0_129_rule(p)) // ((star_targets '='))* |
| 14819 | && |
| 14820 | (a = yield_expr_rule(p)) // yield_expr |
| 14821 | && |
| 14822 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 14823 | ) |
| 14824 | { |
| 14825 | D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "((star_targets '='))* yield_expr '='")); |
| 14826 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "assignment to yield expression not possible" ); |
| 14827 | if (_res == NULL && PyErr_Occurred()) { |
| 14828 | p->error_indicator = 1; |
| 14829 | D(p->level--); |
| 14830 | return NULL; |
| 14831 | } |
| 14832 | goto done; |
| 14833 | } |
| 14834 | p->mark = _mark; |
| 14835 | D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 14836 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "((star_targets '='))* yield_expr '='")); |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 14837 | } |
| 14838 | { // star_expressions augassign (yield_expr | star_expressions) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14839 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14840 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14841 | return NULL; |
| 14842 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14843 | D(fprintf(stderr, "%*c> invalid_assignment[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 14844 | void *_tmp_130_var; |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 14845 | expr_ty a; |
| 14846 | AugOperator* augassign_var; |
| 14847 | if ( |
| 14848 | (a = star_expressions_rule(p)) // star_expressions |
| 14849 | && |
| 14850 | (augassign_var = augassign_rule(p)) // augassign |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 14851 | && |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 14852 | (_tmp_130_var = _tmp_130_rule(p)) // yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14853 | ) |
| 14854 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14855 | D(fprintf(stderr, "%*c+ invalid_assignment[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 14856 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "'%s' is an illegal expression for augmented assignment" , _PyPegen_get_expr_name ( a ) ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14857 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14858 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14859 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14860 | return NULL; |
| 14861 | } |
| 14862 | goto done; |
| 14863 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14864 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14865 | D(fprintf(stderr, "%*c%s invalid_assignment[%d-%d]: %s failed!\n", p->level, ' ', |
| 14866 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions augassign (yield_expr | star_expressions)")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14867 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14868 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14869 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14870 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14871 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14872 | } |
| 14873 | |
| 14874 | // invalid_block: NEWLINE !INDENT |
| 14875 | static void * |
| 14876 | invalid_block_rule(Parser *p) |
| 14877 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14878 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14879 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14880 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14881 | return NULL; |
| 14882 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14883 | void * _res = NULL; |
| 14884 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14885 | { // NEWLINE !INDENT |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14886 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14887 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14888 | return NULL; |
| 14889 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14890 | D(fprintf(stderr, "%*c> invalid_block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT")); |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 14891 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14892 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14893 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14894 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14895 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14896 | ) |
| 14897 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14898 | D(fprintf(stderr, "%*c+ invalid_block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE !INDENT")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14899 | _res = RAISE_INDENTATION_ERROR ( "expected an indented block" ); |
| 14900 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14901 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14902 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14903 | return NULL; |
| 14904 | } |
| 14905 | goto done; |
| 14906 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14907 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14908 | D(fprintf(stderr, "%*c%s invalid_block[%d-%d]: %s failed!\n", p->level, ' ', |
| 14909 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE !INDENT")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14910 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14911 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14912 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14913 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14914 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14915 | } |
| 14916 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14917 | // invalid_comprehension: ('[' | '(' | '{') starred_expression for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14918 | static void * |
| 14919 | invalid_comprehension_rule(Parser *p) |
| 14920 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14921 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14922 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14923 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14924 | return NULL; |
| 14925 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14926 | void * _res = NULL; |
| 14927 | int _mark = p->mark; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14928 | { // ('[' | '(' | '{') starred_expression for_if_clauses |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14929 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14930 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14931 | return NULL; |
| 14932 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14933 | D(fprintf(stderr, "%*c> invalid_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 14934 | void *_tmp_131_var; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14935 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14936 | asdl_seq* for_if_clauses_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14937 | if ( |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 14938 | (_tmp_131_var = _tmp_131_rule(p)) // '[' | '(' | '{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14939 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14940 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14941 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14942 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14943 | ) |
| 14944 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14945 | D(fprintf(stderr, "%*c+ invalid_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 14946 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "iterable unpacking cannot be used in comprehension" ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14947 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14948 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14949 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14950 | return NULL; |
| 14951 | } |
| 14952 | goto done; |
| 14953 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14954 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14955 | D(fprintf(stderr, "%*c%s invalid_comprehension[%d-%d]: %s failed!\n", p->level, ' ', |
| 14956 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('[' | '(' | '{') starred_expression for_if_clauses")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14957 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14958 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14959 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14960 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14961 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14962 | } |
| 14963 | |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 14964 | // invalid_dict_comprehension: '{' '**' bitwise_or for_if_clauses '}' |
| 14965 | static void * |
| 14966 | invalid_dict_comprehension_rule(Parser *p) |
| 14967 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14968 | D(p->level++); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 14969 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14970 | D(p->level--); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 14971 | return NULL; |
| 14972 | } |
| 14973 | void * _res = NULL; |
| 14974 | int _mark = p->mark; |
| 14975 | { // '{' '**' bitwise_or for_if_clauses '}' |
| 14976 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14977 | D(p->level--); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 14978 | return NULL; |
| 14979 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14980 | D(fprintf(stderr, "%*c> invalid_dict_comprehension[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'")); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 14981 | Token * _literal; |
| 14982 | Token * _literal_1; |
| 14983 | Token * a; |
| 14984 | expr_ty bitwise_or_var; |
| 14985 | asdl_seq* for_if_clauses_var; |
| 14986 | if ( |
| 14987 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
| 14988 | && |
| 14989 | (a = _PyPegen_expect_token(p, 35)) // token='**' |
| 14990 | && |
| 14991 | (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or |
| 14992 | && |
| 14993 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
| 14994 | && |
| 14995 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
| 14996 | ) |
| 14997 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 14998 | D(fprintf(stderr, "%*c+ invalid_dict_comprehension[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'")); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 14999 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "dict unpacking cannot be used in dict comprehension" ); |
| 15000 | if (_res == NULL && PyErr_Occurred()) { |
| 15001 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15002 | D(p->level--); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 15003 | return NULL; |
| 15004 | } |
| 15005 | goto done; |
| 15006 | } |
| 15007 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15008 | D(fprintf(stderr, "%*c%s invalid_dict_comprehension[%d-%d]: %s failed!\n", p->level, ' ', |
| 15009 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{' '**' bitwise_or for_if_clauses '}'")); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 15010 | } |
| 15011 | _res = NULL; |
| 15012 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15013 | D(p->level--); |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 15014 | return _res; |
| 15015 | } |
| 15016 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15017 | // invalid_parameters: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15018 | // | param_no_default* (slash_with_default | param_with_default+) param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15019 | static void * |
| 15020 | invalid_parameters_rule(Parser *p) |
| 15021 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15022 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15023 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15024 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15025 | return NULL; |
| 15026 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15027 | void * _res = NULL; |
| 15028 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15029 | { // param_no_default* (slash_with_default | param_with_default+) param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15030 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15031 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15032 | return NULL; |
| 15033 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15034 | D(fprintf(stderr, "%*c> invalid_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 15035 | asdl_seq * _loop0_132_var; |
| 15036 | void *_tmp_133_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15037 | arg_ty param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15038 | if ( |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 15039 | (_loop0_132_var = _loop0_132_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15040 | && |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 15041 | (_tmp_133_var = _tmp_133_rule(p)) // slash_with_default | param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15042 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15043 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15044 | ) |
| 15045 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15046 | D(fprintf(stderr, "%*c+ invalid_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15047 | _res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" ); |
| 15048 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15049 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15050 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15051 | return NULL; |
| 15052 | } |
| 15053 | goto done; |
| 15054 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15055 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15056 | D(fprintf(stderr, "%*c%s invalid_parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 15057 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default* (slash_with_default | param_with_default+) param_no_default")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15058 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15059 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15060 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15061 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15062 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15063 | } |
| 15064 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 15065 | // invalid_lambda_parameters: |
| 15066 | // | lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default |
| 15067 | static void * |
| 15068 | invalid_lambda_parameters_rule(Parser *p) |
| 15069 | { |
| 15070 | D(p->level++); |
| 15071 | if (p->error_indicator) { |
| 15072 | D(p->level--); |
| 15073 | return NULL; |
| 15074 | } |
| 15075 | void * _res = NULL; |
| 15076 | int _mark = p->mark; |
| 15077 | { // lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default |
| 15078 | if (p->error_indicator) { |
| 15079 | D(p->level--); |
| 15080 | return NULL; |
| 15081 | } |
| 15082 | D(fprintf(stderr, "%*c> invalid_lambda_parameters[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default")); |
| 15083 | asdl_seq * _loop0_134_var; |
| 15084 | void *_tmp_135_var; |
| 15085 | arg_ty lambda_param_no_default_var; |
| 15086 | if ( |
| 15087 | (_loop0_134_var = _loop0_134_rule(p)) // lambda_param_no_default* |
| 15088 | && |
| 15089 | (_tmp_135_var = _tmp_135_rule(p)) // lambda_slash_with_default | lambda_param_with_default+ |
| 15090 | && |
| 15091 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
| 15092 | ) |
| 15093 | { |
| 15094 | D(fprintf(stderr, "%*c+ invalid_lambda_parameters[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default")); |
| 15095 | _res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" ); |
| 15096 | if (_res == NULL && PyErr_Occurred()) { |
| 15097 | p->error_indicator = 1; |
| 15098 | D(p->level--); |
| 15099 | return NULL; |
| 15100 | } |
| 15101 | goto done; |
| 15102 | } |
| 15103 | p->mark = _mark; |
| 15104 | D(fprintf(stderr, "%*c%s invalid_lambda_parameters[%d-%d]: %s failed!\n", p->level, ' ', |
| 15105 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default* (lambda_slash_with_default | lambda_param_with_default+) lambda_param_no_default")); |
| 15106 | } |
| 15107 | _res = NULL; |
| 15108 | done: |
| 15109 | D(p->level--); |
| 15110 | return _res; |
| 15111 | } |
| 15112 | |
Lysandros Nikolaou | 75b863a | 2020-05-18 22:14:47 +0300 | [diff] [blame] | 15113 | // invalid_star_etc: '*' (')' | ',' (')' | '**')) | '*' ',' TYPE_COMMENT |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15114 | static void * |
| 15115 | invalid_star_etc_rule(Parser *p) |
| 15116 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15117 | D(p->level++); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15118 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15119 | D(p->level--); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15120 | return NULL; |
| 15121 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15122 | void * _res = NULL; |
| 15123 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15124 | { // '*' (')' | ',' (')' | '**')) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15125 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15126 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15127 | return NULL; |
| 15128 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15129 | D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15130 | Token * _literal; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 15131 | void *_tmp_136_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15132 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15133 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15134 | && |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 15135 | (_tmp_136_var = _tmp_136_rule(p)) // ')' | ',' (')' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15136 | ) |
| 15137 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15138 | D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15139 | _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); |
| 15140 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15141 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15142 | D(p->level--); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15143 | return NULL; |
| 15144 | } |
| 15145 | goto done; |
| 15146 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15147 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15148 | D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 15149 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (')' | ',' (')' | '**'))")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15150 | } |
Lysandros Nikolaou | 75b863a | 2020-05-18 22:14:47 +0300 | [diff] [blame] | 15151 | { // '*' ',' TYPE_COMMENT |
Pablo Galindo | ced4e5c | 2020-05-18 22:47:51 +0100 | [diff] [blame] | 15152 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15153 | D(p->level--); |
Pablo Galindo | ced4e5c | 2020-05-18 22:47:51 +0100 | [diff] [blame] | 15154 | return NULL; |
| 15155 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15156 | D(fprintf(stderr, "%*c> invalid_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT")); |
Lysandros Nikolaou | 75b863a | 2020-05-18 22:14:47 +0300 | [diff] [blame] | 15157 | Token * _literal; |
| 15158 | Token * _literal_1; |
| 15159 | Token * type_comment_var; |
| 15160 | if ( |
| 15161 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 15162 | && |
| 15163 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
| 15164 | && |
| 15165 | (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
| 15166 | ) |
| 15167 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15168 | D(fprintf(stderr, "%*c+ invalid_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' ',' TYPE_COMMENT")); |
Lysandros Nikolaou | 75b863a | 2020-05-18 22:14:47 +0300 | [diff] [blame] | 15169 | _res = RAISE_SYNTAX_ERROR ( "bare * has associated type comment" ); |
| 15170 | if (_res == NULL && PyErr_Occurred()) { |
| 15171 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15172 | D(p->level--); |
Lysandros Nikolaou | 75b863a | 2020-05-18 22:14:47 +0300 | [diff] [blame] | 15173 | return NULL; |
| 15174 | } |
| 15175 | goto done; |
| 15176 | } |
| 15177 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15178 | D(fprintf(stderr, "%*c%s invalid_star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 15179 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' ',' TYPE_COMMENT")); |
Lysandros Nikolaou | 75b863a | 2020-05-18 22:14:47 +0300 | [diff] [blame] | 15180 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15181 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15182 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15183 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15184 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15185 | } |
| 15186 | |
| 15187 | // invalid_lambda_star_etc: '*' (':' | ',' (':' | '**')) |
| 15188 | static void * |
| 15189 | invalid_lambda_star_etc_rule(Parser *p) |
| 15190 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15191 | D(p->level++); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15192 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15193 | D(p->level--); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15194 | return NULL; |
| 15195 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15196 | void * _res = NULL; |
| 15197 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15198 | { // '*' (':' | ',' (':' | '**')) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15199 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15200 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15201 | return NULL; |
| 15202 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15203 | D(fprintf(stderr, "%*c> invalid_lambda_star_etc[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15204 | Token * _literal; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 15205 | void *_tmp_137_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15206 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15207 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15208 | && |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 15209 | (_tmp_137_var = _tmp_137_rule(p)) // ':' | ',' (':' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15210 | ) |
| 15211 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15212 | D(fprintf(stderr, "%*c+ invalid_lambda_star_etc[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15213 | _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); |
| 15214 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15215 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15216 | D(p->level--); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15217 | return NULL; |
| 15218 | } |
| 15219 | goto done; |
| 15220 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15221 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15222 | D(fprintf(stderr, "%*c%s invalid_lambda_star_etc[%d-%d]: %s failed!\n", p->level, ' ', |
| 15223 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'*' (':' | ',' (':' | '**'))")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15224 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15225 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15226 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15227 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15228 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15229 | } |
| 15230 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15231 | // invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
| 15232 | static void * |
| 15233 | invalid_double_type_comments_rule(Parser *p) |
| 15234 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15235 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15236 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15237 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15238 | return NULL; |
| 15239 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15240 | void * _res = NULL; |
| 15241 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15242 | { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15243 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15244 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15245 | return NULL; |
| 15246 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15247 | D(fprintf(stderr, "%*c> invalid_double_type_comments[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15248 | Token * indent_var; |
| 15249 | Token * newline_var; |
| 15250 | Token * newline_var_1; |
| 15251 | Token * type_comment_var; |
| 15252 | Token * type_comment_var_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15253 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15254 | (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15255 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15256 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15257 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15258 | (type_comment_var_1 = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15259 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15260 | (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15261 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15262 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15263 | ) |
| 15264 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15265 | 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")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15266 | _res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" ); |
| 15267 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15268 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15269 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15270 | return NULL; |
| 15271 | } |
| 15272 | goto done; |
| 15273 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15274 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15275 | D(fprintf(stderr, "%*c%s invalid_double_type_comments[%d-%d]: %s failed!\n", p->level, ' ', |
| 15276 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15277 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15278 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15279 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15280 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15281 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15282 | } |
| 15283 | |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 15284 | // invalid_del_target: star_expression &del_target_end |
| 15285 | static void * |
| 15286 | invalid_del_target_rule(Parser *p) |
| 15287 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15288 | D(p->level++); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 15289 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15290 | D(p->level--); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 15291 | return NULL; |
| 15292 | } |
| 15293 | void * _res = NULL; |
| 15294 | int _mark = p->mark; |
| 15295 | { // star_expression &del_target_end |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15296 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15297 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15298 | return NULL; |
| 15299 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15300 | D(fprintf(stderr, "%*c> invalid_del_target[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression &del_target_end")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 15301 | expr_ty a; |
| 15302 | if ( |
| 15303 | (a = star_expression_rule(p)) // star_expression |
| 15304 | && |
| 15305 | _PyPegen_lookahead(1, del_target_end_rule, p) |
| 15306 | ) |
| 15307 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15308 | D(fprintf(stderr, "%*c+ invalid_del_target[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression &del_target_end")); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15309 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "cannot delete %s" , _PyPegen_get_expr_name ( a ) ); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 15310 | if (_res == NULL && PyErr_Occurred()) { |
| 15311 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15312 | D(p->level--); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 15313 | return NULL; |
| 15314 | } |
| 15315 | goto done; |
| 15316 | } |
| 15317 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15318 | D(fprintf(stderr, "%*c%s invalid_del_target[%d-%d]: %s failed!\n", p->level, ' ', |
| 15319 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression &del_target_end")); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 15320 | } |
| 15321 | _res = NULL; |
| 15322 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15323 | D(p->level--); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 15324 | return _res; |
| 15325 | } |
| 15326 | |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 15327 | // invalid_import_from_targets: import_from_as_names ',' |
| 15328 | static void * |
| 15329 | invalid_import_from_targets_rule(Parser *p) |
| 15330 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15331 | D(p->level++); |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 15332 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15333 | D(p->level--); |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 15334 | return NULL; |
| 15335 | } |
| 15336 | void * _res = NULL; |
| 15337 | int _mark = p->mark; |
| 15338 | { // import_from_as_names ',' |
| 15339 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15340 | D(p->level--); |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 15341 | return NULL; |
| 15342 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15343 | D(fprintf(stderr, "%*c> invalid_import_from_targets[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_names ','")); |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 15344 | Token * _literal; |
| 15345 | asdl_seq* import_from_as_names_var; |
| 15346 | if ( |
| 15347 | (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names |
| 15348 | && |
| 15349 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 15350 | ) |
| 15351 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15352 | D(fprintf(stderr, "%*c+ invalid_import_from_targets[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_names ','")); |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 15353 | _res = RAISE_SYNTAX_ERROR ( "trailing comma not allowed without surrounding parentheses" ); |
| 15354 | if (_res == NULL && PyErr_Occurred()) { |
| 15355 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15356 | D(p->level--); |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 15357 | return NULL; |
| 15358 | } |
| 15359 | goto done; |
| 15360 | } |
| 15361 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15362 | D(fprintf(stderr, "%*c%s invalid_import_from_targets[%d-%d]: %s failed!\n", p->level, ' ', |
| 15363 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_names ','")); |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 15364 | } |
| 15365 | _res = NULL; |
| 15366 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15367 | D(p->level--); |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame] | 15368 | return _res; |
| 15369 | } |
| 15370 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15371 | // _loop0_1: NEWLINE |
| 15372 | static asdl_seq * |
| 15373 | _loop0_1_rule(Parser *p) |
| 15374 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15375 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15376 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15377 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15378 | return NULL; |
| 15379 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15380 | void *_res = NULL; |
| 15381 | int _mark = p->mark; |
| 15382 | int _start_mark = p->mark; |
| 15383 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15384 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15385 | p->error_indicator = 1; |
| 15386 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15387 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15388 | return NULL; |
| 15389 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15390 | ssize_t _children_capacity = 1; |
| 15391 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15392 | { // NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15393 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15394 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15395 | return NULL; |
| 15396 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15397 | D(fprintf(stderr, "%*c> _loop0_1[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15398 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15399 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15400 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15401 | ) |
| 15402 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15403 | _res = newline_var; |
| 15404 | if (_n == _children_capacity) { |
| 15405 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15406 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15407 | if (!_new_children) { |
| 15408 | p->error_indicator = 1; |
| 15409 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15410 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15411 | return NULL; |
| 15412 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15413 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15414 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15415 | _children[_n++] = _res; |
| 15416 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15417 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15418 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15419 | D(fprintf(stderr, "%*c%s _loop0_1[%d-%d]: %s failed!\n", p->level, ' ', |
| 15420 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15421 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15422 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15423 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15424 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15425 | p->error_indicator = 1; |
| 15426 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15427 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15428 | return NULL; |
| 15429 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15430 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15431 | PyMem_Free(_children); |
| 15432 | _PyPegen_insert_memo(p, _start_mark, _loop0_1_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15433 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15434 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15435 | } |
| 15436 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15437 | // _loop0_2: NEWLINE |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15438 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15439 | _loop0_2_rule(Parser *p) |
| 15440 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15441 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15442 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15443 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15444 | return NULL; |
| 15445 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15446 | void *_res = NULL; |
| 15447 | int _mark = p->mark; |
| 15448 | int _start_mark = p->mark; |
| 15449 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15450 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15451 | p->error_indicator = 1; |
| 15452 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15453 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15454 | return NULL; |
| 15455 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15456 | ssize_t _children_capacity = 1; |
| 15457 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15458 | { // NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15459 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15460 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15461 | return NULL; |
| 15462 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15463 | D(fprintf(stderr, "%*c> _loop0_2[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE")); |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15464 | Token * newline_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15465 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15466 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15467 | ) |
| 15468 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15469 | _res = newline_var; |
| 15470 | if (_n == _children_capacity) { |
| 15471 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15472 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15473 | if (!_new_children) { |
| 15474 | p->error_indicator = 1; |
| 15475 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15476 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15477 | return NULL; |
| 15478 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15479 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15480 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15481 | _children[_n++] = _res; |
| 15482 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15483 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15484 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15485 | D(fprintf(stderr, "%*c%s _loop0_2[%d-%d]: %s failed!\n", p->level, ' ', |
| 15486 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15487 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15488 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15489 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15490 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15491 | p->error_indicator = 1; |
| 15492 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15493 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15494 | return NULL; |
| 15495 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15496 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15497 | PyMem_Free(_children); |
| 15498 | _PyPegen_insert_memo(p, _start_mark, _loop0_2_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15499 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15500 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15501 | } |
| 15502 | |
| 15503 | // _loop0_4: ',' expression |
| 15504 | static asdl_seq * |
| 15505 | _loop0_4_rule(Parser *p) |
| 15506 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15507 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15508 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15509 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15510 | return NULL; |
| 15511 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15512 | void *_res = NULL; |
| 15513 | int _mark = p->mark; |
| 15514 | int _start_mark = p->mark; |
| 15515 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15516 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15517 | p->error_indicator = 1; |
| 15518 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15519 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15520 | return NULL; |
| 15521 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15522 | ssize_t _children_capacity = 1; |
| 15523 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15524 | { // ',' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15525 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15526 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15527 | return NULL; |
| 15528 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15529 | D(fprintf(stderr, "%*c> _loop0_4[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15530 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15531 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15532 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15533 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15534 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15535 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15536 | ) |
| 15537 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15538 | _res = elem; |
| 15539 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15540 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15541 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15542 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15543 | return NULL; |
| 15544 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15545 | if (_n == _children_capacity) { |
| 15546 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15547 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15548 | if (!_new_children) { |
| 15549 | p->error_indicator = 1; |
| 15550 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15551 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15552 | return NULL; |
| 15553 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15554 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15555 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15556 | _children[_n++] = _res; |
| 15557 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15558 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15559 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15560 | D(fprintf(stderr, "%*c%s _loop0_4[%d-%d]: %s failed!\n", p->level, ' ', |
| 15561 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15562 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15563 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15564 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15565 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15566 | p->error_indicator = 1; |
| 15567 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15568 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15569 | return NULL; |
| 15570 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15571 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15572 | PyMem_Free(_children); |
| 15573 | _PyPegen_insert_memo(p, _start_mark, _loop0_4_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15574 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15575 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15576 | } |
| 15577 | |
| 15578 | // _gather_3: expression _loop0_4 |
| 15579 | static asdl_seq * |
| 15580 | _gather_3_rule(Parser *p) |
| 15581 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15582 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15583 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15584 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15585 | return NULL; |
| 15586 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15587 | asdl_seq * _res = NULL; |
| 15588 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15589 | { // expression _loop0_4 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15590 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15591 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15592 | return NULL; |
| 15593 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15594 | D(fprintf(stderr, "%*c> _gather_3[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_4")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15595 | expr_ty elem; |
| 15596 | asdl_seq * seq; |
| 15597 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15598 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15599 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15600 | (seq = _loop0_4_rule(p)) // _loop0_4 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15601 | ) |
| 15602 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15603 | D(fprintf(stderr, "%*c+ _gather_3[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_4")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15604 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15605 | goto done; |
| 15606 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15607 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15608 | D(fprintf(stderr, "%*c%s _gather_3[%d-%d]: %s failed!\n", p->level, ' ', |
| 15609 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_4")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15610 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15611 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15612 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15613 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15614 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15615 | } |
| 15616 | |
| 15617 | // _loop0_6: ',' expression |
| 15618 | static asdl_seq * |
| 15619 | _loop0_6_rule(Parser *p) |
| 15620 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15621 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15622 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15623 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15624 | return NULL; |
| 15625 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15626 | void *_res = NULL; |
| 15627 | int _mark = p->mark; |
| 15628 | int _start_mark = p->mark; |
| 15629 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15630 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15631 | p->error_indicator = 1; |
| 15632 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15633 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15634 | return NULL; |
| 15635 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15636 | ssize_t _children_capacity = 1; |
| 15637 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15638 | { // ',' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15639 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15640 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15641 | return NULL; |
| 15642 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15643 | D(fprintf(stderr, "%*c> _loop0_6[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15644 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15645 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15646 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15647 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15648 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15649 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15650 | ) |
| 15651 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15652 | _res = elem; |
| 15653 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15654 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15655 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15656 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15657 | return NULL; |
| 15658 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15659 | if (_n == _children_capacity) { |
| 15660 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15661 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15662 | if (!_new_children) { |
| 15663 | p->error_indicator = 1; |
| 15664 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15665 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15666 | return NULL; |
| 15667 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15668 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15669 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15670 | _children[_n++] = _res; |
| 15671 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15672 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15673 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15674 | D(fprintf(stderr, "%*c%s _loop0_6[%d-%d]: %s failed!\n", p->level, ' ', |
| 15675 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15676 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15677 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15678 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15679 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15680 | p->error_indicator = 1; |
| 15681 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15682 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15683 | return NULL; |
| 15684 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15685 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15686 | PyMem_Free(_children); |
| 15687 | _PyPegen_insert_memo(p, _start_mark, _loop0_6_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15688 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15689 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15690 | } |
| 15691 | |
| 15692 | // _gather_5: expression _loop0_6 |
| 15693 | static asdl_seq * |
| 15694 | _gather_5_rule(Parser *p) |
| 15695 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15696 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15697 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15698 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15699 | return NULL; |
| 15700 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15701 | asdl_seq * _res = NULL; |
| 15702 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15703 | { // expression _loop0_6 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15704 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15705 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15706 | return NULL; |
| 15707 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15708 | D(fprintf(stderr, "%*c> _gather_5[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_6")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15709 | expr_ty elem; |
| 15710 | asdl_seq * seq; |
| 15711 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15712 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15713 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15714 | (seq = _loop0_6_rule(p)) // _loop0_6 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15715 | ) |
| 15716 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15717 | D(fprintf(stderr, "%*c+ _gather_5[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_6")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15718 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15719 | goto done; |
| 15720 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15721 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15722 | D(fprintf(stderr, "%*c%s _gather_5[%d-%d]: %s failed!\n", p->level, ' ', |
| 15723 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_6")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15724 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15725 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15726 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15727 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15728 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15729 | } |
| 15730 | |
| 15731 | // _loop0_8: ',' expression |
| 15732 | static asdl_seq * |
| 15733 | _loop0_8_rule(Parser *p) |
| 15734 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15735 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15736 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15737 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15738 | return NULL; |
| 15739 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15740 | void *_res = NULL; |
| 15741 | int _mark = p->mark; |
| 15742 | int _start_mark = p->mark; |
| 15743 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15744 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15745 | p->error_indicator = 1; |
| 15746 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15747 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15748 | return NULL; |
| 15749 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15750 | ssize_t _children_capacity = 1; |
| 15751 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15752 | { // ',' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15753 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15754 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15755 | return NULL; |
| 15756 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15757 | D(fprintf(stderr, "%*c> _loop0_8[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15758 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15759 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15760 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15761 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15762 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15763 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15764 | ) |
| 15765 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15766 | _res = elem; |
| 15767 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15768 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15769 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15770 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15771 | return NULL; |
| 15772 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15773 | if (_n == _children_capacity) { |
| 15774 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15775 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15776 | if (!_new_children) { |
| 15777 | p->error_indicator = 1; |
| 15778 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15779 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15780 | return NULL; |
| 15781 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15782 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15783 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15784 | _children[_n++] = _res; |
| 15785 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15786 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15787 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15788 | D(fprintf(stderr, "%*c%s _loop0_8[%d-%d]: %s failed!\n", p->level, ' ', |
| 15789 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15790 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15791 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15792 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15793 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15794 | p->error_indicator = 1; |
| 15795 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15796 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15797 | return NULL; |
| 15798 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15799 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15800 | PyMem_Free(_children); |
| 15801 | _PyPegen_insert_memo(p, _start_mark, _loop0_8_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15802 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15803 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15804 | } |
| 15805 | |
| 15806 | // _gather_7: expression _loop0_8 |
| 15807 | static asdl_seq * |
| 15808 | _gather_7_rule(Parser *p) |
| 15809 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15810 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15811 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15812 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15813 | return NULL; |
| 15814 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15815 | asdl_seq * _res = NULL; |
| 15816 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15817 | { // expression _loop0_8 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15818 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15819 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15820 | return NULL; |
| 15821 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15822 | D(fprintf(stderr, "%*c> _gather_7[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_8")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15823 | expr_ty elem; |
| 15824 | asdl_seq * seq; |
| 15825 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15826 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15827 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15828 | (seq = _loop0_8_rule(p)) // _loop0_8 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15829 | ) |
| 15830 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15831 | D(fprintf(stderr, "%*c+ _gather_7[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_8")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15832 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15833 | goto done; |
| 15834 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15835 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15836 | D(fprintf(stderr, "%*c%s _gather_7[%d-%d]: %s failed!\n", p->level, ' ', |
| 15837 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_8")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15838 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15839 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15840 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15841 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15842 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15843 | } |
| 15844 | |
| 15845 | // _loop0_10: ',' expression |
| 15846 | static asdl_seq * |
| 15847 | _loop0_10_rule(Parser *p) |
| 15848 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15849 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15850 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15851 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15852 | return NULL; |
| 15853 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15854 | void *_res = NULL; |
| 15855 | int _mark = p->mark; |
| 15856 | int _start_mark = p->mark; |
| 15857 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15858 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15859 | p->error_indicator = 1; |
| 15860 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15861 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15862 | return NULL; |
| 15863 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15864 | ssize_t _children_capacity = 1; |
| 15865 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15866 | { // ',' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15867 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15868 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15869 | return NULL; |
| 15870 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15871 | D(fprintf(stderr, "%*c> _loop0_10[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15872 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15873 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15874 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15875 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15876 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15877 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15878 | ) |
| 15879 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15880 | _res = elem; |
| 15881 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15882 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15883 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15884 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15885 | return NULL; |
| 15886 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15887 | if (_n == _children_capacity) { |
| 15888 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15889 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15890 | if (!_new_children) { |
| 15891 | p->error_indicator = 1; |
| 15892 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15893 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15894 | return NULL; |
| 15895 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15896 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15897 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15898 | _children[_n++] = _res; |
| 15899 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15900 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15901 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15902 | D(fprintf(stderr, "%*c%s _loop0_10[%d-%d]: %s failed!\n", p->level, ' ', |
| 15903 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15904 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15905 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15906 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15907 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15908 | p->error_indicator = 1; |
| 15909 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15910 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15911 | return NULL; |
| 15912 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15913 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15914 | PyMem_Free(_children); |
| 15915 | _PyPegen_insert_memo(p, _start_mark, _loop0_10_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15916 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15917 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15918 | } |
| 15919 | |
| 15920 | // _gather_9: expression _loop0_10 |
| 15921 | static asdl_seq * |
| 15922 | _gather_9_rule(Parser *p) |
| 15923 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15924 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15925 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15926 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15927 | return NULL; |
| 15928 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15929 | asdl_seq * _res = NULL; |
| 15930 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15931 | { // expression _loop0_10 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15932 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15933 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15934 | return NULL; |
| 15935 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15936 | D(fprintf(stderr, "%*c> _gather_9[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression _loop0_10")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15937 | expr_ty elem; |
| 15938 | asdl_seq * seq; |
| 15939 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15940 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15941 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15942 | (seq = _loop0_10_rule(p)) // _loop0_10 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15943 | ) |
| 15944 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15945 | D(fprintf(stderr, "%*c+ _gather_9[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression _loop0_10")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15946 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15947 | goto done; |
| 15948 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15949 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15950 | D(fprintf(stderr, "%*c%s _gather_9[%d-%d]: %s failed!\n", p->level, ' ', |
| 15951 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression _loop0_10")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15952 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15953 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15954 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15955 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15956 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15957 | } |
| 15958 | |
| 15959 | // _loop1_11: statement |
| 15960 | static asdl_seq * |
| 15961 | _loop1_11_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15962 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15963 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15964 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15965 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15966 | return NULL; |
| 15967 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15968 | void *_res = NULL; |
| 15969 | int _mark = p->mark; |
| 15970 | int _start_mark = p->mark; |
| 15971 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15972 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15973 | p->error_indicator = 1; |
| 15974 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15975 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15976 | return NULL; |
| 15977 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15978 | ssize_t _children_capacity = 1; |
| 15979 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15980 | { // statement |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15981 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15982 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15983 | return NULL; |
| 15984 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15985 | D(fprintf(stderr, "%*c> _loop1_11[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "statement")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15986 | asdl_seq* statement_var; |
| 15987 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15988 | (statement_var = statement_rule(p)) // statement |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15989 | ) |
| 15990 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15991 | _res = statement_var; |
| 15992 | if (_n == _children_capacity) { |
| 15993 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15994 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15995 | if (!_new_children) { |
| 15996 | p->error_indicator = 1; |
| 15997 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 15998 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15999 | return NULL; |
| 16000 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16001 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16002 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16003 | _children[_n++] = _res; |
| 16004 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16005 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16006 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16007 | D(fprintf(stderr, "%*c%s _loop1_11[%d-%d]: %s failed!\n", p->level, ' ', |
| 16008 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "statement")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16009 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16010 | if (_n == 0 || p->error_indicator) { |
| 16011 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16012 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16013 | return NULL; |
| 16014 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16015 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16016 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16017 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16018 | p->error_indicator = 1; |
| 16019 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16020 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16021 | return NULL; |
| 16022 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16023 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16024 | PyMem_Free(_children); |
| 16025 | _PyPegen_insert_memo(p, _start_mark, _loop1_11_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16026 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16027 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16028 | } |
| 16029 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16030 | // _loop0_13: ';' small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16031 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16032 | _loop0_13_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16033 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16034 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16035 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16036 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16037 | return NULL; |
| 16038 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16039 | void *_res = NULL; |
| 16040 | int _mark = p->mark; |
| 16041 | int _start_mark = p->mark; |
| 16042 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16043 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16044 | p->error_indicator = 1; |
| 16045 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16046 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16047 | return NULL; |
| 16048 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16049 | ssize_t _children_capacity = 1; |
| 16050 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16051 | { // ';' small_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16052 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16053 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16054 | return NULL; |
| 16055 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16056 | D(fprintf(stderr, "%*c> _loop0_13[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';' small_stmt")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16057 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16058 | stmt_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16059 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16060 | (_literal = _PyPegen_expect_token(p, 13)) // token=';' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16061 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16062 | (elem = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16063 | ) |
| 16064 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16065 | _res = elem; |
| 16066 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16067 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16068 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16069 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16070 | return NULL; |
| 16071 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16072 | if (_n == _children_capacity) { |
| 16073 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16074 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16075 | if (!_new_children) { |
| 16076 | p->error_indicator = 1; |
| 16077 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16078 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16079 | return NULL; |
| 16080 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16081 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16082 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16083 | _children[_n++] = _res; |
| 16084 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16085 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16086 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16087 | D(fprintf(stderr, "%*c%s _loop0_13[%d-%d]: %s failed!\n", p->level, ' ', |
| 16088 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';' small_stmt")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16089 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16090 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16091 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16092 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16093 | p->error_indicator = 1; |
| 16094 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16095 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16096 | return NULL; |
| 16097 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16098 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16099 | PyMem_Free(_children); |
| 16100 | _PyPegen_insert_memo(p, _start_mark, _loop0_13_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16101 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16102 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16103 | } |
| 16104 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16105 | // _gather_12: small_stmt _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16106 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16107 | _gather_12_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16108 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16109 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16110 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16111 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16112 | return NULL; |
| 16113 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16114 | asdl_seq * _res = NULL; |
| 16115 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16116 | { // small_stmt _loop0_13 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16117 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16118 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16119 | return NULL; |
| 16120 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16121 | D(fprintf(stderr, "%*c> _gather_12[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16122 | stmt_ty elem; |
| 16123 | asdl_seq * seq; |
| 16124 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16125 | (elem = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16126 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16127 | (seq = _loop0_13_rule(p)) // _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16128 | ) |
| 16129 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16130 | D(fprintf(stderr, "%*c+ _gather_12[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16131 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16132 | goto done; |
| 16133 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16134 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16135 | D(fprintf(stderr, "%*c%s _gather_12[%d-%d]: %s failed!\n", p->level, ' ', |
| 16136 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "small_stmt _loop0_13")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16137 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16138 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16139 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16140 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16141 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16142 | } |
| 16143 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16144 | // _tmp_14: 'import' | 'from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16145 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16146 | _tmp_14_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16147 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16148 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16149 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16150 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16151 | return NULL; |
| 16152 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16153 | void * _res = NULL; |
| 16154 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16155 | { // 'import' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16156 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16157 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16158 | return NULL; |
| 16159 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16160 | D(fprintf(stderr, "%*c> _tmp_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'import'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16161 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16162 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16163 | (_keyword = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16164 | ) |
| 16165 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16166 | D(fprintf(stderr, "%*c+ _tmp_14[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'import'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16167 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16168 | goto done; |
| 16169 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16170 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16171 | D(fprintf(stderr, "%*c%s _tmp_14[%d-%d]: %s failed!\n", p->level, ' ', |
| 16172 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'import'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16173 | } |
| 16174 | { // 'from' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16175 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16176 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16177 | return NULL; |
| 16178 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16179 | D(fprintf(stderr, "%*c> _tmp_14[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16180 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16181 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16182 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16183 | ) |
| 16184 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16185 | D(fprintf(stderr, "%*c+ _tmp_14[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16186 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16187 | goto done; |
| 16188 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16189 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16190 | D(fprintf(stderr, "%*c%s _tmp_14[%d-%d]: %s failed!\n", p->level, ' ', |
| 16191 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16192 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16193 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16194 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16195 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16196 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16197 | } |
| 16198 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16199 | // _tmp_15: 'def' | '@' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16200 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16201 | _tmp_15_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16202 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16203 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16204 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16205 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16206 | return NULL; |
| 16207 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16208 | void * _res = NULL; |
| 16209 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16210 | { // 'def' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16211 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16212 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16213 | return NULL; |
| 16214 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16215 | D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'def'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16216 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16217 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16218 | (_keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16219 | ) |
| 16220 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16221 | D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'def'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16222 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16223 | goto done; |
| 16224 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16225 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16226 | D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', |
| 16227 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'def'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16228 | } |
| 16229 | { // '@' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16230 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16231 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16232 | return NULL; |
| 16233 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16234 | D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16235 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16236 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16237 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16238 | ) |
| 16239 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16240 | D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16241 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16242 | goto done; |
| 16243 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16244 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16245 | D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', |
| 16246 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16247 | } |
| 16248 | { // ASYNC |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16249 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16250 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16251 | return NULL; |
| 16252 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16253 | D(fprintf(stderr, "%*c> _tmp_15[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC")); |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16254 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16255 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16256 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16257 | ) |
| 16258 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16259 | D(fprintf(stderr, "%*c+ _tmp_15[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16260 | _res = async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16261 | goto done; |
| 16262 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16263 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16264 | D(fprintf(stderr, "%*c%s _tmp_15[%d-%d]: %s failed!\n", p->level, ' ', |
| 16265 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16266 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16267 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16268 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16269 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16270 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16271 | } |
| 16272 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16273 | // _tmp_16: 'class' | '@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16274 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16275 | _tmp_16_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16276 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16277 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16278 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16279 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16280 | return NULL; |
| 16281 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16282 | void * _res = NULL; |
| 16283 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16284 | { // 'class' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16285 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16286 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16287 | return NULL; |
| 16288 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16289 | D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'class'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16290 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16291 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16292 | (_keyword = _PyPegen_expect_token(p, 523)) // token='class' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16293 | ) |
| 16294 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16295 | D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'class'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16296 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16297 | goto done; |
| 16298 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16299 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16300 | D(fprintf(stderr, "%*c%s _tmp_16[%d-%d]: %s failed!\n", p->level, ' ', |
| 16301 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'class'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16302 | } |
| 16303 | { // '@' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16304 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16305 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16306 | return NULL; |
| 16307 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16308 | D(fprintf(stderr, "%*c> _tmp_16[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16309 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16310 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16311 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16312 | ) |
| 16313 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16314 | D(fprintf(stderr, "%*c+ _tmp_16[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16315 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16316 | goto done; |
| 16317 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16318 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16319 | D(fprintf(stderr, "%*c%s _tmp_16[%d-%d]: %s failed!\n", p->level, ' ', |
| 16320 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16321 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16322 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16323 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16324 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16325 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16326 | } |
| 16327 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16328 | // _tmp_17: 'with' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16329 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16330 | _tmp_17_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16331 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16332 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16333 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16334 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16335 | return NULL; |
| 16336 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16337 | void * _res = NULL; |
| 16338 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16339 | { // 'with' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16340 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16341 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16342 | return NULL; |
| 16343 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16344 | D(fprintf(stderr, "%*c> _tmp_17[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'with'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16345 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16346 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16347 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16348 | ) |
| 16349 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16350 | D(fprintf(stderr, "%*c+ _tmp_17[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'with'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16351 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16352 | goto done; |
| 16353 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16354 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16355 | D(fprintf(stderr, "%*c%s _tmp_17[%d-%d]: %s failed!\n", p->level, ' ', |
| 16356 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'with'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16357 | } |
| 16358 | { // ASYNC |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16359 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16360 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16361 | return NULL; |
| 16362 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16363 | D(fprintf(stderr, "%*c> _tmp_17[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC")); |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16364 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16365 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16366 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16367 | ) |
| 16368 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16369 | D(fprintf(stderr, "%*c+ _tmp_17[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16370 | _res = async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16371 | goto done; |
| 16372 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16373 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16374 | D(fprintf(stderr, "%*c%s _tmp_17[%d-%d]: %s failed!\n", p->level, ' ', |
| 16375 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16376 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16377 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16378 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16379 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16380 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16381 | } |
| 16382 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16383 | // _tmp_18: 'for' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16384 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16385 | _tmp_18_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16386 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16387 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16388 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16389 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16390 | return NULL; |
| 16391 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16392 | void * _res = NULL; |
| 16393 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16394 | { // 'for' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16395 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16396 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16397 | return NULL; |
| 16398 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16399 | D(fprintf(stderr, "%*c> _tmp_18[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'for'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16400 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16401 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16402 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16403 | ) |
| 16404 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16405 | D(fprintf(stderr, "%*c+ _tmp_18[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'for'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16406 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16407 | goto done; |
| 16408 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16409 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16410 | D(fprintf(stderr, "%*c%s _tmp_18[%d-%d]: %s failed!\n", p->level, ' ', |
| 16411 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'for'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16412 | } |
| 16413 | { // ASYNC |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16414 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16415 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16416 | return NULL; |
| 16417 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16418 | D(fprintf(stderr, "%*c> _tmp_18[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "ASYNC")); |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16419 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16420 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16421 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16422 | ) |
| 16423 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16424 | D(fprintf(stderr, "%*c+ _tmp_18[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "ASYNC")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16425 | _res = async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16426 | goto done; |
| 16427 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16428 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16429 | D(fprintf(stderr, "%*c%s _tmp_18[%d-%d]: %s failed!\n", p->level, ' ', |
| 16430 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "ASYNC")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16431 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16432 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16433 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16434 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16435 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16436 | } |
| 16437 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16438 | // _tmp_19: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16439 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16440 | _tmp_19_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16441 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16442 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16443 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16444 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16445 | return NULL; |
| 16446 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16447 | void * _res = NULL; |
| 16448 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16449 | { // '=' annotated_rhs |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16450 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16451 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16452 | return NULL; |
| 16453 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16454 | D(fprintf(stderr, "%*c> _tmp_19[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16455 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16456 | expr_ty d; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16457 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16458 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16459 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16460 | (d = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16461 | ) |
| 16462 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16463 | D(fprintf(stderr, "%*c+ _tmp_19[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16464 | _res = d; |
| 16465 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16466 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16467 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16468 | return NULL; |
| 16469 | } |
| 16470 | goto done; |
| 16471 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16472 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16473 | D(fprintf(stderr, "%*c%s _tmp_19[%d-%d]: %s failed!\n", p->level, ' ', |
| 16474 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16475 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16476 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16477 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16478 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16479 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16480 | } |
| 16481 | |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 16482 | // _tmp_20: '(' single_target ')' | single_subscript_attribute_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16483 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16484 | _tmp_20_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16485 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16486 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16487 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16488 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16489 | return NULL; |
| 16490 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16491 | void * _res = NULL; |
| 16492 | int _mark = p->mark; |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 16493 | { // '(' single_target ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16494 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16495 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16496 | return NULL; |
| 16497 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16498 | D(fprintf(stderr, "%*c> _tmp_20[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16499 | Token * _literal; |
| 16500 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16501 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16502 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16503 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16504 | && |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 16505 | (b = single_target_rule(p)) // single_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16506 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16507 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16508 | ) |
| 16509 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16510 | D(fprintf(stderr, "%*c+ _tmp_20[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' single_target ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16511 | _res = b; |
| 16512 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16513 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16514 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16515 | return NULL; |
| 16516 | } |
| 16517 | goto done; |
| 16518 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16519 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16520 | D(fprintf(stderr, "%*c%s _tmp_20[%d-%d]: %s failed!\n", p->level, ' ', |
| 16521 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' single_target ')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16522 | } |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 16523 | { // single_subscript_attribute_target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16524 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16525 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16526 | return NULL; |
| 16527 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16528 | D(fprintf(stderr, "%*c> _tmp_20[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 16529 | expr_ty single_subscript_attribute_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16530 | if ( |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 16531 | (single_subscript_attribute_target_var = single_subscript_attribute_target_rule(p)) // single_subscript_attribute_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16532 | ) |
| 16533 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16534 | D(fprintf(stderr, "%*c+ _tmp_20[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "single_subscript_attribute_target")); |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 16535 | _res = single_subscript_attribute_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16536 | goto done; |
| 16537 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16538 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16539 | D(fprintf(stderr, "%*c%s _tmp_20[%d-%d]: %s failed!\n", p->level, ' ', |
| 16540 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "single_subscript_attribute_target")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16541 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16542 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16543 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16544 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16545 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16546 | } |
| 16547 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16548 | // _tmp_21: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16549 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16550 | _tmp_21_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16551 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16552 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16553 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16554 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16555 | return NULL; |
| 16556 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16557 | void * _res = NULL; |
| 16558 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16559 | { // '=' annotated_rhs |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16560 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16561 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16562 | return NULL; |
| 16563 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16564 | D(fprintf(stderr, "%*c> _tmp_21[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16565 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16566 | expr_ty d; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16567 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16568 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16569 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16570 | (d = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16571 | ) |
| 16572 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16573 | D(fprintf(stderr, "%*c+ _tmp_21[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16574 | _res = d; |
| 16575 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16576 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16577 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16578 | return NULL; |
| 16579 | } |
| 16580 | goto done; |
| 16581 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16582 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16583 | D(fprintf(stderr, "%*c%s _tmp_21[%d-%d]: %s failed!\n", p->level, ' ', |
| 16584 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16585 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16586 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16587 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16588 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16589 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16590 | } |
| 16591 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16592 | // _loop1_22: (star_targets '=') |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16593 | static asdl_seq * |
| 16594 | _loop1_22_rule(Parser *p) |
| 16595 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16596 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16597 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16598 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16599 | return NULL; |
| 16600 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16601 | void *_res = NULL; |
| 16602 | int _mark = p->mark; |
| 16603 | int _start_mark = p->mark; |
| 16604 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16605 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16606 | p->error_indicator = 1; |
| 16607 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16608 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16609 | return NULL; |
| 16610 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16611 | ssize_t _children_capacity = 1; |
| 16612 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16613 | { // (star_targets '=') |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16614 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16615 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16616 | return NULL; |
| 16617 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16618 | D(fprintf(stderr, "%*c> _loop1_22[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 16619 | void *_tmp_138_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16620 | while ( |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 16621 | (_tmp_138_var = _tmp_138_rule(p)) // star_targets '=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16622 | ) |
| 16623 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 16624 | _res = _tmp_138_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16625 | if (_n == _children_capacity) { |
| 16626 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16627 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16628 | if (!_new_children) { |
| 16629 | p->error_indicator = 1; |
| 16630 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16631 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16632 | return NULL; |
| 16633 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16634 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16635 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16636 | _children[_n++] = _res; |
| 16637 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16638 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16639 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16640 | D(fprintf(stderr, "%*c%s _loop1_22[%d-%d]: %s failed!\n", p->level, ' ', |
| 16641 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16642 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16643 | if (_n == 0 || p->error_indicator) { |
| 16644 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16645 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16646 | return NULL; |
| 16647 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16648 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16649 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16650 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16651 | p->error_indicator = 1; |
| 16652 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16653 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16654 | return NULL; |
| 16655 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16656 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16657 | PyMem_Free(_children); |
| 16658 | _PyPegen_insert_memo(p, _start_mark, _loop1_22_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16659 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16660 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16661 | } |
| 16662 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16663 | // _tmp_23: yield_expr | star_expressions |
| 16664 | static void * |
| 16665 | _tmp_23_rule(Parser *p) |
| 16666 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16667 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16668 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16669 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16670 | return NULL; |
| 16671 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16672 | void * _res = NULL; |
| 16673 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16674 | { // yield_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16675 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16676 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16677 | return NULL; |
| 16678 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16679 | D(fprintf(stderr, "%*c> _tmp_23[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16680 | expr_ty yield_expr_var; |
| 16681 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16682 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16683 | ) |
| 16684 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16685 | D(fprintf(stderr, "%*c+ _tmp_23[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16686 | _res = yield_expr_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16687 | goto done; |
| 16688 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16689 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16690 | D(fprintf(stderr, "%*c%s _tmp_23[%d-%d]: %s failed!\n", p->level, ' ', |
| 16691 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16692 | } |
| 16693 | { // star_expressions |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16694 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16695 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16696 | return NULL; |
| 16697 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16698 | D(fprintf(stderr, "%*c> _tmp_23[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16699 | expr_ty star_expressions_var; |
| 16700 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16701 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16702 | ) |
| 16703 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16704 | D(fprintf(stderr, "%*c+ _tmp_23[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16705 | _res = star_expressions_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16706 | goto done; |
| 16707 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16708 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16709 | D(fprintf(stderr, "%*c%s _tmp_23[%d-%d]: %s failed!\n", p->level, ' ', |
| 16710 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16711 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16712 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16713 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16714 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16715 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16716 | } |
| 16717 | |
| 16718 | // _tmp_24: yield_expr | star_expressions |
| 16719 | static void * |
| 16720 | _tmp_24_rule(Parser *p) |
| 16721 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16722 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16723 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16724 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16725 | return NULL; |
| 16726 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16727 | void * _res = NULL; |
| 16728 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16729 | { // yield_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16730 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16731 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16732 | return NULL; |
| 16733 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16734 | D(fprintf(stderr, "%*c> _tmp_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16735 | expr_ty yield_expr_var; |
| 16736 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16737 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16738 | ) |
| 16739 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16740 | D(fprintf(stderr, "%*c+ _tmp_24[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16741 | _res = yield_expr_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16742 | goto done; |
| 16743 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16744 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16745 | D(fprintf(stderr, "%*c%s _tmp_24[%d-%d]: %s failed!\n", p->level, ' ', |
| 16746 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16747 | } |
| 16748 | { // star_expressions |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16749 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16750 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16751 | return NULL; |
| 16752 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16753 | D(fprintf(stderr, "%*c> _tmp_24[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16754 | expr_ty star_expressions_var; |
| 16755 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16756 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16757 | ) |
| 16758 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16759 | D(fprintf(stderr, "%*c+ _tmp_24[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16760 | _res = star_expressions_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16761 | goto done; |
| 16762 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16763 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16764 | D(fprintf(stderr, "%*c%s _tmp_24[%d-%d]: %s failed!\n", p->level, ' ', |
| 16765 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16766 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16767 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16768 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16769 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16770 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16771 | } |
| 16772 | |
| 16773 | // _loop0_26: ',' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16774 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16775 | _loop0_26_rule(Parser *p) |
| 16776 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16777 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16778 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16779 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16780 | return NULL; |
| 16781 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16782 | void *_res = NULL; |
| 16783 | int _mark = p->mark; |
| 16784 | int _start_mark = p->mark; |
| 16785 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16786 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16787 | p->error_indicator = 1; |
| 16788 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16789 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16790 | return NULL; |
| 16791 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16792 | ssize_t _children_capacity = 1; |
| 16793 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16794 | { // ',' NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16795 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16796 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16797 | return NULL; |
| 16798 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16799 | D(fprintf(stderr, "%*c> _loop0_26[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16800 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16801 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16802 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16803 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16804 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16805 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16806 | ) |
| 16807 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16808 | _res = elem; |
| 16809 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16810 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16811 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16812 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16813 | return NULL; |
| 16814 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16815 | if (_n == _children_capacity) { |
| 16816 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16817 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16818 | if (!_new_children) { |
| 16819 | p->error_indicator = 1; |
| 16820 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16821 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16822 | return NULL; |
| 16823 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16824 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16825 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16826 | _children[_n++] = _res; |
| 16827 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16828 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16829 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16830 | D(fprintf(stderr, "%*c%s _loop0_26[%d-%d]: %s failed!\n", p->level, ' ', |
| 16831 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16832 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16833 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16834 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16835 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16836 | p->error_indicator = 1; |
| 16837 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16838 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16839 | return NULL; |
| 16840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16841 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16842 | PyMem_Free(_children); |
| 16843 | _PyPegen_insert_memo(p, _start_mark, _loop0_26_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16844 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16845 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16846 | } |
| 16847 | |
| 16848 | // _gather_25: NAME _loop0_26 |
| 16849 | static asdl_seq * |
| 16850 | _gather_25_rule(Parser *p) |
| 16851 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16852 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16853 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16854 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16855 | return NULL; |
| 16856 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16857 | asdl_seq * _res = NULL; |
| 16858 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16859 | { // NAME _loop0_26 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16860 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16861 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16862 | return NULL; |
| 16863 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16864 | D(fprintf(stderr, "%*c> _gather_25[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16865 | expr_ty elem; |
| 16866 | asdl_seq * seq; |
| 16867 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16868 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16869 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16870 | (seq = _loop0_26_rule(p)) // _loop0_26 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16871 | ) |
| 16872 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16873 | D(fprintf(stderr, "%*c+ _gather_25[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_26")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16874 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16875 | goto done; |
| 16876 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16877 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16878 | D(fprintf(stderr, "%*c%s _gather_25[%d-%d]: %s failed!\n", p->level, ' ', |
| 16879 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_26")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16880 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16881 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16882 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16883 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16884 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16885 | } |
| 16886 | |
| 16887 | // _loop0_28: ',' NAME |
| 16888 | static asdl_seq * |
| 16889 | _loop0_28_rule(Parser *p) |
| 16890 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16891 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16892 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16893 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16894 | return NULL; |
| 16895 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16896 | void *_res = NULL; |
| 16897 | int _mark = p->mark; |
| 16898 | int _start_mark = p->mark; |
| 16899 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16900 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16901 | p->error_indicator = 1; |
| 16902 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16903 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16904 | return NULL; |
| 16905 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16906 | ssize_t _children_capacity = 1; |
| 16907 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16908 | { // ',' NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16909 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16910 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16911 | return NULL; |
| 16912 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16913 | D(fprintf(stderr, "%*c> _loop0_28[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16914 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16915 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16916 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16917 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16918 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16919 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16920 | ) |
| 16921 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16922 | _res = elem; |
| 16923 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16924 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16925 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16926 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16927 | return NULL; |
| 16928 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16929 | if (_n == _children_capacity) { |
| 16930 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16931 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16932 | if (!_new_children) { |
| 16933 | p->error_indicator = 1; |
| 16934 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16935 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16936 | return NULL; |
| 16937 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16938 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16939 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16940 | _children[_n++] = _res; |
| 16941 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16942 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16943 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16944 | D(fprintf(stderr, "%*c%s _loop0_28[%d-%d]: %s failed!\n", p->level, ' ', |
| 16945 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' NAME")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16946 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16947 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16948 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16949 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16950 | p->error_indicator = 1; |
| 16951 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16952 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16953 | return NULL; |
| 16954 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16955 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16956 | PyMem_Free(_children); |
| 16957 | _PyPegen_insert_memo(p, _start_mark, _loop0_28_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16958 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16959 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16960 | } |
| 16961 | |
| 16962 | // _gather_27: NAME _loop0_28 |
| 16963 | static asdl_seq * |
| 16964 | _gather_27_rule(Parser *p) |
| 16965 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16966 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16967 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16968 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16969 | return NULL; |
| 16970 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16971 | asdl_seq * _res = NULL; |
| 16972 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16973 | { // NAME _loop0_28 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16974 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16975 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16976 | return NULL; |
| 16977 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16978 | D(fprintf(stderr, "%*c> _gather_27[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16979 | expr_ty elem; |
| 16980 | asdl_seq * seq; |
| 16981 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16982 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16983 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16984 | (seq = _loop0_28_rule(p)) // _loop0_28 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16985 | ) |
| 16986 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16987 | D(fprintf(stderr, "%*c+ _gather_27[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NAME _loop0_28")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16988 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16989 | goto done; |
| 16990 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16991 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16992 | D(fprintf(stderr, "%*c%s _gather_27[%d-%d]: %s failed!\n", p->level, ' ', |
| 16993 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NAME _loop0_28")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16994 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16995 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16996 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 16997 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16998 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16999 | } |
| 17000 | |
| 17001 | // _tmp_29: ',' expression |
| 17002 | static void * |
| 17003 | _tmp_29_rule(Parser *p) |
| 17004 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17005 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17006 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17007 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17008 | return NULL; |
| 17009 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17010 | void * _res = NULL; |
| 17011 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17012 | { // ',' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17013 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17014 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17015 | return NULL; |
| 17016 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17017 | D(fprintf(stderr, "%*c> _tmp_29[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17018 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17019 | expr_ty z; |
| 17020 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17021 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17022 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17023 | (z = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17024 | ) |
| 17025 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17026 | D(fprintf(stderr, "%*c+ _tmp_29[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17027 | _res = z; |
| 17028 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17029 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17030 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17031 | return NULL; |
| 17032 | } |
| 17033 | goto done; |
| 17034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17035 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17036 | D(fprintf(stderr, "%*c%s _tmp_29[%d-%d]: %s failed!\n", p->level, ' ', |
| 17037 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17038 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17039 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17040 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17041 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17042 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17043 | } |
| 17044 | |
| 17045 | // _loop0_30: ('.' | '...') |
| 17046 | static asdl_seq * |
| 17047 | _loop0_30_rule(Parser *p) |
| 17048 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17049 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17050 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17051 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17052 | return NULL; |
| 17053 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17054 | void *_res = NULL; |
| 17055 | int _mark = p->mark; |
| 17056 | int _start_mark = p->mark; |
| 17057 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17058 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17059 | p->error_indicator = 1; |
| 17060 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17061 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17062 | return NULL; |
| 17063 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17064 | ssize_t _children_capacity = 1; |
| 17065 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17066 | { // ('.' | '...') |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17067 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17068 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17069 | return NULL; |
| 17070 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17071 | D(fprintf(stderr, "%*c> _loop0_30[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 17072 | void *_tmp_139_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17073 | while ( |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 17074 | (_tmp_139_var = _tmp_139_rule(p)) // '.' | '...' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17075 | ) |
| 17076 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 17077 | _res = _tmp_139_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17078 | if (_n == _children_capacity) { |
| 17079 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17080 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17081 | if (!_new_children) { |
| 17082 | p->error_indicator = 1; |
| 17083 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17084 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17085 | return NULL; |
| 17086 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17087 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17088 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17089 | _children[_n++] = _res; |
| 17090 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17091 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17092 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17093 | D(fprintf(stderr, "%*c%s _loop0_30[%d-%d]: %s failed!\n", p->level, ' ', |
| 17094 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17095 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17096 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17097 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17098 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17099 | p->error_indicator = 1; |
| 17100 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17101 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17102 | return NULL; |
| 17103 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17104 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17105 | PyMem_Free(_children); |
| 17106 | _PyPegen_insert_memo(p, _start_mark, _loop0_30_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17107 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17108 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17109 | } |
| 17110 | |
| 17111 | // _loop1_31: ('.' | '...') |
| 17112 | static asdl_seq * |
| 17113 | _loop1_31_rule(Parser *p) |
| 17114 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17115 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17116 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17117 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17118 | return NULL; |
| 17119 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17120 | void *_res = NULL; |
| 17121 | int _mark = p->mark; |
| 17122 | int _start_mark = p->mark; |
| 17123 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17124 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17125 | p->error_indicator = 1; |
| 17126 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17127 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17128 | return NULL; |
| 17129 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17130 | ssize_t _children_capacity = 1; |
| 17131 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17132 | { // ('.' | '...') |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17133 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17134 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17135 | return NULL; |
| 17136 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17137 | D(fprintf(stderr, "%*c> _loop1_31[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('.' | '...')")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 17138 | void *_tmp_140_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17139 | while ( |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 17140 | (_tmp_140_var = _tmp_140_rule(p)) // '.' | '...' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17141 | ) |
| 17142 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 17143 | _res = _tmp_140_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17144 | if (_n == _children_capacity) { |
| 17145 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17146 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17147 | if (!_new_children) { |
| 17148 | p->error_indicator = 1; |
| 17149 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17150 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17151 | return NULL; |
| 17152 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17153 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17154 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17155 | _children[_n++] = _res; |
| 17156 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17157 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17158 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17159 | D(fprintf(stderr, "%*c%s _loop1_31[%d-%d]: %s failed!\n", p->level, ' ', |
| 17160 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('.' | '...')")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17161 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17162 | if (_n == 0 || p->error_indicator) { |
| 17163 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17164 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17165 | return NULL; |
| 17166 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17167 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17168 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17169 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17170 | p->error_indicator = 1; |
| 17171 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17172 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17173 | return NULL; |
| 17174 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17175 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17176 | PyMem_Free(_children); |
| 17177 | _PyPegen_insert_memo(p, _start_mark, _loop1_31_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17178 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17179 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17180 | } |
| 17181 | |
| 17182 | // _loop0_33: ',' import_from_as_name |
| 17183 | static asdl_seq * |
| 17184 | _loop0_33_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17185 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17186 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17187 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17188 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17189 | return NULL; |
| 17190 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17191 | void *_res = NULL; |
| 17192 | int _mark = p->mark; |
| 17193 | int _start_mark = p->mark; |
| 17194 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17195 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17196 | p->error_indicator = 1; |
| 17197 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17198 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17199 | return NULL; |
| 17200 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17201 | ssize_t _children_capacity = 1; |
| 17202 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17203 | { // ',' import_from_as_name |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17204 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17205 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17206 | return NULL; |
| 17207 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17208 | D(fprintf(stderr, "%*c> _loop0_33[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' import_from_as_name")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17209 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17210 | alias_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17211 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17212 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17213 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17214 | (elem = import_from_as_name_rule(p)) // import_from_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17215 | ) |
| 17216 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17217 | _res = elem; |
| 17218 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17219 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17220 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17221 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17222 | return NULL; |
| 17223 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17224 | if (_n == _children_capacity) { |
| 17225 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17226 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17227 | if (!_new_children) { |
| 17228 | p->error_indicator = 1; |
| 17229 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17230 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17231 | return NULL; |
| 17232 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17233 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17234 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17235 | _children[_n++] = _res; |
| 17236 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17237 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17238 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17239 | D(fprintf(stderr, "%*c%s _loop0_33[%d-%d]: %s failed!\n", p->level, ' ', |
| 17240 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' import_from_as_name")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17241 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17242 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17243 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17244 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17245 | p->error_indicator = 1; |
| 17246 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17247 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17248 | return NULL; |
| 17249 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17250 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17251 | PyMem_Free(_children); |
| 17252 | _PyPegen_insert_memo(p, _start_mark, _loop0_33_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17253 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17254 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17255 | } |
| 17256 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17257 | // _gather_32: import_from_as_name _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17258 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17259 | _gather_32_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17260 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17261 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17262 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17263 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17264 | return NULL; |
| 17265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17266 | asdl_seq * _res = NULL; |
| 17267 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17268 | { // import_from_as_name _loop0_33 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17269 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17270 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17271 | return NULL; |
| 17272 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17273 | D(fprintf(stderr, "%*c> _gather_32[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_33")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17274 | alias_ty elem; |
| 17275 | asdl_seq * seq; |
| 17276 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17277 | (elem = import_from_as_name_rule(p)) // import_from_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17278 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17279 | (seq = _loop0_33_rule(p)) // _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17280 | ) |
| 17281 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17282 | D(fprintf(stderr, "%*c+ _gather_32[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "import_from_as_name _loop0_33")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17283 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17284 | goto done; |
| 17285 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17286 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17287 | D(fprintf(stderr, "%*c%s _gather_32[%d-%d]: %s failed!\n", p->level, ' ', |
| 17288 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "import_from_as_name _loop0_33")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17289 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17290 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17291 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17292 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17293 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17294 | } |
| 17295 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17296 | // _tmp_34: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17297 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17298 | _tmp_34_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17299 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17300 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17301 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17302 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17303 | return NULL; |
| 17304 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17305 | void * _res = NULL; |
| 17306 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17307 | { // 'as' NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17308 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17309 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17310 | return NULL; |
| 17311 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17312 | D(fprintf(stderr, "%*c> _tmp_34[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17313 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17314 | expr_ty z; |
| 17315 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17316 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17317 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17318 | (z = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17319 | ) |
| 17320 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17321 | D(fprintf(stderr, "%*c+ _tmp_34[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17322 | _res = z; |
| 17323 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17324 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17325 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17326 | return NULL; |
| 17327 | } |
| 17328 | goto done; |
| 17329 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17330 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17331 | D(fprintf(stderr, "%*c%s _tmp_34[%d-%d]: %s failed!\n", p->level, ' ', |
| 17332 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17333 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17334 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17335 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17336 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17337 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17338 | } |
| 17339 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17340 | // _loop0_36: ',' dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17341 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17342 | _loop0_36_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17343 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17344 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17345 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17346 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17347 | return NULL; |
| 17348 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17349 | void *_res = NULL; |
| 17350 | int _mark = p->mark; |
| 17351 | int _start_mark = p->mark; |
| 17352 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17353 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17354 | p->error_indicator = 1; |
| 17355 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17356 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17357 | return NULL; |
| 17358 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17359 | ssize_t _children_capacity = 1; |
| 17360 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17361 | { // ',' dotted_as_name |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17362 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17363 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17364 | return NULL; |
| 17365 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17366 | D(fprintf(stderr, "%*c> _loop0_36[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' dotted_as_name")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17367 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17368 | alias_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17369 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17370 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17371 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17372 | (elem = dotted_as_name_rule(p)) // dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17373 | ) |
| 17374 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17375 | _res = elem; |
| 17376 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17377 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17378 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17379 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17380 | return NULL; |
| 17381 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17382 | if (_n == _children_capacity) { |
| 17383 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17384 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17385 | if (!_new_children) { |
| 17386 | p->error_indicator = 1; |
| 17387 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17388 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17389 | return NULL; |
| 17390 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17391 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17392 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17393 | _children[_n++] = _res; |
| 17394 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17395 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17396 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17397 | D(fprintf(stderr, "%*c%s _loop0_36[%d-%d]: %s failed!\n", p->level, ' ', |
| 17398 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' dotted_as_name")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17399 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17400 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17401 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17402 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17403 | p->error_indicator = 1; |
| 17404 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17405 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17406 | return NULL; |
| 17407 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17408 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17409 | PyMem_Free(_children); |
| 17410 | _PyPegen_insert_memo(p, _start_mark, _loop0_36_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17411 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17412 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17413 | } |
| 17414 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17415 | // _gather_35: dotted_as_name _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17416 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17417 | _gather_35_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17418 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17419 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17420 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17421 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17422 | return NULL; |
| 17423 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17424 | asdl_seq * _res = NULL; |
| 17425 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17426 | { // dotted_as_name _loop0_36 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17427 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17428 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17429 | return NULL; |
| 17430 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17431 | D(fprintf(stderr, "%*c> _gather_35[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_36")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17432 | alias_ty elem; |
| 17433 | asdl_seq * seq; |
| 17434 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17435 | (elem = dotted_as_name_rule(p)) // dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17436 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17437 | (seq = _loop0_36_rule(p)) // _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17438 | ) |
| 17439 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17440 | D(fprintf(stderr, "%*c+ _gather_35[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dotted_as_name _loop0_36")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17441 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17442 | goto done; |
| 17443 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17444 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17445 | D(fprintf(stderr, "%*c%s _gather_35[%d-%d]: %s failed!\n", p->level, ' ', |
| 17446 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dotted_as_name _loop0_36")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17447 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17448 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17449 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17450 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17451 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17452 | } |
| 17453 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17454 | // _tmp_37: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17455 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17456 | _tmp_37_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17457 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17458 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17459 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17460 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17461 | return NULL; |
| 17462 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17463 | void * _res = NULL; |
| 17464 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17465 | { // 'as' NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17466 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17467 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17468 | return NULL; |
| 17469 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17470 | D(fprintf(stderr, "%*c> _tmp_37[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17471 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17472 | expr_ty z; |
| 17473 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17474 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17475 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17476 | (z = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17477 | ) |
| 17478 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17479 | D(fprintf(stderr, "%*c+ _tmp_37[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17480 | _res = z; |
| 17481 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17482 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17483 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17484 | return NULL; |
| 17485 | } |
| 17486 | goto done; |
| 17487 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17488 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17489 | D(fprintf(stderr, "%*c%s _tmp_37[%d-%d]: %s failed!\n", p->level, ' ', |
| 17490 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17491 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17492 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17493 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17494 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17495 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17496 | } |
| 17497 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17498 | // _loop0_39: ',' with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17499 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17500 | _loop0_39_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17501 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17502 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17503 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17504 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17505 | return NULL; |
| 17506 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17507 | void *_res = NULL; |
| 17508 | int _mark = p->mark; |
| 17509 | int _start_mark = p->mark; |
| 17510 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17511 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17512 | p->error_indicator = 1; |
| 17513 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17514 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17515 | return NULL; |
| 17516 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17517 | ssize_t _children_capacity = 1; |
| 17518 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17519 | { // ',' with_item |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17520 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17521 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17522 | return NULL; |
| 17523 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17524 | D(fprintf(stderr, "%*c> _loop0_39[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17525 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17526 | withitem_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17527 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17528 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17529 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17530 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17531 | ) |
| 17532 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17533 | _res = elem; |
| 17534 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17535 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17536 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17537 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17538 | return NULL; |
| 17539 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17540 | if (_n == _children_capacity) { |
| 17541 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17542 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17543 | if (!_new_children) { |
| 17544 | p->error_indicator = 1; |
| 17545 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17546 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17547 | return NULL; |
| 17548 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17549 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17550 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17551 | _children[_n++] = _res; |
| 17552 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17553 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17554 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17555 | D(fprintf(stderr, "%*c%s _loop0_39[%d-%d]: %s failed!\n", p->level, ' ', |
| 17556 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17557 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17558 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17559 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17560 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17561 | p->error_indicator = 1; |
| 17562 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17563 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17564 | return NULL; |
| 17565 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17566 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17567 | PyMem_Free(_children); |
| 17568 | _PyPegen_insert_memo(p, _start_mark, _loop0_39_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17569 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17570 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17571 | } |
| 17572 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17573 | // _gather_38: with_item _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17574 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17575 | _gather_38_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17576 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17577 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17578 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17579 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17580 | return NULL; |
| 17581 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17582 | asdl_seq * _res = NULL; |
| 17583 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17584 | { // with_item _loop0_39 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17585 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17586 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17587 | return NULL; |
| 17588 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17589 | D(fprintf(stderr, "%*c> _gather_38[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_39")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17590 | withitem_ty elem; |
| 17591 | asdl_seq * seq; |
| 17592 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17593 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17594 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17595 | (seq = _loop0_39_rule(p)) // _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17596 | ) |
| 17597 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17598 | D(fprintf(stderr, "%*c+ _gather_38[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_39")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17599 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17600 | goto done; |
| 17601 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17602 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17603 | D(fprintf(stderr, "%*c%s _gather_38[%d-%d]: %s failed!\n", p->level, ' ', |
| 17604 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_39")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17605 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17606 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17607 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17608 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17609 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17610 | } |
| 17611 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17612 | // _loop0_41: ',' with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17613 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17614 | _loop0_41_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17615 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17616 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17617 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17618 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17619 | return NULL; |
| 17620 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17621 | void *_res = NULL; |
| 17622 | int _mark = p->mark; |
| 17623 | int _start_mark = p->mark; |
| 17624 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17625 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17626 | p->error_indicator = 1; |
| 17627 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17628 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17629 | return NULL; |
| 17630 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17631 | ssize_t _children_capacity = 1; |
| 17632 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17633 | { // ',' with_item |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17634 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17635 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17636 | return NULL; |
| 17637 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17638 | D(fprintf(stderr, "%*c> _loop0_41[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17639 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17640 | withitem_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17641 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17642 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17643 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17644 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17645 | ) |
| 17646 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17647 | _res = elem; |
| 17648 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17649 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17650 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17651 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17652 | return NULL; |
| 17653 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17654 | if (_n == _children_capacity) { |
| 17655 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17656 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17657 | if (!_new_children) { |
| 17658 | p->error_indicator = 1; |
| 17659 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17660 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17661 | return NULL; |
| 17662 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17663 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17664 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17665 | _children[_n++] = _res; |
| 17666 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17667 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17668 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17669 | D(fprintf(stderr, "%*c%s _loop0_41[%d-%d]: %s failed!\n", p->level, ' ', |
| 17670 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17671 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17672 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17673 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17674 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17675 | p->error_indicator = 1; |
| 17676 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17677 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17678 | return NULL; |
| 17679 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17680 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17681 | PyMem_Free(_children); |
| 17682 | _PyPegen_insert_memo(p, _start_mark, _loop0_41_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17683 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17684 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17685 | } |
| 17686 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17687 | // _gather_40: with_item _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17688 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17689 | _gather_40_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17690 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17691 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17692 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17693 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17694 | return NULL; |
| 17695 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17696 | asdl_seq * _res = NULL; |
| 17697 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17698 | { // with_item _loop0_41 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17699 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17700 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17701 | return NULL; |
| 17702 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17703 | D(fprintf(stderr, "%*c> _gather_40[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_41")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17704 | withitem_ty elem; |
| 17705 | asdl_seq * seq; |
| 17706 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17707 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17708 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17709 | (seq = _loop0_41_rule(p)) // _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17710 | ) |
| 17711 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17712 | D(fprintf(stderr, "%*c+ _gather_40[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_41")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17713 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17714 | goto done; |
| 17715 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17716 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17717 | D(fprintf(stderr, "%*c%s _gather_40[%d-%d]: %s failed!\n", p->level, ' ', |
| 17718 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_41")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17719 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17720 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17721 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17722 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17723 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17724 | } |
| 17725 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17726 | // _loop0_43: ',' with_item |
| 17727 | static asdl_seq * |
| 17728 | _loop0_43_rule(Parser *p) |
| 17729 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17730 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17731 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17732 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17733 | return NULL; |
| 17734 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17735 | void *_res = NULL; |
| 17736 | int _mark = p->mark; |
| 17737 | int _start_mark = p->mark; |
| 17738 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17739 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17740 | p->error_indicator = 1; |
| 17741 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17742 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17743 | return NULL; |
| 17744 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17745 | ssize_t _children_capacity = 1; |
| 17746 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17747 | { // ',' with_item |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17748 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17749 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17750 | return NULL; |
| 17751 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17752 | D(fprintf(stderr, "%*c> _loop0_43[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17753 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17754 | withitem_ty elem; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17755 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17756 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17757 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17758 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17759 | ) |
| 17760 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17761 | _res = elem; |
| 17762 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17763 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17764 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17765 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17766 | return NULL; |
| 17767 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17768 | if (_n == _children_capacity) { |
| 17769 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17770 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17771 | if (!_new_children) { |
| 17772 | p->error_indicator = 1; |
| 17773 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17774 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17775 | return NULL; |
| 17776 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17777 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17778 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17779 | _children[_n++] = _res; |
| 17780 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17781 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17782 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17783 | D(fprintf(stderr, "%*c%s _loop0_43[%d-%d]: %s failed!\n", p->level, ' ', |
| 17784 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17785 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17786 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17787 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17788 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17789 | p->error_indicator = 1; |
| 17790 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17791 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17792 | return NULL; |
| 17793 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17794 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17795 | PyMem_Free(_children); |
| 17796 | _PyPegen_insert_memo(p, _start_mark, _loop0_43_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17797 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17798 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17799 | } |
| 17800 | |
| 17801 | // _gather_42: with_item _loop0_43 |
| 17802 | static asdl_seq * |
| 17803 | _gather_42_rule(Parser *p) |
| 17804 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17805 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17806 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17807 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17808 | return NULL; |
| 17809 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17810 | asdl_seq * _res = NULL; |
| 17811 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17812 | { // with_item _loop0_43 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17813 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17814 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17815 | return NULL; |
| 17816 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17817 | D(fprintf(stderr, "%*c> _gather_42[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_43")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17818 | withitem_ty elem; |
| 17819 | asdl_seq * seq; |
| 17820 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17821 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17822 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17823 | (seq = _loop0_43_rule(p)) // _loop0_43 |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17824 | ) |
| 17825 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17826 | D(fprintf(stderr, "%*c+ _gather_42[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_43")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17827 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17828 | goto done; |
| 17829 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17830 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17831 | D(fprintf(stderr, "%*c%s _gather_42[%d-%d]: %s failed!\n", p->level, ' ', |
| 17832 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_43")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17833 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17834 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17835 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17836 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17837 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17838 | } |
| 17839 | |
| 17840 | // _loop0_45: ',' with_item |
| 17841 | static asdl_seq * |
| 17842 | _loop0_45_rule(Parser *p) |
| 17843 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17844 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17845 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17846 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17847 | return NULL; |
| 17848 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17849 | void *_res = NULL; |
| 17850 | int _mark = p->mark; |
| 17851 | int _start_mark = p->mark; |
| 17852 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17853 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17854 | p->error_indicator = 1; |
| 17855 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17856 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17857 | return NULL; |
| 17858 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17859 | ssize_t _children_capacity = 1; |
| 17860 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17861 | { // ',' with_item |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17862 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17863 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17864 | return NULL; |
| 17865 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17866 | D(fprintf(stderr, "%*c> _loop0_45[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' with_item")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17867 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17868 | withitem_ty elem; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17869 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17870 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17871 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17872 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17873 | ) |
| 17874 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17875 | _res = elem; |
| 17876 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17877 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17878 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17879 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17880 | return NULL; |
| 17881 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17882 | if (_n == _children_capacity) { |
| 17883 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17884 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17885 | if (!_new_children) { |
| 17886 | p->error_indicator = 1; |
| 17887 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17888 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17889 | return NULL; |
| 17890 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17891 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17892 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17893 | _children[_n++] = _res; |
| 17894 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17895 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17896 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17897 | D(fprintf(stderr, "%*c%s _loop0_45[%d-%d]: %s failed!\n", p->level, ' ', |
| 17898 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' with_item")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17899 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17900 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17901 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17902 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17903 | p->error_indicator = 1; |
| 17904 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17905 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17906 | return NULL; |
| 17907 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17908 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17909 | PyMem_Free(_children); |
| 17910 | _PyPegen_insert_memo(p, _start_mark, _loop0_45_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17911 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17912 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17913 | } |
| 17914 | |
| 17915 | // _gather_44: with_item _loop0_45 |
| 17916 | static asdl_seq * |
| 17917 | _gather_44_rule(Parser *p) |
| 17918 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17919 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17920 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17921 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17922 | return NULL; |
| 17923 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17924 | asdl_seq * _res = NULL; |
| 17925 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17926 | { // with_item _loop0_45 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17927 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17928 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17929 | return NULL; |
| 17930 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17931 | D(fprintf(stderr, "%*c> _gather_44[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "with_item _loop0_45")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17932 | withitem_ty elem; |
| 17933 | asdl_seq * seq; |
| 17934 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17935 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17936 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17937 | (seq = _loop0_45_rule(p)) // _loop0_45 |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17938 | ) |
| 17939 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17940 | D(fprintf(stderr, "%*c+ _gather_44[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "with_item _loop0_45")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17941 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17942 | goto done; |
| 17943 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17944 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17945 | D(fprintf(stderr, "%*c%s _gather_44[%d-%d]: %s failed!\n", p->level, ' ', |
| 17946 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "with_item _loop0_45")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17947 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17948 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17949 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17950 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17951 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17952 | } |
| 17953 | |
| 17954 | // _tmp_46: 'as' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17955 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17956 | _tmp_46_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17957 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17958 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17959 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17960 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17961 | return NULL; |
| 17962 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17963 | void * _res = NULL; |
| 17964 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17965 | { // 'as' target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17966 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17967 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17968 | return NULL; |
| 17969 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17970 | D(fprintf(stderr, "%*c> _tmp_46[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' target")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17971 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17972 | expr_ty t; |
| 17973 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17974 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17975 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17976 | (t = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17977 | ) |
| 17978 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17979 | D(fprintf(stderr, "%*c+ _tmp_46[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' target")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17980 | _res = t; |
| 17981 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17982 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17983 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17984 | return NULL; |
| 17985 | } |
| 17986 | goto done; |
| 17987 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17988 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17989 | D(fprintf(stderr, "%*c%s _tmp_46[%d-%d]: %s failed!\n", p->level, ' ', |
| 17990 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' target")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17991 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17992 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17993 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 17994 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17995 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17996 | } |
| 17997 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17998 | // _loop1_47: except_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17999 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18000 | _loop1_47_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18001 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18002 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18003 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18004 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18005 | return NULL; |
| 18006 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18007 | void *_res = NULL; |
| 18008 | int _mark = p->mark; |
| 18009 | int _start_mark = p->mark; |
| 18010 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18011 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18012 | p->error_indicator = 1; |
| 18013 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18014 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18015 | return NULL; |
| 18016 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18017 | ssize_t _children_capacity = 1; |
| 18018 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18019 | { // except_block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18020 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18021 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18022 | return NULL; |
| 18023 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18024 | D(fprintf(stderr, "%*c> _loop1_47[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "except_block")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18025 | excepthandler_ty except_block_var; |
| 18026 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18027 | (except_block_var = except_block_rule(p)) // except_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18028 | ) |
| 18029 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18030 | _res = except_block_var; |
| 18031 | if (_n == _children_capacity) { |
| 18032 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18033 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18034 | if (!_new_children) { |
| 18035 | p->error_indicator = 1; |
| 18036 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18037 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18038 | return NULL; |
| 18039 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18040 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18041 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18042 | _children[_n++] = _res; |
| 18043 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18044 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18045 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18046 | D(fprintf(stderr, "%*c%s _loop1_47[%d-%d]: %s failed!\n", p->level, ' ', |
| 18047 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "except_block")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18048 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18049 | if (_n == 0 || p->error_indicator) { |
| 18050 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18051 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18052 | return NULL; |
| 18053 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18054 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18055 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18056 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18057 | p->error_indicator = 1; |
| 18058 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18059 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18060 | return NULL; |
| 18061 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18062 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18063 | PyMem_Free(_children); |
| 18064 | _PyPegen_insert_memo(p, _start_mark, _loop1_47_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18065 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18066 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18067 | } |
| 18068 | |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 18069 | // _tmp_48: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18070 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18071 | _tmp_48_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18072 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18073 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18074 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18075 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18076 | return NULL; |
| 18077 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18078 | void * _res = NULL; |
| 18079 | int _mark = p->mark; |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 18080 | { // 'as' NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18081 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18082 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18083 | return NULL; |
| 18084 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18085 | D(fprintf(stderr, "%*c> _tmp_48[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18086 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18087 | expr_ty z; |
| 18088 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18089 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18090 | && |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 18091 | (z = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18092 | ) |
| 18093 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18094 | D(fprintf(stderr, "%*c+ _tmp_48[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'as' NAME")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18095 | _res = z; |
| 18096 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18097 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18098 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18099 | return NULL; |
| 18100 | } |
| 18101 | goto done; |
| 18102 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18103 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18104 | D(fprintf(stderr, "%*c%s _tmp_48[%d-%d]: %s failed!\n", p->level, ' ', |
| 18105 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'as' NAME")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18106 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18107 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18108 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18109 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18110 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18111 | } |
| 18112 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18113 | // _tmp_49: 'from' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18114 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18115 | _tmp_49_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18116 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18117 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18118 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18119 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18120 | return NULL; |
| 18121 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18122 | void * _res = NULL; |
| 18123 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18124 | { // 'from' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18125 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18126 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18127 | return NULL; |
| 18128 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18129 | D(fprintf(stderr, "%*c> _tmp_49[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'from' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18130 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18131 | expr_ty z; |
| 18132 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18133 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18134 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18135 | (z = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18136 | ) |
| 18137 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18138 | D(fprintf(stderr, "%*c+ _tmp_49[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'from' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18139 | _res = z; |
| 18140 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18141 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18142 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18143 | return NULL; |
| 18144 | } |
| 18145 | goto done; |
| 18146 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18147 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18148 | D(fprintf(stderr, "%*c%s _tmp_49[%d-%d]: %s failed!\n", p->level, ' ', |
| 18149 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'from' expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18150 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18151 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18152 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18153 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18154 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18155 | } |
| 18156 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18157 | // _tmp_50: '->' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18158 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18159 | _tmp_50_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18160 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18161 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18162 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18163 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18164 | return NULL; |
| 18165 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18166 | void * _res = NULL; |
| 18167 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18168 | { // '->' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18169 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18170 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18171 | return NULL; |
| 18172 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18173 | D(fprintf(stderr, "%*c> _tmp_50[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18174 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18175 | expr_ty z; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18176 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18177 | (_literal = _PyPegen_expect_token(p, 51)) // token='->' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18178 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18179 | (z = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18180 | ) |
| 18181 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18182 | D(fprintf(stderr, "%*c+ _tmp_50[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18183 | _res = z; |
| 18184 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18185 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18186 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18187 | return NULL; |
| 18188 | } |
| 18189 | goto done; |
| 18190 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18191 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18192 | D(fprintf(stderr, "%*c%s _tmp_50[%d-%d]: %s failed!\n", p->level, ' ', |
| 18193 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18194 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18195 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18196 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18197 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18198 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18199 | } |
| 18200 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18201 | // _tmp_51: '->' expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18202 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18203 | _tmp_51_rule(Parser *p) |
| 18204 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18205 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18206 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18207 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18208 | return NULL; |
| 18209 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18210 | void * _res = NULL; |
| 18211 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18212 | { // '->' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18213 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18214 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18215 | return NULL; |
| 18216 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18217 | D(fprintf(stderr, "%*c> _tmp_51[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'->' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18218 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18219 | expr_ty z; |
| 18220 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18221 | (_literal = _PyPegen_expect_token(p, 51)) // token='->' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18222 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18223 | (z = expression_rule(p)) // expression |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18224 | ) |
| 18225 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18226 | D(fprintf(stderr, "%*c+ _tmp_51[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'->' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18227 | _res = z; |
| 18228 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18229 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18230 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18231 | return NULL; |
| 18232 | } |
| 18233 | goto done; |
| 18234 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18235 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18236 | D(fprintf(stderr, "%*c%s _tmp_51[%d-%d]: %s failed!\n", p->level, ' ', |
| 18237 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'->' expression")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18238 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18239 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18240 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18241 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18242 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18243 | } |
| 18244 | |
| 18245 | // _tmp_52: NEWLINE INDENT |
| 18246 | static void * |
| 18247 | _tmp_52_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18248 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18249 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18250 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18251 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18252 | return NULL; |
| 18253 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18254 | void * _res = NULL; |
| 18255 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18256 | { // NEWLINE INDENT |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18257 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18258 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18259 | return NULL; |
| 18260 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18261 | D(fprintf(stderr, "%*c> _tmp_52[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 18262 | Token * indent_var; |
| 18263 | Token * newline_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18264 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18265 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18266 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18267 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18268 | ) |
| 18269 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18270 | D(fprintf(stderr, "%*c+ _tmp_52[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "NEWLINE INDENT")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18271 | _res = _PyPegen_dummy_name(p, newline_var, indent_var); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18272 | goto done; |
| 18273 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18274 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18275 | D(fprintf(stderr, "%*c%s _tmp_52[%d-%d]: %s failed!\n", p->level, ' ', |
| 18276 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18277 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18278 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18279 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18280 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18281 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18282 | } |
| 18283 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18284 | // _loop0_53: param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18285 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18286 | _loop0_53_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18287 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18288 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18289 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18290 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18291 | return NULL; |
| 18292 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18293 | void *_res = NULL; |
| 18294 | int _mark = p->mark; |
| 18295 | int _start_mark = p->mark; |
| 18296 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18297 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18298 | p->error_indicator = 1; |
| 18299 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18300 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18301 | return NULL; |
| 18302 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18303 | ssize_t _children_capacity = 1; |
| 18304 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18305 | { // param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18306 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18307 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18308 | return NULL; |
| 18309 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18310 | D(fprintf(stderr, "%*c> _loop0_53[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18311 | arg_ty param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18312 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18313 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18314 | ) |
| 18315 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18316 | _res = param_no_default_var; |
| 18317 | if (_n == _children_capacity) { |
| 18318 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18319 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18320 | if (!_new_children) { |
| 18321 | p->error_indicator = 1; |
| 18322 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18323 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18324 | return NULL; |
| 18325 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18326 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18327 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18328 | _children[_n++] = _res; |
| 18329 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18330 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18331 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18332 | D(fprintf(stderr, "%*c%s _loop0_53[%d-%d]: %s failed!\n", p->level, ' ', |
| 18333 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18334 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18335 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18336 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18337 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18338 | p->error_indicator = 1; |
| 18339 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18340 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18341 | return NULL; |
| 18342 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18343 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18344 | PyMem_Free(_children); |
| 18345 | _PyPegen_insert_memo(p, _start_mark, _loop0_53_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18346 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18347 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18348 | } |
| 18349 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18350 | // _loop0_54: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18351 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18352 | _loop0_54_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18353 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18354 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18355 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18356 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18357 | return NULL; |
| 18358 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18359 | void *_res = NULL; |
| 18360 | int _mark = p->mark; |
| 18361 | int _start_mark = p->mark; |
| 18362 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18363 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18364 | p->error_indicator = 1; |
| 18365 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18366 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18367 | return NULL; |
| 18368 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18369 | ssize_t _children_capacity = 1; |
| 18370 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18371 | { // param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18372 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18373 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18374 | return NULL; |
| 18375 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18376 | D(fprintf(stderr, "%*c> _loop0_54[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18377 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18378 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18379 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18380 | ) |
| 18381 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18382 | _res = param_with_default_var; |
| 18383 | if (_n == _children_capacity) { |
| 18384 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18385 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18386 | if (!_new_children) { |
| 18387 | p->error_indicator = 1; |
| 18388 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18389 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18390 | return NULL; |
| 18391 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18392 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18393 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18394 | _children[_n++] = _res; |
| 18395 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18396 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18397 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18398 | D(fprintf(stderr, "%*c%s _loop0_54[%d-%d]: %s failed!\n", p->level, ' ', |
| 18399 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18400 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18401 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18402 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18403 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18404 | p->error_indicator = 1; |
| 18405 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18406 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18407 | return NULL; |
| 18408 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18409 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18410 | PyMem_Free(_children); |
| 18411 | _PyPegen_insert_memo(p, _start_mark, _loop0_54_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18412 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18413 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18414 | } |
| 18415 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18416 | // _loop0_55: param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18417 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18418 | _loop0_55_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18419 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18420 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18421 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18422 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18423 | return NULL; |
| 18424 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18425 | void *_res = NULL; |
| 18426 | int _mark = p->mark; |
| 18427 | int _start_mark = p->mark; |
| 18428 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18429 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18430 | p->error_indicator = 1; |
| 18431 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18432 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18433 | return NULL; |
| 18434 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18435 | ssize_t _children_capacity = 1; |
| 18436 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18437 | { // param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18438 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18439 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18440 | return NULL; |
| 18441 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18442 | D(fprintf(stderr, "%*c> _loop0_55[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18443 | NameDefaultPair* param_with_default_var; |
| 18444 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18445 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18446 | ) |
| 18447 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18448 | _res = param_with_default_var; |
| 18449 | if (_n == _children_capacity) { |
| 18450 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18451 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18452 | if (!_new_children) { |
| 18453 | p->error_indicator = 1; |
| 18454 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18455 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18456 | return NULL; |
| 18457 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18458 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18459 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18460 | _children[_n++] = _res; |
| 18461 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18462 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18463 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18464 | D(fprintf(stderr, "%*c%s _loop0_55[%d-%d]: %s failed!\n", p->level, ' ', |
| 18465 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18466 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18467 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18468 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18469 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18470 | p->error_indicator = 1; |
| 18471 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18472 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18473 | return NULL; |
| 18474 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18475 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18476 | PyMem_Free(_children); |
| 18477 | _PyPegen_insert_memo(p, _start_mark, _loop0_55_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18478 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18479 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18480 | } |
| 18481 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18482 | // _loop1_56: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18483 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18484 | _loop1_56_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18485 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18486 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18487 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18488 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18489 | return NULL; |
| 18490 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18491 | void *_res = NULL; |
| 18492 | int _mark = p->mark; |
| 18493 | int _start_mark = p->mark; |
| 18494 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18495 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18496 | p->error_indicator = 1; |
| 18497 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18498 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18499 | return NULL; |
| 18500 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18501 | ssize_t _children_capacity = 1; |
| 18502 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18503 | { // param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18504 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18505 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18506 | return NULL; |
| 18507 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18508 | D(fprintf(stderr, "%*c> _loop1_56[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18509 | arg_ty param_no_default_var; |
| 18510 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18511 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18512 | ) |
| 18513 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18514 | _res = param_no_default_var; |
| 18515 | if (_n == _children_capacity) { |
| 18516 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18517 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18518 | if (!_new_children) { |
| 18519 | p->error_indicator = 1; |
| 18520 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18521 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18522 | return NULL; |
| 18523 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18524 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18525 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18526 | _children[_n++] = _res; |
| 18527 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18528 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18529 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18530 | D(fprintf(stderr, "%*c%s _loop1_56[%d-%d]: %s failed!\n", p->level, ' ', |
| 18531 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18532 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18533 | if (_n == 0 || p->error_indicator) { |
| 18534 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18535 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18536 | return NULL; |
| 18537 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18538 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18539 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18540 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18541 | p->error_indicator = 1; |
| 18542 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18543 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18544 | return NULL; |
| 18545 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18546 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18547 | PyMem_Free(_children); |
| 18548 | _PyPegen_insert_memo(p, _start_mark, _loop1_56_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18549 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18550 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18551 | } |
| 18552 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18553 | // _loop0_57: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18554 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18555 | _loop0_57_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18556 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18557 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18558 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18559 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18560 | return NULL; |
| 18561 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18562 | void *_res = NULL; |
| 18563 | int _mark = p->mark; |
| 18564 | int _start_mark = p->mark; |
| 18565 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18566 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18567 | p->error_indicator = 1; |
| 18568 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18569 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18570 | return NULL; |
| 18571 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18572 | ssize_t _children_capacity = 1; |
| 18573 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18574 | { // param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18575 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18576 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18577 | return NULL; |
| 18578 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18579 | D(fprintf(stderr, "%*c> _loop0_57[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18580 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18581 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18582 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18583 | ) |
| 18584 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18585 | _res = param_with_default_var; |
| 18586 | if (_n == _children_capacity) { |
| 18587 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18588 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18589 | if (!_new_children) { |
| 18590 | p->error_indicator = 1; |
| 18591 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18592 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18593 | return NULL; |
| 18594 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18595 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18596 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18597 | _children[_n++] = _res; |
| 18598 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18599 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18600 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18601 | D(fprintf(stderr, "%*c%s _loop0_57[%d-%d]: %s failed!\n", p->level, ' ', |
| 18602 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18603 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18604 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18605 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18606 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18607 | p->error_indicator = 1; |
| 18608 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18609 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18610 | return NULL; |
| 18611 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18612 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18613 | PyMem_Free(_children); |
| 18614 | _PyPegen_insert_memo(p, _start_mark, _loop0_57_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18615 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18616 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18617 | } |
| 18618 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18619 | // _loop1_58: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18620 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18621 | _loop1_58_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18622 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18623 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18624 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18625 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18626 | return NULL; |
| 18627 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18628 | void *_res = NULL; |
| 18629 | int _mark = p->mark; |
| 18630 | int _start_mark = p->mark; |
| 18631 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18632 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18633 | p->error_indicator = 1; |
| 18634 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18635 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18636 | return NULL; |
| 18637 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18638 | ssize_t _children_capacity = 1; |
| 18639 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18640 | { // param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18641 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18642 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18643 | return NULL; |
| 18644 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18645 | D(fprintf(stderr, "%*c> _loop1_58[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18646 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18647 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18648 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18649 | ) |
| 18650 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18651 | _res = param_with_default_var; |
| 18652 | if (_n == _children_capacity) { |
| 18653 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18654 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18655 | if (!_new_children) { |
| 18656 | p->error_indicator = 1; |
| 18657 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18658 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18659 | return NULL; |
| 18660 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18661 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18662 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18663 | _children[_n++] = _res; |
| 18664 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18665 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18666 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18667 | D(fprintf(stderr, "%*c%s _loop1_58[%d-%d]: %s failed!\n", p->level, ' ', |
| 18668 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18669 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18670 | if (_n == 0 || p->error_indicator) { |
| 18671 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18672 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18673 | return NULL; |
| 18674 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18675 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18676 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18677 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18678 | p->error_indicator = 1; |
| 18679 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18680 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18681 | return NULL; |
| 18682 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18683 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18684 | PyMem_Free(_children); |
| 18685 | _PyPegen_insert_memo(p, _start_mark, _loop1_58_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18686 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18687 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18688 | } |
| 18689 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18690 | // _loop1_59: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18691 | static asdl_seq * |
| 18692 | _loop1_59_rule(Parser *p) |
| 18693 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18694 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18695 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18696 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18697 | return NULL; |
| 18698 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18699 | void *_res = NULL; |
| 18700 | int _mark = p->mark; |
| 18701 | int _start_mark = p->mark; |
| 18702 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18703 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18704 | p->error_indicator = 1; |
| 18705 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18706 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18707 | return NULL; |
| 18708 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18709 | ssize_t _children_capacity = 1; |
| 18710 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18711 | { // param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18712 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18713 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18714 | return NULL; |
| 18715 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18716 | D(fprintf(stderr, "%*c> _loop1_59[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18717 | arg_ty param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18718 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18719 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18720 | ) |
| 18721 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18722 | _res = param_no_default_var; |
| 18723 | if (_n == _children_capacity) { |
| 18724 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18725 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18726 | if (!_new_children) { |
| 18727 | p->error_indicator = 1; |
| 18728 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18729 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18730 | return NULL; |
| 18731 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18732 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18733 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18734 | _children[_n++] = _res; |
| 18735 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18736 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18737 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18738 | D(fprintf(stderr, "%*c%s _loop1_59[%d-%d]: %s failed!\n", p->level, ' ', |
| 18739 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18740 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18741 | if (_n == 0 || p->error_indicator) { |
| 18742 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18743 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18744 | return NULL; |
| 18745 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18746 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18747 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18748 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18749 | p->error_indicator = 1; |
| 18750 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18751 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18752 | return NULL; |
| 18753 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18754 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18755 | PyMem_Free(_children); |
| 18756 | _PyPegen_insert_memo(p, _start_mark, _loop1_59_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18757 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18758 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18759 | } |
| 18760 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18761 | // _loop1_60: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18762 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18763 | _loop1_60_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18764 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18765 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18766 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18767 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18768 | return NULL; |
| 18769 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18770 | void *_res = NULL; |
| 18771 | int _mark = p->mark; |
| 18772 | int _start_mark = p->mark; |
| 18773 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18774 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18775 | p->error_indicator = 1; |
| 18776 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18777 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18778 | return NULL; |
| 18779 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18780 | ssize_t _children_capacity = 1; |
| 18781 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18782 | { // param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18783 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18784 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18785 | return NULL; |
| 18786 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18787 | D(fprintf(stderr, "%*c> _loop1_60[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18788 | arg_ty param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18789 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18790 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18791 | ) |
| 18792 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18793 | _res = param_no_default_var; |
| 18794 | if (_n == _children_capacity) { |
| 18795 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18796 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18797 | if (!_new_children) { |
| 18798 | p->error_indicator = 1; |
| 18799 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18800 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18801 | return NULL; |
| 18802 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18803 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18804 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18805 | _children[_n++] = _res; |
| 18806 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18807 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18808 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18809 | D(fprintf(stderr, "%*c%s _loop1_60[%d-%d]: %s failed!\n", p->level, ' ', |
| 18810 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18811 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18812 | if (_n == 0 || p->error_indicator) { |
| 18813 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18814 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18815 | return NULL; |
| 18816 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18817 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18818 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18819 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18820 | p->error_indicator = 1; |
| 18821 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18822 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18823 | return NULL; |
| 18824 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18825 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18826 | PyMem_Free(_children); |
| 18827 | _PyPegen_insert_memo(p, _start_mark, _loop1_60_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18828 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18829 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18830 | } |
| 18831 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18832 | // _loop0_61: param_no_default |
| 18833 | static asdl_seq * |
| 18834 | _loop0_61_rule(Parser *p) |
| 18835 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18836 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18837 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18838 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18839 | return NULL; |
| 18840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18841 | void *_res = NULL; |
| 18842 | int _mark = p->mark; |
| 18843 | int _start_mark = p->mark; |
| 18844 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18845 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18846 | p->error_indicator = 1; |
| 18847 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18848 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18849 | return NULL; |
| 18850 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18851 | ssize_t _children_capacity = 1; |
| 18852 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18853 | { // param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18854 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18855 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18856 | return NULL; |
| 18857 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18858 | D(fprintf(stderr, "%*c> _loop0_61[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18859 | arg_ty param_no_default_var; |
| 18860 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18861 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18862 | ) |
| 18863 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18864 | _res = param_no_default_var; |
| 18865 | if (_n == _children_capacity) { |
| 18866 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18867 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18868 | if (!_new_children) { |
| 18869 | p->error_indicator = 1; |
| 18870 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18871 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18872 | return NULL; |
| 18873 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18874 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18875 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18876 | _children[_n++] = _res; |
| 18877 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18878 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18879 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18880 | D(fprintf(stderr, "%*c%s _loop0_61[%d-%d]: %s failed!\n", p->level, ' ', |
| 18881 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18882 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18883 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18884 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18885 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18886 | p->error_indicator = 1; |
| 18887 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18888 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18889 | return NULL; |
| 18890 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18891 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18892 | PyMem_Free(_children); |
| 18893 | _PyPegen_insert_memo(p, _start_mark, _loop0_61_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18894 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18895 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18896 | } |
| 18897 | |
| 18898 | // _loop1_62: param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18899 | static asdl_seq * |
| 18900 | _loop1_62_rule(Parser *p) |
| 18901 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18902 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18903 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18904 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18905 | return NULL; |
| 18906 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18907 | void *_res = NULL; |
| 18908 | int _mark = p->mark; |
| 18909 | int _start_mark = p->mark; |
| 18910 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18911 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18912 | p->error_indicator = 1; |
| 18913 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18914 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18915 | return NULL; |
| 18916 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18917 | ssize_t _children_capacity = 1; |
| 18918 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18919 | { // param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18920 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18921 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18922 | return NULL; |
| 18923 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18924 | D(fprintf(stderr, "%*c> _loop1_62[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18925 | NameDefaultPair* param_with_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18926 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18927 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18928 | ) |
| 18929 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18930 | _res = param_with_default_var; |
| 18931 | if (_n == _children_capacity) { |
| 18932 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18933 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18934 | if (!_new_children) { |
| 18935 | p->error_indicator = 1; |
| 18936 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18937 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18938 | return NULL; |
| 18939 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18940 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18941 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18942 | _children[_n++] = _res; |
| 18943 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18944 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18945 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18946 | D(fprintf(stderr, "%*c%s _loop1_62[%d-%d]: %s failed!\n", p->level, ' ', |
| 18947 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18948 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18949 | if (_n == 0 || p->error_indicator) { |
| 18950 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18951 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18952 | return NULL; |
| 18953 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18954 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18955 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18956 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18957 | p->error_indicator = 1; |
| 18958 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18959 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18960 | return NULL; |
| 18961 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18962 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18963 | PyMem_Free(_children); |
| 18964 | _PyPegen_insert_memo(p, _start_mark, _loop1_62_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18965 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18966 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18967 | } |
| 18968 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18969 | // _loop0_63: param_no_default |
| 18970 | static asdl_seq * |
| 18971 | _loop0_63_rule(Parser *p) |
| 18972 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18973 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18974 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18975 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18976 | return NULL; |
| 18977 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18978 | void *_res = NULL; |
| 18979 | int _mark = p->mark; |
| 18980 | int _start_mark = p->mark; |
| 18981 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18982 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18983 | p->error_indicator = 1; |
| 18984 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18985 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18986 | return NULL; |
| 18987 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18988 | ssize_t _children_capacity = 1; |
| 18989 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18990 | { // param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18991 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18992 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18993 | return NULL; |
| 18994 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 18995 | D(fprintf(stderr, "%*c> _loop0_63[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18996 | arg_ty param_no_default_var; |
| 18997 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18998 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18999 | ) |
| 19000 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19001 | _res = param_no_default_var; |
| 19002 | if (_n == _children_capacity) { |
| 19003 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19004 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19005 | if (!_new_children) { |
| 19006 | p->error_indicator = 1; |
| 19007 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19008 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19009 | return NULL; |
| 19010 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19011 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19012 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19013 | _children[_n++] = _res; |
| 19014 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19015 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19016 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19017 | D(fprintf(stderr, "%*c%s _loop0_63[%d-%d]: %s failed!\n", p->level, ' ', |
| 19018 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19019 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19020 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 19021 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19022 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19023 | p->error_indicator = 1; |
| 19024 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19025 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19026 | return NULL; |
| 19027 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19028 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 19029 | PyMem_Free(_children); |
| 19030 | _PyPegen_insert_memo(p, _start_mark, _loop0_63_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19031 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19032 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19033 | } |
| 19034 | |
| 19035 | // _loop1_64: param_with_default |
| 19036 | static asdl_seq * |
| 19037 | _loop1_64_rule(Parser *p) |
| 19038 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19039 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19040 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19041 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19042 | return NULL; |
| 19043 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19044 | void *_res = NULL; |
| 19045 | int _mark = p->mark; |
| 19046 | int _start_mark = p->mark; |
| 19047 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19048 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19049 | p->error_indicator = 1; |
| 19050 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19051 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19052 | return NULL; |
| 19053 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19054 | ssize_t _children_capacity = 1; |
| 19055 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19056 | { // param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19057 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19058 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19059 | return NULL; |
| 19060 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19061 | D(fprintf(stderr, "%*c> _loop1_64[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19062 | NameDefaultPair* param_with_default_var; |
| 19063 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19064 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19065 | ) |
| 19066 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19067 | _res = param_with_default_var; |
| 19068 | if (_n == _children_capacity) { |
| 19069 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19070 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19071 | if (!_new_children) { |
| 19072 | p->error_indicator = 1; |
| 19073 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19074 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19075 | return NULL; |
| 19076 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19077 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19078 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19079 | _children[_n++] = _res; |
| 19080 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19081 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19082 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19083 | D(fprintf(stderr, "%*c%s _loop1_64[%d-%d]: %s failed!\n", p->level, ' ', |
| 19084 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19085 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19086 | if (_n == 0 || p->error_indicator) { |
| 19087 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19088 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19089 | return NULL; |
| 19090 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19091 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 19092 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19093 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19094 | p->error_indicator = 1; |
| 19095 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19096 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19097 | return NULL; |
| 19098 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19099 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 19100 | PyMem_Free(_children); |
| 19101 | _PyPegen_insert_memo(p, _start_mark, _loop1_64_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19102 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19103 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19104 | } |
| 19105 | |
| 19106 | // _loop0_65: param_maybe_default |
| 19107 | static asdl_seq * |
| 19108 | _loop0_65_rule(Parser *p) |
| 19109 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19110 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19111 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19112 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19113 | return NULL; |
| 19114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19115 | void *_res = NULL; |
| 19116 | int _mark = p->mark; |
| 19117 | int _start_mark = p->mark; |
| 19118 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19119 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19120 | p->error_indicator = 1; |
| 19121 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19122 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19123 | return NULL; |
| 19124 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19125 | ssize_t _children_capacity = 1; |
| 19126 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19127 | { // param_maybe_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19128 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19129 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19130 | return NULL; |
| 19131 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19132 | D(fprintf(stderr, "%*c> _loop0_65[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19133 | NameDefaultPair* param_maybe_default_var; |
| 19134 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19135 | (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19136 | ) |
| 19137 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19138 | _res = param_maybe_default_var; |
| 19139 | if (_n == _children_capacity) { |
| 19140 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19141 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19142 | if (!_new_children) { |
| 19143 | p->error_indicator = 1; |
| 19144 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19145 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19146 | return NULL; |
| 19147 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19148 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19149 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19150 | _children[_n++] = _res; |
| 19151 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19152 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19153 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19154 | D(fprintf(stderr, "%*c%s _loop0_65[%d-%d]: %s failed!\n", p->level, ' ', |
| 19155 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19156 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19157 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 19158 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19159 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19160 | p->error_indicator = 1; |
| 19161 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19162 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19163 | return NULL; |
| 19164 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19165 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 19166 | PyMem_Free(_children); |
| 19167 | _PyPegen_insert_memo(p, _start_mark, _loop0_65_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19168 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19169 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19170 | } |
| 19171 | |
| 19172 | // _loop1_66: param_maybe_default |
| 19173 | static asdl_seq * |
| 19174 | _loop1_66_rule(Parser *p) |
| 19175 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19176 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19177 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19178 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19179 | return NULL; |
| 19180 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19181 | void *_res = NULL; |
| 19182 | int _mark = p->mark; |
| 19183 | int _start_mark = p->mark; |
| 19184 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19185 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19186 | p->error_indicator = 1; |
| 19187 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19188 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19189 | return NULL; |
| 19190 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19191 | ssize_t _children_capacity = 1; |
| 19192 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19193 | { // param_maybe_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19194 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19195 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19196 | return NULL; |
| 19197 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19198 | D(fprintf(stderr, "%*c> _loop1_66[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_maybe_default")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19199 | NameDefaultPair* param_maybe_default_var; |
| 19200 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19201 | (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19202 | ) |
| 19203 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19204 | _res = param_maybe_default_var; |
| 19205 | if (_n == _children_capacity) { |
| 19206 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19207 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19208 | if (!_new_children) { |
| 19209 | p->error_indicator = 1; |
| 19210 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19211 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19212 | return NULL; |
| 19213 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19214 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19215 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19216 | _children[_n++] = _res; |
| 19217 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19218 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19219 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19220 | D(fprintf(stderr, "%*c%s _loop1_66[%d-%d]: %s failed!\n", p->level, ' ', |
| 19221 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_maybe_default")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19222 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19223 | if (_n == 0 || p->error_indicator) { |
| 19224 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19225 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19226 | return NULL; |
| 19227 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19228 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 19229 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19230 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19231 | p->error_indicator = 1; |
| 19232 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19233 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19234 | return NULL; |
| 19235 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19236 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 19237 | PyMem_Free(_children); |
| 19238 | _PyPegen_insert_memo(p, _start_mark, _loop1_66_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19239 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19240 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19241 | } |
| 19242 | |
| 19243 | // _loop1_67: ('@' named_expression NEWLINE) |
| 19244 | static asdl_seq * |
| 19245 | _loop1_67_rule(Parser *p) |
| 19246 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19247 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19248 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19249 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19250 | return NULL; |
| 19251 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19252 | void *_res = NULL; |
| 19253 | int _mark = p->mark; |
| 19254 | int _start_mark = p->mark; |
| 19255 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19256 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19257 | p->error_indicator = 1; |
| 19258 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19259 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19260 | return NULL; |
| 19261 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19262 | ssize_t _children_capacity = 1; |
| 19263 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19264 | { // ('@' named_expression NEWLINE) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19265 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19266 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19267 | return NULL; |
| 19268 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19269 | D(fprintf(stderr, "%*c> _loop1_67[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('@' named_expression NEWLINE)")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 19270 | void *_tmp_141_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19271 | while ( |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 19272 | (_tmp_141_var = _tmp_141_rule(p)) // '@' named_expression NEWLINE |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19273 | ) |
| 19274 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 19275 | _res = _tmp_141_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19276 | if (_n == _children_capacity) { |
| 19277 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19278 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19279 | if (!_new_children) { |
| 19280 | p->error_indicator = 1; |
| 19281 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19282 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19283 | return NULL; |
| 19284 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19285 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19286 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19287 | _children[_n++] = _res; |
| 19288 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19289 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19290 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19291 | D(fprintf(stderr, "%*c%s _loop1_67[%d-%d]: %s failed!\n", p->level, ' ', |
| 19292 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('@' named_expression NEWLINE)")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19293 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19294 | if (_n == 0 || p->error_indicator) { |
| 19295 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19296 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19297 | return NULL; |
| 19298 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19299 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 19300 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19301 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19302 | p->error_indicator = 1; |
| 19303 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19304 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19305 | return NULL; |
| 19306 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19307 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 19308 | PyMem_Free(_children); |
| 19309 | _PyPegen_insert_memo(p, _start_mark, _loop1_67_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19310 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19311 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19312 | } |
| 19313 | |
| 19314 | // _tmp_68: '(' arguments? ')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19315 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19316 | _tmp_68_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19317 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19318 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19319 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19320 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19321 | return NULL; |
| 19322 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19323 | void * _res = NULL; |
| 19324 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19325 | { // '(' arguments? ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19326 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19327 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19328 | return NULL; |
| 19329 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19330 | D(fprintf(stderr, "%*c> _tmp_68[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19331 | Token * _literal; |
| 19332 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19333 | void *z; |
| 19334 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19335 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19336 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19337 | (z = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19338 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19339 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19340 | ) |
| 19341 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19342 | D(fprintf(stderr, "%*c+ _tmp_68[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'(' arguments? ')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19343 | _res = z; |
| 19344 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19345 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19346 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19347 | return NULL; |
| 19348 | } |
| 19349 | goto done; |
| 19350 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19351 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19352 | D(fprintf(stderr, "%*c%s _tmp_68[%d-%d]: %s failed!\n", p->level, ' ', |
| 19353 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'(' arguments? ')'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19354 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19355 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19356 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19357 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19358 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19359 | } |
| 19360 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19361 | // _loop0_70: ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19362 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19363 | _loop0_70_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19364 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19365 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19366 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19367 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19368 | return NULL; |
| 19369 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19370 | void *_res = NULL; |
| 19371 | int _mark = p->mark; |
| 19372 | int _start_mark = p->mark; |
| 19373 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19374 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19375 | p->error_indicator = 1; |
| 19376 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19377 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19378 | return NULL; |
| 19379 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19380 | ssize_t _children_capacity = 1; |
| 19381 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19382 | { // ',' star_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19383 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19384 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19385 | return NULL; |
| 19386 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19387 | D(fprintf(stderr, "%*c> _loop0_70[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19388 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19389 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19390 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19391 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19392 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19393 | (elem = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19394 | ) |
| 19395 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19396 | _res = elem; |
| 19397 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19398 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19399 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19400 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19401 | return NULL; |
| 19402 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19403 | if (_n == _children_capacity) { |
| 19404 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19405 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19406 | if (!_new_children) { |
| 19407 | p->error_indicator = 1; |
| 19408 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19409 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19410 | return NULL; |
| 19411 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19412 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19413 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19414 | _children[_n++] = _res; |
| 19415 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19416 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19417 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19418 | D(fprintf(stderr, "%*c%s _loop0_70[%d-%d]: %s failed!\n", p->level, ' ', |
| 19419 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19420 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19421 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 19422 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19423 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19424 | p->error_indicator = 1; |
| 19425 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19426 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19427 | return NULL; |
| 19428 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19429 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 19430 | PyMem_Free(_children); |
| 19431 | _PyPegen_insert_memo(p, _start_mark, _loop0_70_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19432 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19433 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19434 | } |
| 19435 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19436 | // _gather_69: star_expression _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19437 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19438 | _gather_69_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19439 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19440 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19441 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19442 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19443 | return NULL; |
| 19444 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19445 | asdl_seq * _res = NULL; |
| 19446 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19447 | { // star_expression _loop0_70 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19448 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19449 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19450 | return NULL; |
| 19451 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19452 | D(fprintf(stderr, "%*c> _gather_69[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_70")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19453 | expr_ty elem; |
| 19454 | asdl_seq * seq; |
| 19455 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19456 | (elem = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19457 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19458 | (seq = _loop0_70_rule(p)) // _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19459 | ) |
| 19460 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19461 | D(fprintf(stderr, "%*c+ _gather_69[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expression _loop0_70")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19462 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19463 | goto done; |
| 19464 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19465 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19466 | D(fprintf(stderr, "%*c%s _gather_69[%d-%d]: %s failed!\n", p->level, ' ', |
| 19467 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expression _loop0_70")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19468 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19469 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19470 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19471 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19472 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19473 | } |
| 19474 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19475 | // _loop1_71: (',' star_expression) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19476 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19477 | _loop1_71_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19478 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19479 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19480 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19481 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19482 | return NULL; |
| 19483 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19484 | void *_res = NULL; |
| 19485 | int _mark = p->mark; |
| 19486 | int _start_mark = p->mark; |
| 19487 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19488 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19489 | p->error_indicator = 1; |
| 19490 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19491 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19492 | return NULL; |
| 19493 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19494 | ssize_t _children_capacity = 1; |
| 19495 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19496 | { // (',' star_expression) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19497 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19498 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19499 | return NULL; |
| 19500 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19501 | D(fprintf(stderr, "%*c> _loop1_71[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_expression)")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 19502 | void *_tmp_142_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19503 | while ( |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 19504 | (_tmp_142_var = _tmp_142_rule(p)) // ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19505 | ) |
| 19506 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 19507 | _res = _tmp_142_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19508 | if (_n == _children_capacity) { |
| 19509 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19510 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19511 | if (!_new_children) { |
| 19512 | p->error_indicator = 1; |
| 19513 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19514 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19515 | return NULL; |
| 19516 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19517 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19518 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19519 | _children[_n++] = _res; |
| 19520 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19521 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19522 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19523 | D(fprintf(stderr, "%*c%s _loop1_71[%d-%d]: %s failed!\n", p->level, ' ', |
| 19524 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_expression)")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19525 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19526 | if (_n == 0 || p->error_indicator) { |
| 19527 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19528 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19529 | return NULL; |
| 19530 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19531 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 19532 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19533 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19534 | p->error_indicator = 1; |
| 19535 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19536 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19537 | return NULL; |
| 19538 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19539 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 19540 | PyMem_Free(_children); |
| 19541 | _PyPegen_insert_memo(p, _start_mark, _loop1_71_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19542 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19543 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19544 | } |
| 19545 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19546 | // _loop0_73: ',' star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19547 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19548 | _loop0_73_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19549 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19550 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19551 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19552 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19553 | return NULL; |
| 19554 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19555 | void *_res = NULL; |
| 19556 | int _mark = p->mark; |
| 19557 | int _start_mark = p->mark; |
| 19558 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19559 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19560 | p->error_indicator = 1; |
| 19561 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19562 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19563 | return NULL; |
| 19564 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19565 | ssize_t _children_capacity = 1; |
| 19566 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19567 | { // ',' star_named_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19568 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19569 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19570 | return NULL; |
| 19571 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19572 | D(fprintf(stderr, "%*c> _loop0_73[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_named_expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19573 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19574 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19575 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19576 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19577 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19578 | (elem = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19579 | ) |
| 19580 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19581 | _res = elem; |
| 19582 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19583 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19584 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19585 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19586 | return NULL; |
| 19587 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19588 | if (_n == _children_capacity) { |
| 19589 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19590 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19591 | if (!_new_children) { |
| 19592 | p->error_indicator = 1; |
| 19593 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19594 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19595 | return NULL; |
| 19596 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19597 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19598 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19599 | _children[_n++] = _res; |
| 19600 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19601 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19602 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19603 | D(fprintf(stderr, "%*c%s _loop0_73[%d-%d]: %s failed!\n", p->level, ' ', |
| 19604 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_named_expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19605 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19606 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 19607 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19608 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19609 | p->error_indicator = 1; |
| 19610 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19611 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19612 | return NULL; |
| 19613 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19614 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 19615 | PyMem_Free(_children); |
| 19616 | _PyPegen_insert_memo(p, _start_mark, _loop0_73_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19617 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19618 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19619 | } |
| 19620 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19621 | // _gather_72: star_named_expression _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19622 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19623 | _gather_72_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19624 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19625 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19626 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19627 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19628 | return NULL; |
| 19629 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19630 | asdl_seq * _res = NULL; |
| 19631 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19632 | { // star_named_expression _loop0_73 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19633 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19634 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19635 | return NULL; |
| 19636 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19637 | D(fprintf(stderr, "%*c> _gather_72[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_73")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19638 | expr_ty elem; |
| 19639 | asdl_seq * seq; |
| 19640 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19641 | (elem = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19642 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19643 | (seq = _loop0_73_rule(p)) // _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19644 | ) |
| 19645 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19646 | D(fprintf(stderr, "%*c+ _gather_72[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression _loop0_73")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19647 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19648 | goto done; |
| 19649 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19650 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19651 | D(fprintf(stderr, "%*c%s _gather_72[%d-%d]: %s failed!\n", p->level, ' ', |
| 19652 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression _loop0_73")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19653 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19654 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19655 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19656 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19657 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19658 | } |
| 19659 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19660 | // _loop1_74: (',' expression) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19661 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 19662 | _loop1_74_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19663 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19664 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19665 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19666 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19667 | return NULL; |
| 19668 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19669 | void *_res = NULL; |
| 19670 | int _mark = p->mark; |
| 19671 | int _start_mark = p->mark; |
| 19672 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19673 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19674 | p->error_indicator = 1; |
| 19675 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19676 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19677 | return NULL; |
| 19678 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19679 | ssize_t _children_capacity = 1; |
| 19680 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19681 | { // (',' expression) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19682 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19683 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19684 | return NULL; |
| 19685 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19686 | D(fprintf(stderr, "%*c> _loop1_74[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' expression)")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 19687 | void *_tmp_143_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19688 | while ( |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 19689 | (_tmp_143_var = _tmp_143_rule(p)) // ',' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19690 | ) |
| 19691 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 19692 | _res = _tmp_143_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19693 | if (_n == _children_capacity) { |
| 19694 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19695 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19696 | if (!_new_children) { |
| 19697 | p->error_indicator = 1; |
| 19698 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19699 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19700 | return NULL; |
| 19701 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19702 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19703 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19704 | _children[_n++] = _res; |
| 19705 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19706 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19707 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19708 | D(fprintf(stderr, "%*c%s _loop1_74[%d-%d]: %s failed!\n", p->level, ' ', |
| 19709 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' expression)")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19710 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19711 | if (_n == 0 || p->error_indicator) { |
| 19712 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19713 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19714 | return NULL; |
| 19715 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19716 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 19717 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19718 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19719 | p->error_indicator = 1; |
| 19720 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19721 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19722 | return NULL; |
| 19723 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19724 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 19725 | PyMem_Free(_children); |
| 19726 | _PyPegen_insert_memo(p, _start_mark, _loop1_74_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19727 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19728 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19729 | } |
| 19730 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19731 | // _loop0_75: lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19732 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19733 | _loop0_75_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19734 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19735 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19736 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19737 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19738 | return NULL; |
| 19739 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19740 | void *_res = NULL; |
| 19741 | int _mark = p->mark; |
| 19742 | int _start_mark = p->mark; |
| 19743 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19744 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19745 | p->error_indicator = 1; |
| 19746 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19747 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19748 | return NULL; |
| 19749 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19750 | ssize_t _children_capacity = 1; |
| 19751 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19752 | { // lambda_param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19753 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19754 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19755 | return NULL; |
| 19756 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19757 | D(fprintf(stderr, "%*c> _loop0_75[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19758 | arg_ty lambda_param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19759 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19760 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19761 | ) |
| 19762 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19763 | _res = lambda_param_no_default_var; |
| 19764 | if (_n == _children_capacity) { |
| 19765 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19766 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19767 | if (!_new_children) { |
| 19768 | p->error_indicator = 1; |
| 19769 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19770 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19771 | return NULL; |
| 19772 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19773 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19774 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19775 | _children[_n++] = _res; |
| 19776 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19777 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19778 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19779 | D(fprintf(stderr, "%*c%s _loop0_75[%d-%d]: %s failed!\n", p->level, ' ', |
| 19780 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19781 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19782 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 19783 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19784 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19785 | p->error_indicator = 1; |
| 19786 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19787 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19788 | return NULL; |
| 19789 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19790 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 19791 | PyMem_Free(_children); |
| 19792 | _PyPegen_insert_memo(p, _start_mark, _loop0_75_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19793 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19794 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19795 | } |
| 19796 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19797 | // _loop0_76: lambda_param_with_default |
| 19798 | static asdl_seq * |
| 19799 | _loop0_76_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19800 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19801 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19802 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19803 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19804 | return NULL; |
| 19805 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19806 | void *_res = NULL; |
| 19807 | int _mark = p->mark; |
| 19808 | int _start_mark = p->mark; |
| 19809 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19810 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19811 | p->error_indicator = 1; |
| 19812 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19813 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19814 | return NULL; |
| 19815 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19816 | ssize_t _children_capacity = 1; |
| 19817 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19818 | { // lambda_param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19819 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19820 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19821 | return NULL; |
| 19822 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19823 | D(fprintf(stderr, "%*c> _loop0_76[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19824 | NameDefaultPair* lambda_param_with_default_var; |
| 19825 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19826 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19827 | ) |
| 19828 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19829 | _res = lambda_param_with_default_var; |
| 19830 | if (_n == _children_capacity) { |
| 19831 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19832 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19833 | if (!_new_children) { |
| 19834 | p->error_indicator = 1; |
| 19835 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19836 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19837 | return NULL; |
| 19838 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19839 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19841 | _children[_n++] = _res; |
| 19842 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19843 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19844 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19845 | D(fprintf(stderr, "%*c%s _loop0_76[%d-%d]: %s failed!\n", p->level, ' ', |
| 19846 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19847 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19848 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 19849 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19850 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19851 | p->error_indicator = 1; |
| 19852 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19853 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19854 | return NULL; |
| 19855 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19856 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 19857 | PyMem_Free(_children); |
| 19858 | _PyPegen_insert_memo(p, _start_mark, _loop0_76_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19859 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19860 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19861 | } |
| 19862 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19863 | // _loop0_77: lambda_param_with_default |
| 19864 | static asdl_seq * |
| 19865 | _loop0_77_rule(Parser *p) |
| 19866 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19867 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19868 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19869 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19870 | return NULL; |
| 19871 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19872 | void *_res = NULL; |
| 19873 | int _mark = p->mark; |
| 19874 | int _start_mark = p->mark; |
| 19875 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19876 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19877 | p->error_indicator = 1; |
| 19878 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19879 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19880 | return NULL; |
| 19881 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19882 | ssize_t _children_capacity = 1; |
| 19883 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19884 | { // lambda_param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19885 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19886 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19887 | return NULL; |
| 19888 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19889 | D(fprintf(stderr, "%*c> _loop0_77[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19890 | NameDefaultPair* lambda_param_with_default_var; |
| 19891 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19892 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19893 | ) |
| 19894 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19895 | _res = lambda_param_with_default_var; |
| 19896 | if (_n == _children_capacity) { |
| 19897 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19898 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19899 | if (!_new_children) { |
| 19900 | p->error_indicator = 1; |
| 19901 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19902 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19903 | return NULL; |
| 19904 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19905 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19906 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19907 | _children[_n++] = _res; |
| 19908 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19909 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19910 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19911 | D(fprintf(stderr, "%*c%s _loop0_77[%d-%d]: %s failed!\n", p->level, ' ', |
| 19912 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19913 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19914 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 19915 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19916 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19917 | p->error_indicator = 1; |
| 19918 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19919 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19920 | return NULL; |
| 19921 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19922 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 19923 | PyMem_Free(_children); |
| 19924 | _PyPegen_insert_memo(p, _start_mark, _loop0_77_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19925 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19926 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19927 | } |
| 19928 | |
| 19929 | // _loop1_78: lambda_param_no_default |
| 19930 | static asdl_seq * |
| 19931 | _loop1_78_rule(Parser *p) |
| 19932 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19933 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19934 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19935 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19936 | return NULL; |
| 19937 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19938 | void *_res = NULL; |
| 19939 | int _mark = p->mark; |
| 19940 | int _start_mark = p->mark; |
| 19941 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19942 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19943 | p->error_indicator = 1; |
| 19944 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19945 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19946 | return NULL; |
| 19947 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19948 | ssize_t _children_capacity = 1; |
| 19949 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19950 | { // lambda_param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19951 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19952 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19953 | return NULL; |
| 19954 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19955 | D(fprintf(stderr, "%*c> _loop1_78[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19956 | arg_ty lambda_param_no_default_var; |
| 19957 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19958 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19959 | ) |
| 19960 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19961 | _res = lambda_param_no_default_var; |
| 19962 | if (_n == _children_capacity) { |
| 19963 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19964 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19965 | if (!_new_children) { |
| 19966 | p->error_indicator = 1; |
| 19967 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19968 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19969 | return NULL; |
| 19970 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19971 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19972 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19973 | _children[_n++] = _res; |
| 19974 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19975 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19976 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19977 | D(fprintf(stderr, "%*c%s _loop1_78[%d-%d]: %s failed!\n", p->level, ' ', |
| 19978 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19979 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19980 | if (_n == 0 || p->error_indicator) { |
| 19981 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19982 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19983 | return NULL; |
| 19984 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19985 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 19986 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19987 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19988 | p->error_indicator = 1; |
| 19989 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19990 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19991 | return NULL; |
| 19992 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19993 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 19994 | PyMem_Free(_children); |
| 19995 | _PyPegen_insert_memo(p, _start_mark, _loop1_78_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 19996 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19997 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 19998 | } |
| 19999 | |
| 20000 | // _loop0_79: lambda_param_with_default |
| 20001 | static asdl_seq * |
| 20002 | _loop0_79_rule(Parser *p) |
| 20003 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20004 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20005 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20006 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20007 | return NULL; |
| 20008 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20009 | void *_res = NULL; |
| 20010 | int _mark = p->mark; |
| 20011 | int _start_mark = p->mark; |
| 20012 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20013 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20014 | p->error_indicator = 1; |
| 20015 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20016 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20017 | return NULL; |
| 20018 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20019 | ssize_t _children_capacity = 1; |
| 20020 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20021 | { // lambda_param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20022 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20023 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20024 | return NULL; |
| 20025 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20026 | D(fprintf(stderr, "%*c> _loop0_79[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20027 | NameDefaultPair* lambda_param_with_default_var; |
| 20028 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 20029 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20030 | ) |
| 20031 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20032 | _res = lambda_param_with_default_var; |
| 20033 | if (_n == _children_capacity) { |
| 20034 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20035 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20036 | if (!_new_children) { |
| 20037 | p->error_indicator = 1; |
| 20038 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20039 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20040 | return NULL; |
| 20041 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20042 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20043 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20044 | _children[_n++] = _res; |
| 20045 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20046 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20047 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20048 | D(fprintf(stderr, "%*c%s _loop0_79[%d-%d]: %s failed!\n", p->level, ' ', |
| 20049 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20050 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20051 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 20052 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20053 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20054 | p->error_indicator = 1; |
| 20055 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20056 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20057 | return NULL; |
| 20058 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20059 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 20060 | PyMem_Free(_children); |
| 20061 | _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20062 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20063 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20064 | } |
| 20065 | |
| 20066 | // _loop1_80: lambda_param_with_default |
| 20067 | static asdl_seq * |
| 20068 | _loop1_80_rule(Parser *p) |
| 20069 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20070 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20071 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20072 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20073 | return NULL; |
| 20074 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20075 | void *_res = NULL; |
| 20076 | int _mark = p->mark; |
| 20077 | int _start_mark = p->mark; |
| 20078 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20079 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20080 | p->error_indicator = 1; |
| 20081 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20082 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20083 | return NULL; |
| 20084 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20085 | ssize_t _children_capacity = 1; |
| 20086 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20087 | { // lambda_param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20088 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20089 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20090 | return NULL; |
| 20091 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20092 | D(fprintf(stderr, "%*c> _loop1_80[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20093 | NameDefaultPair* lambda_param_with_default_var; |
| 20094 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 20095 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20096 | ) |
| 20097 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20098 | _res = lambda_param_with_default_var; |
| 20099 | if (_n == _children_capacity) { |
| 20100 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20101 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20102 | if (!_new_children) { |
| 20103 | p->error_indicator = 1; |
| 20104 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20105 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20106 | return NULL; |
| 20107 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20108 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20109 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20110 | _children[_n++] = _res; |
| 20111 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20112 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20113 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20114 | D(fprintf(stderr, "%*c%s _loop1_80[%d-%d]: %s failed!\n", p->level, ' ', |
| 20115 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20116 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20117 | if (_n == 0 || p->error_indicator) { |
| 20118 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20119 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20120 | return NULL; |
| 20121 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20122 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 20123 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20124 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20125 | p->error_indicator = 1; |
| 20126 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20127 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20128 | return NULL; |
| 20129 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20130 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 20131 | PyMem_Free(_children); |
| 20132 | _PyPegen_insert_memo(p, _start_mark, _loop1_80_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20133 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20134 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20135 | } |
| 20136 | |
| 20137 | // _loop1_81: lambda_param_no_default |
| 20138 | static asdl_seq * |
| 20139 | _loop1_81_rule(Parser *p) |
| 20140 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20141 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20142 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20143 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20144 | return NULL; |
| 20145 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20146 | void *_res = NULL; |
| 20147 | int _mark = p->mark; |
| 20148 | int _start_mark = p->mark; |
| 20149 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20150 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20151 | p->error_indicator = 1; |
| 20152 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20153 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20154 | return NULL; |
| 20155 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20156 | ssize_t _children_capacity = 1; |
| 20157 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20158 | { // lambda_param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20159 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20160 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20161 | return NULL; |
| 20162 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20163 | D(fprintf(stderr, "%*c> _loop1_81[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20164 | arg_ty lambda_param_no_default_var; |
| 20165 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 20166 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20167 | ) |
| 20168 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20169 | _res = lambda_param_no_default_var; |
| 20170 | if (_n == _children_capacity) { |
| 20171 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20172 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20173 | if (!_new_children) { |
| 20174 | p->error_indicator = 1; |
| 20175 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20176 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20177 | return NULL; |
| 20178 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20179 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20180 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20181 | _children[_n++] = _res; |
| 20182 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20183 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20184 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20185 | D(fprintf(stderr, "%*c%s _loop1_81[%d-%d]: %s failed!\n", p->level, ' ', |
| 20186 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20187 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20188 | if (_n == 0 || p->error_indicator) { |
| 20189 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20190 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20191 | return NULL; |
| 20192 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20193 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 20194 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20195 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20196 | p->error_indicator = 1; |
| 20197 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20198 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20199 | return NULL; |
| 20200 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20201 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 20202 | PyMem_Free(_children); |
| 20203 | _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20204 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20205 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20206 | } |
| 20207 | |
| 20208 | // _loop1_82: lambda_param_no_default |
| 20209 | static asdl_seq * |
| 20210 | _loop1_82_rule(Parser *p) |
| 20211 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20212 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20213 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20214 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20215 | return NULL; |
| 20216 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20217 | void *_res = NULL; |
| 20218 | int _mark = p->mark; |
| 20219 | int _start_mark = p->mark; |
| 20220 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20221 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20222 | p->error_indicator = 1; |
| 20223 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20224 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20225 | return NULL; |
| 20226 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20227 | ssize_t _children_capacity = 1; |
| 20228 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20229 | { // lambda_param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20230 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20231 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20232 | return NULL; |
| 20233 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20234 | D(fprintf(stderr, "%*c> _loop1_82[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20235 | arg_ty lambda_param_no_default_var; |
| 20236 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 20237 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20238 | ) |
| 20239 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20240 | _res = lambda_param_no_default_var; |
| 20241 | if (_n == _children_capacity) { |
| 20242 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20243 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20244 | if (!_new_children) { |
| 20245 | p->error_indicator = 1; |
| 20246 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20247 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20248 | return NULL; |
| 20249 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20250 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20251 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20252 | _children[_n++] = _res; |
| 20253 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20254 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20255 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20256 | D(fprintf(stderr, "%*c%s _loop1_82[%d-%d]: %s failed!\n", p->level, ' ', |
| 20257 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20258 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20259 | if (_n == 0 || p->error_indicator) { |
| 20260 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20261 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20262 | return NULL; |
| 20263 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20264 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 20265 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20266 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20267 | p->error_indicator = 1; |
| 20268 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20269 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20270 | return NULL; |
| 20271 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20272 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 20273 | PyMem_Free(_children); |
| 20274 | _PyPegen_insert_memo(p, _start_mark, _loop1_82_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20275 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20276 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20277 | } |
| 20278 | |
| 20279 | // _loop0_83: lambda_param_no_default |
| 20280 | static asdl_seq * |
| 20281 | _loop0_83_rule(Parser *p) |
| 20282 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20283 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20284 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20285 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20286 | return NULL; |
| 20287 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20288 | void *_res = NULL; |
| 20289 | int _mark = p->mark; |
| 20290 | int _start_mark = p->mark; |
| 20291 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20292 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20293 | p->error_indicator = 1; |
| 20294 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20295 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20296 | return NULL; |
| 20297 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20298 | ssize_t _children_capacity = 1; |
| 20299 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20300 | { // lambda_param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20301 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20302 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20303 | return NULL; |
| 20304 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20305 | D(fprintf(stderr, "%*c> _loop0_83[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20306 | arg_ty lambda_param_no_default_var; |
| 20307 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 20308 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20309 | ) |
| 20310 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20311 | _res = lambda_param_no_default_var; |
| 20312 | if (_n == _children_capacity) { |
| 20313 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20314 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20315 | if (!_new_children) { |
| 20316 | p->error_indicator = 1; |
| 20317 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20318 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20319 | return NULL; |
| 20320 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20321 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20322 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20323 | _children[_n++] = _res; |
| 20324 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20325 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20326 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20327 | D(fprintf(stderr, "%*c%s _loop0_83[%d-%d]: %s failed!\n", p->level, ' ', |
| 20328 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20329 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20330 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 20331 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20332 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20333 | p->error_indicator = 1; |
| 20334 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20335 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20336 | return NULL; |
| 20337 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20338 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 20339 | PyMem_Free(_children); |
| 20340 | _PyPegen_insert_memo(p, _start_mark, _loop0_83_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20341 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20342 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20343 | } |
| 20344 | |
| 20345 | // _loop1_84: lambda_param_with_default |
| 20346 | static asdl_seq * |
| 20347 | _loop1_84_rule(Parser *p) |
| 20348 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20349 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20350 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20351 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20352 | return NULL; |
| 20353 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20354 | void *_res = NULL; |
| 20355 | int _mark = p->mark; |
| 20356 | int _start_mark = p->mark; |
| 20357 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20358 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20359 | p->error_indicator = 1; |
| 20360 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20361 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20362 | return NULL; |
| 20363 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20364 | ssize_t _children_capacity = 1; |
| 20365 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20366 | { // lambda_param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20367 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20368 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20369 | return NULL; |
| 20370 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20371 | D(fprintf(stderr, "%*c> _loop1_84[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20372 | NameDefaultPair* lambda_param_with_default_var; |
| 20373 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 20374 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20375 | ) |
| 20376 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20377 | _res = lambda_param_with_default_var; |
| 20378 | if (_n == _children_capacity) { |
| 20379 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20380 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20381 | if (!_new_children) { |
| 20382 | p->error_indicator = 1; |
| 20383 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20384 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20385 | return NULL; |
| 20386 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20387 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20388 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20389 | _children[_n++] = _res; |
| 20390 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20391 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20392 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20393 | D(fprintf(stderr, "%*c%s _loop1_84[%d-%d]: %s failed!\n", p->level, ' ', |
| 20394 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20395 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20396 | if (_n == 0 || p->error_indicator) { |
| 20397 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20398 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20399 | return NULL; |
| 20400 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20401 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 20402 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20403 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20404 | p->error_indicator = 1; |
| 20405 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20406 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20407 | return NULL; |
| 20408 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20409 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 20410 | PyMem_Free(_children); |
| 20411 | _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20412 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20413 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20414 | } |
| 20415 | |
| 20416 | // _loop0_85: lambda_param_no_default |
| 20417 | static asdl_seq * |
| 20418 | _loop0_85_rule(Parser *p) |
| 20419 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20420 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20421 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20422 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20423 | return NULL; |
| 20424 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20425 | void *_res = NULL; |
| 20426 | int _mark = p->mark; |
| 20427 | int _start_mark = p->mark; |
| 20428 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20429 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20430 | p->error_indicator = 1; |
| 20431 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20432 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20433 | return NULL; |
| 20434 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20435 | ssize_t _children_capacity = 1; |
| 20436 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20437 | { // lambda_param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20438 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20439 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20440 | return NULL; |
| 20441 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20442 | D(fprintf(stderr, "%*c> _loop0_85[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20443 | arg_ty lambda_param_no_default_var; |
| 20444 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 20445 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20446 | ) |
| 20447 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20448 | _res = lambda_param_no_default_var; |
| 20449 | if (_n == _children_capacity) { |
| 20450 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20451 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20452 | if (!_new_children) { |
| 20453 | p->error_indicator = 1; |
| 20454 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20455 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20456 | return NULL; |
| 20457 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20458 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20459 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20460 | _children[_n++] = _res; |
| 20461 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20462 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20463 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20464 | D(fprintf(stderr, "%*c%s _loop0_85[%d-%d]: %s failed!\n", p->level, ' ', |
| 20465 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20466 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20467 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 20468 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20469 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20470 | p->error_indicator = 1; |
| 20471 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20472 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20473 | return NULL; |
| 20474 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20475 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 20476 | PyMem_Free(_children); |
| 20477 | _PyPegen_insert_memo(p, _start_mark, _loop0_85_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20478 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20479 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20480 | } |
| 20481 | |
| 20482 | // _loop1_86: lambda_param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20483 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 20484 | _loop1_86_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20485 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20486 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20487 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20488 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20489 | return NULL; |
| 20490 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20491 | void *_res = NULL; |
| 20492 | int _mark = p->mark; |
| 20493 | int _start_mark = p->mark; |
| 20494 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20495 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20496 | p->error_indicator = 1; |
| 20497 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20498 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20499 | return NULL; |
| 20500 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20501 | ssize_t _children_capacity = 1; |
| 20502 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20503 | { // lambda_param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20504 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20505 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20506 | return NULL; |
| 20507 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20508 | D(fprintf(stderr, "%*c> _loop1_86[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20509 | NameDefaultPair* lambda_param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20510 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 20511 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20512 | ) |
| 20513 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20514 | _res = lambda_param_with_default_var; |
| 20515 | if (_n == _children_capacity) { |
| 20516 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20517 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20518 | if (!_new_children) { |
| 20519 | p->error_indicator = 1; |
| 20520 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20521 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20522 | return NULL; |
| 20523 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20524 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20525 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20526 | _children[_n++] = _res; |
| 20527 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20528 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20529 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20530 | D(fprintf(stderr, "%*c%s _loop1_86[%d-%d]: %s failed!\n", p->level, ' ', |
| 20531 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20532 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20533 | if (_n == 0 || p->error_indicator) { |
| 20534 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20535 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20536 | return NULL; |
| 20537 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20538 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 20539 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20540 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20541 | p->error_indicator = 1; |
| 20542 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20543 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20544 | return NULL; |
| 20545 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20546 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 20547 | PyMem_Free(_children); |
| 20548 | _PyPegen_insert_memo(p, _start_mark, _loop1_86_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20549 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20550 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20551 | } |
| 20552 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20553 | // _loop0_87: lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20554 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20555 | _loop0_87_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20556 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20557 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20558 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20559 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20560 | return NULL; |
| 20561 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20562 | void *_res = NULL; |
| 20563 | int _mark = p->mark; |
| 20564 | int _start_mark = p->mark; |
| 20565 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20566 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20567 | p->error_indicator = 1; |
| 20568 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20569 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20570 | return NULL; |
| 20571 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20572 | ssize_t _children_capacity = 1; |
| 20573 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20574 | { // lambda_param_maybe_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20575 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20576 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20577 | return NULL; |
| 20578 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20579 | D(fprintf(stderr, "%*c> _loop0_87[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20580 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20581 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 20582 | (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20583 | ) |
| 20584 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20585 | _res = lambda_param_maybe_default_var; |
| 20586 | if (_n == _children_capacity) { |
| 20587 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20588 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20589 | if (!_new_children) { |
| 20590 | p->error_indicator = 1; |
| 20591 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20592 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20593 | return NULL; |
| 20594 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20595 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20596 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20597 | _children[_n++] = _res; |
| 20598 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20599 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20600 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20601 | D(fprintf(stderr, "%*c%s _loop0_87[%d-%d]: %s failed!\n", p->level, ' ', |
| 20602 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20603 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20604 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 20605 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20606 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20607 | p->error_indicator = 1; |
| 20608 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20609 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20610 | return NULL; |
| 20611 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20612 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 20613 | PyMem_Free(_children); |
| 20614 | _PyPegen_insert_memo(p, _start_mark, _loop0_87_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20615 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20616 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20617 | } |
| 20618 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20619 | // _loop1_88: lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20620 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20621 | _loop1_88_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20622 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20623 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20624 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20625 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20626 | return NULL; |
| 20627 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20628 | void *_res = NULL; |
| 20629 | int _mark = p->mark; |
| 20630 | int _start_mark = p->mark; |
| 20631 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20632 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20633 | p->error_indicator = 1; |
| 20634 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20635 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20636 | return NULL; |
| 20637 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20638 | ssize_t _children_capacity = 1; |
| 20639 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20640 | { // lambda_param_maybe_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20641 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20642 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20643 | return NULL; |
| 20644 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20645 | D(fprintf(stderr, "%*c> _loop1_88[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_maybe_default")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20646 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20647 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 20648 | (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20649 | ) |
| 20650 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20651 | _res = lambda_param_maybe_default_var; |
| 20652 | if (_n == _children_capacity) { |
| 20653 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20654 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20655 | if (!_new_children) { |
| 20656 | p->error_indicator = 1; |
| 20657 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20658 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20659 | return NULL; |
| 20660 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20661 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20662 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20663 | _children[_n++] = _res; |
| 20664 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20665 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20666 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20667 | D(fprintf(stderr, "%*c%s _loop1_88[%d-%d]: %s failed!\n", p->level, ' ', |
| 20668 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_maybe_default")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20669 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20670 | if (_n == 0 || p->error_indicator) { |
| 20671 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20672 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20673 | return NULL; |
| 20674 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20675 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 20676 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20677 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20678 | p->error_indicator = 1; |
| 20679 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20680 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20681 | return NULL; |
| 20682 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20683 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 20684 | PyMem_Free(_children); |
| 20685 | _PyPegen_insert_memo(p, _start_mark, _loop1_88_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20686 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20687 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20688 | } |
| 20689 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20690 | // _loop1_89: ('or' conjunction) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20691 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20692 | _loop1_89_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20693 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20694 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20695 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20696 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20697 | return NULL; |
| 20698 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20699 | void *_res = NULL; |
| 20700 | int _mark = p->mark; |
| 20701 | int _start_mark = p->mark; |
| 20702 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20703 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20704 | p->error_indicator = 1; |
| 20705 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20706 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20707 | return NULL; |
| 20708 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20709 | ssize_t _children_capacity = 1; |
| 20710 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20711 | { // ('or' conjunction) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20712 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20713 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20714 | return NULL; |
| 20715 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20716 | D(fprintf(stderr, "%*c> _loop1_89[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('or' conjunction)")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 20717 | void *_tmp_144_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20718 | while ( |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 20719 | (_tmp_144_var = _tmp_144_rule(p)) // 'or' conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20720 | ) |
| 20721 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 20722 | _res = _tmp_144_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20723 | if (_n == _children_capacity) { |
| 20724 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20725 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20726 | if (!_new_children) { |
| 20727 | p->error_indicator = 1; |
| 20728 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20729 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20730 | return NULL; |
| 20731 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20732 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20733 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20734 | _children[_n++] = _res; |
| 20735 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20736 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20737 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20738 | D(fprintf(stderr, "%*c%s _loop1_89[%d-%d]: %s failed!\n", p->level, ' ', |
| 20739 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('or' conjunction)")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20740 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20741 | if (_n == 0 || p->error_indicator) { |
| 20742 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20743 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20744 | return NULL; |
| 20745 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20746 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 20747 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20748 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20749 | p->error_indicator = 1; |
| 20750 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20751 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20752 | return NULL; |
| 20753 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20754 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 20755 | PyMem_Free(_children); |
| 20756 | _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20757 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20758 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20759 | } |
| 20760 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20761 | // _loop1_90: ('and' inversion) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20762 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20763 | _loop1_90_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20764 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20765 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20766 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20767 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20768 | return NULL; |
| 20769 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20770 | void *_res = NULL; |
| 20771 | int _mark = p->mark; |
| 20772 | int _start_mark = p->mark; |
| 20773 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20774 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20775 | p->error_indicator = 1; |
| 20776 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20777 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20778 | return NULL; |
| 20779 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20780 | ssize_t _children_capacity = 1; |
| 20781 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20782 | { // ('and' inversion) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20783 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20784 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20785 | return NULL; |
| 20786 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20787 | D(fprintf(stderr, "%*c> _loop1_90[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('and' inversion)")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 20788 | void *_tmp_145_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20789 | while ( |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 20790 | (_tmp_145_var = _tmp_145_rule(p)) // 'and' inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20791 | ) |
| 20792 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 20793 | _res = _tmp_145_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20794 | if (_n == _children_capacity) { |
| 20795 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20796 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20797 | if (!_new_children) { |
| 20798 | p->error_indicator = 1; |
| 20799 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20800 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20801 | return NULL; |
| 20802 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20803 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20804 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20805 | _children[_n++] = _res; |
| 20806 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20807 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20808 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20809 | D(fprintf(stderr, "%*c%s _loop1_90[%d-%d]: %s failed!\n", p->level, ' ', |
| 20810 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('and' inversion)")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20811 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20812 | if (_n == 0 || p->error_indicator) { |
| 20813 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20814 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20815 | return NULL; |
| 20816 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20817 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 20818 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20819 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20820 | p->error_indicator = 1; |
| 20821 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20822 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20823 | return NULL; |
| 20824 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20825 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 20826 | PyMem_Free(_children); |
| 20827 | _PyPegen_insert_memo(p, _start_mark, _loop1_90_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20828 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20829 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20830 | } |
| 20831 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20832 | // _loop1_91: compare_op_bitwise_or_pair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20833 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20834 | _loop1_91_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20835 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20836 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20837 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20838 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20839 | return NULL; |
| 20840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20841 | void *_res = NULL; |
| 20842 | int _mark = p->mark; |
| 20843 | int _start_mark = p->mark; |
| 20844 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20845 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20846 | p->error_indicator = 1; |
| 20847 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20848 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20849 | return NULL; |
| 20850 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20851 | ssize_t _children_capacity = 1; |
| 20852 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20853 | { // compare_op_bitwise_or_pair |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20854 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20855 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20856 | return NULL; |
| 20857 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20858 | D(fprintf(stderr, "%*c> _loop1_91[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "compare_op_bitwise_or_pair")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20859 | CmpopExprPair* compare_op_bitwise_or_pair_var; |
| 20860 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 20861 | (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20862 | ) |
| 20863 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20864 | _res = compare_op_bitwise_or_pair_var; |
| 20865 | if (_n == _children_capacity) { |
| 20866 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20867 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20868 | if (!_new_children) { |
| 20869 | p->error_indicator = 1; |
| 20870 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20871 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20872 | return NULL; |
| 20873 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20874 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20875 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20876 | _children[_n++] = _res; |
| 20877 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20878 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20879 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20880 | D(fprintf(stderr, "%*c%s _loop1_91[%d-%d]: %s failed!\n", p->level, ' ', |
| 20881 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compare_op_bitwise_or_pair")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20882 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20883 | if (_n == 0 || p->error_indicator) { |
| 20884 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20885 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20886 | return NULL; |
| 20887 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20888 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 20889 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20890 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20891 | p->error_indicator = 1; |
| 20892 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20893 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20894 | return NULL; |
| 20895 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20896 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 20897 | PyMem_Free(_children); |
| 20898 | _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20899 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20900 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20901 | } |
| 20902 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20903 | // _tmp_92: '!=' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 20904 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20905 | _tmp_92_rule(Parser *p) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 20906 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20907 | D(p->level++); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 20908 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20909 | D(p->level--); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 20910 | return NULL; |
| 20911 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20912 | void * _res = NULL; |
| 20913 | int _mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 20914 | { // '!=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20915 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20916 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20917 | return NULL; |
| 20918 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20919 | D(fprintf(stderr, "%*c> _tmp_92[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'!='")); |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 20920 | Token * tok; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 20921 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 20922 | (tok = _PyPegen_expect_token(p, 28)) // token='!=' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 20923 | ) |
| 20924 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20925 | D(fprintf(stderr, "%*c+ _tmp_92[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'!='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20926 | _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; |
| 20927 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 20928 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20929 | D(p->level--); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 20930 | return NULL; |
| 20931 | } |
| 20932 | goto done; |
| 20933 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20934 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20935 | D(fprintf(stderr, "%*c%s _tmp_92[%d-%d]: %s failed!\n", p->level, ' ', |
| 20936 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'!='")); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 20937 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20938 | _res = NULL; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 20939 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20940 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20941 | return _res; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 20942 | } |
| 20943 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20944 | // _loop0_94: ',' slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20945 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 20946 | _loop0_94_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20947 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20948 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20949 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20950 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20951 | return NULL; |
| 20952 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20953 | void *_res = NULL; |
| 20954 | int _mark = p->mark; |
| 20955 | int _start_mark = p->mark; |
| 20956 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 20957 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20958 | p->error_indicator = 1; |
| 20959 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20960 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20961 | return NULL; |
| 20962 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20963 | ssize_t _children_capacity = 1; |
| 20964 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20965 | { // ',' slice |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20966 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20967 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 20968 | return NULL; |
| 20969 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20970 | D(fprintf(stderr, "%*c> _loop0_94[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' slice")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20971 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20972 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20973 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20974 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20975 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 20976 | (elem = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20977 | ) |
| 20978 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20979 | _res = elem; |
| 20980 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20981 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20982 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20983 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20984 | return NULL; |
| 20985 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20986 | if (_n == _children_capacity) { |
| 20987 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20988 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 20989 | if (!_new_children) { |
| 20990 | p->error_indicator = 1; |
| 20991 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 20992 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20993 | return NULL; |
| 20994 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 20995 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20996 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 20997 | _children[_n++] = _res; |
| 20998 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 20999 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21000 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21001 | D(fprintf(stderr, "%*c%s _loop0_94[%d-%d]: %s failed!\n", p->level, ' ', |
| 21002 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' slice")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21003 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21004 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 21005 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21006 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21007 | p->error_indicator = 1; |
| 21008 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21009 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21010 | return NULL; |
| 21011 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21012 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 21013 | PyMem_Free(_children); |
| 21014 | _PyPegen_insert_memo(p, _start_mark, _loop0_94_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21015 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21016 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21017 | } |
| 21018 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21019 | // _gather_93: slice _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21020 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21021 | _gather_93_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21022 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21023 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21024 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21025 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21026 | return NULL; |
| 21027 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21028 | asdl_seq * _res = NULL; |
| 21029 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21030 | { // slice _loop0_94 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21031 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21032 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21033 | return NULL; |
| 21034 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21035 | D(fprintf(stderr, "%*c> _gather_93[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slice _loop0_94")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21036 | expr_ty elem; |
| 21037 | asdl_seq * seq; |
| 21038 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21039 | (elem = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21040 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21041 | (seq = _loop0_94_rule(p)) // _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21042 | ) |
| 21043 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21044 | D(fprintf(stderr, "%*c+ _gather_93[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slice _loop0_94")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21045 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21046 | goto done; |
| 21047 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21048 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21049 | D(fprintf(stderr, "%*c%s _gather_93[%d-%d]: %s failed!\n", p->level, ' ', |
| 21050 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slice _loop0_94")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21051 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21052 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21053 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21054 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21055 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21056 | } |
| 21057 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21058 | // _tmp_95: ':' expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21059 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21060 | _tmp_95_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21061 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21062 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21063 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21064 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21065 | return NULL; |
| 21066 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21067 | void * _res = NULL; |
| 21068 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21069 | { // ':' expression? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21070 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21071 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21072 | return NULL; |
| 21073 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21074 | D(fprintf(stderr, "%*c> _tmp_95[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':' expression?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21075 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21076 | void *d; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21077 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21078 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21079 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21080 | (d = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21081 | ) |
| 21082 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21083 | D(fprintf(stderr, "%*c+ _tmp_95[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':' expression?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21084 | _res = d; |
| 21085 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21086 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21087 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21088 | return NULL; |
| 21089 | } |
| 21090 | goto done; |
| 21091 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21092 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21093 | D(fprintf(stderr, "%*c%s _tmp_95[%d-%d]: %s failed!\n", p->level, ' ', |
| 21094 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':' expression?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21095 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21096 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21097 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21098 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21099 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21100 | } |
| 21101 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21102 | // _tmp_96: tuple | group | genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21103 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21104 | _tmp_96_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21105 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21106 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21107 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21108 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21109 | return NULL; |
| 21110 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21111 | void * _res = NULL; |
| 21112 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21113 | { // tuple |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21114 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21115 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21116 | return NULL; |
| 21117 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21118 | D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "tuple")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21119 | expr_ty tuple_var; |
| 21120 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21121 | (tuple_var = tuple_rule(p)) // tuple |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21122 | ) |
| 21123 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21124 | D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "tuple")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21125 | _res = tuple_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21126 | goto done; |
| 21127 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21128 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21129 | D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ', |
| 21130 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "tuple")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21131 | } |
| 21132 | { // group |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21133 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21134 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21135 | return NULL; |
| 21136 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21137 | D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "group")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21138 | expr_ty group_var; |
| 21139 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21140 | (group_var = group_rule(p)) // group |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21141 | ) |
| 21142 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21143 | D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "group")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21144 | _res = group_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21145 | goto done; |
| 21146 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21147 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21148 | D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ', |
| 21149 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "group")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21150 | } |
| 21151 | { // genexp |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21152 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21153 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21154 | return NULL; |
| 21155 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21156 | D(fprintf(stderr, "%*c> _tmp_96[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "genexp")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21157 | expr_ty genexp_var; |
| 21158 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21159 | (genexp_var = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21160 | ) |
| 21161 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21162 | D(fprintf(stderr, "%*c+ _tmp_96[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "genexp")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21163 | _res = genexp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21164 | goto done; |
| 21165 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21166 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21167 | D(fprintf(stderr, "%*c%s _tmp_96[%d-%d]: %s failed!\n", p->level, ' ', |
| 21168 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "genexp")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21169 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21170 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21171 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21172 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21173 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21174 | } |
| 21175 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21176 | // _tmp_97: list | listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21177 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21178 | _tmp_97_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21179 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21180 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21181 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21182 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21183 | return NULL; |
| 21184 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21185 | void * _res = NULL; |
| 21186 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21187 | { // list |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21188 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21189 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21190 | return NULL; |
| 21191 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21192 | D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "list")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21193 | expr_ty list_var; |
| 21194 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21195 | (list_var = list_rule(p)) // list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21196 | ) |
| 21197 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21198 | D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "list")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21199 | _res = list_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21200 | goto done; |
| 21201 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21202 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21203 | D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ', |
| 21204 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "list")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21205 | } |
| 21206 | { // listcomp |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21207 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21208 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21209 | return NULL; |
| 21210 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21211 | D(fprintf(stderr, "%*c> _tmp_97[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "listcomp")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21212 | expr_ty listcomp_var; |
| 21213 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21214 | (listcomp_var = listcomp_rule(p)) // listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21215 | ) |
| 21216 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21217 | D(fprintf(stderr, "%*c+ _tmp_97[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "listcomp")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21218 | _res = listcomp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21219 | goto done; |
| 21220 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21221 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21222 | D(fprintf(stderr, "%*c%s _tmp_97[%d-%d]: %s failed!\n", p->level, ' ', |
| 21223 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "listcomp")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21224 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21225 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21226 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21227 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21228 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21229 | } |
| 21230 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21231 | // _tmp_98: dict | set | dictcomp | setcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21232 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21233 | _tmp_98_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21234 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21235 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21236 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21237 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21238 | return NULL; |
| 21239 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21240 | void * _res = NULL; |
| 21241 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21242 | { // dict |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21243 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21244 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21245 | return NULL; |
| 21246 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21247 | D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dict")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21248 | expr_ty dict_var; |
| 21249 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21250 | (dict_var = dict_rule(p)) // dict |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21251 | ) |
| 21252 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21253 | D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dict")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21254 | _res = dict_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21255 | goto done; |
| 21256 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21257 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21258 | D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ', |
| 21259 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dict")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21260 | } |
| 21261 | { // set |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21262 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21263 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21264 | return NULL; |
| 21265 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21266 | D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "set")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21267 | expr_ty set_var; |
| 21268 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21269 | (set_var = set_rule(p)) // set |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21270 | ) |
| 21271 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21272 | D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "set")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21273 | _res = set_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21274 | goto done; |
| 21275 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21276 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21277 | D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ', |
| 21278 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "set")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21279 | } |
| 21280 | { // dictcomp |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21281 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21282 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21283 | return NULL; |
| 21284 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21285 | D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "dictcomp")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21286 | expr_ty dictcomp_var; |
| 21287 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21288 | (dictcomp_var = dictcomp_rule(p)) // dictcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21289 | ) |
| 21290 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21291 | D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "dictcomp")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21292 | _res = dictcomp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21293 | goto done; |
| 21294 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21295 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21296 | D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ', |
| 21297 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "dictcomp")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21298 | } |
| 21299 | { // setcomp |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21300 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21301 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21302 | return NULL; |
| 21303 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21304 | D(fprintf(stderr, "%*c> _tmp_98[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "setcomp")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21305 | expr_ty setcomp_var; |
| 21306 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21307 | (setcomp_var = setcomp_rule(p)) // setcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21308 | ) |
| 21309 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21310 | D(fprintf(stderr, "%*c+ _tmp_98[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "setcomp")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21311 | _res = setcomp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21312 | goto done; |
| 21313 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21314 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21315 | D(fprintf(stderr, "%*c%s _tmp_98[%d-%d]: %s failed!\n", p->level, ' ', |
| 21316 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "setcomp")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21317 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21318 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21319 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21320 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21321 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21322 | } |
| 21323 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21324 | // _loop1_99: STRING |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21325 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21326 | _loop1_99_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21327 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21328 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21329 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21330 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21331 | return NULL; |
| 21332 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21333 | void *_res = NULL; |
| 21334 | int _mark = p->mark; |
| 21335 | int _start_mark = p->mark; |
| 21336 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 21337 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21338 | p->error_indicator = 1; |
| 21339 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21340 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21341 | return NULL; |
| 21342 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21343 | ssize_t _children_capacity = 1; |
| 21344 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21345 | { // STRING |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21346 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21347 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21348 | return NULL; |
| 21349 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21350 | D(fprintf(stderr, "%*c> _loop1_99[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "STRING")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21351 | expr_ty string_var; |
| 21352 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21353 | (string_var = _PyPegen_string_token(p)) // STRING |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21354 | ) |
| 21355 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21356 | _res = string_var; |
| 21357 | if (_n == _children_capacity) { |
| 21358 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21359 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 21360 | if (!_new_children) { |
| 21361 | p->error_indicator = 1; |
| 21362 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21363 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21364 | return NULL; |
| 21365 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21366 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21367 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21368 | _children[_n++] = _res; |
| 21369 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21370 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21371 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21372 | D(fprintf(stderr, "%*c%s _loop1_99[%d-%d]: %s failed!\n", p->level, ' ', |
| 21373 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "STRING")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21374 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21375 | if (_n == 0 || p->error_indicator) { |
| 21376 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21377 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21378 | return NULL; |
| 21379 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21380 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 21381 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21382 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21383 | p->error_indicator = 1; |
| 21384 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21385 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21386 | return NULL; |
| 21387 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21388 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 21389 | PyMem_Free(_children); |
| 21390 | _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21391 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21392 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21393 | } |
| 21394 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21395 | // _tmp_100: star_named_expression ',' star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21396 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21397 | _tmp_100_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21398 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21399 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21400 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21401 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21402 | return NULL; |
| 21403 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21404 | void * _res = NULL; |
| 21405 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21406 | { // star_named_expression ',' star_named_expressions? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21407 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21408 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21409 | return NULL; |
| 21410 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21411 | D(fprintf(stderr, "%*c> _tmp_100[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21412 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21413 | expr_ty y; |
| 21414 | void *z; |
| 21415 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21416 | (y = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21417 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21418 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21419 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21420 | (z = star_named_expressions_rule(p), 1) // star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21421 | ) |
| 21422 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21423 | D(fprintf(stderr, "%*c+ _tmp_100[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_named_expression ',' star_named_expressions?")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21424 | _res = _PyPegen_seq_insert_in_front ( p , y , z ); |
| 21425 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21426 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21427 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21428 | return NULL; |
| 21429 | } |
| 21430 | goto done; |
| 21431 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21432 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21433 | D(fprintf(stderr, "%*c%s _tmp_100[%d-%d]: %s failed!\n", p->level, ' ', |
| 21434 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expression ',' star_named_expressions?")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21435 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21436 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21437 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21438 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21439 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21440 | } |
| 21441 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21442 | // _tmp_101: yield_expr | named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21443 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21444 | _tmp_101_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21445 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21446 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21447 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21448 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21449 | return NULL; |
| 21450 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21451 | void * _res = NULL; |
| 21452 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21453 | { // yield_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21454 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21455 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21456 | return NULL; |
| 21457 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21458 | D(fprintf(stderr, "%*c> _tmp_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21459 | expr_ty yield_expr_var; |
| 21460 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21461 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21462 | ) |
| 21463 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21464 | D(fprintf(stderr, "%*c+ _tmp_101[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21465 | _res = yield_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21466 | goto done; |
| 21467 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21468 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21469 | D(fprintf(stderr, "%*c%s _tmp_101[%d-%d]: %s failed!\n", p->level, ' ', |
| 21470 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21471 | } |
| 21472 | { // named_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21473 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21474 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21475 | return NULL; |
| 21476 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21477 | D(fprintf(stderr, "%*c> _tmp_101[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "named_expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21478 | expr_ty named_expression_var; |
| 21479 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21480 | (named_expression_var = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21481 | ) |
| 21482 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21483 | D(fprintf(stderr, "%*c+ _tmp_101[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "named_expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21484 | _res = named_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21485 | goto done; |
| 21486 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21487 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21488 | D(fprintf(stderr, "%*c%s _tmp_101[%d-%d]: %s failed!\n", p->level, ' ', |
| 21489 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "named_expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21490 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21491 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21492 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21493 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21494 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21495 | } |
| 21496 | |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 21497 | // _loop0_103: ',' double_starred_kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21498 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21499 | _loop0_103_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21500 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21501 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21502 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21503 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21504 | return NULL; |
| 21505 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21506 | void *_res = NULL; |
| 21507 | int _mark = p->mark; |
| 21508 | int _start_mark = p->mark; |
| 21509 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 21510 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21511 | p->error_indicator = 1; |
| 21512 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21513 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21514 | return NULL; |
| 21515 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21516 | ssize_t _children_capacity = 1; |
| 21517 | ssize_t _n = 0; |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 21518 | { // ',' double_starred_kvpair |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21519 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21520 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21521 | return NULL; |
| 21522 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21523 | D(fprintf(stderr, "%*c> _loop0_103[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' double_starred_kvpair")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21524 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21525 | KeyValuePair* elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21526 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21527 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21528 | && |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 21529 | (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21530 | ) |
| 21531 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21532 | _res = elem; |
| 21533 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21534 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21535 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21536 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21537 | return NULL; |
| 21538 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21539 | if (_n == _children_capacity) { |
| 21540 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21541 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 21542 | if (!_new_children) { |
| 21543 | p->error_indicator = 1; |
| 21544 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21545 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21546 | return NULL; |
| 21547 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21548 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21549 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21550 | _children[_n++] = _res; |
| 21551 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21552 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21553 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21554 | D(fprintf(stderr, "%*c%s _loop0_103[%d-%d]: %s failed!\n", p->level, ' ', |
| 21555 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' double_starred_kvpair")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21556 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21557 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 21558 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21559 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21560 | p->error_indicator = 1; |
| 21561 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21562 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21563 | return NULL; |
| 21564 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21565 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 21566 | PyMem_Free(_children); |
| 21567 | _PyPegen_insert_memo(p, _start_mark, _loop0_103_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21568 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21569 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21570 | } |
| 21571 | |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 21572 | // _gather_102: double_starred_kvpair _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21573 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21574 | _gather_102_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21575 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21576 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21577 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21578 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21579 | return NULL; |
| 21580 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21581 | asdl_seq * _res = NULL; |
| 21582 | int _mark = p->mark; |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 21583 | { // double_starred_kvpair _loop0_103 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21584 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21585 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21586 | return NULL; |
| 21587 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21588 | D(fprintf(stderr, "%*c> _gather_102[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_103")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21589 | KeyValuePair* elem; |
| 21590 | asdl_seq * seq; |
| 21591 | if ( |
Batuhan Taskaya | b8a65ec | 2020-05-22 01:39:56 +0300 | [diff] [blame] | 21592 | (elem = double_starred_kvpair_rule(p)) // double_starred_kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21593 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21594 | (seq = _loop0_103_rule(p)) // _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21595 | ) |
| 21596 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21597 | D(fprintf(stderr, "%*c+ _gather_102[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "double_starred_kvpair _loop0_103")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21598 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21599 | goto done; |
| 21600 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21601 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21602 | D(fprintf(stderr, "%*c%s _gather_102[%d-%d]: %s failed!\n", p->level, ' ', |
| 21603 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "double_starred_kvpair _loop0_103")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21604 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21605 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21606 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21607 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21608 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21609 | } |
| 21610 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21611 | // _loop1_104: for_if_clause |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21612 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21613 | _loop1_104_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21614 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21615 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21616 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21617 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21618 | return NULL; |
| 21619 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21620 | void *_res = NULL; |
| 21621 | int _mark = p->mark; |
| 21622 | int _start_mark = p->mark; |
| 21623 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 21624 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21625 | p->error_indicator = 1; |
| 21626 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21627 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21628 | return NULL; |
| 21629 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21630 | ssize_t _children_capacity = 1; |
| 21631 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21632 | { // for_if_clause |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21633 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21634 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21635 | return NULL; |
| 21636 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21637 | D(fprintf(stderr, "%*c> _loop1_104[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "for_if_clause")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21638 | comprehension_ty for_if_clause_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21639 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21640 | (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21641 | ) |
| 21642 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21643 | _res = for_if_clause_var; |
| 21644 | if (_n == _children_capacity) { |
| 21645 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21646 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 21647 | if (!_new_children) { |
| 21648 | p->error_indicator = 1; |
| 21649 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21650 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21651 | return NULL; |
| 21652 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21653 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21654 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21655 | _children[_n++] = _res; |
| 21656 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21657 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21658 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21659 | D(fprintf(stderr, "%*c%s _loop1_104[%d-%d]: %s failed!\n", p->level, ' ', |
| 21660 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "for_if_clause")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21661 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21662 | if (_n == 0 || p->error_indicator) { |
| 21663 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21664 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21665 | return NULL; |
| 21666 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21667 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 21668 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21669 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21670 | p->error_indicator = 1; |
| 21671 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21672 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21673 | return NULL; |
| 21674 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21675 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 21676 | PyMem_Free(_children); |
| 21677 | _PyPegen_insert_memo(p, _start_mark, _loop1_104_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21678 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21679 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 21680 | } |
| 21681 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21682 | // _loop0_105: ('if' disjunction) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 21683 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21684 | _loop0_105_rule(Parser *p) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 21685 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21686 | D(p->level++); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 21687 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21688 | D(p->level--); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 21689 | return NULL; |
| 21690 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21691 | void *_res = NULL; |
| 21692 | int _mark = p->mark; |
| 21693 | int _start_mark = p->mark; |
| 21694 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 21695 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21696 | p->error_indicator = 1; |
| 21697 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21698 | D(p->level--); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 21699 | return NULL; |
| 21700 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21701 | ssize_t _children_capacity = 1; |
| 21702 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21703 | { // ('if' disjunction) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21704 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21705 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21706 | return NULL; |
| 21707 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21708 | D(fprintf(stderr, "%*c> _loop0_105[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 21709 | void *_tmp_146_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 21710 | while ( |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 21711 | (_tmp_146_var = _tmp_146_rule(p)) // 'if' disjunction |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 21712 | ) |
| 21713 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 21714 | _res = _tmp_146_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21715 | if (_n == _children_capacity) { |
| 21716 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21717 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 21718 | if (!_new_children) { |
| 21719 | p->error_indicator = 1; |
| 21720 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21721 | D(p->level--); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 21722 | return NULL; |
| 21723 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21724 | _children = _new_children; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 21725 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21726 | _children[_n++] = _res; |
| 21727 | _mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 21728 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21729 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21730 | D(fprintf(stderr, "%*c%s _loop0_105[%d-%d]: %s failed!\n", p->level, ' ', |
| 21731 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 21732 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21733 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 21734 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21735 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21736 | p->error_indicator = 1; |
| 21737 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21738 | D(p->level--); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 21739 | return NULL; |
| 21740 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21741 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 21742 | PyMem_Free(_children); |
| 21743 | _PyPegen_insert_memo(p, _start_mark, _loop0_105_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21744 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21745 | return _seq; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 21746 | } |
| 21747 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21748 | // _loop0_106: ('if' disjunction) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 21749 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21750 | _loop0_106_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 21751 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21752 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 21753 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21754 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 21755 | return NULL; |
| 21756 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21757 | void *_res = NULL; |
| 21758 | int _mark = p->mark; |
| 21759 | int _start_mark = p->mark; |
| 21760 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 21761 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21762 | p->error_indicator = 1; |
| 21763 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21764 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21765 | return NULL; |
| 21766 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21767 | ssize_t _children_capacity = 1; |
| 21768 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21769 | { // ('if' disjunction) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21770 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21771 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21772 | return NULL; |
| 21773 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21774 | D(fprintf(stderr, "%*c> _loop0_106[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "('if' disjunction)")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 21775 | void *_tmp_147_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21776 | while ( |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 21777 | (_tmp_147_var = _tmp_147_rule(p)) // 'if' disjunction |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 21778 | ) |
| 21779 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 21780 | _res = _tmp_147_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21781 | if (_n == _children_capacity) { |
| 21782 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21783 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 21784 | if (!_new_children) { |
| 21785 | p->error_indicator = 1; |
| 21786 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21787 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21788 | return NULL; |
| 21789 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21790 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21791 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21792 | _children[_n++] = _res; |
| 21793 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21794 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21795 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21796 | D(fprintf(stderr, "%*c%s _loop0_106[%d-%d]: %s failed!\n", p->level, ' ', |
| 21797 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "('if' disjunction)")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21798 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21799 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 21800 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21801 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21802 | p->error_indicator = 1; |
| 21803 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21804 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21805 | return NULL; |
| 21806 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21807 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 21808 | PyMem_Free(_children); |
| 21809 | _PyPegen_insert_memo(p, _start_mark, _loop0_106_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21810 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21811 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21812 | } |
| 21813 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21814 | // _tmp_107: ',' args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21815 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21816 | _tmp_107_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21817 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21818 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21819 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21820 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21821 | return NULL; |
| 21822 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21823 | void * _res = NULL; |
| 21824 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21825 | { // ',' args |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21826 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21827 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21828 | return NULL; |
| 21829 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21830 | D(fprintf(stderr, "%*c> _tmp_107[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21831 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21832 | expr_ty c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21833 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21834 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21835 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21836 | (c = args_rule(p)) // args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21837 | ) |
| 21838 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21839 | D(fprintf(stderr, "%*c+ _tmp_107[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21840 | _res = c; |
| 21841 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21842 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21843 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21844 | return NULL; |
| 21845 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 21846 | goto done; |
| 21847 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21848 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21849 | D(fprintf(stderr, "%*c%s _tmp_107[%d-%d]: %s failed!\n", p->level, ' ', |
| 21850 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 21851 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21852 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 21853 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21854 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21855 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 21856 | } |
| 21857 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21858 | // _tmp_108: ',' args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21859 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21860 | _tmp_108_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21861 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21862 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21863 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21864 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21865 | return NULL; |
| 21866 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21867 | void * _res = NULL; |
| 21868 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21869 | { // ',' args |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21870 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21871 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21872 | return NULL; |
| 21873 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21874 | D(fprintf(stderr, "%*c> _tmp_108[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' args")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21875 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21876 | expr_ty c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21877 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21878 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21879 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21880 | (c = args_rule(p)) // args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21881 | ) |
| 21882 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21883 | D(fprintf(stderr, "%*c+ _tmp_108[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' args")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21884 | _res = c; |
| 21885 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21886 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21887 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21888 | return NULL; |
| 21889 | } |
| 21890 | goto done; |
| 21891 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21892 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21893 | D(fprintf(stderr, "%*c%s _tmp_108[%d-%d]: %s failed!\n", p->level, ' ', |
| 21894 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' args")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21895 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21896 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21897 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21898 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21899 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 21900 | } |
| 21901 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21902 | // _loop0_110: ',' kwarg_or_starred |
| 21903 | static asdl_seq * |
| 21904 | _loop0_110_rule(Parser *p) |
| 21905 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21906 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21907 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21908 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21909 | return NULL; |
| 21910 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21911 | void *_res = NULL; |
| 21912 | int _mark = p->mark; |
| 21913 | int _start_mark = p->mark; |
| 21914 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 21915 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21916 | p->error_indicator = 1; |
| 21917 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21918 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21919 | return NULL; |
| 21920 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21921 | ssize_t _children_capacity = 1; |
| 21922 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21923 | { // ',' kwarg_or_starred |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21924 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21925 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21926 | return NULL; |
| 21927 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21928 | D(fprintf(stderr, "%*c> _loop0_110[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21929 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21930 | KeywordOrStarred* elem; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21931 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21932 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21933 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21934 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21935 | ) |
| 21936 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21937 | _res = elem; |
| 21938 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21939 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21940 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21941 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21942 | return NULL; |
| 21943 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21944 | if (_n == _children_capacity) { |
| 21945 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21946 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 21947 | if (!_new_children) { |
| 21948 | p->error_indicator = 1; |
| 21949 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21950 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21951 | return NULL; |
| 21952 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21953 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21954 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21955 | _children[_n++] = _res; |
| 21956 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21957 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21958 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21959 | D(fprintf(stderr, "%*c%s _loop0_110[%d-%d]: %s failed!\n", p->level, ' ', |
| 21960 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21961 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21962 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 21963 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21964 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 21965 | p->error_indicator = 1; |
| 21966 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21967 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21968 | return NULL; |
| 21969 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21970 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 21971 | PyMem_Free(_children); |
| 21972 | _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21973 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21974 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21975 | } |
| 21976 | |
| 21977 | // _gather_109: kwarg_or_starred _loop0_110 |
| 21978 | static asdl_seq * |
| 21979 | _gather_109_rule(Parser *p) |
| 21980 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21981 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21982 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21983 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21984 | return NULL; |
| 21985 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 21986 | asdl_seq * _res = NULL; |
| 21987 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21988 | { // kwarg_or_starred _loop0_110 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21989 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21990 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 21991 | return NULL; |
| 21992 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 21993 | D(fprintf(stderr, "%*c> _gather_109[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_110")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21994 | KeywordOrStarred* elem; |
| 21995 | asdl_seq * seq; |
| 21996 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21997 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 21998 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 21999 | (seq = _loop0_110_rule(p)) // _loop0_110 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22000 | ) |
| 22001 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22002 | D(fprintf(stderr, "%*c+ _gather_109[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_110")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22003 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22004 | goto done; |
| 22005 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22006 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22007 | D(fprintf(stderr, "%*c%s _gather_109[%d-%d]: %s failed!\n", p->level, ' ', |
| 22008 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_110")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22009 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22010 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22011 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22012 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22013 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22014 | } |
| 22015 | |
| 22016 | // _loop0_112: ',' kwarg_or_double_starred |
| 22017 | static asdl_seq * |
| 22018 | _loop0_112_rule(Parser *p) |
| 22019 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22020 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22021 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22022 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22023 | return NULL; |
| 22024 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22025 | void *_res = NULL; |
| 22026 | int _mark = p->mark; |
| 22027 | int _start_mark = p->mark; |
| 22028 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 22029 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22030 | p->error_indicator = 1; |
| 22031 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22032 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22033 | return NULL; |
| 22034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22035 | ssize_t _children_capacity = 1; |
| 22036 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22037 | { // ',' kwarg_or_double_starred |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22038 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22039 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22040 | return NULL; |
| 22041 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22042 | D(fprintf(stderr, "%*c> _loop0_112[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22043 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22044 | KeywordOrStarred* elem; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22045 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22046 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22047 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22048 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22049 | ) |
| 22050 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22051 | _res = elem; |
| 22052 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22053 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22054 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22055 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22056 | return NULL; |
| 22057 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22058 | if (_n == _children_capacity) { |
| 22059 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22060 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 22061 | if (!_new_children) { |
| 22062 | p->error_indicator = 1; |
| 22063 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22064 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22065 | return NULL; |
| 22066 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22067 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22068 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22069 | _children[_n++] = _res; |
| 22070 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22071 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22072 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22073 | D(fprintf(stderr, "%*c%s _loop0_112[%d-%d]: %s failed!\n", p->level, ' ', |
| 22074 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22075 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22076 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 22077 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22078 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22079 | p->error_indicator = 1; |
| 22080 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22081 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22082 | return NULL; |
| 22083 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22084 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 22085 | PyMem_Free(_children); |
| 22086 | _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22087 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22088 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22089 | } |
| 22090 | |
| 22091 | // _gather_111: kwarg_or_double_starred _loop0_112 |
| 22092 | static asdl_seq * |
| 22093 | _gather_111_rule(Parser *p) |
| 22094 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22095 | D(p->level++); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22096 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22097 | D(p->level--); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22098 | return NULL; |
| 22099 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22100 | asdl_seq * _res = NULL; |
| 22101 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22102 | { // kwarg_or_double_starred _loop0_112 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22103 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22104 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22105 | return NULL; |
| 22106 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22107 | D(fprintf(stderr, "%*c> _gather_111[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_112")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22108 | KeywordOrStarred* elem; |
| 22109 | asdl_seq * seq; |
| 22110 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22111 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22112 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22113 | (seq = _loop0_112_rule(p)) // _loop0_112 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22114 | ) |
| 22115 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22116 | D(fprintf(stderr, "%*c+ _gather_111[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_112")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22117 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22118 | goto done; |
| 22119 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22120 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22121 | D(fprintf(stderr, "%*c%s _gather_111[%d-%d]: %s failed!\n", p->level, ' ', |
| 22122 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_112")); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22123 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22124 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22125 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22126 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22127 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22128 | } |
| 22129 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22130 | // _loop0_114: ',' kwarg_or_starred |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 22131 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22132 | _loop0_114_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22133 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22134 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22135 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22136 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22137 | return NULL; |
| 22138 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22139 | void *_res = NULL; |
| 22140 | int _mark = p->mark; |
| 22141 | int _start_mark = p->mark; |
| 22142 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 22143 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22144 | p->error_indicator = 1; |
| 22145 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22146 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22147 | return NULL; |
| 22148 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22149 | ssize_t _children_capacity = 1; |
| 22150 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22151 | { // ',' kwarg_or_starred |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22152 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22153 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22154 | return NULL; |
| 22155 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22156 | D(fprintf(stderr, "%*c> _loop0_114[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_starred")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22157 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22158 | KeywordOrStarred* elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22159 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22160 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22161 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22162 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22163 | ) |
| 22164 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22165 | _res = elem; |
| 22166 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22167 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22168 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22169 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22170 | return NULL; |
| 22171 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22172 | if (_n == _children_capacity) { |
| 22173 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22174 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 22175 | if (!_new_children) { |
| 22176 | p->error_indicator = 1; |
| 22177 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22178 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22179 | return NULL; |
| 22180 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22181 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22182 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22183 | _children[_n++] = _res; |
| 22184 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22185 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22186 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22187 | D(fprintf(stderr, "%*c%s _loop0_114[%d-%d]: %s failed!\n", p->level, ' ', |
| 22188 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_starred")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22189 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22190 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 22191 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22192 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22193 | p->error_indicator = 1; |
| 22194 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22195 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22196 | return NULL; |
| 22197 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22198 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 22199 | PyMem_Free(_children); |
| 22200 | _PyPegen_insert_memo(p, _start_mark, _loop0_114_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22201 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22202 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22203 | } |
| 22204 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22205 | // _gather_113: kwarg_or_starred _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22206 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22207 | _gather_113_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22208 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22209 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22210 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22211 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22212 | return NULL; |
| 22213 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22214 | asdl_seq * _res = NULL; |
| 22215 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22216 | { // kwarg_or_starred _loop0_114 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22217 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22218 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22219 | return NULL; |
| 22220 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22221 | D(fprintf(stderr, "%*c> _gather_113[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_114")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22222 | KeywordOrStarred* elem; |
| 22223 | asdl_seq * seq; |
| 22224 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22225 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22226 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22227 | (seq = _loop0_114_rule(p)) // _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22228 | ) |
| 22229 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22230 | D(fprintf(stderr, "%*c+ _gather_113[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_starred _loop0_114")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22231 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22232 | goto done; |
| 22233 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22234 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22235 | D(fprintf(stderr, "%*c%s _gather_113[%d-%d]: %s failed!\n", p->level, ' ', |
| 22236 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_starred _loop0_114")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22237 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22238 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22239 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22240 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22241 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22242 | } |
| 22243 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22244 | // _loop0_116: ',' kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22245 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22246 | _loop0_116_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22247 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22248 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22249 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22250 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22251 | return NULL; |
| 22252 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22253 | void *_res = NULL; |
| 22254 | int _mark = p->mark; |
| 22255 | int _start_mark = p->mark; |
| 22256 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 22257 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22258 | p->error_indicator = 1; |
| 22259 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22260 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22261 | return NULL; |
| 22262 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22263 | ssize_t _children_capacity = 1; |
| 22264 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22265 | { // ',' kwarg_or_double_starred |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22266 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22267 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22268 | return NULL; |
| 22269 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22270 | D(fprintf(stderr, "%*c> _loop0_116[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' kwarg_or_double_starred")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22271 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22272 | KeywordOrStarred* elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22273 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22274 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22275 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22276 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22277 | ) |
| 22278 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22279 | _res = elem; |
| 22280 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22281 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22282 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22283 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22284 | return NULL; |
| 22285 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22286 | if (_n == _children_capacity) { |
| 22287 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22288 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 22289 | if (!_new_children) { |
| 22290 | p->error_indicator = 1; |
| 22291 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22292 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22293 | return NULL; |
| 22294 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22295 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22296 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22297 | _children[_n++] = _res; |
| 22298 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22299 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22300 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22301 | D(fprintf(stderr, "%*c%s _loop0_116[%d-%d]: %s failed!\n", p->level, ' ', |
| 22302 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' kwarg_or_double_starred")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22303 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22304 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 22305 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22306 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22307 | p->error_indicator = 1; |
| 22308 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22309 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22310 | return NULL; |
| 22311 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22312 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 22313 | PyMem_Free(_children); |
| 22314 | _PyPegen_insert_memo(p, _start_mark, _loop0_116_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22315 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22316 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22317 | } |
| 22318 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22319 | // _gather_115: kwarg_or_double_starred _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22320 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22321 | _gather_115_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22322 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22323 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22324 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22325 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22326 | return NULL; |
| 22327 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22328 | asdl_seq * _res = NULL; |
| 22329 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22330 | { // kwarg_or_double_starred _loop0_116 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22331 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22332 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22333 | return NULL; |
| 22334 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22335 | D(fprintf(stderr, "%*c> _gather_115[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_116")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22336 | KeywordOrStarred* elem; |
| 22337 | asdl_seq * seq; |
| 22338 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22339 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22340 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22341 | (seq = _loop0_116_rule(p)) // _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22342 | ) |
| 22343 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22344 | D(fprintf(stderr, "%*c+ _gather_115[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "kwarg_or_double_starred _loop0_116")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22345 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22346 | goto done; |
| 22347 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22348 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22349 | D(fprintf(stderr, "%*c%s _gather_115[%d-%d]: %s failed!\n", p->level, ' ', |
| 22350 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "kwarg_or_double_starred _loop0_116")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22351 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22352 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22353 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22354 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22355 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22356 | } |
| 22357 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22358 | // _loop0_117: (',' star_target) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22359 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22360 | _loop0_117_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22361 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22362 | D(p->level++); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22363 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22364 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22365 | return NULL; |
| 22366 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22367 | void *_res = NULL; |
| 22368 | int _mark = p->mark; |
| 22369 | int _start_mark = p->mark; |
| 22370 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 22371 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22372 | p->error_indicator = 1; |
| 22373 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22374 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22375 | return NULL; |
| 22376 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22377 | ssize_t _children_capacity = 1; |
| 22378 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22379 | { // (',' star_target) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22380 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22381 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22382 | return NULL; |
| 22383 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22384 | D(fprintf(stderr, "%*c> _loop0_117[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(',' star_target)")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 22385 | void *_tmp_148_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22386 | while ( |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 22387 | (_tmp_148_var = _tmp_148_rule(p)) // ',' star_target |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22388 | ) |
| 22389 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 22390 | _res = _tmp_148_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22391 | if (_n == _children_capacity) { |
| 22392 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22393 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 22394 | if (!_new_children) { |
| 22395 | p->error_indicator = 1; |
| 22396 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22397 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22398 | return NULL; |
| 22399 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22400 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22401 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22402 | _children[_n++] = _res; |
| 22403 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22404 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22405 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22406 | D(fprintf(stderr, "%*c%s _loop0_117[%d-%d]: %s failed!\n", p->level, ' ', |
| 22407 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(',' star_target)")); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22408 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22409 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 22410 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22411 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22412 | p->error_indicator = 1; |
| 22413 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22414 | D(p->level--); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22415 | return NULL; |
| 22416 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22417 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 22418 | PyMem_Free(_children); |
| 22419 | _PyPegen_insert_memo(p, _start_mark, _loop0_117_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22420 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22421 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22422 | } |
| 22423 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22424 | // _loop0_119: ',' star_target |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 22425 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22426 | _loop0_119_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22427 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22428 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22429 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22430 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22431 | return NULL; |
| 22432 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22433 | void *_res = NULL; |
| 22434 | int _mark = p->mark; |
| 22435 | int _start_mark = p->mark; |
| 22436 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 22437 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22438 | p->error_indicator = 1; |
| 22439 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22440 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 22441 | return NULL; |
| 22442 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22443 | ssize_t _children_capacity = 1; |
| 22444 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22445 | { // ',' star_target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22446 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22447 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22448 | return NULL; |
| 22449 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22450 | D(fprintf(stderr, "%*c> _loop0_119[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22451 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22452 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22453 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22454 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22455 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22456 | (elem = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22457 | ) |
| 22458 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22459 | _res = elem; |
| 22460 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22461 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22462 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22463 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22464 | return NULL; |
| 22465 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22466 | if (_n == _children_capacity) { |
| 22467 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22468 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 22469 | if (!_new_children) { |
| 22470 | p->error_indicator = 1; |
| 22471 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22472 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22473 | return NULL; |
| 22474 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22475 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22476 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22477 | _children[_n++] = _res; |
| 22478 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22479 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22480 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22481 | D(fprintf(stderr, "%*c%s _loop0_119[%d-%d]: %s failed!\n", p->level, ' ', |
| 22482 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22483 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22484 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 22485 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22486 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22487 | p->error_indicator = 1; |
| 22488 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22489 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22490 | return NULL; |
| 22491 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22492 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 22493 | PyMem_Free(_children); |
| 22494 | _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22495 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22496 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22497 | } |
| 22498 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22499 | // _gather_118: star_target _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22500 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22501 | _gather_118_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22502 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22503 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22504 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22505 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22506 | return NULL; |
| 22507 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22508 | asdl_seq * _res = NULL; |
| 22509 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22510 | { // star_target _loop0_119 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22511 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22512 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22513 | return NULL; |
| 22514 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22515 | D(fprintf(stderr, "%*c> _gather_118[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_target _loop0_119")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22516 | expr_ty elem; |
| 22517 | asdl_seq * seq; |
| 22518 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22519 | (elem = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22520 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22521 | (seq = _loop0_119_rule(p)) // _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22522 | ) |
| 22523 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22524 | D(fprintf(stderr, "%*c+ _gather_118[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_target _loop0_119")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22525 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22526 | goto done; |
| 22527 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22528 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22529 | D(fprintf(stderr, "%*c%s _gather_118[%d-%d]: %s failed!\n", p->level, ' ', |
| 22530 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_target _loop0_119")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22531 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22532 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22533 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22534 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22535 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22536 | } |
| 22537 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22538 | // _tmp_120: !'*' star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22539 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22540 | _tmp_120_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22541 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22542 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22543 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22544 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22545 | return NULL; |
| 22546 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22547 | void * _res = NULL; |
| 22548 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22549 | { // !'*' star_target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22550 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22551 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22552 | return NULL; |
| 22553 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22554 | D(fprintf(stderr, "%*c> _tmp_120[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22555 | expr_ty star_target_var; |
| 22556 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22557 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22558 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22559 | (star_target_var = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22560 | ) |
| 22561 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22562 | D(fprintf(stderr, "%*c+ _tmp_120[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "!'*' star_target")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22563 | _res = star_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22564 | goto done; |
| 22565 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22566 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22567 | D(fprintf(stderr, "%*c%s _tmp_120[%d-%d]: %s failed!\n", p->level, ' ', |
| 22568 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "!'*' star_target")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22569 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22570 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22571 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22572 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22573 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22574 | } |
| 22575 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22576 | // _loop0_122: ',' del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22577 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22578 | _loop0_122_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22579 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22580 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22581 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22582 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22583 | return NULL; |
| 22584 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22585 | void *_res = NULL; |
| 22586 | int _mark = p->mark; |
| 22587 | int _start_mark = p->mark; |
| 22588 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 22589 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22590 | p->error_indicator = 1; |
| 22591 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22592 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22593 | return NULL; |
| 22594 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22595 | ssize_t _children_capacity = 1; |
| 22596 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22597 | { // ',' del_target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22598 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22599 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22600 | return NULL; |
| 22601 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22602 | D(fprintf(stderr, "%*c> _loop0_122[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' del_target")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22603 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22604 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22605 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22606 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22607 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22608 | (elem = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22609 | ) |
| 22610 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22611 | _res = elem; |
| 22612 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22613 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22614 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22615 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22616 | return NULL; |
| 22617 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22618 | if (_n == _children_capacity) { |
| 22619 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22620 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 22621 | if (!_new_children) { |
| 22622 | p->error_indicator = 1; |
| 22623 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22624 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22625 | return NULL; |
| 22626 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22627 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22628 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22629 | _children[_n++] = _res; |
| 22630 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22631 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22632 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22633 | D(fprintf(stderr, "%*c%s _loop0_122[%d-%d]: %s failed!\n", p->level, ' ', |
| 22634 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' del_target")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22635 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22636 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 22637 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22638 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22639 | p->error_indicator = 1; |
| 22640 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22641 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22642 | return NULL; |
| 22643 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22644 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 22645 | PyMem_Free(_children); |
| 22646 | _PyPegen_insert_memo(p, _start_mark, _loop0_122_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22647 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22648 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22649 | } |
| 22650 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22651 | // _gather_121: del_target _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22652 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22653 | _gather_121_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22654 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22655 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22656 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22657 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22658 | return NULL; |
| 22659 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22660 | asdl_seq * _res = NULL; |
| 22661 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22662 | { // del_target _loop0_122 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22663 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22664 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22665 | return NULL; |
| 22666 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22667 | D(fprintf(stderr, "%*c> _gather_121[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "del_target _loop0_122")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22668 | expr_ty elem; |
| 22669 | asdl_seq * seq; |
| 22670 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22671 | (elem = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22672 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22673 | (seq = _loop0_122_rule(p)) // _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22674 | ) |
| 22675 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22676 | D(fprintf(stderr, "%*c+ _gather_121[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "del_target _loop0_122")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22677 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22678 | goto done; |
| 22679 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22680 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22681 | D(fprintf(stderr, "%*c%s _gather_121[%d-%d]: %s failed!\n", p->level, ' ', |
| 22682 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "del_target _loop0_122")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22683 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22684 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22685 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22686 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22687 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22688 | } |
| 22689 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22690 | // _loop0_124: ',' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22691 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22692 | _loop0_124_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22693 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22694 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22695 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22696 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22697 | return NULL; |
| 22698 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22699 | void *_res = NULL; |
| 22700 | int _mark = p->mark; |
| 22701 | int _start_mark = p->mark; |
| 22702 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 22703 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22704 | p->error_indicator = 1; |
| 22705 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22706 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22707 | return NULL; |
| 22708 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22709 | ssize_t _children_capacity = 1; |
| 22710 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22711 | { // ',' target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22712 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22713 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22714 | return NULL; |
| 22715 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22716 | D(fprintf(stderr, "%*c> _loop0_124[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' target")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22717 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22718 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22719 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22720 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22721 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22722 | (elem = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22723 | ) |
| 22724 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22725 | _res = elem; |
| 22726 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22727 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22728 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22729 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22730 | return NULL; |
| 22731 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22732 | if (_n == _children_capacity) { |
| 22733 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22734 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 22735 | if (!_new_children) { |
| 22736 | p->error_indicator = 1; |
| 22737 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22738 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22739 | return NULL; |
| 22740 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22741 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22742 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22743 | _children[_n++] = _res; |
| 22744 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22745 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22746 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22747 | D(fprintf(stderr, "%*c%s _loop0_124[%d-%d]: %s failed!\n", p->level, ' ', |
| 22748 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' target")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22749 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22750 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 22751 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22752 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22753 | p->error_indicator = 1; |
| 22754 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22755 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22756 | return NULL; |
| 22757 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22758 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 22759 | PyMem_Free(_children); |
| 22760 | _PyPegen_insert_memo(p, _start_mark, _loop0_124_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22761 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22762 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22763 | } |
| 22764 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22765 | // _gather_123: target _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22766 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22767 | _gather_123_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22768 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22769 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22770 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22771 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22772 | return NULL; |
| 22773 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22774 | asdl_seq * _res = NULL; |
| 22775 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22776 | { // target _loop0_124 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22777 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22778 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22779 | return NULL; |
| 22780 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22781 | D(fprintf(stderr, "%*c> _gather_123[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "target _loop0_124")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22782 | expr_ty elem; |
| 22783 | asdl_seq * seq; |
| 22784 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22785 | (elem = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22786 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22787 | (seq = _loop0_124_rule(p)) // _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22788 | ) |
| 22789 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22790 | D(fprintf(stderr, "%*c+ _gather_123[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "target _loop0_124")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22791 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22792 | goto done; |
| 22793 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22794 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22795 | D(fprintf(stderr, "%*c%s _gather_123[%d-%d]: %s failed!\n", p->level, ' ', |
| 22796 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "target _loop0_124")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22797 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22798 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22799 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22800 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22801 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22802 | } |
| 22803 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22804 | // _tmp_125: args | expression for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22805 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 22806 | _tmp_125_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22807 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22808 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22809 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22810 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22811 | return NULL; |
| 22812 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22813 | void * _res = NULL; |
| 22814 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22815 | { // args |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22816 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22817 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22818 | return NULL; |
| 22819 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22820 | D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "args")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22821 | expr_ty args_var; |
| 22822 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22823 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22824 | ) |
| 22825 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22826 | D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "args")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22827 | _res = args_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22828 | goto done; |
| 22829 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22830 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22831 | D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', |
| 22832 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "args")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22833 | } |
| 22834 | { // expression for_if_clauses |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22835 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22836 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22837 | return NULL; |
| 22838 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22839 | D(fprintf(stderr, "%*c> _tmp_125[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22840 | expr_ty expression_var; |
| 22841 | asdl_seq* for_if_clauses_var; |
| 22842 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22843 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22844 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22845 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22846 | ) |
| 22847 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22848 | D(fprintf(stderr, "%*c+ _tmp_125[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "expression for_if_clauses")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22849 | _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22850 | goto done; |
| 22851 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22852 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22853 | D(fprintf(stderr, "%*c%s _tmp_125[%d-%d]: %s failed!\n", p->level, ' ', |
| 22854 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "expression for_if_clauses")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22855 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22856 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22857 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22858 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22859 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22860 | } |
| 22861 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 22862 | // _loop0_126: star_named_expressions |
| 22863 | static asdl_seq * |
| 22864 | _loop0_126_rule(Parser *p) |
| 22865 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22866 | D(p->level++); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 22867 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22868 | D(p->level--); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 22869 | return NULL; |
| 22870 | } |
| 22871 | void *_res = NULL; |
| 22872 | int _mark = p->mark; |
| 22873 | int _start_mark = p->mark; |
| 22874 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 22875 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22876 | p->error_indicator = 1; |
| 22877 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22878 | D(p->level--); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 22879 | return NULL; |
| 22880 | } |
| 22881 | ssize_t _children_capacity = 1; |
| 22882 | ssize_t _n = 0; |
| 22883 | { // star_named_expressions |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22884 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22885 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22886 | return NULL; |
| 22887 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22888 | D(fprintf(stderr, "%*c> _loop0_126[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_named_expressions")); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 22889 | asdl_seq* star_named_expressions_var; |
| 22890 | while ( |
| 22891 | (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions |
| 22892 | ) |
| 22893 | { |
| 22894 | _res = star_named_expressions_var; |
| 22895 | if (_n == _children_capacity) { |
| 22896 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22897 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 22898 | if (!_new_children) { |
| 22899 | p->error_indicator = 1; |
| 22900 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22901 | D(p->level--); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 22902 | return NULL; |
| 22903 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22904 | _children = _new_children; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 22905 | } |
| 22906 | _children[_n++] = _res; |
| 22907 | _mark = p->mark; |
| 22908 | } |
| 22909 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22910 | D(fprintf(stderr, "%*c%s _loop0_126[%d-%d]: %s failed!\n", p->level, ' ', |
| 22911 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_named_expressions")); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 22912 | } |
| 22913 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 22914 | if (!_seq) { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 22915 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 22916 | p->error_indicator = 1; |
| 22917 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22918 | D(p->level--); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 22919 | return NULL; |
| 22920 | } |
| 22921 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 22922 | PyMem_Free(_children); |
| 22923 | _PyPegen_insert_memo(p, _start_mark, _loop0_126_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22924 | D(p->level--); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 22925 | return _seq; |
| 22926 | } |
| 22927 | |
| 22928 | // _tmp_127: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22929 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 22930 | _tmp_127_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22931 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22932 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22933 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22934 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22935 | return NULL; |
| 22936 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22937 | void * _res = NULL; |
| 22938 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22939 | { // '=' annotated_rhs |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22940 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22941 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22942 | return NULL; |
| 22943 | } |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22944 | D(fprintf(stderr, "%*c> _tmp_127[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22945 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22946 | expr_ty annotated_rhs_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22947 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22948 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22949 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 22950 | (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22951 | ) |
| 22952 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22953 | D(fprintf(stderr, "%*c+ _tmp_127[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'=' annotated_rhs")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22954 | _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22955 | goto done; |
| 22956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22957 | p->mark = _mark; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22958 | D(fprintf(stderr, "%*c%s _tmp_127[%d-%d]: %s failed!\n", p->level, ' ', |
| 22959 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'=' annotated_rhs")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22960 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22961 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22962 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22963 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22964 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22965 | } |
| 22966 | |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 22967 | // _loop0_128: (star_targets '=') |
| 22968 | static asdl_seq * |
| 22969 | _loop0_128_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22970 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22971 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22972 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22973 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22974 | return NULL; |
| 22975 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 22976 | void *_res = NULL; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 22977 | int _mark = p->mark; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 22978 | int _start_mark = p->mark; |
| 22979 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 22980 | if (!_children) { |
| 22981 | p->error_indicator = 1; |
| 22982 | PyErr_NoMemory(); |
| 22983 | D(p->level--); |
| 22984 | return NULL; |
| 22985 | } |
| 22986 | ssize_t _children_capacity = 1; |
| 22987 | ssize_t _n = 0; |
| 22988 | { // (star_targets '=') |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22989 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 22990 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 22991 | return NULL; |
| 22992 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 22993 | D(fprintf(stderr, "%*c> _loop0_128[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 22994 | void *_tmp_149_var; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 22995 | while ( |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 22996 | (_tmp_149_var = _tmp_149_rule(p)) // star_targets '=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 22997 | ) |
| 22998 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 22999 | _res = _tmp_149_var; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23000 | if (_n == _children_capacity) { |
| 23001 | _children_capacity *= 2; |
| 23002 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23003 | if (!_new_children) { |
| 23004 | p->error_indicator = 1; |
| 23005 | PyErr_NoMemory(); |
| 23006 | D(p->level--); |
| 23007 | return NULL; |
| 23008 | } |
| 23009 | _children = _new_children; |
| 23010 | } |
| 23011 | _children[_n++] = _res; |
| 23012 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23013 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23014 | p->mark = _mark; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23015 | D(fprintf(stderr, "%*c%s _loop0_128[%d-%d]: %s failed!\n", p->level, ' ', |
| 23016 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23017 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23018 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 23019 | if (!_seq) { |
| 23020 | PyMem_Free(_children); |
| 23021 | p->error_indicator = 1; |
| 23022 | PyErr_NoMemory(); |
| 23023 | D(p->level--); |
| 23024 | return NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23025 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23026 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 23027 | PyMem_Free(_children); |
| 23028 | _PyPegen_insert_memo(p, _start_mark, _loop0_128_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23029 | D(p->level--); |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23030 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23031 | } |
| 23032 | |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23033 | // _loop0_129: (star_targets '=') |
| 23034 | static asdl_seq * |
| 23035 | _loop0_129_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23036 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23037 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23038 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23039 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23040 | return NULL; |
| 23041 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23042 | void *_res = NULL; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23043 | int _mark = p->mark; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23044 | int _start_mark = p->mark; |
| 23045 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23046 | if (!_children) { |
| 23047 | p->error_indicator = 1; |
| 23048 | PyErr_NoMemory(); |
| 23049 | D(p->level--); |
| 23050 | return NULL; |
| 23051 | } |
| 23052 | ssize_t _children_capacity = 1; |
| 23053 | ssize_t _n = 0; |
| 23054 | { // (star_targets '=') |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23055 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23056 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23057 | return NULL; |
| 23058 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23059 | D(fprintf(stderr, "%*c> _loop0_129[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "(star_targets '=')")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23060 | void *_tmp_150_var; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23061 | while ( |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23062 | (_tmp_150_var = _tmp_150_rule(p)) // star_targets '=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23063 | ) |
| 23064 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23065 | _res = _tmp_150_var; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23066 | if (_n == _children_capacity) { |
| 23067 | _children_capacity *= 2; |
| 23068 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23069 | if (!_new_children) { |
| 23070 | p->error_indicator = 1; |
| 23071 | PyErr_NoMemory(); |
| 23072 | D(p->level--); |
| 23073 | return NULL; |
| 23074 | } |
| 23075 | _children = _new_children; |
| 23076 | } |
| 23077 | _children[_n++] = _res; |
| 23078 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23079 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23080 | p->mark = _mark; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23081 | D(fprintf(stderr, "%*c%s _loop0_129[%d-%d]: %s failed!\n", p->level, ' ', |
| 23082 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "(star_targets '=')")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23083 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23084 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 23085 | if (!_seq) { |
| 23086 | PyMem_Free(_children); |
| 23087 | p->error_indicator = 1; |
| 23088 | PyErr_NoMemory(); |
| 23089 | D(p->level--); |
| 23090 | return NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23091 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23092 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 23093 | PyMem_Free(_children); |
| 23094 | _PyPegen_insert_memo(p, _start_mark, _loop0_129_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23095 | D(p->level--); |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23096 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23097 | } |
| 23098 | |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23099 | // _tmp_130: yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23100 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 23101 | _tmp_130_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23102 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23103 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23104 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23105 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23106 | return NULL; |
| 23107 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23108 | void * _res = NULL; |
| 23109 | int _mark = p->mark; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23110 | { // yield_expr |
| 23111 | if (p->error_indicator) { |
| 23112 | D(p->level--); |
| 23113 | return NULL; |
| 23114 | } |
| 23115 | D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
| 23116 | expr_ty yield_expr_var; |
| 23117 | if ( |
| 23118 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
| 23119 | ) |
| 23120 | { |
| 23121 | D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "yield_expr")); |
| 23122 | _res = yield_expr_var; |
| 23123 | goto done; |
| 23124 | } |
| 23125 | p->mark = _mark; |
| 23126 | D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ', |
| 23127 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "yield_expr")); |
| 23128 | } |
| 23129 | { // star_expressions |
| 23130 | if (p->error_indicator) { |
| 23131 | D(p->level--); |
| 23132 | return NULL; |
| 23133 | } |
| 23134 | D(fprintf(stderr, "%*c> _tmp_130[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
| 23135 | expr_ty star_expressions_var; |
| 23136 | if ( |
| 23137 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
| 23138 | ) |
| 23139 | { |
| 23140 | D(fprintf(stderr, "%*c+ _tmp_130[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions")); |
| 23141 | _res = star_expressions_var; |
| 23142 | goto done; |
| 23143 | } |
| 23144 | p->mark = _mark; |
| 23145 | D(fprintf(stderr, "%*c%s _tmp_130[%d-%d]: %s failed!\n", p->level, ' ', |
| 23146 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions")); |
| 23147 | } |
| 23148 | _res = NULL; |
| 23149 | done: |
| 23150 | D(p->level--); |
| 23151 | return _res; |
| 23152 | } |
| 23153 | |
| 23154 | // _tmp_131: '[' | '(' | '{' |
| 23155 | static void * |
| 23156 | _tmp_131_rule(Parser *p) |
| 23157 | { |
| 23158 | D(p->level++); |
| 23159 | if (p->error_indicator) { |
| 23160 | D(p->level--); |
| 23161 | return NULL; |
| 23162 | } |
| 23163 | void * _res = NULL; |
| 23164 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23165 | { // '[' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23166 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23167 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23168 | return NULL; |
| 23169 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23170 | D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'['")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23171 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23172 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23173 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23174 | ) |
| 23175 | { |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23176 | D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'['")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23177 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23178 | goto done; |
| 23179 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23180 | p->mark = _mark; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23181 | D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23182 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'['")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23183 | } |
| 23184 | { // '(' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23185 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23186 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23187 | return NULL; |
| 23188 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23189 | D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'('")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23190 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23191 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23192 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23193 | ) |
| 23194 | { |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23195 | D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'('")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23196 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23197 | goto done; |
| 23198 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23199 | p->mark = _mark; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23200 | D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23201 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'('")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23202 | } |
| 23203 | { // '{' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23204 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23205 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23206 | return NULL; |
| 23207 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23208 | D(fprintf(stderr, "%*c> _tmp_131[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'{'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23209 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23210 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23211 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23212 | ) |
| 23213 | { |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23214 | D(fprintf(stderr, "%*c+ _tmp_131[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'{'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23215 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23216 | goto done; |
| 23217 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23218 | p->mark = _mark; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23219 | D(fprintf(stderr, "%*c%s _tmp_131[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23220 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'{'")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23221 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23222 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23223 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23224 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23225 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23226 | } |
| 23227 | |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23228 | // _loop0_132: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 23229 | static asdl_seq * |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23230 | _loop0_132_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23231 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23232 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23233 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23234 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23235 | return NULL; |
| 23236 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23237 | void *_res = NULL; |
| 23238 | int _mark = p->mark; |
| 23239 | int _start_mark = p->mark; |
| 23240 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23241 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 23242 | p->error_indicator = 1; |
| 23243 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23244 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 23245 | return NULL; |
| 23246 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23247 | ssize_t _children_capacity = 1; |
| 23248 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 23249 | { // param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23250 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23251 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23252 | return NULL; |
| 23253 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23254 | D(fprintf(stderr, "%*c> _loop0_132[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_no_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 23255 | arg_ty param_no_default_var; |
| 23256 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 23257 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23258 | ) |
| 23259 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23260 | _res = param_no_default_var; |
| 23261 | if (_n == _children_capacity) { |
| 23262 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 23263 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23264 | if (!_new_children) { |
| 23265 | p->error_indicator = 1; |
| 23266 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23267 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 23268 | return NULL; |
| 23269 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 23270 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 23271 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23272 | _children[_n++] = _res; |
| 23273 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23274 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23275 | p->mark = _mark; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23276 | D(fprintf(stderr, "%*c%s _loop0_132[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23277 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_no_default")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23278 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23279 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 23280 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23281 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 23282 | p->error_indicator = 1; |
| 23283 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23284 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 23285 | return NULL; |
| 23286 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23287 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 23288 | PyMem_Free(_children); |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23289 | _PyPegen_insert_memo(p, _start_mark, _loop0_132_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23290 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23291 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23292 | } |
| 23293 | |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23294 | // _tmp_133: slash_with_default | param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23295 | static void * |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23296 | _tmp_133_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23297 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23298 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23299 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23300 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23301 | return NULL; |
| 23302 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23303 | void * _res = NULL; |
| 23304 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23305 | { // slash_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23306 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23307 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23308 | return NULL; |
| 23309 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23310 | D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "slash_with_default")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23311 | SlashWithDefault* slash_with_default_var; |
| 23312 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 23313 | (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23314 | ) |
| 23315 | { |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23316 | D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "slash_with_default")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23317 | _res = slash_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23318 | goto done; |
| 23319 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23320 | p->mark = _mark; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23321 | D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23322 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "slash_with_default")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23323 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 23324 | { // param_with_default+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23325 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23326 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23327 | return NULL; |
| 23328 | } |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23329 | D(fprintf(stderr, "%*c> _tmp_133[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default+")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23330 | asdl_seq * _loop1_151_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23331 | if ( |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23332 | (_loop1_151_var = _loop1_151_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23333 | ) |
| 23334 | { |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23335 | D(fprintf(stderr, "%*c+ _tmp_133[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "param_with_default+")); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23336 | _res = _loop1_151_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23337 | goto done; |
| 23338 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23339 | p->mark = _mark; |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23340 | D(fprintf(stderr, "%*c%s _tmp_133[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23341 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default+")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23342 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23343 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23344 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23345 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23346 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23347 | } |
| 23348 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23349 | // _loop0_134: lambda_param_no_default |
| 23350 | static asdl_seq * |
| 23351 | _loop0_134_rule(Parser *p) |
| 23352 | { |
| 23353 | D(p->level++); |
| 23354 | if (p->error_indicator) { |
| 23355 | D(p->level--); |
| 23356 | return NULL; |
| 23357 | } |
| 23358 | void *_res = NULL; |
| 23359 | int _mark = p->mark; |
| 23360 | int _start_mark = p->mark; |
| 23361 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 23362 | if (!_children) { |
| 23363 | p->error_indicator = 1; |
| 23364 | PyErr_NoMemory(); |
| 23365 | D(p->level--); |
| 23366 | return NULL; |
| 23367 | } |
| 23368 | ssize_t _children_capacity = 1; |
| 23369 | ssize_t _n = 0; |
| 23370 | { // lambda_param_no_default |
| 23371 | if (p->error_indicator) { |
| 23372 | D(p->level--); |
| 23373 | return NULL; |
| 23374 | } |
| 23375 | D(fprintf(stderr, "%*c> _loop0_134[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_no_default")); |
| 23376 | arg_ty lambda_param_no_default_var; |
| 23377 | while ( |
| 23378 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
| 23379 | ) |
| 23380 | { |
| 23381 | _res = lambda_param_no_default_var; |
| 23382 | if (_n == _children_capacity) { |
| 23383 | _children_capacity *= 2; |
| 23384 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 23385 | if (!_new_children) { |
| 23386 | p->error_indicator = 1; |
| 23387 | PyErr_NoMemory(); |
| 23388 | D(p->level--); |
| 23389 | return NULL; |
| 23390 | } |
| 23391 | _children = _new_children; |
| 23392 | } |
| 23393 | _children[_n++] = _res; |
| 23394 | _mark = p->mark; |
| 23395 | } |
| 23396 | p->mark = _mark; |
| 23397 | D(fprintf(stderr, "%*c%s _loop0_134[%d-%d]: %s failed!\n", p->level, ' ', |
| 23398 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_no_default")); |
| 23399 | } |
| 23400 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 23401 | if (!_seq) { |
| 23402 | PyMem_Free(_children); |
| 23403 | p->error_indicator = 1; |
| 23404 | PyErr_NoMemory(); |
| 23405 | D(p->level--); |
| 23406 | return NULL; |
| 23407 | } |
| 23408 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 23409 | PyMem_Free(_children); |
| 23410 | _PyPegen_insert_memo(p, _start_mark, _loop0_134_type, _seq); |
| 23411 | D(p->level--); |
| 23412 | return _seq; |
| 23413 | } |
| 23414 | |
| 23415 | // _tmp_135: lambda_slash_with_default | lambda_param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23416 | static void * |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23417 | _tmp_135_rule(Parser *p) |
| 23418 | { |
| 23419 | D(p->level++); |
| 23420 | if (p->error_indicator) { |
| 23421 | D(p->level--); |
| 23422 | return NULL; |
| 23423 | } |
| 23424 | void * _res = NULL; |
| 23425 | int _mark = p->mark; |
| 23426 | { // lambda_slash_with_default |
| 23427 | if (p->error_indicator) { |
| 23428 | D(p->level--); |
| 23429 | return NULL; |
| 23430 | } |
| 23431 | D(fprintf(stderr, "%*c> _tmp_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); |
| 23432 | SlashWithDefault* lambda_slash_with_default_var; |
| 23433 | if ( |
| 23434 | (lambda_slash_with_default_var = lambda_slash_with_default_rule(p)) // lambda_slash_with_default |
| 23435 | ) |
| 23436 | { |
| 23437 | D(fprintf(stderr, "%*c+ _tmp_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_slash_with_default")); |
| 23438 | _res = lambda_slash_with_default_var; |
| 23439 | goto done; |
| 23440 | } |
| 23441 | p->mark = _mark; |
| 23442 | D(fprintf(stderr, "%*c%s _tmp_135[%d-%d]: %s failed!\n", p->level, ' ', |
| 23443 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_slash_with_default")); |
| 23444 | } |
| 23445 | { // lambda_param_with_default+ |
| 23446 | if (p->error_indicator) { |
| 23447 | D(p->level--); |
| 23448 | return NULL; |
| 23449 | } |
| 23450 | D(fprintf(stderr, "%*c> _tmp_135[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); |
| 23451 | asdl_seq * _loop1_152_var; |
| 23452 | if ( |
| 23453 | (_loop1_152_var = _loop1_152_rule(p)) // lambda_param_with_default+ |
| 23454 | ) |
| 23455 | { |
| 23456 | D(fprintf(stderr, "%*c+ _tmp_135[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default+")); |
| 23457 | _res = _loop1_152_var; |
| 23458 | goto done; |
| 23459 | } |
| 23460 | p->mark = _mark; |
| 23461 | D(fprintf(stderr, "%*c%s _tmp_135[%d-%d]: %s failed!\n", p->level, ' ', |
| 23462 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default+")); |
| 23463 | } |
| 23464 | _res = NULL; |
| 23465 | done: |
| 23466 | D(p->level--); |
| 23467 | return _res; |
| 23468 | } |
| 23469 | |
| 23470 | // _tmp_136: ')' | ',' (')' | '**') |
| 23471 | static void * |
| 23472 | _tmp_136_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23473 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23474 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23475 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23476 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23477 | return NULL; |
| 23478 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23479 | void * _res = NULL; |
| 23480 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23481 | { // ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23482 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23483 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23484 | return NULL; |
| 23485 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23486 | D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23487 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23488 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23489 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23490 | ) |
| 23491 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23492 | D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23493 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23494 | goto done; |
| 23495 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23496 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23497 | D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23498 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23499 | } |
| 23500 | { // ',' (')' | '**') |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23501 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23502 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23503 | return NULL; |
| 23504 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23505 | D(fprintf(stderr, "%*c> _tmp_136[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23506 | Token * _literal; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23507 | void *_tmp_153_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23508 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23509 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23510 | && |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23511 | (_tmp_153_var = _tmp_153_rule(p)) // ')' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23512 | ) |
| 23513 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23514 | D(fprintf(stderr, "%*c+ _tmp_136[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (')' | '**')")); |
| 23515 | _res = _PyPegen_dummy_name(p, _literal, _tmp_153_var); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23516 | goto done; |
| 23517 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23518 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23519 | D(fprintf(stderr, "%*c%s _tmp_136[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23520 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (')' | '**')")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23521 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23522 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23523 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23524 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23525 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23526 | } |
| 23527 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23528 | // _tmp_137: ':' | ',' (':' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23529 | static void * |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23530 | _tmp_137_rule(Parser *p) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23531 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23532 | D(p->level++); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23533 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23534 | D(p->level--); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23535 | return NULL; |
| 23536 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23537 | void * _res = NULL; |
| 23538 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23539 | { // ':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23540 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23541 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23542 | return NULL; |
| 23543 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23544 | D(fprintf(stderr, "%*c> _tmp_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23545 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23546 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23547 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23548 | ) |
| 23549 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23550 | D(fprintf(stderr, "%*c+ _tmp_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23551 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23552 | goto done; |
| 23553 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23554 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23555 | D(fprintf(stderr, "%*c%s _tmp_137[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23556 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23557 | } |
| 23558 | { // ',' (':' | '**') |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23559 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23560 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23561 | return NULL; |
| 23562 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23563 | D(fprintf(stderr, "%*c> _tmp_137[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23564 | Token * _literal; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23565 | void *_tmp_154_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23566 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23567 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23568 | && |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23569 | (_tmp_154_var = _tmp_154_rule(p)) // ':' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23570 | ) |
| 23571 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23572 | D(fprintf(stderr, "%*c+ _tmp_137[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' (':' | '**')")); |
| 23573 | _res = _PyPegen_dummy_name(p, _literal, _tmp_154_var); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23574 | goto done; |
| 23575 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23576 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23577 | D(fprintf(stderr, "%*c%s _tmp_137[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23578 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' (':' | '**')")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23579 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23580 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23581 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23582 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23583 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23584 | } |
| 23585 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23586 | // _tmp_138: star_targets '=' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23587 | static void * |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23588 | _tmp_138_rule(Parser *p) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23589 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23590 | D(p->level++); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23591 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23592 | D(p->level--); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23593 | return NULL; |
| 23594 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23595 | void * _res = NULL; |
| 23596 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23597 | { // star_targets '=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23598 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23599 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23600 | return NULL; |
| 23601 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23602 | D(fprintf(stderr, "%*c> _tmp_138[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23603 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23604 | expr_ty z; |
| 23605 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 23606 | (z = star_targets_rule(p)) // star_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23607 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23608 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23609 | ) |
| 23610 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23611 | D(fprintf(stderr, "%*c+ _tmp_138[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23612 | _res = z; |
| 23613 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23614 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23615 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23616 | return NULL; |
| 23617 | } |
| 23618 | goto done; |
| 23619 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23620 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23621 | D(fprintf(stderr, "%*c%s _tmp_138[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23622 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23623 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23624 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23625 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23626 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23627 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23628 | } |
| 23629 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23630 | // _tmp_139: '.' | '...' |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23631 | static void * |
| 23632 | _tmp_139_rule(Parser *p) |
| 23633 | { |
| 23634 | D(p->level++); |
| 23635 | if (p->error_indicator) { |
| 23636 | D(p->level--); |
| 23637 | return NULL; |
| 23638 | } |
| 23639 | void * _res = NULL; |
| 23640 | int _mark = p->mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23641 | { // '.' |
| 23642 | if (p->error_indicator) { |
| 23643 | D(p->level--); |
| 23644 | return NULL; |
| 23645 | } |
| 23646 | D(fprintf(stderr, "%*c> _tmp_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); |
| 23647 | Token * _literal; |
| 23648 | if ( |
| 23649 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 23650 | ) |
| 23651 | { |
| 23652 | D(fprintf(stderr, "%*c+ _tmp_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); |
| 23653 | _res = _literal; |
| 23654 | goto done; |
| 23655 | } |
| 23656 | p->mark = _mark; |
| 23657 | D(fprintf(stderr, "%*c%s _tmp_139[%d-%d]: %s failed!\n", p->level, ' ', |
| 23658 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); |
| 23659 | } |
| 23660 | { // '...' |
| 23661 | if (p->error_indicator) { |
| 23662 | D(p->level--); |
| 23663 | return NULL; |
| 23664 | } |
| 23665 | D(fprintf(stderr, "%*c> _tmp_139[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); |
| 23666 | Token * _literal; |
| 23667 | if ( |
| 23668 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
| 23669 | ) |
| 23670 | { |
| 23671 | D(fprintf(stderr, "%*c+ _tmp_139[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); |
| 23672 | _res = _literal; |
| 23673 | goto done; |
| 23674 | } |
| 23675 | p->mark = _mark; |
| 23676 | D(fprintf(stderr, "%*c%s _tmp_139[%d-%d]: %s failed!\n", p->level, ' ', |
| 23677 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); |
| 23678 | } |
| 23679 | _res = NULL; |
| 23680 | done: |
| 23681 | D(p->level--); |
| 23682 | return _res; |
| 23683 | } |
| 23684 | |
| 23685 | // _tmp_140: '.' | '...' |
| 23686 | static void * |
| 23687 | _tmp_140_rule(Parser *p) |
| 23688 | { |
| 23689 | D(p->level++); |
| 23690 | if (p->error_indicator) { |
| 23691 | D(p->level--); |
| 23692 | return NULL; |
| 23693 | } |
| 23694 | void * _res = NULL; |
| 23695 | int _mark = p->mark; |
| 23696 | { // '.' |
| 23697 | if (p->error_indicator) { |
| 23698 | D(p->level--); |
| 23699 | return NULL; |
| 23700 | } |
| 23701 | D(fprintf(stderr, "%*c> _tmp_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'.'")); |
| 23702 | Token * _literal; |
| 23703 | if ( |
| 23704 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 23705 | ) |
| 23706 | { |
| 23707 | D(fprintf(stderr, "%*c+ _tmp_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'.'")); |
| 23708 | _res = _literal; |
| 23709 | goto done; |
| 23710 | } |
| 23711 | p->mark = _mark; |
| 23712 | D(fprintf(stderr, "%*c%s _tmp_140[%d-%d]: %s failed!\n", p->level, ' ', |
| 23713 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'.'")); |
| 23714 | } |
| 23715 | { // '...' |
| 23716 | if (p->error_indicator) { |
| 23717 | D(p->level--); |
| 23718 | return NULL; |
| 23719 | } |
| 23720 | D(fprintf(stderr, "%*c> _tmp_140[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'...'")); |
| 23721 | Token * _literal; |
| 23722 | if ( |
| 23723 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
| 23724 | ) |
| 23725 | { |
| 23726 | D(fprintf(stderr, "%*c+ _tmp_140[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'...'")); |
| 23727 | _res = _literal; |
| 23728 | goto done; |
| 23729 | } |
| 23730 | p->mark = _mark; |
| 23731 | D(fprintf(stderr, "%*c%s _tmp_140[%d-%d]: %s failed!\n", p->level, ' ', |
| 23732 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'...'")); |
| 23733 | } |
| 23734 | _res = NULL; |
| 23735 | done: |
| 23736 | D(p->level--); |
| 23737 | return _res; |
| 23738 | } |
| 23739 | |
| 23740 | // _tmp_141: '@' named_expression NEWLINE |
| 23741 | static void * |
| 23742 | _tmp_141_rule(Parser *p) |
| 23743 | { |
| 23744 | D(p->level++); |
| 23745 | if (p->error_indicator) { |
| 23746 | D(p->level--); |
| 23747 | return NULL; |
| 23748 | } |
| 23749 | void * _res = NULL; |
| 23750 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23751 | { // '@' named_expression NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23752 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23753 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23754 | return NULL; |
| 23755 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23756 | D(fprintf(stderr, "%*c> _tmp_141[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23757 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23758 | expr_ty f; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 23759 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23760 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23761 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23762 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 23763 | (f = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23764 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 23765 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23766 | ) |
| 23767 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23768 | D(fprintf(stderr, "%*c+ _tmp_141[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'@' named_expression NEWLINE")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23769 | _res = f; |
| 23770 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23771 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23772 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23773 | return NULL; |
| 23774 | } |
| 23775 | goto done; |
| 23776 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23777 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23778 | D(fprintf(stderr, "%*c%s _tmp_141[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23779 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'@' named_expression NEWLINE")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23780 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23781 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23782 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23783 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23784 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23785 | } |
| 23786 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23787 | // _tmp_142: ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23788 | static void * |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23789 | _tmp_142_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23790 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23791 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23792 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23793 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23794 | return NULL; |
| 23795 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23796 | void * _res = NULL; |
| 23797 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23798 | { // ',' star_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23799 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23800 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23801 | return NULL; |
| 23802 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23803 | D(fprintf(stderr, "%*c> _tmp_142[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23804 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23805 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23806 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23807 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23808 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 23809 | (c = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23810 | ) |
| 23811 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23812 | D(fprintf(stderr, "%*c+ _tmp_142[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23813 | _res = c; |
| 23814 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23815 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23816 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23817 | return NULL; |
| 23818 | } |
| 23819 | goto done; |
| 23820 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23821 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23822 | D(fprintf(stderr, "%*c%s _tmp_142[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23823 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23824 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23825 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23826 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23827 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23828 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23829 | } |
| 23830 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23831 | // _tmp_143: ',' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23832 | static void * |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23833 | _tmp_143_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23834 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23835 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23836 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23837 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23838 | return NULL; |
| 23839 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23840 | void * _res = NULL; |
| 23841 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23842 | { // ',' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23843 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23844 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23845 | return NULL; |
| 23846 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23847 | D(fprintf(stderr, "%*c> _tmp_143[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23848 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23849 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23850 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23851 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23852 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 23853 | (c = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23854 | ) |
| 23855 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23856 | D(fprintf(stderr, "%*c+ _tmp_143[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' expression")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23857 | _res = c; |
| 23858 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23859 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23860 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23861 | return NULL; |
| 23862 | } |
| 23863 | goto done; |
| 23864 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23865 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23866 | D(fprintf(stderr, "%*c%s _tmp_143[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23867 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' expression")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23868 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23869 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23870 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23871 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23872 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23873 | } |
| 23874 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23875 | // _tmp_144: 'or' conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23876 | static void * |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23877 | _tmp_144_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23878 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23879 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23880 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23881 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23882 | return NULL; |
| 23883 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23884 | void * _res = NULL; |
| 23885 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23886 | { // 'or' conjunction |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23887 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23888 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23889 | return NULL; |
| 23890 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23891 | D(fprintf(stderr, "%*c> _tmp_144[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23892 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23893 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23894 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23895 | (_keyword = _PyPegen_expect_token(p, 532)) // token='or' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23896 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 23897 | (c = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23898 | ) |
| 23899 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23900 | D(fprintf(stderr, "%*c+ _tmp_144[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'or' conjunction")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23901 | _res = c; |
| 23902 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23903 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23904 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23905 | return NULL; |
| 23906 | } |
| 23907 | goto done; |
| 23908 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23909 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23910 | D(fprintf(stderr, "%*c%s _tmp_144[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23911 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'or' conjunction")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23912 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23913 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23914 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23915 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23916 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23917 | } |
| 23918 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23919 | // _tmp_145: 'and' inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23920 | static void * |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23921 | _tmp_145_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23922 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23923 | D(p->level++); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23924 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23925 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23926 | return NULL; |
| 23927 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23928 | void * _res = NULL; |
| 23929 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23930 | { // 'and' inversion |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23931 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23932 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 23933 | return NULL; |
| 23934 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23935 | D(fprintf(stderr, "%*c> _tmp_145[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'and' inversion")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23936 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23937 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23938 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23939 | (_keyword = _PyPegen_expect_token(p, 533)) // token='and' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23940 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 23941 | (c = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23942 | ) |
| 23943 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23944 | D(fprintf(stderr, "%*c+ _tmp_145[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'and' inversion")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23945 | _res = c; |
| 23946 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23947 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23948 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 23949 | return NULL; |
| 23950 | } |
| 23951 | goto done; |
| 23952 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23953 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23954 | D(fprintf(stderr, "%*c%s _tmp_145[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23955 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'and' inversion")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23957 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23958 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 23959 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 23960 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 23961 | } |
| 23962 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23963 | // _tmp_146: 'if' disjunction |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 23964 | static void * |
| 23965 | _tmp_146_rule(Parser *p) |
| 23966 | { |
| 23967 | D(p->level++); |
| 23968 | if (p->error_indicator) { |
| 23969 | D(p->level--); |
| 23970 | return NULL; |
| 23971 | } |
| 23972 | void * _res = NULL; |
| 23973 | int _mark = p->mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 23974 | { // 'if' disjunction |
| 23975 | if (p->error_indicator) { |
| 23976 | D(p->level--); |
| 23977 | return NULL; |
| 23978 | } |
| 23979 | D(fprintf(stderr, "%*c> _tmp_146[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); |
| 23980 | Token * _keyword; |
| 23981 | expr_ty z; |
| 23982 | if ( |
| 23983 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
| 23984 | && |
| 23985 | (z = disjunction_rule(p)) // disjunction |
| 23986 | ) |
| 23987 | { |
| 23988 | D(fprintf(stderr, "%*c+ _tmp_146[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); |
| 23989 | _res = z; |
| 23990 | if (_res == NULL && PyErr_Occurred()) { |
| 23991 | p->error_indicator = 1; |
| 23992 | D(p->level--); |
| 23993 | return NULL; |
| 23994 | } |
| 23995 | goto done; |
| 23996 | } |
| 23997 | p->mark = _mark; |
| 23998 | D(fprintf(stderr, "%*c%s _tmp_146[%d-%d]: %s failed!\n", p->level, ' ', |
| 23999 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); |
| 24000 | } |
| 24001 | _res = NULL; |
| 24002 | done: |
| 24003 | D(p->level--); |
| 24004 | return _res; |
| 24005 | } |
| 24006 | |
| 24007 | // _tmp_147: 'if' disjunction |
| 24008 | static void * |
| 24009 | _tmp_147_rule(Parser *p) |
| 24010 | { |
| 24011 | D(p->level++); |
| 24012 | if (p->error_indicator) { |
| 24013 | D(p->level--); |
| 24014 | return NULL; |
| 24015 | } |
| 24016 | void * _res = NULL; |
| 24017 | int _mark = p->mark; |
| 24018 | { // 'if' disjunction |
| 24019 | if (p->error_indicator) { |
| 24020 | D(p->level--); |
| 24021 | return NULL; |
| 24022 | } |
| 24023 | D(fprintf(stderr, "%*c> _tmp_147[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); |
| 24024 | Token * _keyword; |
| 24025 | expr_ty z; |
| 24026 | if ( |
| 24027 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
| 24028 | && |
| 24029 | (z = disjunction_rule(p)) // disjunction |
| 24030 | ) |
| 24031 | { |
| 24032 | D(fprintf(stderr, "%*c+ _tmp_147[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'if' disjunction")); |
| 24033 | _res = z; |
| 24034 | if (_res == NULL && PyErr_Occurred()) { |
| 24035 | p->error_indicator = 1; |
| 24036 | D(p->level--); |
| 24037 | return NULL; |
| 24038 | } |
| 24039 | goto done; |
| 24040 | } |
| 24041 | p->mark = _mark; |
| 24042 | D(fprintf(stderr, "%*c%s _tmp_147[%d-%d]: %s failed!\n", p->level, ' ', |
| 24043 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'if' disjunction")); |
| 24044 | } |
| 24045 | _res = NULL; |
| 24046 | done: |
| 24047 | D(p->level--); |
| 24048 | return _res; |
| 24049 | } |
| 24050 | |
| 24051 | // _tmp_148: ',' star_target |
| 24052 | static void * |
| 24053 | _tmp_148_rule(Parser *p) |
| 24054 | { |
| 24055 | D(p->level++); |
| 24056 | if (p->error_indicator) { |
| 24057 | D(p->level--); |
| 24058 | return NULL; |
| 24059 | } |
| 24060 | void * _res = NULL; |
| 24061 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 24062 | { // ',' star_target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 24063 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24064 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 24065 | return NULL; |
| 24066 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24067 | D(fprintf(stderr, "%*c> _tmp_148[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "',' star_target")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24068 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 24069 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 24070 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24071 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 24072 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 24073 | (c = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 24074 | ) |
| 24075 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24076 | D(fprintf(stderr, "%*c+ _tmp_148[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "',' star_target")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24077 | _res = c; |
| 24078 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 24079 | p->error_indicator = 1; |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24080 | D(p->level--); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 24081 | return NULL; |
| 24082 | } |
| 24083 | goto done; |
| 24084 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24085 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24086 | D(fprintf(stderr, "%*c%s _tmp_148[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24087 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "',' star_target")); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 24088 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24089 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 24090 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24091 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24092 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 24093 | } |
| 24094 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24095 | // _tmp_149: star_targets '=' |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 24096 | static void * |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24097 | _tmp_149_rule(Parser *p) |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 24098 | { |
| 24099 | D(p->level++); |
| 24100 | if (p->error_indicator) { |
| 24101 | D(p->level--); |
| 24102 | return NULL; |
| 24103 | } |
| 24104 | void * _res = NULL; |
| 24105 | int _mark = p->mark; |
| 24106 | { // star_targets '=' |
| 24107 | if (p->error_indicator) { |
| 24108 | D(p->level--); |
| 24109 | return NULL; |
| 24110 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24111 | D(fprintf(stderr, "%*c> _tmp_149[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 24112 | Token * _literal; |
| 24113 | expr_ty star_targets_var; |
| 24114 | if ( |
| 24115 | (star_targets_var = star_targets_rule(p)) // star_targets |
| 24116 | && |
| 24117 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 24118 | ) |
| 24119 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24120 | D(fprintf(stderr, "%*c+ _tmp_149[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 24121 | _res = _PyPegen_dummy_name(p, star_targets_var, _literal); |
| 24122 | goto done; |
| 24123 | } |
| 24124 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24125 | D(fprintf(stderr, "%*c%s _tmp_149[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 24126 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); |
| 24127 | } |
| 24128 | _res = NULL; |
| 24129 | done: |
| 24130 | D(p->level--); |
| 24131 | return _res; |
| 24132 | } |
| 24133 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24134 | // _tmp_150: star_targets '=' |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 24135 | static void * |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24136 | _tmp_150_rule(Parser *p) |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 24137 | { |
| 24138 | D(p->level++); |
| 24139 | if (p->error_indicator) { |
| 24140 | D(p->level--); |
| 24141 | return NULL; |
| 24142 | } |
| 24143 | void * _res = NULL; |
| 24144 | int _mark = p->mark; |
| 24145 | { // star_targets '=' |
| 24146 | if (p->error_indicator) { |
| 24147 | D(p->level--); |
| 24148 | return NULL; |
| 24149 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24150 | D(fprintf(stderr, "%*c> _tmp_150[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_targets '='")); |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 24151 | Token * _literal; |
| 24152 | expr_ty star_targets_var; |
| 24153 | if ( |
| 24154 | (star_targets_var = star_targets_rule(p)) // star_targets |
| 24155 | && |
| 24156 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 24157 | ) |
| 24158 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24159 | D(fprintf(stderr, "%*c+ _tmp_150[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_targets '='")); |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 24160 | _res = _PyPegen_dummy_name(p, star_targets_var, _literal); |
| 24161 | goto done; |
| 24162 | } |
| 24163 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24164 | D(fprintf(stderr, "%*c%s _tmp_150[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 9f49590 | 2020-06-08 02:57:00 +0100 | [diff] [blame] | 24165 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_targets '='")); |
| 24166 | } |
| 24167 | _res = NULL; |
| 24168 | done: |
| 24169 | D(p->level--); |
| 24170 | return _res; |
| 24171 | } |
| 24172 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24173 | // _loop1_151: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 24174 | static asdl_seq * |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24175 | _loop1_151_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24176 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24177 | D(p->level++); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24178 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24179 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24180 | return NULL; |
| 24181 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24182 | void *_res = NULL; |
| 24183 | int _mark = p->mark; |
| 24184 | int _start_mark = p->mark; |
| 24185 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24186 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 24187 | p->error_indicator = 1; |
| 24188 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24189 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24190 | return NULL; |
| 24191 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24192 | ssize_t _children_capacity = 1; |
| 24193 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24194 | { // param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 24195 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24196 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 24197 | return NULL; |
| 24198 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24199 | D(fprintf(stderr, "%*c> _loop1_151[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "param_with_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24200 | NameDefaultPair* param_with_default_var; |
| 24201 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 24202 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24203 | ) |
| 24204 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24205 | _res = param_with_default_var; |
| 24206 | if (_n == _children_capacity) { |
| 24207 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 24208 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24209 | if (!_new_children) { |
| 24210 | p->error_indicator = 1; |
| 24211 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24212 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24213 | return NULL; |
| 24214 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 24215 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24216 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24217 | _children[_n++] = _res; |
| 24218 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24219 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24220 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24221 | D(fprintf(stderr, "%*c%s _loop1_151[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24222 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "param_with_default")); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24223 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24224 | if (_n == 0 || p->error_indicator) { |
| 24225 | PyMem_Free(_children); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24226 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24227 | return NULL; |
| 24228 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24229 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 24230 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24231 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 24232 | p->error_indicator = 1; |
| 24233 | PyErr_NoMemory(); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24234 | D(p->level--); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24235 | return NULL; |
| 24236 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24237 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 24238 | PyMem_Free(_children); |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24239 | _PyPegen_insert_memo(p, _start_mark, _loop1_151_type, _seq); |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24240 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24241 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24242 | } |
| 24243 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24244 | // _loop1_152: lambda_param_with_default |
| 24245 | static asdl_seq * |
| 24246 | _loop1_152_rule(Parser *p) |
| 24247 | { |
| 24248 | D(p->level++); |
| 24249 | if (p->error_indicator) { |
| 24250 | D(p->level--); |
| 24251 | return NULL; |
| 24252 | } |
| 24253 | void *_res = NULL; |
| 24254 | int _mark = p->mark; |
| 24255 | int _start_mark = p->mark; |
| 24256 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 24257 | if (!_children) { |
| 24258 | p->error_indicator = 1; |
| 24259 | PyErr_NoMemory(); |
| 24260 | D(p->level--); |
| 24261 | return NULL; |
| 24262 | } |
| 24263 | ssize_t _children_capacity = 1; |
| 24264 | ssize_t _n = 0; |
| 24265 | { // lambda_param_with_default |
| 24266 | if (p->error_indicator) { |
| 24267 | D(p->level--); |
| 24268 | return NULL; |
| 24269 | } |
| 24270 | D(fprintf(stderr, "%*c> _loop1_152[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "lambda_param_with_default")); |
| 24271 | NameDefaultPair* lambda_param_with_default_var; |
| 24272 | while ( |
| 24273 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
| 24274 | ) |
| 24275 | { |
| 24276 | _res = lambda_param_with_default_var; |
| 24277 | if (_n == _children_capacity) { |
| 24278 | _children_capacity *= 2; |
| 24279 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 24280 | if (!_new_children) { |
| 24281 | p->error_indicator = 1; |
| 24282 | PyErr_NoMemory(); |
| 24283 | D(p->level--); |
| 24284 | return NULL; |
| 24285 | } |
| 24286 | _children = _new_children; |
| 24287 | } |
| 24288 | _children[_n++] = _res; |
| 24289 | _mark = p->mark; |
| 24290 | } |
| 24291 | p->mark = _mark; |
| 24292 | D(fprintf(stderr, "%*c%s _loop1_152[%d-%d]: %s failed!\n", p->level, ' ', |
| 24293 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "lambda_param_with_default")); |
| 24294 | } |
| 24295 | if (_n == 0 || p->error_indicator) { |
| 24296 | PyMem_Free(_children); |
| 24297 | D(p->level--); |
| 24298 | return NULL; |
| 24299 | } |
| 24300 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 24301 | if (!_seq) { |
| 24302 | PyMem_Free(_children); |
| 24303 | p->error_indicator = 1; |
| 24304 | PyErr_NoMemory(); |
| 24305 | D(p->level--); |
| 24306 | return NULL; |
| 24307 | } |
| 24308 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 24309 | PyMem_Free(_children); |
| 24310 | _PyPegen_insert_memo(p, _start_mark, _loop1_152_type, _seq); |
| 24311 | D(p->level--); |
| 24312 | return _seq; |
| 24313 | } |
| 24314 | |
| 24315 | // _tmp_153: ')' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24316 | static void * |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24317 | _tmp_153_rule(Parser *p) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24318 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24319 | D(p->level++); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24320 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24321 | D(p->level--); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24322 | return NULL; |
| 24323 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24324 | void * _res = NULL; |
| 24325 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24326 | { // ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 24327 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24328 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 24329 | return NULL; |
| 24330 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24331 | D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24332 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24333 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24334 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24335 | ) |
| 24336 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24337 | D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "')'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24338 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24339 | goto done; |
| 24340 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24341 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24342 | D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24343 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "')'")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24344 | } |
| 24345 | { // '**' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 24346 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24347 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 24348 | return NULL; |
| 24349 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24350 | D(fprintf(stderr, "%*c> _tmp_153[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24351 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24352 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24353 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24354 | ) |
| 24355 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24356 | D(fprintf(stderr, "%*c+ _tmp_153[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24357 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24358 | goto done; |
| 24359 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24360 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24361 | D(fprintf(stderr, "%*c%s _tmp_153[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24362 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24363 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24364 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24365 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24366 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24367 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24368 | } |
| 24369 | |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24370 | // _tmp_154: ':' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24371 | static void * |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24372 | _tmp_154_rule(Parser *p) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24373 | { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24374 | D(p->level++); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24375 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24376 | D(p->level--); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24377 | return NULL; |
| 24378 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24379 | void * _res = NULL; |
| 24380 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24381 | { // ':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 24382 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24383 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 24384 | return NULL; |
| 24385 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24386 | D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "':'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24387 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24388 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24389 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24390 | ) |
| 24391 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24392 | D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "':'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24393 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24394 | goto done; |
| 24395 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24396 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24397 | D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24398 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "':'")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24399 | } |
| 24400 | { // '**' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 24401 | if (p->error_indicator) { |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24402 | D(p->level--); |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 24403 | return NULL; |
| 24404 | } |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24405 | D(fprintf(stderr, "%*c> _tmp_154[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'**'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24406 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24407 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24408 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24409 | ) |
| 24410 | { |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24411 | D(fprintf(stderr, "%*c+ _tmp_154[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'**'")); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24412 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24413 | goto done; |
| 24414 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24415 | p->mark = _mark; |
Pablo Galindo | c6483c9 | 2020-06-10 14:07:06 +0100 | [diff] [blame^] | 24416 | D(fprintf(stderr, "%*c%s _tmp_154[%d-%d]: %s failed!\n", p->level, ' ', |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24417 | p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'**'")); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24418 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24419 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24420 | done: |
Pablo Galindo | 800a35c6 | 2020-05-25 18:38:45 +0100 | [diff] [blame] | 24421 | D(p->level--); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 24422 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 24423 | } |
| 24424 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 24425 | void * |
| 24426 | _PyPegen_parse(Parser *p) |
| 24427 | { |
| 24428 | // Initialize keywords |
| 24429 | p->keywords = reserved_keywords; |
| 24430 | p->n_keyword_lists = n_keyword_lists; |
| 24431 | |
| 24432 | // Run parser |
| 24433 | void *result = NULL; |
| 24434 | if (p->start_rule == Py_file_input) { |
| 24435 | result = file_rule(p); |
| 24436 | } else if (p->start_rule == Py_single_input) { |
| 24437 | result = interactive_rule(p); |
| 24438 | } else if (p->start_rule == Py_eval_input) { |
| 24439 | result = eval_rule(p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 24440 | } else if (p->start_rule == Py_func_type_input) { |
| 24441 | result = func_type_rule(p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 24442 | } else if (p->start_rule == Py_fstring_input) { |
| 24443 | result = fstring_rule(p); |
| 24444 | } |
| 24445 | |
| 24446 | return result; |
| 24447 | } |
| 24448 | |
| 24449 | // The end |