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" |
| 3 | static const int n_keyword_lists = 15; |
| 4 | static KeywordToken *reserved_keywords[] = { |
| 5 | NULL, |
| 6 | NULL, |
| 7 | (KeywordToken[]) { |
| 8 | {"if", 510}, |
| 9 | {"in", 518}, |
| 10 | {"is", 526}, |
| 11 | {"as", 531}, |
| 12 | {"or", 532}, |
| 13 | {NULL, -1}, |
| 14 | }, |
| 15 | (KeywordToken[]) { |
| 16 | {"del", 503}, |
| 17 | {"try", 511}, |
| 18 | {"for", 517}, |
| 19 | {"def", 522}, |
| 20 | {"not", 525}, |
| 21 | {"and", 533}, |
| 22 | {NULL, -1}, |
| 23 | }, |
| 24 | (KeywordToken[]) { |
| 25 | {"pass", 502}, |
| 26 | {"from", 514}, |
| 27 | {"elif", 515}, |
| 28 | {"else", 516}, |
| 29 | {"with", 519}, |
| 30 | {"True", 527}, |
| 31 | {"None", 529}, |
| 32 | {NULL, -1}, |
| 33 | }, |
| 34 | (KeywordToken[]) { |
| 35 | {"raise", 501}, |
| 36 | {"yield", 504}, |
| 37 | {"break", 506}, |
| 38 | {"while", 512}, |
| 39 | {"class", 523}, |
| 40 | {"False", 528}, |
| 41 | {NULL, -1}, |
| 42 | }, |
| 43 | (KeywordToken[]) { |
| 44 | {"return", 500}, |
| 45 | {"assert", 505}, |
| 46 | {"global", 508}, |
| 47 | {"import", 513}, |
| 48 | {"except", 520}, |
| 49 | {"lambda", 524}, |
| 50 | {NULL, -1}, |
| 51 | }, |
| 52 | (KeywordToken[]) { |
| 53 | {"finally", 521}, |
| 54 | {NULL, -1}, |
| 55 | }, |
| 56 | (KeywordToken[]) { |
| 57 | {"continue", 507}, |
| 58 | {"nonlocal", 509}, |
| 59 | {NULL, -1}, |
| 60 | }, |
| 61 | NULL, |
| 62 | NULL, |
| 63 | NULL, |
| 64 | NULL, |
| 65 | NULL, |
| 66 | (KeywordToken[]) { |
| 67 | {"__new_parser__", 530}, |
| 68 | {NULL, -1}, |
| 69 | }, |
| 70 | }; |
| 71 | #define file_type 1000 |
| 72 | #define interactive_type 1001 |
| 73 | #define eval_type 1002 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 74 | #define func_type_type 1003 |
| 75 | #define fstring_type 1004 |
| 76 | #define type_expressions_type 1005 |
| 77 | #define statements_type 1006 |
| 78 | #define statement_type 1007 |
| 79 | #define statement_newline_type 1008 |
| 80 | #define simple_stmt_type 1009 |
| 81 | #define small_stmt_type 1010 |
| 82 | #define compound_stmt_type 1011 |
| 83 | #define assignment_type 1012 |
| 84 | #define augassign_type 1013 |
| 85 | #define global_stmt_type 1014 |
| 86 | #define nonlocal_stmt_type 1015 |
| 87 | #define yield_stmt_type 1016 |
| 88 | #define assert_stmt_type 1017 |
| 89 | #define del_stmt_type 1018 |
| 90 | #define import_stmt_type 1019 |
| 91 | #define import_name_type 1020 |
| 92 | #define import_from_type 1021 |
| 93 | #define import_from_targets_type 1022 |
| 94 | #define import_from_as_names_type 1023 |
| 95 | #define import_from_as_name_type 1024 |
| 96 | #define dotted_as_names_type 1025 |
| 97 | #define dotted_as_name_type 1026 |
| 98 | #define dotted_name_type 1027 // Left-recursive |
| 99 | #define if_stmt_type 1028 |
| 100 | #define elif_stmt_type 1029 |
| 101 | #define else_block_type 1030 |
| 102 | #define while_stmt_type 1031 |
| 103 | #define for_stmt_type 1032 |
| 104 | #define with_stmt_type 1033 |
| 105 | #define with_item_type 1034 |
| 106 | #define try_stmt_type 1035 |
| 107 | #define except_block_type 1036 |
| 108 | #define finally_block_type 1037 |
| 109 | #define return_stmt_type 1038 |
| 110 | #define raise_stmt_type 1039 |
| 111 | #define function_def_type 1040 |
| 112 | #define function_def_raw_type 1041 |
| 113 | #define func_type_comment_type 1042 |
| 114 | #define params_type 1043 |
| 115 | #define parameters_type 1044 |
| 116 | #define slash_no_default_type 1045 |
| 117 | #define slash_with_default_type 1046 |
| 118 | #define star_etc_type 1047 |
| 119 | #define kwds_type 1048 |
| 120 | #define param_no_default_type 1049 |
| 121 | #define param_with_default_type 1050 |
| 122 | #define param_maybe_default_type 1051 |
| 123 | #define param_type 1052 |
| 124 | #define annotation_type 1053 |
| 125 | #define default_type 1054 |
| 126 | #define decorators_type 1055 |
| 127 | #define class_def_type 1056 |
| 128 | #define class_def_raw_type 1057 |
| 129 | #define block_type 1058 |
| 130 | #define expressions_list_type 1059 |
| 131 | #define star_expressions_type 1060 |
| 132 | #define star_expression_type 1061 |
| 133 | #define star_named_expressions_type 1062 |
| 134 | #define star_named_expression_type 1063 |
| 135 | #define named_expression_type 1064 |
| 136 | #define annotated_rhs_type 1065 |
| 137 | #define expressions_type 1066 |
| 138 | #define expression_type 1067 |
| 139 | #define lambdef_type 1068 |
| 140 | #define lambda_parameters_type 1069 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 141 | #define lambda_slash_no_default_type 1070 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 142 | #define lambda_slash_with_default_type 1071 |
| 143 | #define lambda_star_etc_type 1072 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 144 | #define lambda_kwds_type 1073 |
| 145 | #define lambda_param_no_default_type 1074 |
| 146 | #define lambda_param_with_default_type 1075 |
| 147 | #define lambda_param_maybe_default_type 1076 |
| 148 | #define lambda_param_type 1077 |
| 149 | #define disjunction_type 1078 |
| 150 | #define conjunction_type 1079 |
| 151 | #define inversion_type 1080 |
| 152 | #define comparison_type 1081 |
| 153 | #define compare_op_bitwise_or_pair_type 1082 |
| 154 | #define eq_bitwise_or_type 1083 |
| 155 | #define noteq_bitwise_or_type 1084 |
| 156 | #define lte_bitwise_or_type 1085 |
| 157 | #define lt_bitwise_or_type 1086 |
| 158 | #define gte_bitwise_or_type 1087 |
| 159 | #define gt_bitwise_or_type 1088 |
| 160 | #define notin_bitwise_or_type 1089 |
| 161 | #define in_bitwise_or_type 1090 |
| 162 | #define isnot_bitwise_or_type 1091 |
| 163 | #define is_bitwise_or_type 1092 |
| 164 | #define bitwise_or_type 1093 // Left-recursive |
| 165 | #define bitwise_xor_type 1094 // Left-recursive |
| 166 | #define bitwise_and_type 1095 // Left-recursive |
| 167 | #define shift_expr_type 1096 // Left-recursive |
| 168 | #define sum_type 1097 // Left-recursive |
| 169 | #define term_type 1098 // Left-recursive |
| 170 | #define factor_type 1099 |
| 171 | #define power_type 1100 |
| 172 | #define await_primary_type 1101 |
| 173 | #define primary_type 1102 // Left-recursive |
| 174 | #define slices_type 1103 |
| 175 | #define slice_type 1104 |
| 176 | #define atom_type 1105 |
| 177 | #define strings_type 1106 |
| 178 | #define list_type 1107 |
| 179 | #define listcomp_type 1108 |
| 180 | #define tuple_type 1109 |
| 181 | #define group_type 1110 |
| 182 | #define genexp_type 1111 |
| 183 | #define set_type 1112 |
| 184 | #define setcomp_type 1113 |
| 185 | #define dict_type 1114 |
| 186 | #define dictcomp_type 1115 |
| 187 | #define kvpairs_type 1116 |
| 188 | #define kvpair_type 1117 |
| 189 | #define for_if_clauses_type 1118 |
| 190 | #define for_if_clause_type 1119 |
| 191 | #define yield_expr_type 1120 |
| 192 | #define arguments_type 1121 |
| 193 | #define args_type 1122 |
| 194 | #define kwargs_type 1123 |
| 195 | #define starred_expression_type 1124 |
| 196 | #define kwarg_or_starred_type 1125 |
| 197 | #define kwarg_or_double_starred_type 1126 |
| 198 | #define star_targets_type 1127 |
| 199 | #define star_targets_seq_type 1128 |
| 200 | #define star_target_type 1129 |
| 201 | #define star_atom_type 1130 |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 202 | #define single_target_type 1131 |
| 203 | #define single_subscript_attribute_target_type 1132 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 204 | #define del_targets_type 1133 |
| 205 | #define del_target_type 1134 |
| 206 | #define del_t_atom_type 1135 |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 207 | #define del_target_end_type 1136 |
| 208 | #define targets_type 1137 |
| 209 | #define target_type 1138 |
| 210 | #define t_primary_type 1139 // Left-recursive |
| 211 | #define t_lookahead_type 1140 |
| 212 | #define t_atom_type 1141 |
| 213 | #define incorrect_arguments_type 1142 |
| 214 | #define invalid_kwarg_type 1143 |
| 215 | #define invalid_named_expression_type 1144 |
| 216 | #define invalid_assignment_type 1145 |
| 217 | #define invalid_block_type 1146 |
| 218 | #define invalid_comprehension_type 1147 |
| 219 | #define invalid_parameters_type 1148 |
| 220 | #define invalid_star_etc_type 1149 |
| 221 | #define invalid_lambda_star_etc_type 1150 |
| 222 | #define invalid_double_type_comments_type 1151 |
| 223 | #define invalid_del_target_type 1152 |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame^] | 224 | #define invalid_import_from_targets_type 1153 |
| 225 | #define _loop0_1_type 1154 |
| 226 | #define _loop0_2_type 1155 |
| 227 | #define _loop0_4_type 1156 |
| 228 | #define _gather_3_type 1157 |
| 229 | #define _loop0_6_type 1158 |
| 230 | #define _gather_5_type 1159 |
| 231 | #define _loop0_8_type 1160 |
| 232 | #define _gather_7_type 1161 |
| 233 | #define _loop0_10_type 1162 |
| 234 | #define _gather_9_type 1163 |
| 235 | #define _loop1_11_type 1164 |
| 236 | #define _loop0_13_type 1165 |
| 237 | #define _gather_12_type 1166 |
| 238 | #define _tmp_14_type 1167 |
| 239 | #define _tmp_15_type 1168 |
| 240 | #define _tmp_16_type 1169 |
| 241 | #define _tmp_17_type 1170 |
| 242 | #define _tmp_18_type 1171 |
| 243 | #define _tmp_19_type 1172 |
| 244 | #define _tmp_20_type 1173 |
| 245 | #define _tmp_21_type 1174 |
| 246 | #define _loop1_22_type 1175 |
| 247 | #define _tmp_23_type 1176 |
| 248 | #define _tmp_24_type 1177 |
| 249 | #define _loop0_26_type 1178 |
| 250 | #define _gather_25_type 1179 |
| 251 | #define _loop0_28_type 1180 |
| 252 | #define _gather_27_type 1181 |
| 253 | #define _tmp_29_type 1182 |
| 254 | #define _loop0_30_type 1183 |
| 255 | #define _loop1_31_type 1184 |
| 256 | #define _loop0_33_type 1185 |
| 257 | #define _gather_32_type 1186 |
| 258 | #define _tmp_34_type 1187 |
| 259 | #define _loop0_36_type 1188 |
| 260 | #define _gather_35_type 1189 |
| 261 | #define _tmp_37_type 1190 |
| 262 | #define _loop0_39_type 1191 |
| 263 | #define _gather_38_type 1192 |
| 264 | #define _loop0_41_type 1193 |
| 265 | #define _gather_40_type 1194 |
| 266 | #define _loop0_43_type 1195 |
| 267 | #define _gather_42_type 1196 |
| 268 | #define _loop0_45_type 1197 |
| 269 | #define _gather_44_type 1198 |
| 270 | #define _tmp_46_type 1199 |
| 271 | #define _loop1_47_type 1200 |
| 272 | #define _tmp_48_type 1201 |
| 273 | #define _tmp_49_type 1202 |
| 274 | #define _tmp_50_type 1203 |
| 275 | #define _tmp_51_type 1204 |
| 276 | #define _tmp_52_type 1205 |
| 277 | #define _loop0_53_type 1206 |
| 278 | #define _loop0_54_type 1207 |
| 279 | #define _loop0_55_type 1208 |
| 280 | #define _loop1_56_type 1209 |
| 281 | #define _loop0_57_type 1210 |
| 282 | #define _loop1_58_type 1211 |
| 283 | #define _loop1_59_type 1212 |
| 284 | #define _loop1_60_type 1213 |
| 285 | #define _loop0_61_type 1214 |
| 286 | #define _loop1_62_type 1215 |
| 287 | #define _loop0_63_type 1216 |
| 288 | #define _loop1_64_type 1217 |
| 289 | #define _loop0_65_type 1218 |
| 290 | #define _loop1_66_type 1219 |
| 291 | #define _loop1_67_type 1220 |
| 292 | #define _tmp_68_type 1221 |
| 293 | #define _loop0_70_type 1222 |
| 294 | #define _gather_69_type 1223 |
| 295 | #define _loop1_71_type 1224 |
| 296 | #define _loop0_73_type 1225 |
| 297 | #define _gather_72_type 1226 |
| 298 | #define _loop1_74_type 1227 |
| 299 | #define _loop0_75_type 1228 |
| 300 | #define _loop0_76_type 1229 |
| 301 | #define _loop0_77_type 1230 |
| 302 | #define _loop1_78_type 1231 |
| 303 | #define _loop0_79_type 1232 |
| 304 | #define _loop1_80_type 1233 |
| 305 | #define _loop1_81_type 1234 |
| 306 | #define _loop1_82_type 1235 |
| 307 | #define _loop0_83_type 1236 |
| 308 | #define _loop1_84_type 1237 |
| 309 | #define _loop0_85_type 1238 |
| 310 | #define _loop1_86_type 1239 |
| 311 | #define _loop0_87_type 1240 |
| 312 | #define _loop1_88_type 1241 |
| 313 | #define _loop1_89_type 1242 |
| 314 | #define _loop1_90_type 1243 |
| 315 | #define _loop1_91_type 1244 |
| 316 | #define _tmp_92_type 1245 |
| 317 | #define _loop0_94_type 1246 |
| 318 | #define _gather_93_type 1247 |
| 319 | #define _tmp_95_type 1248 |
| 320 | #define _tmp_96_type 1249 |
| 321 | #define _tmp_97_type 1250 |
| 322 | #define _tmp_98_type 1251 |
| 323 | #define _loop1_99_type 1252 |
| 324 | #define _tmp_100_type 1253 |
| 325 | #define _tmp_101_type 1254 |
| 326 | #define _loop0_103_type 1255 |
| 327 | #define _gather_102_type 1256 |
| 328 | #define _loop1_104_type 1257 |
| 329 | #define _loop0_105_type 1258 |
| 330 | #define _loop0_106_type 1259 |
| 331 | #define _tmp_107_type 1260 |
| 332 | #define _tmp_108_type 1261 |
| 333 | #define _loop0_110_type 1262 |
| 334 | #define _gather_109_type 1263 |
| 335 | #define _loop0_112_type 1264 |
| 336 | #define _gather_111_type 1265 |
| 337 | #define _loop0_114_type 1266 |
| 338 | #define _gather_113_type 1267 |
| 339 | #define _loop0_116_type 1268 |
| 340 | #define _gather_115_type 1269 |
| 341 | #define _loop0_117_type 1270 |
| 342 | #define _loop0_119_type 1271 |
| 343 | #define _gather_118_type 1272 |
| 344 | #define _tmp_120_type 1273 |
| 345 | #define _loop0_122_type 1274 |
| 346 | #define _gather_121_type 1275 |
| 347 | #define _loop0_124_type 1276 |
| 348 | #define _gather_123_type 1277 |
| 349 | #define _tmp_125_type 1278 |
| 350 | #define _loop0_126_type 1279 |
| 351 | #define _tmp_127_type 1280 |
| 352 | #define _tmp_128_type 1281 |
| 353 | #define _tmp_129_type 1282 |
| 354 | #define _tmp_130_type 1283 |
| 355 | #define _loop0_131_type 1284 |
| 356 | #define _tmp_132_type 1285 |
| 357 | #define _tmp_133_type 1286 |
| 358 | #define _tmp_134_type 1287 |
| 359 | #define _tmp_135_type 1288 |
| 360 | #define _tmp_136_type 1289 |
| 361 | #define _tmp_137_type 1290 |
| 362 | #define _tmp_138_type 1291 |
| 363 | #define _tmp_139_type 1292 |
| 364 | #define _tmp_140_type 1293 |
| 365 | #define _tmp_141_type 1294 |
| 366 | #define _tmp_142_type 1295 |
| 367 | #define _tmp_143_type 1296 |
| 368 | #define _tmp_144_type 1297 |
| 369 | #define _tmp_145_type 1298 |
| 370 | #define _loop1_146_type 1299 |
| 371 | #define _tmp_147_type 1300 |
| 372 | #define _tmp_148_type 1301 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 373 | |
| 374 | static mod_ty file_rule(Parser *p); |
| 375 | static mod_ty interactive_rule(Parser *p); |
| 376 | static mod_ty eval_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 377 | static mod_ty func_type_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 378 | static expr_ty fstring_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 379 | static asdl_seq* type_expressions_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 380 | static asdl_seq* statements_rule(Parser *p); |
| 381 | static asdl_seq* statement_rule(Parser *p); |
| 382 | static asdl_seq* statement_newline_rule(Parser *p); |
| 383 | static asdl_seq* simple_stmt_rule(Parser *p); |
| 384 | static stmt_ty small_stmt_rule(Parser *p); |
| 385 | static stmt_ty compound_stmt_rule(Parser *p); |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 386 | static stmt_ty assignment_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 387 | static AugOperator* augassign_rule(Parser *p); |
| 388 | static stmt_ty global_stmt_rule(Parser *p); |
| 389 | static stmt_ty nonlocal_stmt_rule(Parser *p); |
| 390 | static stmt_ty yield_stmt_rule(Parser *p); |
| 391 | static stmt_ty assert_stmt_rule(Parser *p); |
| 392 | static stmt_ty del_stmt_rule(Parser *p); |
| 393 | static stmt_ty import_stmt_rule(Parser *p); |
| 394 | static stmt_ty import_name_rule(Parser *p); |
| 395 | static stmt_ty import_from_rule(Parser *p); |
| 396 | static asdl_seq* import_from_targets_rule(Parser *p); |
| 397 | static asdl_seq* import_from_as_names_rule(Parser *p); |
| 398 | static alias_ty import_from_as_name_rule(Parser *p); |
| 399 | static asdl_seq* dotted_as_names_rule(Parser *p); |
| 400 | static alias_ty dotted_as_name_rule(Parser *p); |
| 401 | static expr_ty dotted_name_rule(Parser *p); |
| 402 | static stmt_ty if_stmt_rule(Parser *p); |
| 403 | static stmt_ty elif_stmt_rule(Parser *p); |
| 404 | static asdl_seq* else_block_rule(Parser *p); |
| 405 | static stmt_ty while_stmt_rule(Parser *p); |
| 406 | static stmt_ty for_stmt_rule(Parser *p); |
| 407 | static stmt_ty with_stmt_rule(Parser *p); |
| 408 | static withitem_ty with_item_rule(Parser *p); |
| 409 | static stmt_ty try_stmt_rule(Parser *p); |
| 410 | static excepthandler_ty except_block_rule(Parser *p); |
| 411 | static asdl_seq* finally_block_rule(Parser *p); |
| 412 | static stmt_ty return_stmt_rule(Parser *p); |
| 413 | static stmt_ty raise_stmt_rule(Parser *p); |
| 414 | static stmt_ty function_def_rule(Parser *p); |
| 415 | static stmt_ty function_def_raw_rule(Parser *p); |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 416 | static Token* func_type_comment_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 417 | static arguments_ty params_rule(Parser *p); |
| 418 | static arguments_ty parameters_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 419 | static asdl_seq* slash_no_default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 420 | static SlashWithDefault* slash_with_default_rule(Parser *p); |
| 421 | static StarEtc* star_etc_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 422 | static arg_ty kwds_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 423 | static arg_ty param_no_default_rule(Parser *p); |
| 424 | static NameDefaultPair* param_with_default_rule(Parser *p); |
| 425 | static NameDefaultPair* param_maybe_default_rule(Parser *p); |
| 426 | static arg_ty param_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 427 | static expr_ty annotation_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 428 | static expr_ty default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 429 | static asdl_seq* decorators_rule(Parser *p); |
| 430 | static stmt_ty class_def_rule(Parser *p); |
| 431 | static stmt_ty class_def_raw_rule(Parser *p); |
| 432 | static asdl_seq* block_rule(Parser *p); |
| 433 | static asdl_seq* expressions_list_rule(Parser *p); |
| 434 | static expr_ty star_expressions_rule(Parser *p); |
| 435 | static expr_ty star_expression_rule(Parser *p); |
| 436 | static asdl_seq* star_named_expressions_rule(Parser *p); |
| 437 | static expr_ty star_named_expression_rule(Parser *p); |
| 438 | static expr_ty named_expression_rule(Parser *p); |
| 439 | static expr_ty annotated_rhs_rule(Parser *p); |
| 440 | static expr_ty expressions_rule(Parser *p); |
| 441 | static expr_ty expression_rule(Parser *p); |
| 442 | static expr_ty lambdef_rule(Parser *p); |
| 443 | static arguments_ty lambda_parameters_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 444 | static asdl_seq* lambda_slash_no_default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 445 | static SlashWithDefault* lambda_slash_with_default_rule(Parser *p); |
| 446 | static StarEtc* lambda_star_etc_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 447 | static arg_ty lambda_kwds_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 448 | static arg_ty lambda_param_no_default_rule(Parser *p); |
| 449 | static NameDefaultPair* lambda_param_with_default_rule(Parser *p); |
| 450 | static NameDefaultPair* lambda_param_maybe_default_rule(Parser *p); |
| 451 | static arg_ty lambda_param_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 452 | static expr_ty disjunction_rule(Parser *p); |
| 453 | static expr_ty conjunction_rule(Parser *p); |
| 454 | static expr_ty inversion_rule(Parser *p); |
| 455 | static expr_ty comparison_rule(Parser *p); |
| 456 | static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p); |
| 457 | static CmpopExprPair* eq_bitwise_or_rule(Parser *p); |
| 458 | static CmpopExprPair* noteq_bitwise_or_rule(Parser *p); |
| 459 | static CmpopExprPair* lte_bitwise_or_rule(Parser *p); |
| 460 | static CmpopExprPair* lt_bitwise_or_rule(Parser *p); |
| 461 | static CmpopExprPair* gte_bitwise_or_rule(Parser *p); |
| 462 | static CmpopExprPair* gt_bitwise_or_rule(Parser *p); |
| 463 | static CmpopExprPair* notin_bitwise_or_rule(Parser *p); |
| 464 | static CmpopExprPair* in_bitwise_or_rule(Parser *p); |
| 465 | static CmpopExprPair* isnot_bitwise_or_rule(Parser *p); |
| 466 | static CmpopExprPair* is_bitwise_or_rule(Parser *p); |
| 467 | static expr_ty bitwise_or_rule(Parser *p); |
| 468 | static expr_ty bitwise_xor_rule(Parser *p); |
| 469 | static expr_ty bitwise_and_rule(Parser *p); |
| 470 | static expr_ty shift_expr_rule(Parser *p); |
| 471 | static expr_ty sum_rule(Parser *p); |
| 472 | static expr_ty term_rule(Parser *p); |
| 473 | static expr_ty factor_rule(Parser *p); |
| 474 | static expr_ty power_rule(Parser *p); |
| 475 | static expr_ty await_primary_rule(Parser *p); |
| 476 | static expr_ty primary_rule(Parser *p); |
| 477 | static expr_ty slices_rule(Parser *p); |
| 478 | static expr_ty slice_rule(Parser *p); |
| 479 | static expr_ty atom_rule(Parser *p); |
| 480 | static expr_ty strings_rule(Parser *p); |
| 481 | static expr_ty list_rule(Parser *p); |
| 482 | static expr_ty listcomp_rule(Parser *p); |
| 483 | static expr_ty tuple_rule(Parser *p); |
| 484 | static expr_ty group_rule(Parser *p); |
| 485 | static expr_ty genexp_rule(Parser *p); |
| 486 | static expr_ty set_rule(Parser *p); |
| 487 | static expr_ty setcomp_rule(Parser *p); |
| 488 | static expr_ty dict_rule(Parser *p); |
| 489 | static expr_ty dictcomp_rule(Parser *p); |
| 490 | static asdl_seq* kvpairs_rule(Parser *p); |
| 491 | static KeyValuePair* kvpair_rule(Parser *p); |
| 492 | static asdl_seq* for_if_clauses_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 493 | static comprehension_ty for_if_clause_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 494 | static expr_ty yield_expr_rule(Parser *p); |
| 495 | static expr_ty arguments_rule(Parser *p); |
| 496 | static expr_ty args_rule(Parser *p); |
| 497 | static asdl_seq* kwargs_rule(Parser *p); |
| 498 | static expr_ty starred_expression_rule(Parser *p); |
| 499 | static KeywordOrStarred* kwarg_or_starred_rule(Parser *p); |
| 500 | static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p); |
| 501 | static expr_ty star_targets_rule(Parser *p); |
| 502 | static asdl_seq* star_targets_seq_rule(Parser *p); |
| 503 | static expr_ty star_target_rule(Parser *p); |
| 504 | static expr_ty star_atom_rule(Parser *p); |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 505 | static expr_ty single_target_rule(Parser *p); |
| 506 | static expr_ty single_subscript_attribute_target_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 507 | static asdl_seq* del_targets_rule(Parser *p); |
| 508 | static expr_ty del_target_rule(Parser *p); |
| 509 | static expr_ty del_t_atom_rule(Parser *p); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 510 | static void *del_target_end_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 511 | static asdl_seq* targets_rule(Parser *p); |
| 512 | static expr_ty target_rule(Parser *p); |
| 513 | static expr_ty t_primary_rule(Parser *p); |
| 514 | static void *t_lookahead_rule(Parser *p); |
| 515 | static expr_ty t_atom_rule(Parser *p); |
| 516 | static void *incorrect_arguments_rule(Parser *p); |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 517 | static void *invalid_kwarg_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 518 | static void *invalid_named_expression_rule(Parser *p); |
| 519 | static void *invalid_assignment_rule(Parser *p); |
| 520 | static void *invalid_block_rule(Parser *p); |
| 521 | static void *invalid_comprehension_rule(Parser *p); |
| 522 | static void *invalid_parameters_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 523 | static void *invalid_star_etc_rule(Parser *p); |
| 524 | static void *invalid_lambda_star_etc_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 525 | static void *invalid_double_type_comments_rule(Parser *p); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 526 | static void *invalid_del_target_rule(Parser *p); |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame^] | 527 | static void *invalid_import_from_targets_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 528 | static asdl_seq *_loop0_1_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 529 | static asdl_seq *_loop0_2_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 530 | static asdl_seq *_loop0_4_rule(Parser *p); |
| 531 | static asdl_seq *_gather_3_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 532 | static asdl_seq *_loop0_6_rule(Parser *p); |
| 533 | static asdl_seq *_gather_5_rule(Parser *p); |
| 534 | static asdl_seq *_loop0_8_rule(Parser *p); |
| 535 | static asdl_seq *_gather_7_rule(Parser *p); |
| 536 | static asdl_seq *_loop0_10_rule(Parser *p); |
| 537 | static asdl_seq *_gather_9_rule(Parser *p); |
| 538 | static asdl_seq *_loop1_11_rule(Parser *p); |
| 539 | static asdl_seq *_loop0_13_rule(Parser *p); |
| 540 | static asdl_seq *_gather_12_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 541 | static void *_tmp_14_rule(Parser *p); |
| 542 | static void *_tmp_15_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 543 | static void *_tmp_16_rule(Parser *p); |
| 544 | static void *_tmp_17_rule(Parser *p); |
| 545 | static void *_tmp_18_rule(Parser *p); |
| 546 | static void *_tmp_19_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 547 | static void *_tmp_20_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 548 | static void *_tmp_21_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 549 | static asdl_seq *_loop1_22_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 550 | static void *_tmp_23_rule(Parser *p); |
| 551 | static void *_tmp_24_rule(Parser *p); |
| 552 | static asdl_seq *_loop0_26_rule(Parser *p); |
| 553 | static asdl_seq *_gather_25_rule(Parser *p); |
| 554 | static asdl_seq *_loop0_28_rule(Parser *p); |
| 555 | static asdl_seq *_gather_27_rule(Parser *p); |
| 556 | static void *_tmp_29_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 557 | static asdl_seq *_loop0_30_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 558 | static asdl_seq *_loop1_31_rule(Parser *p); |
| 559 | static asdl_seq *_loop0_33_rule(Parser *p); |
| 560 | static asdl_seq *_gather_32_rule(Parser *p); |
| 561 | static void *_tmp_34_rule(Parser *p); |
| 562 | static asdl_seq *_loop0_36_rule(Parser *p); |
| 563 | static asdl_seq *_gather_35_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 564 | static void *_tmp_37_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 565 | static asdl_seq *_loop0_39_rule(Parser *p); |
| 566 | static asdl_seq *_gather_38_rule(Parser *p); |
| 567 | static asdl_seq *_loop0_41_rule(Parser *p); |
| 568 | static asdl_seq *_gather_40_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 569 | static asdl_seq *_loop0_43_rule(Parser *p); |
| 570 | static asdl_seq *_gather_42_rule(Parser *p); |
| 571 | static asdl_seq *_loop0_45_rule(Parser *p); |
| 572 | static asdl_seq *_gather_44_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 573 | static void *_tmp_46_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 574 | static asdl_seq *_loop1_47_rule(Parser *p); |
| 575 | static void *_tmp_48_rule(Parser *p); |
| 576 | static void *_tmp_49_rule(Parser *p); |
| 577 | static void *_tmp_50_rule(Parser *p); |
| 578 | static void *_tmp_51_rule(Parser *p); |
| 579 | static void *_tmp_52_rule(Parser *p); |
| 580 | static asdl_seq *_loop0_53_rule(Parser *p); |
| 581 | static asdl_seq *_loop0_54_rule(Parser *p); |
| 582 | static asdl_seq *_loop0_55_rule(Parser *p); |
| 583 | static asdl_seq *_loop1_56_rule(Parser *p); |
| 584 | static asdl_seq *_loop0_57_rule(Parser *p); |
| 585 | static asdl_seq *_loop1_58_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 586 | static asdl_seq *_loop1_59_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 587 | static asdl_seq *_loop1_60_rule(Parser *p); |
| 588 | static asdl_seq *_loop0_61_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 589 | static asdl_seq *_loop1_62_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 590 | static asdl_seq *_loop0_63_rule(Parser *p); |
| 591 | static asdl_seq *_loop1_64_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 592 | static asdl_seq *_loop0_65_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 593 | static asdl_seq *_loop1_66_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 594 | static asdl_seq *_loop1_67_rule(Parser *p); |
| 595 | static void *_tmp_68_rule(Parser *p); |
| 596 | static asdl_seq *_loop0_70_rule(Parser *p); |
| 597 | static asdl_seq *_gather_69_rule(Parser *p); |
| 598 | static asdl_seq *_loop1_71_rule(Parser *p); |
| 599 | static asdl_seq *_loop0_73_rule(Parser *p); |
| 600 | static asdl_seq *_gather_72_rule(Parser *p); |
| 601 | static asdl_seq *_loop1_74_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 602 | static asdl_seq *_loop0_75_rule(Parser *p); |
| 603 | static asdl_seq *_loop0_76_rule(Parser *p); |
| 604 | static asdl_seq *_loop0_77_rule(Parser *p); |
| 605 | static asdl_seq *_loop1_78_rule(Parser *p); |
| 606 | static asdl_seq *_loop0_79_rule(Parser *p); |
| 607 | static asdl_seq *_loop1_80_rule(Parser *p); |
| 608 | static asdl_seq *_loop1_81_rule(Parser *p); |
| 609 | static asdl_seq *_loop1_82_rule(Parser *p); |
| 610 | static asdl_seq *_loop0_83_rule(Parser *p); |
| 611 | static asdl_seq *_loop1_84_rule(Parser *p); |
| 612 | static asdl_seq *_loop0_85_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 613 | static asdl_seq *_loop1_86_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 614 | static asdl_seq *_loop0_87_rule(Parser *p); |
| 615 | static asdl_seq *_loop1_88_rule(Parser *p); |
| 616 | static asdl_seq *_loop1_89_rule(Parser *p); |
| 617 | static asdl_seq *_loop1_90_rule(Parser *p); |
| 618 | static asdl_seq *_loop1_91_rule(Parser *p); |
| 619 | static void *_tmp_92_rule(Parser *p); |
| 620 | static asdl_seq *_loop0_94_rule(Parser *p); |
| 621 | static asdl_seq *_gather_93_rule(Parser *p); |
| 622 | static void *_tmp_95_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 623 | static void *_tmp_96_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 624 | static void *_tmp_97_rule(Parser *p); |
| 625 | static void *_tmp_98_rule(Parser *p); |
| 626 | static asdl_seq *_loop1_99_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 627 | static void *_tmp_100_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 628 | static void *_tmp_101_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 629 | static asdl_seq *_loop0_103_rule(Parser *p); |
| 630 | static asdl_seq *_gather_102_rule(Parser *p); |
| 631 | static asdl_seq *_loop1_104_rule(Parser *p); |
| 632 | static asdl_seq *_loop0_105_rule(Parser *p); |
| 633 | static asdl_seq *_loop0_106_rule(Parser *p); |
| 634 | static void *_tmp_107_rule(Parser *p); |
| 635 | static void *_tmp_108_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 636 | static asdl_seq *_loop0_110_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 637 | static asdl_seq *_gather_109_rule(Parser *p); |
| 638 | static asdl_seq *_loop0_112_rule(Parser *p); |
| 639 | static asdl_seq *_gather_111_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 640 | static asdl_seq *_loop0_114_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 641 | static asdl_seq *_gather_113_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 642 | static asdl_seq *_loop0_116_rule(Parser *p); |
| 643 | static asdl_seq *_gather_115_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 644 | static asdl_seq *_loop0_117_rule(Parser *p); |
| 645 | static asdl_seq *_loop0_119_rule(Parser *p); |
| 646 | static asdl_seq *_gather_118_rule(Parser *p); |
| 647 | static void *_tmp_120_rule(Parser *p); |
| 648 | static asdl_seq *_loop0_122_rule(Parser *p); |
| 649 | static asdl_seq *_gather_121_rule(Parser *p); |
| 650 | static asdl_seq *_loop0_124_rule(Parser *p); |
| 651 | static asdl_seq *_gather_123_rule(Parser *p); |
| 652 | static void *_tmp_125_rule(Parser *p); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 653 | static asdl_seq *_loop0_126_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 654 | static void *_tmp_127_rule(Parser *p); |
| 655 | static void *_tmp_128_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 656 | static void *_tmp_129_rule(Parser *p); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 657 | static void *_tmp_130_rule(Parser *p); |
| 658 | static asdl_seq *_loop0_131_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 659 | static void *_tmp_132_rule(Parser *p); |
| 660 | static void *_tmp_133_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 661 | static void *_tmp_134_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 662 | static void *_tmp_135_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 663 | static void *_tmp_136_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 664 | static void *_tmp_137_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 665 | static void *_tmp_138_rule(Parser *p); |
| 666 | static void *_tmp_139_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 667 | static void *_tmp_140_rule(Parser *p); |
| 668 | static void *_tmp_141_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 669 | static void *_tmp_142_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 670 | static void *_tmp_143_rule(Parser *p); |
| 671 | static void *_tmp_144_rule(Parser *p); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 672 | static void *_tmp_145_rule(Parser *p); |
| 673 | static asdl_seq *_loop1_146_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 674 | static void *_tmp_147_rule(Parser *p); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 675 | static void *_tmp_148_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 676 | |
| 677 | |
| 678 | // file: statements? $ |
| 679 | static mod_ty |
| 680 | file_rule(Parser *p) |
| 681 | { |
| 682 | if (p->error_indicator) { |
| 683 | return NULL; |
| 684 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 685 | mod_ty _res = NULL; |
| 686 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 687 | { // statements? $ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 688 | if (p->error_indicator) { |
| 689 | return NULL; |
| 690 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 691 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 692 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 693 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 694 | (a = statements_rule(p), 1) // statements? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 695 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 696 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 697 | ) |
| 698 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 699 | _res = _PyPegen_make_module ( p , a ); |
| 700 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 701 | p->error_indicator = 1; |
| 702 | return NULL; |
| 703 | } |
| 704 | goto done; |
| 705 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 706 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 707 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 708 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 709 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 710 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | // interactive: statement_newline |
| 714 | static mod_ty |
| 715 | interactive_rule(Parser *p) |
| 716 | { |
| 717 | if (p->error_indicator) { |
| 718 | return NULL; |
| 719 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 720 | mod_ty _res = NULL; |
| 721 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 722 | { // statement_newline |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 723 | if (p->error_indicator) { |
| 724 | return NULL; |
| 725 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 726 | asdl_seq* a; |
| 727 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 728 | (a = statement_newline_rule(p)) // statement_newline |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 729 | ) |
| 730 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 731 | _res = Interactive ( a , p -> arena ); |
| 732 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 733 | p->error_indicator = 1; |
| 734 | return NULL; |
| 735 | } |
| 736 | goto done; |
| 737 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 738 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 739 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 740 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 741 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 742 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 743 | } |
| 744 | |
| 745 | // eval: expressions NEWLINE* $ |
| 746 | static mod_ty |
| 747 | eval_rule(Parser *p) |
| 748 | { |
| 749 | if (p->error_indicator) { |
| 750 | return NULL; |
| 751 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 752 | mod_ty _res = NULL; |
| 753 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 754 | { // expressions NEWLINE* $ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 755 | if (p->error_indicator) { |
| 756 | return NULL; |
| 757 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 758 | asdl_seq * _loop0_1_var; |
| 759 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 760 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 761 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 762 | (a = expressions_rule(p)) // expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 763 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 764 | (_loop0_1_var = _loop0_1_rule(p)) // NEWLINE* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 765 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 766 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 767 | ) |
| 768 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 769 | _res = Expression ( a , p -> arena ); |
| 770 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 771 | p->error_indicator = 1; |
| 772 | return NULL; |
| 773 | } |
| 774 | goto done; |
| 775 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 776 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 777 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 778 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 779 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 780 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 781 | } |
| 782 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 783 | // func_type: '(' type_expressions? ')' '->' expression NEWLINE* $ |
| 784 | static mod_ty |
| 785 | func_type_rule(Parser *p) |
| 786 | { |
| 787 | if (p->error_indicator) { |
| 788 | return NULL; |
| 789 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 790 | mod_ty _res = NULL; |
| 791 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 792 | { // '(' type_expressions? ')' '->' expression NEWLINE* $ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 793 | if (p->error_indicator) { |
| 794 | return NULL; |
| 795 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 796 | Token * _literal; |
| 797 | Token * _literal_1; |
| 798 | Token * _literal_2; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 799 | asdl_seq * _loop0_2_var; |
| 800 | void *a; |
| 801 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 802 | Token * endmarker_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 803 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 804 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 805 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 806 | (a = type_expressions_rule(p), 1) // type_expressions? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 807 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 808 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 809 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 810 | (_literal_2 = _PyPegen_expect_token(p, 51)) // token='->' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 811 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 812 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 813 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 814 | (_loop0_2_var = _loop0_2_rule(p)) // NEWLINE* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 815 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 816 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 817 | ) |
| 818 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 819 | _res = FunctionType ( a , b , p -> arena ); |
| 820 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 821 | p->error_indicator = 1; |
| 822 | return NULL; |
| 823 | } |
| 824 | goto done; |
| 825 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 826 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 827 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 828 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 829 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 830 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 831 | } |
| 832 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 833 | // fstring: star_expressions |
| 834 | static expr_ty |
| 835 | fstring_rule(Parser *p) |
| 836 | { |
| 837 | if (p->error_indicator) { |
| 838 | return NULL; |
| 839 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 840 | expr_ty _res = NULL; |
| 841 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 842 | { // star_expressions |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 843 | if (p->error_indicator) { |
| 844 | return NULL; |
| 845 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 846 | expr_ty star_expressions_var; |
| 847 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 848 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 849 | ) |
| 850 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 851 | _res = star_expressions_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 852 | goto done; |
| 853 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 854 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 855 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 856 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 857 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 858 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 859 | } |
| 860 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 861 | // type_expressions: |
| 862 | // | ','.expression+ ',' '*' expression ',' '**' expression |
| 863 | // | ','.expression+ ',' '*' expression |
| 864 | // | ','.expression+ ',' '**' expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 865 | // | '*' expression ',' '**' expression |
| 866 | // | '*' expression |
| 867 | // | '**' expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 868 | // | ','.expression+ |
| 869 | static asdl_seq* |
| 870 | type_expressions_rule(Parser *p) |
| 871 | { |
| 872 | if (p->error_indicator) { |
| 873 | return NULL; |
| 874 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 875 | asdl_seq* _res = NULL; |
| 876 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 877 | { // ','.expression+ ',' '*' expression ',' '**' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 878 | if (p->error_indicator) { |
| 879 | return NULL; |
| 880 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 881 | Token * _literal; |
| 882 | Token * _literal_1; |
| 883 | Token * _literal_2; |
| 884 | Token * _literal_3; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 885 | asdl_seq * a; |
| 886 | expr_ty b; |
| 887 | expr_ty c; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 888 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 889 | (a = _gather_3_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 890 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 891 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 892 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 893 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 894 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 895 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 896 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 897 | (_literal_2 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 898 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 899 | (_literal_3 = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 900 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 901 | (c = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 902 | ) |
| 903 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 904 | _res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_seq_append_to_end ( p , a , b ) ) , c ); |
| 905 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 906 | p->error_indicator = 1; |
| 907 | return NULL; |
| 908 | } |
| 909 | goto done; |
| 910 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 911 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 912 | } |
| 913 | { // ','.expression+ ',' '*' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 914 | if (p->error_indicator) { |
| 915 | return NULL; |
| 916 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 917 | Token * _literal; |
| 918 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 919 | asdl_seq * a; |
| 920 | expr_ty b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 921 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 922 | (a = _gather_5_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 923 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 924 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 925 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 926 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 927 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 928 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 929 | ) |
| 930 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 931 | _res = _PyPegen_seq_append_to_end ( p , a , b ); |
| 932 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 933 | p->error_indicator = 1; |
| 934 | return NULL; |
| 935 | } |
| 936 | goto done; |
| 937 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 938 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 939 | } |
| 940 | { // ','.expression+ ',' '**' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 941 | if (p->error_indicator) { |
| 942 | return NULL; |
| 943 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 944 | Token * _literal; |
| 945 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 946 | asdl_seq * a; |
| 947 | expr_ty b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 948 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 949 | (a = _gather_7_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 950 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 951 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 952 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 953 | (_literal_1 = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 954 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 955 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 956 | ) |
| 957 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 958 | _res = _PyPegen_seq_append_to_end ( p , a , b ); |
| 959 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 960 | p->error_indicator = 1; |
| 961 | return NULL; |
| 962 | } |
| 963 | goto done; |
| 964 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 965 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 966 | } |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 967 | { // '*' expression ',' '**' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 968 | if (p->error_indicator) { |
| 969 | return NULL; |
| 970 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 971 | Token * _literal; |
| 972 | Token * _literal_1; |
| 973 | Token * _literal_2; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 974 | expr_ty a; |
| 975 | expr_ty b; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 976 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 977 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 978 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 979 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 980 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 981 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 982 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 983 | (_literal_2 = _PyPegen_expect_token(p, 35)) // token='**' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 984 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 985 | (b = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 986 | ) |
| 987 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 988 | _res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_singleton_seq ( p , a ) ) , b ); |
| 989 | if (_res == NULL && PyErr_Occurred()) { |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 990 | p->error_indicator = 1; |
| 991 | return NULL; |
| 992 | } |
| 993 | goto done; |
| 994 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 995 | p->mark = _mark; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 996 | } |
| 997 | { // '*' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 998 | if (p->error_indicator) { |
| 999 | return NULL; |
| 1000 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1001 | Token * _literal; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1002 | expr_ty a; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1003 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1004 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1005 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1006 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1007 | ) |
| 1008 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1009 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1010 | if (_res == NULL && PyErr_Occurred()) { |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1011 | p->error_indicator = 1; |
| 1012 | return NULL; |
| 1013 | } |
| 1014 | goto done; |
| 1015 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1016 | p->mark = _mark; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1017 | } |
| 1018 | { // '**' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1019 | if (p->error_indicator) { |
| 1020 | return NULL; |
| 1021 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1022 | Token * _literal; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1023 | expr_ty a; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1024 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1025 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1026 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1027 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1028 | ) |
| 1029 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1030 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1031 | if (_res == NULL && PyErr_Occurred()) { |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1032 | p->error_indicator = 1; |
| 1033 | return NULL; |
| 1034 | } |
| 1035 | goto done; |
| 1036 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1037 | p->mark = _mark; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1038 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1039 | { // ','.expression+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1040 | if (p->error_indicator) { |
| 1041 | return NULL; |
| 1042 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1043 | asdl_seq * _gather_9_var; |
| 1044 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1045 | (_gather_9_var = _gather_9_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1046 | ) |
| 1047 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1048 | _res = _gather_9_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1049 | goto done; |
| 1050 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1051 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1052 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1053 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1054 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1055 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1056 | } |
| 1057 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1058 | // statements: statement+ |
| 1059 | static asdl_seq* |
| 1060 | statements_rule(Parser *p) |
| 1061 | { |
| 1062 | if (p->error_indicator) { |
| 1063 | return NULL; |
| 1064 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1065 | asdl_seq* _res = NULL; |
| 1066 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1067 | { // statement+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1068 | if (p->error_indicator) { |
| 1069 | return NULL; |
| 1070 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1071 | asdl_seq * a; |
| 1072 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1073 | (a = _loop1_11_rule(p)) // statement+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1074 | ) |
| 1075 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1076 | _res = _PyPegen_seq_flatten ( p , a ); |
| 1077 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1078 | p->error_indicator = 1; |
| 1079 | return NULL; |
| 1080 | } |
| 1081 | goto done; |
| 1082 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1083 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1084 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1085 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1086 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1087 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1088 | } |
| 1089 | |
| 1090 | // statement: compound_stmt | simple_stmt |
| 1091 | static asdl_seq* |
| 1092 | statement_rule(Parser *p) |
| 1093 | { |
| 1094 | if (p->error_indicator) { |
| 1095 | return NULL; |
| 1096 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1097 | asdl_seq* _res = NULL; |
| 1098 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1099 | { // compound_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1100 | if (p->error_indicator) { |
| 1101 | return NULL; |
| 1102 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1103 | stmt_ty a; |
| 1104 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1105 | (a = compound_stmt_rule(p)) // compound_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1106 | ) |
| 1107 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1108 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1109 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1110 | p->error_indicator = 1; |
| 1111 | return NULL; |
| 1112 | } |
| 1113 | goto done; |
| 1114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1115 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1116 | } |
| 1117 | { // simple_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1118 | if (p->error_indicator) { |
| 1119 | return NULL; |
| 1120 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1121 | asdl_seq* simple_stmt_var; |
| 1122 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1123 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1124 | ) |
| 1125 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1126 | _res = simple_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1127 | goto done; |
| 1128 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1129 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1130 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1131 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1132 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1133 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1134 | } |
| 1135 | |
| 1136 | // statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $ |
| 1137 | static asdl_seq* |
| 1138 | statement_newline_rule(Parser *p) |
| 1139 | { |
| 1140 | if (p->error_indicator) { |
| 1141 | return NULL; |
| 1142 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1143 | asdl_seq* _res = NULL; |
| 1144 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1145 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1146 | p->error_indicator = 1; |
| 1147 | return NULL; |
| 1148 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1149 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1150 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1151 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1152 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1153 | { // compound_stmt NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1154 | if (p->error_indicator) { |
| 1155 | return NULL; |
| 1156 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1157 | stmt_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1158 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1159 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1160 | (a = compound_stmt_rule(p)) // compound_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1161 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1162 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1163 | ) |
| 1164 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1165 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1166 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1167 | p->error_indicator = 1; |
| 1168 | return NULL; |
| 1169 | } |
| 1170 | goto done; |
| 1171 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1172 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1173 | } |
| 1174 | { // simple_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1175 | if (p->error_indicator) { |
| 1176 | return NULL; |
| 1177 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1178 | asdl_seq* simple_stmt_var; |
| 1179 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1180 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1181 | ) |
| 1182 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1183 | _res = simple_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1184 | goto done; |
| 1185 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1186 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1187 | } |
| 1188 | { // NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1189 | if (p->error_indicator) { |
| 1190 | return NULL; |
| 1191 | } |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1192 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1193 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1194 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1195 | ) |
| 1196 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1197 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1198 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1199 | return NULL; |
| 1200 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1201 | int _end_lineno = _token->end_lineno; |
| 1202 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1203 | int _end_col_offset = _token->end_col_offset; |
| 1204 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1205 | _res = _PyPegen_singleton_seq ( p , CHECK ( _Py_Pass ( EXTRA ) ) ); |
| 1206 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1207 | p->error_indicator = 1; |
| 1208 | return NULL; |
| 1209 | } |
| 1210 | goto done; |
| 1211 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1212 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1213 | } |
| 1214 | { // $ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1215 | if (p->error_indicator) { |
| 1216 | return NULL; |
| 1217 | } |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1218 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1219 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1220 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1221 | ) |
| 1222 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1223 | _res = _PyPegen_interactive_exit ( p ); |
| 1224 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1225 | p->error_indicator = 1; |
| 1226 | return NULL; |
| 1227 | } |
| 1228 | goto done; |
| 1229 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1230 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1231 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1232 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1233 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1234 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1235 | } |
| 1236 | |
| 1237 | // simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE |
| 1238 | static asdl_seq* |
| 1239 | simple_stmt_rule(Parser *p) |
| 1240 | { |
| 1241 | if (p->error_indicator) { |
| 1242 | return NULL; |
| 1243 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1244 | asdl_seq* _res = NULL; |
| 1245 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1246 | { // small_stmt !';' NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1247 | if (p->error_indicator) { |
| 1248 | return NULL; |
| 1249 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1250 | stmt_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1251 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1252 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1253 | (a = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1254 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1255 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1256 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1257 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1258 | ) |
| 1259 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1260 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1261 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1262 | p->error_indicator = 1; |
| 1263 | return NULL; |
| 1264 | } |
| 1265 | goto done; |
| 1266 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1267 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1268 | } |
| 1269 | { // ';'.small_stmt+ ';'? NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1270 | if (p->error_indicator) { |
| 1271 | return NULL; |
| 1272 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1273 | void *_opt_var; |
| 1274 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1275 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1276 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1277 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1278 | (a = _gather_12_rule(p)) // ';'.small_stmt+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1279 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1280 | (_opt_var = _PyPegen_expect_token(p, 13), 1) // ';'? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1281 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1282 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1283 | ) |
| 1284 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1285 | _res = a; |
| 1286 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1287 | p->error_indicator = 1; |
| 1288 | return NULL; |
| 1289 | } |
| 1290 | goto done; |
| 1291 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1292 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1293 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1294 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1295 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1296 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1297 | } |
| 1298 | |
| 1299 | // small_stmt: |
| 1300 | // | assignment |
| 1301 | // | star_expressions |
| 1302 | // | &'return' return_stmt |
| 1303 | // | &('import' | 'from') import_stmt |
| 1304 | // | &'raise' raise_stmt |
| 1305 | // | 'pass' |
| 1306 | // | &'del' del_stmt |
| 1307 | // | &'yield' yield_stmt |
| 1308 | // | &'assert' assert_stmt |
| 1309 | // | 'break' |
| 1310 | // | 'continue' |
| 1311 | // | &'global' global_stmt |
| 1312 | // | &'nonlocal' nonlocal_stmt |
| 1313 | static stmt_ty |
| 1314 | small_stmt_rule(Parser *p) |
| 1315 | { |
| 1316 | if (p->error_indicator) { |
| 1317 | return NULL; |
| 1318 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1319 | stmt_ty _res = NULL; |
| 1320 | if (_PyPegen_is_memoized(p, small_stmt_type, &_res)) |
| 1321 | return _res; |
| 1322 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1323 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1324 | p->error_indicator = 1; |
| 1325 | return NULL; |
| 1326 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1327 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1328 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1329 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1330 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1331 | { // assignment |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1332 | if (p->error_indicator) { |
| 1333 | return NULL; |
| 1334 | } |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 1335 | stmt_ty assignment_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1336 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1337 | (assignment_var = assignment_rule(p)) // assignment |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1338 | ) |
| 1339 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1340 | _res = assignment_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1341 | goto done; |
| 1342 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1343 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1344 | } |
| 1345 | { // star_expressions |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1346 | if (p->error_indicator) { |
| 1347 | return NULL; |
| 1348 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1349 | expr_ty e; |
| 1350 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1351 | (e = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1352 | ) |
| 1353 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1354 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1355 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1356 | return NULL; |
| 1357 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1358 | int _end_lineno = _token->end_lineno; |
| 1359 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1360 | int _end_col_offset = _token->end_col_offset; |
| 1361 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1362 | _res = _Py_Expr ( e , EXTRA ); |
| 1363 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1364 | p->error_indicator = 1; |
| 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 | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1370 | } |
| 1371 | { // &'return' return_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1372 | if (p->error_indicator) { |
| 1373 | return NULL; |
| 1374 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1375 | stmt_ty return_stmt_var; |
| 1376 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1377 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1378 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1379 | (return_stmt_var = return_stmt_rule(p)) // return_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1380 | ) |
| 1381 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1382 | _res = return_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1383 | goto done; |
| 1384 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1385 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1386 | } |
| 1387 | { // &('import' | 'from') import_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1388 | if (p->error_indicator) { |
| 1389 | return NULL; |
| 1390 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1391 | stmt_ty import_stmt_var; |
| 1392 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1393 | _PyPegen_lookahead(1, _tmp_14_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1394 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1395 | (import_stmt_var = import_stmt_rule(p)) // import_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1396 | ) |
| 1397 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1398 | _res = import_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1399 | goto done; |
| 1400 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1401 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1402 | } |
| 1403 | { // &'raise' raise_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1404 | if (p->error_indicator) { |
| 1405 | return NULL; |
| 1406 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1407 | stmt_ty raise_stmt_var; |
| 1408 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1409 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1410 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1411 | (raise_stmt_var = raise_stmt_rule(p)) // raise_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1412 | ) |
| 1413 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1414 | _res = raise_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1415 | goto done; |
| 1416 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1417 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1418 | } |
| 1419 | { // 'pass' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1420 | if (p->error_indicator) { |
| 1421 | return NULL; |
| 1422 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1423 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1424 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1425 | (_keyword = _PyPegen_expect_token(p, 502)) // token='pass' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1426 | ) |
| 1427 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1428 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1429 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1430 | return NULL; |
| 1431 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1432 | int _end_lineno = _token->end_lineno; |
| 1433 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1434 | int _end_col_offset = _token->end_col_offset; |
| 1435 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1436 | _res = _Py_Pass ( EXTRA ); |
| 1437 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1438 | p->error_indicator = 1; |
| 1439 | return NULL; |
| 1440 | } |
| 1441 | goto done; |
| 1442 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1443 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1444 | } |
| 1445 | { // &'del' del_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1446 | if (p->error_indicator) { |
| 1447 | return NULL; |
| 1448 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1449 | stmt_ty del_stmt_var; |
| 1450 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1451 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) // token='del' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1452 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1453 | (del_stmt_var = del_stmt_rule(p)) // del_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1454 | ) |
| 1455 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1456 | _res = del_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1457 | goto done; |
| 1458 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1459 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1460 | } |
| 1461 | { // &'yield' yield_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1462 | if (p->error_indicator) { |
| 1463 | return NULL; |
| 1464 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1465 | stmt_ty yield_stmt_var; |
| 1466 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1467 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1468 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1469 | (yield_stmt_var = yield_stmt_rule(p)) // yield_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1470 | ) |
| 1471 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1472 | _res = yield_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1473 | goto done; |
| 1474 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1475 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1476 | } |
| 1477 | { // &'assert' assert_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1478 | if (p->error_indicator) { |
| 1479 | return NULL; |
| 1480 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1481 | stmt_ty assert_stmt_var; |
| 1482 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1483 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) // token='assert' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1484 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1485 | (assert_stmt_var = assert_stmt_rule(p)) // assert_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1486 | ) |
| 1487 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1488 | _res = assert_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1489 | goto done; |
| 1490 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1491 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1492 | } |
| 1493 | { // 'break' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1494 | if (p->error_indicator) { |
| 1495 | return NULL; |
| 1496 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1497 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1498 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1499 | (_keyword = _PyPegen_expect_token(p, 506)) // token='break' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1500 | ) |
| 1501 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1502 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1503 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1504 | return NULL; |
| 1505 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1506 | int _end_lineno = _token->end_lineno; |
| 1507 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1508 | int _end_col_offset = _token->end_col_offset; |
| 1509 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1510 | _res = _Py_Break ( EXTRA ); |
| 1511 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1512 | p->error_indicator = 1; |
| 1513 | return NULL; |
| 1514 | } |
| 1515 | goto done; |
| 1516 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1517 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1518 | } |
| 1519 | { // 'continue' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1520 | if (p->error_indicator) { |
| 1521 | return NULL; |
| 1522 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1523 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1524 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1525 | (_keyword = _PyPegen_expect_token(p, 507)) // token='continue' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1526 | ) |
| 1527 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1528 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1529 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1530 | return NULL; |
| 1531 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1532 | int _end_lineno = _token->end_lineno; |
| 1533 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1534 | int _end_col_offset = _token->end_col_offset; |
| 1535 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1536 | _res = _Py_Continue ( EXTRA ); |
| 1537 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1538 | p->error_indicator = 1; |
| 1539 | return NULL; |
| 1540 | } |
| 1541 | goto done; |
| 1542 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1543 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1544 | } |
| 1545 | { // &'global' global_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1546 | if (p->error_indicator) { |
| 1547 | return NULL; |
| 1548 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1549 | stmt_ty global_stmt_var; |
| 1550 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1551 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1552 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1553 | (global_stmt_var = global_stmt_rule(p)) // global_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1554 | ) |
| 1555 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1556 | _res = global_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1557 | goto done; |
| 1558 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1559 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1560 | } |
| 1561 | { // &'nonlocal' nonlocal_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1562 | if (p->error_indicator) { |
| 1563 | return NULL; |
| 1564 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1565 | stmt_ty nonlocal_stmt_var; |
| 1566 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1567 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1568 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1569 | (nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1570 | ) |
| 1571 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1572 | _res = nonlocal_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1573 | goto done; |
| 1574 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1575 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1576 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1577 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1578 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1579 | _PyPegen_insert_memo(p, _mark, small_stmt_type, _res); |
| 1580 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1581 | } |
| 1582 | |
| 1583 | // compound_stmt: |
| 1584 | // | &('def' | '@' | ASYNC) function_def |
| 1585 | // | &'if' if_stmt |
| 1586 | // | &('class' | '@') class_def |
| 1587 | // | &('with' | ASYNC) with_stmt |
| 1588 | // | &('for' | ASYNC) for_stmt |
| 1589 | // | &'try' try_stmt |
| 1590 | // | &'while' while_stmt |
| 1591 | static stmt_ty |
| 1592 | compound_stmt_rule(Parser *p) |
| 1593 | { |
| 1594 | if (p->error_indicator) { |
| 1595 | return NULL; |
| 1596 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1597 | stmt_ty _res = NULL; |
| 1598 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1599 | { // &('def' | '@' | ASYNC) function_def |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1600 | if (p->error_indicator) { |
| 1601 | return NULL; |
| 1602 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1603 | stmt_ty function_def_var; |
| 1604 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1605 | _PyPegen_lookahead(1, _tmp_15_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1606 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1607 | (function_def_var = function_def_rule(p)) // function_def |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1608 | ) |
| 1609 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1610 | _res = function_def_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1611 | goto done; |
| 1612 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1613 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1614 | } |
| 1615 | { // &'if' if_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1616 | if (p->error_indicator) { |
| 1617 | return NULL; |
| 1618 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1619 | stmt_ty if_stmt_var; |
| 1620 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1621 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 510) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1622 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1623 | (if_stmt_var = if_stmt_rule(p)) // if_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1624 | ) |
| 1625 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1626 | _res = if_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1627 | goto done; |
| 1628 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1629 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1630 | } |
| 1631 | { // &('class' | '@') class_def |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1632 | if (p->error_indicator) { |
| 1633 | return NULL; |
| 1634 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1635 | stmt_ty class_def_var; |
| 1636 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1637 | _PyPegen_lookahead(1, _tmp_16_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1638 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1639 | (class_def_var = class_def_rule(p)) // class_def |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1640 | ) |
| 1641 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1642 | _res = class_def_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1643 | goto done; |
| 1644 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1645 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1646 | } |
| 1647 | { // &('with' | ASYNC) with_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1648 | if (p->error_indicator) { |
| 1649 | return NULL; |
| 1650 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1651 | stmt_ty with_stmt_var; |
| 1652 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1653 | _PyPegen_lookahead(1, _tmp_17_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1654 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1655 | (with_stmt_var = with_stmt_rule(p)) // with_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1656 | ) |
| 1657 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1658 | _res = with_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1659 | goto done; |
| 1660 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1661 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1662 | } |
| 1663 | { // &('for' | ASYNC) for_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1664 | if (p->error_indicator) { |
| 1665 | return NULL; |
| 1666 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1667 | stmt_ty for_stmt_var; |
| 1668 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1669 | _PyPegen_lookahead(1, _tmp_18_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1670 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1671 | (for_stmt_var = for_stmt_rule(p)) // for_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1672 | ) |
| 1673 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1674 | _res = for_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1675 | goto done; |
| 1676 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1677 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1678 | } |
| 1679 | { // &'try' try_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1680 | if (p->error_indicator) { |
| 1681 | return NULL; |
| 1682 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1683 | stmt_ty try_stmt_var; |
| 1684 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1685 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 511) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1686 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1687 | (try_stmt_var = try_stmt_rule(p)) // try_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1688 | ) |
| 1689 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1690 | _res = try_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1691 | goto done; |
| 1692 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1693 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1694 | } |
| 1695 | { // &'while' while_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1696 | if (p->error_indicator) { |
| 1697 | return NULL; |
| 1698 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1699 | stmt_ty while_stmt_var; |
| 1700 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1701 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 512) // token='while' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1702 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1703 | (while_stmt_var = while_stmt_rule(p)) // while_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1704 | ) |
| 1705 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1706 | _res = while_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1707 | goto done; |
| 1708 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1709 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1710 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1711 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1712 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1713 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1714 | } |
| 1715 | |
| 1716 | // assignment: |
| 1717 | // | NAME ':' expression ['=' annotated_rhs] |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 1718 | // | ('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs] |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1719 | // | ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT? |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 1720 | // | single_target augassign (yield_expr | star_expressions) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1721 | // | invalid_assignment |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 1722 | static stmt_ty |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1723 | assignment_rule(Parser *p) |
| 1724 | { |
| 1725 | if (p->error_indicator) { |
| 1726 | return NULL; |
| 1727 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1728 | stmt_ty _res = NULL; |
| 1729 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1730 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1731 | p->error_indicator = 1; |
| 1732 | return NULL; |
| 1733 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1734 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1735 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1736 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1737 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1738 | { // NAME ':' expression ['=' annotated_rhs] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1739 | if (p->error_indicator) { |
| 1740 | return NULL; |
| 1741 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1742 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1743 | expr_ty a; |
| 1744 | expr_ty b; |
| 1745 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1746 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1747 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1748 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1749 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1750 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1751 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1752 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1753 | (c = _tmp_19_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1754 | ) |
| 1755 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1756 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1757 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1758 | return NULL; |
| 1759 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1760 | int _end_lineno = _token->end_lineno; |
| 1761 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1762 | int _end_col_offset = _token->end_col_offset; |
| 1763 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1764 | _res = CHECK_VERSION ( 6 , "Variable annotation syntax is" , _Py_AnnAssign ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , c , 1 , EXTRA ) ); |
| 1765 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1766 | p->error_indicator = 1; |
| 1767 | return NULL; |
| 1768 | } |
| 1769 | goto done; |
| 1770 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1771 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1772 | } |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 1773 | { // ('(' single_target ')' | single_subscript_attribute_target) ':' expression ['=' annotated_rhs] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1774 | if (p->error_indicator) { |
| 1775 | return NULL; |
| 1776 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1777 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1778 | void *a; |
| 1779 | expr_ty b; |
| 1780 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1781 | if ( |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 1782 | (a = _tmp_20_rule(p)) // '(' single_target ')' | single_subscript_attribute_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1783 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1784 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1785 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1786 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1787 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1788 | (c = _tmp_21_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1789 | ) |
| 1790 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1791 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1792 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1793 | return NULL; |
| 1794 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1795 | int _end_lineno = _token->end_lineno; |
| 1796 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1797 | int _end_col_offset = _token->end_col_offset; |
| 1798 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1799 | _res = CHECK_VERSION ( 6 , "Variable annotations syntax is" , _Py_AnnAssign ( a , b , c , 0 , EXTRA ) ); |
| 1800 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1801 | p->error_indicator = 1; |
| 1802 | return NULL; |
| 1803 | } |
| 1804 | goto done; |
| 1805 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1806 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1807 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1808 | { // ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1809 | if (p->error_indicator) { |
| 1810 | return NULL; |
| 1811 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1812 | asdl_seq * a; |
| 1813 | void *b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1814 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1815 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1816 | (a = _loop1_22_rule(p)) // ((star_targets '='))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1817 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1818 | (b = _tmp_23_rule(p)) // yield_expr | star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1819 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1820 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1821 | ) |
| 1822 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1823 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1824 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1825 | return NULL; |
| 1826 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1827 | int _end_lineno = _token->end_lineno; |
| 1828 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1829 | int _end_col_offset = _token->end_col_offset; |
| 1830 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1831 | _res = _Py_Assign ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 1832 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1833 | p->error_indicator = 1; |
| 1834 | return NULL; |
| 1835 | } |
| 1836 | goto done; |
| 1837 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1838 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1839 | } |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 1840 | { // single_target augassign (yield_expr | star_expressions) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1841 | if (p->error_indicator) { |
| 1842 | return NULL; |
| 1843 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1844 | expr_ty a; |
| 1845 | AugOperator* b; |
| 1846 | void *c; |
| 1847 | if ( |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 1848 | (a = single_target_rule(p)) // single_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1849 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1850 | (b = augassign_rule(p)) // augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1851 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1852 | (c = _tmp_24_rule(p)) // yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1853 | ) |
| 1854 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1855 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1856 | if (_token == NULL) { |
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 | int _end_lineno = _token->end_lineno; |
| 1860 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1861 | int _end_col_offset = _token->end_col_offset; |
| 1862 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1863 | _res = _Py_AugAssign ( a , b -> kind , c , EXTRA ); |
| 1864 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1865 | p->error_indicator = 1; |
| 1866 | return NULL; |
| 1867 | } |
| 1868 | goto done; |
| 1869 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1870 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1871 | } |
| 1872 | { // invalid_assignment |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1873 | if (p->error_indicator) { |
| 1874 | return NULL; |
| 1875 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1876 | void *invalid_assignment_var; |
| 1877 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1878 | (invalid_assignment_var = invalid_assignment_rule(p)) // invalid_assignment |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1879 | ) |
| 1880 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1881 | _res = invalid_assignment_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1882 | goto done; |
| 1883 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1884 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1885 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1886 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1887 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1888 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1889 | } |
| 1890 | |
| 1891 | // augassign: |
| 1892 | // | '+=' |
| 1893 | // | '-=' |
| 1894 | // | '*=' |
| 1895 | // | '@=' |
| 1896 | // | '/=' |
| 1897 | // | '%=' |
| 1898 | // | '&=' |
| 1899 | // | '|=' |
| 1900 | // | '^=' |
| 1901 | // | '<<=' |
| 1902 | // | '>>=' |
| 1903 | // | '**=' |
| 1904 | // | '//=' |
| 1905 | static AugOperator* |
| 1906 | augassign_rule(Parser *p) |
| 1907 | { |
| 1908 | if (p->error_indicator) { |
| 1909 | return NULL; |
| 1910 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1911 | AugOperator* _res = NULL; |
| 1912 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1913 | { // '+=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1914 | if (p->error_indicator) { |
| 1915 | return NULL; |
| 1916 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1917 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1918 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1919 | (_literal = _PyPegen_expect_token(p, 36)) // token='+=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1920 | ) |
| 1921 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1922 | _res = _PyPegen_augoperator ( p , Add ); |
| 1923 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1924 | p->error_indicator = 1; |
| 1925 | return NULL; |
| 1926 | } |
| 1927 | goto done; |
| 1928 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1929 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1930 | } |
| 1931 | { // '-=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1932 | if (p->error_indicator) { |
| 1933 | return NULL; |
| 1934 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1935 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1936 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1937 | (_literal = _PyPegen_expect_token(p, 37)) // token='-=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1938 | ) |
| 1939 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1940 | _res = _PyPegen_augoperator ( p , Sub ); |
| 1941 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1942 | p->error_indicator = 1; |
| 1943 | return NULL; |
| 1944 | } |
| 1945 | goto done; |
| 1946 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1947 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1948 | } |
| 1949 | { // '*=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1950 | if (p->error_indicator) { |
| 1951 | return NULL; |
| 1952 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1953 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1954 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1955 | (_literal = _PyPegen_expect_token(p, 38)) // token='*=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1956 | ) |
| 1957 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1958 | _res = _PyPegen_augoperator ( p , Mult ); |
| 1959 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1960 | p->error_indicator = 1; |
| 1961 | return NULL; |
| 1962 | } |
| 1963 | goto done; |
| 1964 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1965 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1966 | } |
| 1967 | { // '@=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1968 | if (p->error_indicator) { |
| 1969 | return NULL; |
| 1970 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1971 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1972 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1973 | (_literal = _PyPegen_expect_token(p, 50)) // token='@=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1974 | ) |
| 1975 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1976 | _res = CHECK_VERSION ( 5 , "The '@' operator is" , _PyPegen_augoperator ( p , MatMult ) ); |
| 1977 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1978 | p->error_indicator = 1; |
| 1979 | return NULL; |
| 1980 | } |
| 1981 | goto done; |
| 1982 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1983 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1984 | } |
| 1985 | { // '/=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 1986 | if (p->error_indicator) { |
| 1987 | return NULL; |
| 1988 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1989 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1990 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1991 | (_literal = _PyPegen_expect_token(p, 39)) // token='/=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1992 | ) |
| 1993 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1994 | _res = _PyPegen_augoperator ( p , Div ); |
| 1995 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1996 | p->error_indicator = 1; |
| 1997 | return NULL; |
| 1998 | } |
| 1999 | goto done; |
| 2000 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2001 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2002 | } |
| 2003 | { // '%=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2004 | if (p->error_indicator) { |
| 2005 | return NULL; |
| 2006 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2007 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2008 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2009 | (_literal = _PyPegen_expect_token(p, 40)) // token='%=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2010 | ) |
| 2011 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2012 | _res = _PyPegen_augoperator ( p , Mod ); |
| 2013 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2014 | p->error_indicator = 1; |
| 2015 | return NULL; |
| 2016 | } |
| 2017 | goto done; |
| 2018 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2019 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2020 | } |
| 2021 | { // '&=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2022 | if (p->error_indicator) { |
| 2023 | return NULL; |
| 2024 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2025 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2026 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2027 | (_literal = _PyPegen_expect_token(p, 41)) // token='&=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2028 | ) |
| 2029 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2030 | _res = _PyPegen_augoperator ( p , BitAnd ); |
| 2031 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2032 | p->error_indicator = 1; |
| 2033 | return NULL; |
| 2034 | } |
| 2035 | goto done; |
| 2036 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2037 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2038 | } |
| 2039 | { // '|=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2040 | if (p->error_indicator) { |
| 2041 | return NULL; |
| 2042 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2043 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2044 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2045 | (_literal = _PyPegen_expect_token(p, 42)) // token='|=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2046 | ) |
| 2047 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2048 | _res = _PyPegen_augoperator ( p , BitOr ); |
| 2049 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2050 | p->error_indicator = 1; |
| 2051 | return NULL; |
| 2052 | } |
| 2053 | goto done; |
| 2054 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2055 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2056 | } |
| 2057 | { // '^=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2058 | if (p->error_indicator) { |
| 2059 | return NULL; |
| 2060 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2061 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2062 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2063 | (_literal = _PyPegen_expect_token(p, 43)) // token='^=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2064 | ) |
| 2065 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2066 | _res = _PyPegen_augoperator ( p , BitXor ); |
| 2067 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2068 | p->error_indicator = 1; |
| 2069 | return NULL; |
| 2070 | } |
| 2071 | goto done; |
| 2072 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2073 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2074 | } |
| 2075 | { // '<<=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2076 | if (p->error_indicator) { |
| 2077 | return NULL; |
| 2078 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2079 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2080 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2081 | (_literal = _PyPegen_expect_token(p, 44)) // token='<<=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2082 | ) |
| 2083 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2084 | _res = _PyPegen_augoperator ( p , LShift ); |
| 2085 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2086 | p->error_indicator = 1; |
| 2087 | return NULL; |
| 2088 | } |
| 2089 | goto done; |
| 2090 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2091 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2092 | } |
| 2093 | { // '>>=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2094 | if (p->error_indicator) { |
| 2095 | return NULL; |
| 2096 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2097 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2098 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2099 | (_literal = _PyPegen_expect_token(p, 45)) // token='>>=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2100 | ) |
| 2101 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2102 | _res = _PyPegen_augoperator ( p , RShift ); |
| 2103 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2104 | p->error_indicator = 1; |
| 2105 | return NULL; |
| 2106 | } |
| 2107 | goto done; |
| 2108 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2109 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2110 | } |
| 2111 | { // '**=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2112 | if (p->error_indicator) { |
| 2113 | return NULL; |
| 2114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2115 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2116 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2117 | (_literal = _PyPegen_expect_token(p, 46)) // token='**=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2118 | ) |
| 2119 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2120 | _res = _PyPegen_augoperator ( p , Pow ); |
| 2121 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2122 | p->error_indicator = 1; |
| 2123 | return NULL; |
| 2124 | } |
| 2125 | goto done; |
| 2126 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2127 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2128 | } |
| 2129 | { // '//=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2130 | if (p->error_indicator) { |
| 2131 | return NULL; |
| 2132 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2133 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2134 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2135 | (_literal = _PyPegen_expect_token(p, 48)) // token='//=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2136 | ) |
| 2137 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2138 | _res = _PyPegen_augoperator ( p , FloorDiv ); |
| 2139 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2140 | p->error_indicator = 1; |
| 2141 | return NULL; |
| 2142 | } |
| 2143 | goto done; |
| 2144 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2145 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2146 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2147 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2148 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2149 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2150 | } |
| 2151 | |
| 2152 | // global_stmt: 'global' ','.NAME+ |
| 2153 | static stmt_ty |
| 2154 | global_stmt_rule(Parser *p) |
| 2155 | { |
| 2156 | if (p->error_indicator) { |
| 2157 | return NULL; |
| 2158 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2159 | stmt_ty _res = NULL; |
| 2160 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2161 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2162 | p->error_indicator = 1; |
| 2163 | return NULL; |
| 2164 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2165 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2166 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2167 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2168 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2169 | { // 'global' ','.NAME+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2170 | if (p->error_indicator) { |
| 2171 | return NULL; |
| 2172 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2173 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2174 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2175 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2176 | (_keyword = _PyPegen_expect_token(p, 508)) // token='global' |
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 | (a = _gather_25_rule(p)) // ','.NAME+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2179 | ) |
| 2180 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2181 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2182 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2183 | return NULL; |
| 2184 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2185 | int _end_lineno = _token->end_lineno; |
| 2186 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2187 | int _end_col_offset = _token->end_col_offset; |
| 2188 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2189 | _res = _Py_Global ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
| 2190 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2191 | p->error_indicator = 1; |
| 2192 | return NULL; |
| 2193 | } |
| 2194 | goto done; |
| 2195 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2196 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2197 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2198 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2199 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2200 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2201 | } |
| 2202 | |
| 2203 | // nonlocal_stmt: 'nonlocal' ','.NAME+ |
| 2204 | static stmt_ty |
| 2205 | nonlocal_stmt_rule(Parser *p) |
| 2206 | { |
| 2207 | if (p->error_indicator) { |
| 2208 | return NULL; |
| 2209 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2210 | stmt_ty _res = NULL; |
| 2211 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2212 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2213 | p->error_indicator = 1; |
| 2214 | return NULL; |
| 2215 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2216 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2217 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2218 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2219 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2220 | { // 'nonlocal' ','.NAME+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2221 | if (p->error_indicator) { |
| 2222 | return NULL; |
| 2223 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2224 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2225 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2226 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2227 | (_keyword = _PyPegen_expect_token(p, 509)) // token='nonlocal' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2228 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2229 | (a = _gather_27_rule(p)) // ','.NAME+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2230 | ) |
| 2231 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2232 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2233 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2234 | return NULL; |
| 2235 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2236 | int _end_lineno = _token->end_lineno; |
| 2237 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2238 | int _end_col_offset = _token->end_col_offset; |
| 2239 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2240 | _res = _Py_Nonlocal ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
| 2241 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2242 | p->error_indicator = 1; |
| 2243 | return NULL; |
| 2244 | } |
| 2245 | goto done; |
| 2246 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2247 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2248 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2249 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2250 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2251 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2252 | } |
| 2253 | |
| 2254 | // yield_stmt: yield_expr |
| 2255 | static stmt_ty |
| 2256 | yield_stmt_rule(Parser *p) |
| 2257 | { |
| 2258 | if (p->error_indicator) { |
| 2259 | return NULL; |
| 2260 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2261 | stmt_ty _res = NULL; |
| 2262 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2263 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2264 | p->error_indicator = 1; |
| 2265 | return NULL; |
| 2266 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2267 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2268 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2269 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2270 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2271 | { // yield_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2272 | if (p->error_indicator) { |
| 2273 | return NULL; |
| 2274 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2275 | expr_ty y; |
| 2276 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2277 | (y = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2278 | ) |
| 2279 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2280 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2281 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2282 | return NULL; |
| 2283 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2284 | int _end_lineno = _token->end_lineno; |
| 2285 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2286 | int _end_col_offset = _token->end_col_offset; |
| 2287 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2288 | _res = _Py_Expr ( y , EXTRA ); |
| 2289 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2290 | p->error_indicator = 1; |
| 2291 | return NULL; |
| 2292 | } |
| 2293 | goto done; |
| 2294 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2295 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2296 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2297 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2298 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2299 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2300 | } |
| 2301 | |
| 2302 | // assert_stmt: 'assert' expression [',' expression] |
| 2303 | static stmt_ty |
| 2304 | assert_stmt_rule(Parser *p) |
| 2305 | { |
| 2306 | if (p->error_indicator) { |
| 2307 | return NULL; |
| 2308 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2309 | stmt_ty _res = NULL; |
| 2310 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2311 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2312 | p->error_indicator = 1; |
| 2313 | return NULL; |
| 2314 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2315 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2316 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2317 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2318 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2319 | { // 'assert' expression [',' expression] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2320 | if (p->error_indicator) { |
| 2321 | return NULL; |
| 2322 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2323 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2324 | expr_ty a; |
| 2325 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2326 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2327 | (_keyword = _PyPegen_expect_token(p, 505)) // token='assert' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2328 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2329 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2330 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2331 | (b = _tmp_29_rule(p), 1) // [',' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2332 | ) |
| 2333 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2334 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2335 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2336 | return NULL; |
| 2337 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2338 | int _end_lineno = _token->end_lineno; |
| 2339 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2340 | int _end_col_offset = _token->end_col_offset; |
| 2341 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2342 | _res = _Py_Assert ( a , b , EXTRA ); |
| 2343 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2344 | p->error_indicator = 1; |
| 2345 | return NULL; |
| 2346 | } |
| 2347 | goto done; |
| 2348 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2349 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2350 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2351 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2352 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2353 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2354 | } |
| 2355 | |
| 2356 | // del_stmt: 'del' del_targets |
| 2357 | static stmt_ty |
| 2358 | del_stmt_rule(Parser *p) |
| 2359 | { |
| 2360 | if (p->error_indicator) { |
| 2361 | return NULL; |
| 2362 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2363 | stmt_ty _res = NULL; |
| 2364 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2365 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2366 | p->error_indicator = 1; |
| 2367 | return NULL; |
| 2368 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2369 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2370 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2371 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2372 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2373 | { // 'del' del_targets |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2374 | if (p->error_indicator) { |
| 2375 | return NULL; |
| 2376 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2377 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2378 | asdl_seq* a; |
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 | (_keyword = _PyPegen_expect_token(p, 503)) // token='del' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2381 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2382 | (a = del_targets_rule(p)) // del_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2383 | ) |
| 2384 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2385 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2386 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2387 | return NULL; |
| 2388 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2389 | int _end_lineno = _token->end_lineno; |
| 2390 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2391 | int _end_col_offset = _token->end_col_offset; |
| 2392 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2393 | _res = _Py_Delete ( a , EXTRA ); |
| 2394 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2395 | p->error_indicator = 1; |
| 2396 | return NULL; |
| 2397 | } |
| 2398 | goto done; |
| 2399 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2400 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2401 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2402 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2403 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2404 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2405 | } |
| 2406 | |
| 2407 | // import_stmt: import_name | import_from |
| 2408 | static stmt_ty |
| 2409 | import_stmt_rule(Parser *p) |
| 2410 | { |
| 2411 | if (p->error_indicator) { |
| 2412 | return NULL; |
| 2413 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2414 | stmt_ty _res = NULL; |
| 2415 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2416 | { // import_name |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2417 | if (p->error_indicator) { |
| 2418 | return NULL; |
| 2419 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2420 | stmt_ty import_name_var; |
| 2421 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2422 | (import_name_var = import_name_rule(p)) // import_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2423 | ) |
| 2424 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2425 | _res = import_name_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2426 | goto done; |
| 2427 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2428 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2429 | } |
| 2430 | { // import_from |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2431 | if (p->error_indicator) { |
| 2432 | return NULL; |
| 2433 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2434 | stmt_ty import_from_var; |
| 2435 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2436 | (import_from_var = import_from_rule(p)) // import_from |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2437 | ) |
| 2438 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2439 | _res = import_from_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2440 | goto done; |
| 2441 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2442 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2443 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2444 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2445 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2446 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2447 | } |
| 2448 | |
| 2449 | // import_name: 'import' dotted_as_names |
| 2450 | static stmt_ty |
| 2451 | import_name_rule(Parser *p) |
| 2452 | { |
| 2453 | if (p->error_indicator) { |
| 2454 | return NULL; |
| 2455 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2456 | stmt_ty _res = NULL; |
| 2457 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2458 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2459 | p->error_indicator = 1; |
| 2460 | return NULL; |
| 2461 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2462 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2463 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2464 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2465 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2466 | { // 'import' dotted_as_names |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2467 | if (p->error_indicator) { |
| 2468 | return NULL; |
| 2469 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2470 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2471 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2472 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2473 | (_keyword = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2474 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2475 | (a = dotted_as_names_rule(p)) // dotted_as_names |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2476 | ) |
| 2477 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2478 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2479 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2480 | return NULL; |
| 2481 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2482 | int _end_lineno = _token->end_lineno; |
| 2483 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2484 | int _end_col_offset = _token->end_col_offset; |
| 2485 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2486 | _res = _Py_Import ( a , EXTRA ); |
| 2487 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2488 | p->error_indicator = 1; |
| 2489 | return NULL; |
| 2490 | } |
| 2491 | goto done; |
| 2492 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2493 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2494 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2495 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2496 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2497 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2498 | } |
| 2499 | |
| 2500 | // import_from: |
| 2501 | // | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
| 2502 | // | 'from' (('.' | '...'))+ 'import' import_from_targets |
| 2503 | static stmt_ty |
| 2504 | import_from_rule(Parser *p) |
| 2505 | { |
| 2506 | if (p->error_indicator) { |
| 2507 | return NULL; |
| 2508 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2509 | stmt_ty _res = NULL; |
| 2510 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2511 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2512 | p->error_indicator = 1; |
| 2513 | return NULL; |
| 2514 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2515 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2516 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2517 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2518 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2519 | { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2520 | if (p->error_indicator) { |
| 2521 | return NULL; |
| 2522 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2523 | Token * _keyword; |
| 2524 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2525 | asdl_seq * a; |
| 2526 | expr_ty b; |
| 2527 | asdl_seq* c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2528 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2529 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2530 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2531 | (a = _loop0_30_rule(p)) // (('.' | '...'))* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2532 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2533 | (b = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2534 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2535 | (_keyword_1 = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2536 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2537 | (c = import_from_targets_rule(p)) // import_from_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2538 | ) |
| 2539 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2540 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2541 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2542 | return NULL; |
| 2543 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2544 | int _end_lineno = _token->end_lineno; |
| 2545 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2546 | int _end_col_offset = _token->end_col_offset; |
| 2547 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2548 | _res = _Py_ImportFrom ( b -> v . Name . id , c , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
| 2549 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2550 | p->error_indicator = 1; |
| 2551 | return NULL; |
| 2552 | } |
| 2553 | goto done; |
| 2554 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2555 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2556 | } |
| 2557 | { // 'from' (('.' | '...'))+ 'import' import_from_targets |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2558 | if (p->error_indicator) { |
| 2559 | return NULL; |
| 2560 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2561 | Token * _keyword; |
| 2562 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2563 | asdl_seq * a; |
| 2564 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2565 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2566 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2567 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2568 | (a = _loop1_31_rule(p)) // (('.' | '...'))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2569 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2570 | (_keyword_1 = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2571 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2572 | (b = import_from_targets_rule(p)) // import_from_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2573 | ) |
| 2574 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2575 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2576 | if (_token == NULL) { |
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 | int _end_lineno = _token->end_lineno; |
| 2580 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2581 | int _end_col_offset = _token->end_col_offset; |
| 2582 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2583 | _res = _Py_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
| 2584 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2585 | p->error_indicator = 1; |
| 2586 | return NULL; |
| 2587 | } |
| 2588 | goto done; |
| 2589 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2590 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2591 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2592 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2593 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2594 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2595 | } |
| 2596 | |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame^] | 2597 | // import_from_targets: |
| 2598 | // | '(' import_from_as_names ','? ')' |
| 2599 | // | import_from_as_names !',' |
| 2600 | // | '*' |
| 2601 | // | invalid_import_from_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2602 | static asdl_seq* |
| 2603 | import_from_targets_rule(Parser *p) |
| 2604 | { |
| 2605 | if (p->error_indicator) { |
| 2606 | return NULL; |
| 2607 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2608 | asdl_seq* _res = NULL; |
| 2609 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2610 | { // '(' import_from_as_names ','? ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2611 | if (p->error_indicator) { |
| 2612 | return NULL; |
| 2613 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2614 | Token * _literal; |
| 2615 | Token * _literal_1; |
| 2616 | void *_opt_var; |
| 2617 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2618 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2619 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2620 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2621 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2622 | (a = import_from_as_names_rule(p)) // import_from_as_names |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2623 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2624 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
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 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2627 | ) |
| 2628 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2629 | _res = a; |
| 2630 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2631 | p->error_indicator = 1; |
| 2632 | return NULL; |
| 2633 | } |
| 2634 | goto done; |
| 2635 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2636 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2637 | } |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame^] | 2638 | { // import_from_as_names !',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2639 | if (p->error_indicator) { |
| 2640 | return NULL; |
| 2641 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2642 | asdl_seq* import_from_as_names_var; |
| 2643 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2644 | (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^] | 2645 | && |
| 2646 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2647 | ) |
| 2648 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2649 | _res = import_from_as_names_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2650 | goto done; |
| 2651 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2652 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2653 | } |
| 2654 | { // '*' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2655 | if (p->error_indicator) { |
| 2656 | return NULL; |
| 2657 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2658 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2659 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2660 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2661 | ) |
| 2662 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2663 | _res = _PyPegen_singleton_seq ( p , CHECK ( _PyPegen_alias_for_star ( p ) ) ); |
| 2664 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2665 | p->error_indicator = 1; |
| 2666 | return NULL; |
| 2667 | } |
| 2668 | goto done; |
| 2669 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2670 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2671 | } |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame^] | 2672 | { // invalid_import_from_targets |
| 2673 | if (p->error_indicator) { |
| 2674 | return NULL; |
| 2675 | } |
| 2676 | void *invalid_import_from_targets_var; |
| 2677 | if ( |
| 2678 | (invalid_import_from_targets_var = invalid_import_from_targets_rule(p)) // invalid_import_from_targets |
| 2679 | ) |
| 2680 | { |
| 2681 | _res = invalid_import_from_targets_var; |
| 2682 | goto done; |
| 2683 | } |
| 2684 | p->mark = _mark; |
| 2685 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2686 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2687 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2688 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2689 | } |
| 2690 | |
| 2691 | // import_from_as_names: ','.import_from_as_name+ |
| 2692 | static asdl_seq* |
| 2693 | import_from_as_names_rule(Parser *p) |
| 2694 | { |
| 2695 | if (p->error_indicator) { |
| 2696 | return NULL; |
| 2697 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2698 | asdl_seq* _res = NULL; |
| 2699 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2700 | { // ','.import_from_as_name+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2701 | if (p->error_indicator) { |
| 2702 | return NULL; |
| 2703 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2704 | asdl_seq * a; |
| 2705 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2706 | (a = _gather_32_rule(p)) // ','.import_from_as_name+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2707 | ) |
| 2708 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2709 | _res = a; |
| 2710 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2711 | p->error_indicator = 1; |
| 2712 | return NULL; |
| 2713 | } |
| 2714 | goto done; |
| 2715 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2716 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2717 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2718 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2719 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2720 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2721 | } |
| 2722 | |
| 2723 | // import_from_as_name: NAME ['as' NAME] |
| 2724 | static alias_ty |
| 2725 | import_from_as_name_rule(Parser *p) |
| 2726 | { |
| 2727 | if (p->error_indicator) { |
| 2728 | return NULL; |
| 2729 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2730 | alias_ty _res = NULL; |
| 2731 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2732 | { // NAME ['as' NAME] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2733 | if (p->error_indicator) { |
| 2734 | return NULL; |
| 2735 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2736 | expr_ty a; |
| 2737 | void *b; |
| 2738 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2739 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2740 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2741 | (b = _tmp_34_rule(p), 1) // ['as' NAME] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2742 | ) |
| 2743 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2744 | _res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena ); |
| 2745 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2746 | p->error_indicator = 1; |
| 2747 | return NULL; |
| 2748 | } |
| 2749 | goto done; |
| 2750 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2751 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2752 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2753 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2754 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2755 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2756 | } |
| 2757 | |
| 2758 | // dotted_as_names: ','.dotted_as_name+ |
| 2759 | static asdl_seq* |
| 2760 | dotted_as_names_rule(Parser *p) |
| 2761 | { |
| 2762 | if (p->error_indicator) { |
| 2763 | return NULL; |
| 2764 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2765 | asdl_seq* _res = NULL; |
| 2766 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2767 | { // ','.dotted_as_name+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2768 | if (p->error_indicator) { |
| 2769 | return NULL; |
| 2770 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2771 | asdl_seq * a; |
| 2772 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2773 | (a = _gather_35_rule(p)) // ','.dotted_as_name+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2774 | ) |
| 2775 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2776 | _res = a; |
| 2777 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2778 | p->error_indicator = 1; |
| 2779 | return NULL; |
| 2780 | } |
| 2781 | goto done; |
| 2782 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2783 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2784 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2785 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2786 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2787 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2788 | } |
| 2789 | |
| 2790 | // dotted_as_name: dotted_name ['as' NAME] |
| 2791 | static alias_ty |
| 2792 | dotted_as_name_rule(Parser *p) |
| 2793 | { |
| 2794 | if (p->error_indicator) { |
| 2795 | return NULL; |
| 2796 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2797 | alias_ty _res = NULL; |
| 2798 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2799 | { // dotted_name ['as' NAME] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2800 | if (p->error_indicator) { |
| 2801 | return NULL; |
| 2802 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2803 | expr_ty a; |
| 2804 | void *b; |
| 2805 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2806 | (a = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2807 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2808 | (b = _tmp_37_rule(p), 1) // ['as' NAME] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2809 | ) |
| 2810 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2811 | _res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena ); |
| 2812 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2813 | p->error_indicator = 1; |
| 2814 | return NULL; |
| 2815 | } |
| 2816 | goto done; |
| 2817 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2818 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2819 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2820 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2821 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2822 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2823 | } |
| 2824 | |
| 2825 | // Left-recursive |
| 2826 | // dotted_name: dotted_name '.' NAME | NAME |
| 2827 | static expr_ty dotted_name_raw(Parser *); |
| 2828 | static expr_ty |
| 2829 | dotted_name_rule(Parser *p) |
| 2830 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2831 | expr_ty _res = NULL; |
| 2832 | if (_PyPegen_is_memoized(p, dotted_name_type, &_res)) |
| 2833 | return _res; |
| 2834 | int _mark = p->mark; |
| 2835 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2836 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2837 | int tmpvar_0 = _PyPegen_update_memo(p, _mark, dotted_name_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2838 | if (tmpvar_0) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2839 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2841 | p->mark = _mark; |
| 2842 | void *_raw = dotted_name_raw(p); |
| 2843 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2844 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2845 | _resmark = p->mark; |
| 2846 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2847 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2848 | p->mark = _resmark; |
| 2849 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2850 | } |
| 2851 | static expr_ty |
| 2852 | dotted_name_raw(Parser *p) |
| 2853 | { |
| 2854 | if (p->error_indicator) { |
| 2855 | return NULL; |
| 2856 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2857 | expr_ty _res = NULL; |
| 2858 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2859 | { // dotted_name '.' NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2860 | if (p->error_indicator) { |
| 2861 | return NULL; |
| 2862 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2863 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2864 | expr_ty a; |
| 2865 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2866 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2867 | (a = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2868 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2869 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2870 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2871 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2872 | ) |
| 2873 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2874 | _res = _PyPegen_join_names_with_dot ( p , a , b ); |
| 2875 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2876 | p->error_indicator = 1; |
| 2877 | return NULL; |
| 2878 | } |
| 2879 | goto done; |
| 2880 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2881 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2882 | } |
| 2883 | { // NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2884 | if (p->error_indicator) { |
| 2885 | return NULL; |
| 2886 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2887 | expr_ty name_var; |
| 2888 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2889 | (name_var = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2890 | ) |
| 2891 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2892 | _res = name_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2893 | goto done; |
| 2894 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2895 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2896 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2897 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2898 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2899 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2900 | } |
| 2901 | |
| 2902 | // if_stmt: |
| 2903 | // | 'if' named_expression ':' block elif_stmt |
| 2904 | // | 'if' named_expression ':' block else_block? |
| 2905 | static stmt_ty |
| 2906 | if_stmt_rule(Parser *p) |
| 2907 | { |
| 2908 | if (p->error_indicator) { |
| 2909 | return NULL; |
| 2910 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2911 | stmt_ty _res = NULL; |
| 2912 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2913 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2914 | p->error_indicator = 1; |
| 2915 | return NULL; |
| 2916 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2917 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2918 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2919 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2920 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2921 | { // 'if' named_expression ':' block elif_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2922 | if (p->error_indicator) { |
| 2923 | return NULL; |
| 2924 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2925 | Token * _keyword; |
| 2926 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2927 | expr_ty a; |
| 2928 | asdl_seq* b; |
| 2929 | stmt_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2930 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2931 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2932 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2933 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2934 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2935 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2936 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2937 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2938 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2939 | (c = elif_stmt_rule(p)) // elif_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2940 | ) |
| 2941 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2942 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2943 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2944 | return NULL; |
| 2945 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2946 | int _end_lineno = _token->end_lineno; |
| 2947 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2948 | int _end_col_offset = _token->end_col_offset; |
| 2949 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2950 | _res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
| 2951 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2952 | p->error_indicator = 1; |
| 2953 | return NULL; |
| 2954 | } |
| 2955 | goto done; |
| 2956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2957 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2958 | } |
| 2959 | { // 'if' named_expression ':' block else_block? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 2960 | if (p->error_indicator) { |
| 2961 | return NULL; |
| 2962 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2963 | Token * _keyword; |
| 2964 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2965 | expr_ty a; |
| 2966 | asdl_seq* b; |
| 2967 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2968 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2969 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2970 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2971 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2972 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2973 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2974 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2975 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2976 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2977 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2978 | ) |
| 2979 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2980 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2981 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2982 | return NULL; |
| 2983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2984 | int _end_lineno = _token->end_lineno; |
| 2985 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2986 | int _end_col_offset = _token->end_col_offset; |
| 2987 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2988 | _res = _Py_If ( a , b , c , EXTRA ); |
| 2989 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2990 | p->error_indicator = 1; |
| 2991 | return NULL; |
| 2992 | } |
| 2993 | goto done; |
| 2994 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2995 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2996 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2997 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2998 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2999 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3000 | } |
| 3001 | |
| 3002 | // elif_stmt: |
| 3003 | // | 'elif' named_expression ':' block elif_stmt |
| 3004 | // | 'elif' named_expression ':' block else_block? |
| 3005 | static stmt_ty |
| 3006 | elif_stmt_rule(Parser *p) |
| 3007 | { |
| 3008 | if (p->error_indicator) { |
| 3009 | return NULL; |
| 3010 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3011 | stmt_ty _res = NULL; |
| 3012 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3013 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3014 | p->error_indicator = 1; |
| 3015 | return NULL; |
| 3016 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3017 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3018 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3019 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3020 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3021 | { // 'elif' named_expression ':' block elif_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3022 | if (p->error_indicator) { |
| 3023 | return NULL; |
| 3024 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3025 | Token * _keyword; |
| 3026 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3027 | expr_ty a; |
| 3028 | asdl_seq* b; |
| 3029 | stmt_ty 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, 515)) // token='elif' |
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 = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3034 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3035 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3036 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3037 | (b = block_rule(p)) // block |
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 = elif_stmt_rule(p)) // elif_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3040 | ) |
| 3041 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3042 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3043 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3044 | return NULL; |
| 3045 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3046 | int _end_lineno = _token->end_lineno; |
| 3047 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3048 | int _end_col_offset = _token->end_col_offset; |
| 3049 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3050 | _res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
| 3051 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3052 | p->error_indicator = 1; |
| 3053 | return NULL; |
| 3054 | } |
| 3055 | goto done; |
| 3056 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3057 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3058 | } |
| 3059 | { // 'elif' named_expression ':' block else_block? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3060 | if (p->error_indicator) { |
| 3061 | return NULL; |
| 3062 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3063 | Token * _keyword; |
| 3064 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3065 | expr_ty a; |
| 3066 | asdl_seq* b; |
| 3067 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3068 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3069 | (_keyword = _PyPegen_expect_token(p, 515)) // token='elif' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3070 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3071 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3072 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3073 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3074 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3075 | (b = block_rule(p)) // block |
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 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3078 | ) |
| 3079 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3080 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3081 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3082 | return NULL; |
| 3083 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3084 | int _end_lineno = _token->end_lineno; |
| 3085 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3086 | int _end_col_offset = _token->end_col_offset; |
| 3087 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3088 | _res = _Py_If ( a , b , c , EXTRA ); |
| 3089 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3090 | p->error_indicator = 1; |
| 3091 | return NULL; |
| 3092 | } |
| 3093 | goto done; |
| 3094 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3095 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3096 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3097 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3098 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3099 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3100 | } |
| 3101 | |
| 3102 | // else_block: 'else' ':' block |
| 3103 | static asdl_seq* |
| 3104 | else_block_rule(Parser *p) |
| 3105 | { |
| 3106 | if (p->error_indicator) { |
| 3107 | return NULL; |
| 3108 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3109 | asdl_seq* _res = NULL; |
| 3110 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3111 | { // 'else' ':' block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3112 | if (p->error_indicator) { |
| 3113 | return NULL; |
| 3114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3115 | Token * _keyword; |
| 3116 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3117 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3118 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3119 | (_keyword = _PyPegen_expect_token(p, 516)) // token='else' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3120 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3121 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3122 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3123 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3124 | ) |
| 3125 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3126 | _res = b; |
| 3127 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3128 | p->error_indicator = 1; |
| 3129 | return NULL; |
| 3130 | } |
| 3131 | goto done; |
| 3132 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3133 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3134 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3135 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3136 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3137 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3138 | } |
| 3139 | |
| 3140 | // while_stmt: 'while' named_expression ':' block else_block? |
| 3141 | static stmt_ty |
| 3142 | while_stmt_rule(Parser *p) |
| 3143 | { |
| 3144 | if (p->error_indicator) { |
| 3145 | return NULL; |
| 3146 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3147 | stmt_ty _res = NULL; |
| 3148 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3149 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3150 | p->error_indicator = 1; |
| 3151 | return NULL; |
| 3152 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3153 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3154 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3155 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3156 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3157 | { // 'while' named_expression ':' block else_block? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3158 | if (p->error_indicator) { |
| 3159 | return NULL; |
| 3160 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3161 | Token * _keyword; |
| 3162 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3163 | expr_ty a; |
| 3164 | asdl_seq* b; |
| 3165 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3166 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3167 | (_keyword = _PyPegen_expect_token(p, 512)) // token='while' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3168 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3169 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3170 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3171 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3172 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3173 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3174 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3175 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3176 | ) |
| 3177 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3178 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3179 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3180 | return NULL; |
| 3181 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3182 | int _end_lineno = _token->end_lineno; |
| 3183 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3184 | int _end_col_offset = _token->end_col_offset; |
| 3185 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3186 | _res = _Py_While ( a , b , c , EXTRA ); |
| 3187 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3188 | p->error_indicator = 1; |
| 3189 | return NULL; |
| 3190 | } |
| 3191 | goto done; |
| 3192 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3193 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3194 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3195 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3196 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3197 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3198 | } |
| 3199 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3200 | // for_stmt: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3201 | // | 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
| 3202 | // | ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3203 | static stmt_ty |
| 3204 | for_stmt_rule(Parser *p) |
| 3205 | { |
| 3206 | if (p->error_indicator) { |
| 3207 | return NULL; |
| 3208 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3209 | stmt_ty _res = NULL; |
| 3210 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3211 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3212 | p->error_indicator = 1; |
| 3213 | return NULL; |
| 3214 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3215 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3216 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3217 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3218 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3219 | { // 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3220 | if (p->error_indicator) { |
| 3221 | return NULL; |
| 3222 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3223 | Token * _keyword; |
| 3224 | Token * _keyword_1; |
| 3225 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3226 | asdl_seq* b; |
| 3227 | void *el; |
| 3228 | expr_ty ex; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3229 | expr_ty t; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3230 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3231 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3232 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3233 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3234 | (t = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3235 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3236 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3237 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3238 | (ex = star_expressions_rule(p)) // star_expressions |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3239 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3240 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3241 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3242 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3243 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3244 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3245 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3246 | (el = else_block_rule(p), 1) // else_block? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3247 | ) |
| 3248 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3249 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3250 | if (_token == NULL) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3251 | return NULL; |
| 3252 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3253 | int _end_lineno = _token->end_lineno; |
| 3254 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3255 | int _end_col_offset = _token->end_col_offset; |
| 3256 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3257 | _res = _Py_For ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 3258 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3259 | p->error_indicator = 1; |
| 3260 | return NULL; |
| 3261 | } |
| 3262 | goto done; |
| 3263 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3264 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3265 | } |
| 3266 | { // ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3267 | if (p->error_indicator) { |
| 3268 | return NULL; |
| 3269 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3270 | Token * _keyword; |
| 3271 | Token * _keyword_1; |
| 3272 | Token * _literal; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3273 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3274 | asdl_seq* b; |
| 3275 | void *el; |
| 3276 | expr_ty ex; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3277 | expr_ty t; |
| 3278 | void *tc; |
| 3279 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3280 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3281 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3282 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3283 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3284 | (t = star_targets_rule(p)) // star_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3285 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3286 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3287 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3288 | (ex = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3289 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3290 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3291 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3292 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3293 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3294 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3295 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3296 | (el = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3297 | ) |
| 3298 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3299 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3300 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3301 | return NULL; |
| 3302 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3303 | int _end_lineno = _token->end_lineno; |
| 3304 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3305 | int _end_col_offset = _token->end_col_offset; |
| 3306 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3307 | _res = CHECK_VERSION ( 5 , "Async for loops are" , _Py_AsyncFor ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
| 3308 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3309 | p->error_indicator = 1; |
| 3310 | return NULL; |
| 3311 | } |
| 3312 | goto done; |
| 3313 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3314 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3315 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3316 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3317 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3318 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3319 | } |
| 3320 | |
| 3321 | // with_stmt: |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3322 | // | 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3323 | // | 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3324 | // | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3325 | // | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3326 | static stmt_ty |
| 3327 | with_stmt_rule(Parser *p) |
| 3328 | { |
| 3329 | if (p->error_indicator) { |
| 3330 | return NULL; |
| 3331 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3332 | stmt_ty _res = NULL; |
| 3333 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3334 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3335 | p->error_indicator = 1; |
| 3336 | return NULL; |
| 3337 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3338 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3339 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3340 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3341 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3342 | { // 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3343 | if (p->error_indicator) { |
| 3344 | return NULL; |
| 3345 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3346 | Token * _keyword; |
| 3347 | Token * _literal; |
| 3348 | Token * _literal_1; |
| 3349 | Token * _literal_2; |
| 3350 | void *_opt_var; |
| 3351 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3352 | asdl_seq * a; |
| 3353 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3354 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3355 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3356 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3357 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3358 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3359 | (a = _gather_38_rule(p)) // ','.with_item+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3360 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3361 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3362 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3363 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3364 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3365 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3366 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3367 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3368 | ) |
| 3369 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3370 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3371 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3372 | return NULL; |
| 3373 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3374 | int _end_lineno = _token->end_lineno; |
| 3375 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3376 | int _end_col_offset = _token->end_col_offset; |
| 3377 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3378 | _res = _Py_With ( a , b , NULL , EXTRA ); |
| 3379 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3380 | p->error_indicator = 1; |
| 3381 | return NULL; |
| 3382 | } |
| 3383 | goto done; |
| 3384 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3385 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3386 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3387 | { // 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3388 | if (p->error_indicator) { |
| 3389 | return NULL; |
| 3390 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3391 | Token * _keyword; |
| 3392 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3393 | asdl_seq * a; |
| 3394 | asdl_seq* b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3395 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3396 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3397 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3398 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3399 | (a = _gather_40_rule(p)) // ','.with_item+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3400 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3401 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3402 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3403 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3404 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3405 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3406 | ) |
| 3407 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3408 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3409 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3410 | return NULL; |
| 3411 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3412 | int _end_lineno = _token->end_lineno; |
| 3413 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3414 | int _end_col_offset = _token->end_col_offset; |
| 3415 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3416 | _res = _Py_With ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 3417 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3418 | p->error_indicator = 1; |
| 3419 | return NULL; |
| 3420 | } |
| 3421 | goto done; |
| 3422 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3423 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3424 | } |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3425 | { // ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3426 | if (p->error_indicator) { |
| 3427 | return NULL; |
| 3428 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3429 | Token * _keyword; |
| 3430 | Token * _literal; |
| 3431 | Token * _literal_1; |
| 3432 | Token * _literal_2; |
| 3433 | void *_opt_var; |
| 3434 | UNUSED(_opt_var); // Silence compiler warnings |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3435 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3436 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3437 | asdl_seq* b; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3438 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3439 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3440 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3441 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3442 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3443 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3444 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3445 | (a = _gather_42_rule(p)) // ','.with_item+ |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3446 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3447 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3448 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3449 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3450 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3451 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3452 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3453 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3454 | ) |
| 3455 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3456 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3457 | if (_token == NULL) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3458 | return NULL; |
| 3459 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3460 | int _end_lineno = _token->end_lineno; |
| 3461 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3462 | int _end_col_offset = _token->end_col_offset; |
| 3463 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3464 | _res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NULL , EXTRA ) ); |
| 3465 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3466 | p->error_indicator = 1; |
| 3467 | return NULL; |
| 3468 | } |
| 3469 | goto done; |
| 3470 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3471 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3472 | } |
| 3473 | { // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3474 | if (p->error_indicator) { |
| 3475 | return NULL; |
| 3476 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3477 | Token * _keyword; |
| 3478 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3479 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3480 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3481 | asdl_seq* b; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3482 | void *tc; |
| 3483 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3484 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3485 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3486 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3487 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3488 | (a = _gather_44_rule(p)) // ','.with_item+ |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3489 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3490 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3491 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3492 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3493 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3494 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3495 | ) |
| 3496 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3497 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3498 | if (_token == NULL) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3499 | return NULL; |
| 3500 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3501 | int _end_lineno = _token->end_lineno; |
| 3502 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3503 | int _end_col_offset = _token->end_col_offset; |
| 3504 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3505 | _res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
| 3506 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3507 | p->error_indicator = 1; |
| 3508 | return NULL; |
| 3509 | } |
| 3510 | goto done; |
| 3511 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3512 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3513 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3514 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3515 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3516 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3517 | } |
| 3518 | |
| 3519 | // with_item: expression ['as' target] |
| 3520 | static withitem_ty |
| 3521 | with_item_rule(Parser *p) |
| 3522 | { |
| 3523 | if (p->error_indicator) { |
| 3524 | return NULL; |
| 3525 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3526 | withitem_ty _res = NULL; |
| 3527 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3528 | { // expression ['as' target] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3529 | if (p->error_indicator) { |
| 3530 | return NULL; |
| 3531 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3532 | expr_ty e; |
| 3533 | void *o; |
| 3534 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3535 | (e = expression_rule(p)) // expression |
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 | (o = _tmp_46_rule(p), 1) // ['as' target] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3538 | ) |
| 3539 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3540 | _res = _Py_withitem ( e , o , p -> arena ); |
| 3541 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3542 | p->error_indicator = 1; |
| 3543 | return NULL; |
| 3544 | } |
| 3545 | goto done; |
| 3546 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3547 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3548 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3549 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3550 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3551 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3552 | } |
| 3553 | |
| 3554 | // try_stmt: |
| 3555 | // | 'try' ':' block finally_block |
| 3556 | // | 'try' ':' block except_block+ else_block? finally_block? |
| 3557 | static stmt_ty |
| 3558 | try_stmt_rule(Parser *p) |
| 3559 | { |
| 3560 | if (p->error_indicator) { |
| 3561 | return NULL; |
| 3562 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3563 | stmt_ty _res = NULL; |
| 3564 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3565 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3566 | p->error_indicator = 1; |
| 3567 | return NULL; |
| 3568 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3569 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3570 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3571 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3572 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3573 | { // 'try' ':' block finally_block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3574 | if (p->error_indicator) { |
| 3575 | return NULL; |
| 3576 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3577 | Token * _keyword; |
| 3578 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3579 | asdl_seq* b; |
| 3580 | asdl_seq* f; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3581 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3582 | (_keyword = _PyPegen_expect_token(p, 511)) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3583 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3584 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3585 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3586 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3587 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3588 | (f = finally_block_rule(p)) // finally_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3589 | ) |
| 3590 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3591 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3592 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3593 | return NULL; |
| 3594 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3595 | int _end_lineno = _token->end_lineno; |
| 3596 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3597 | int _end_col_offset = _token->end_col_offset; |
| 3598 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3599 | _res = _Py_Try ( b , NULL , NULL , f , EXTRA ); |
| 3600 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3601 | p->error_indicator = 1; |
| 3602 | return NULL; |
| 3603 | } |
| 3604 | goto done; |
| 3605 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3606 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3607 | } |
| 3608 | { // 'try' ':' block except_block+ else_block? finally_block? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3609 | if (p->error_indicator) { |
| 3610 | return NULL; |
| 3611 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3612 | Token * _keyword; |
| 3613 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3614 | asdl_seq* b; |
| 3615 | void *el; |
| 3616 | asdl_seq * ex; |
| 3617 | void *f; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3618 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3619 | (_keyword = _PyPegen_expect_token(p, 511)) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3620 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3621 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3622 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3623 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3624 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3625 | (ex = _loop1_47_rule(p)) // except_block+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3626 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3627 | (el = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3628 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3629 | (f = finally_block_rule(p), 1) // finally_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3630 | ) |
| 3631 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3632 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3633 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3634 | return NULL; |
| 3635 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3636 | int _end_lineno = _token->end_lineno; |
| 3637 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3638 | int _end_col_offset = _token->end_col_offset; |
| 3639 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3640 | _res = _Py_Try ( b , ex , el , f , EXTRA ); |
| 3641 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3642 | p->error_indicator = 1; |
| 3643 | return NULL; |
| 3644 | } |
| 3645 | goto done; |
| 3646 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3647 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3648 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3649 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3650 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3651 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3652 | } |
| 3653 | |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 3654 | // except_block: 'except' expression ['as' NAME] ':' block | 'except' ':' block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3655 | static excepthandler_ty |
| 3656 | except_block_rule(Parser *p) |
| 3657 | { |
| 3658 | if (p->error_indicator) { |
| 3659 | return NULL; |
| 3660 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3661 | excepthandler_ty _res = NULL; |
| 3662 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3663 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3664 | p->error_indicator = 1; |
| 3665 | return NULL; |
| 3666 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3667 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3668 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3669 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3670 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 3671 | { // 'except' expression ['as' NAME] ':' block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3672 | if (p->error_indicator) { |
| 3673 | return NULL; |
| 3674 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3675 | Token * _keyword; |
| 3676 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3677 | asdl_seq* b; |
| 3678 | expr_ty e; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3679 | void *t; |
| 3680 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3681 | (_keyword = _PyPegen_expect_token(p, 520)) // token='except' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3682 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3683 | (e = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3684 | && |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 3685 | (t = _tmp_48_rule(p), 1) // ['as' NAME] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3686 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3687 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3688 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3689 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3690 | ) |
| 3691 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3692 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3693 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3694 | return NULL; |
| 3695 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3696 | int _end_lineno = _token->end_lineno; |
| 3697 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3698 | int _end_col_offset = _token->end_col_offset; |
| 3699 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3700 | _res = _Py_ExceptHandler ( e , ( t ) ? ( ( expr_ty ) t ) -> v . Name . id : NULL , b , EXTRA ); |
| 3701 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3702 | p->error_indicator = 1; |
| 3703 | return NULL; |
| 3704 | } |
| 3705 | goto done; |
| 3706 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3707 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3708 | } |
| 3709 | { // 'except' ':' block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3710 | if (p->error_indicator) { |
| 3711 | return NULL; |
| 3712 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3713 | Token * _keyword; |
| 3714 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3715 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3716 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3717 | (_keyword = _PyPegen_expect_token(p, 520)) // token='except' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3718 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3719 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3720 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3721 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3722 | ) |
| 3723 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3724 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3725 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3726 | return NULL; |
| 3727 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3728 | int _end_lineno = _token->end_lineno; |
| 3729 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3730 | int _end_col_offset = _token->end_col_offset; |
| 3731 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3732 | _res = _Py_ExceptHandler ( NULL , NULL , b , EXTRA ); |
| 3733 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3734 | p->error_indicator = 1; |
| 3735 | return NULL; |
| 3736 | } |
| 3737 | goto done; |
| 3738 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3739 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3740 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3741 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3742 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3743 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3744 | } |
| 3745 | |
| 3746 | // finally_block: 'finally' ':' block |
| 3747 | static asdl_seq* |
| 3748 | finally_block_rule(Parser *p) |
| 3749 | { |
| 3750 | if (p->error_indicator) { |
| 3751 | return NULL; |
| 3752 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3753 | asdl_seq* _res = NULL; |
| 3754 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3755 | { // 'finally' ':' block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3756 | if (p->error_indicator) { |
| 3757 | return NULL; |
| 3758 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3759 | Token * _keyword; |
| 3760 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3761 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3762 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3763 | (_keyword = _PyPegen_expect_token(p, 521)) // token='finally' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3764 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3765 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3766 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3767 | (a = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3768 | ) |
| 3769 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3770 | _res = a; |
| 3771 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3772 | p->error_indicator = 1; |
| 3773 | return NULL; |
| 3774 | } |
| 3775 | goto done; |
| 3776 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3777 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3778 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3779 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3780 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3781 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3782 | } |
| 3783 | |
| 3784 | // return_stmt: 'return' star_expressions? |
| 3785 | static stmt_ty |
| 3786 | return_stmt_rule(Parser *p) |
| 3787 | { |
| 3788 | if (p->error_indicator) { |
| 3789 | return NULL; |
| 3790 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3791 | stmt_ty _res = NULL; |
| 3792 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3793 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3794 | p->error_indicator = 1; |
| 3795 | return NULL; |
| 3796 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3797 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3798 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3799 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3800 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3801 | { // 'return' star_expressions? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3802 | if (p->error_indicator) { |
| 3803 | return NULL; |
| 3804 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3805 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3806 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3807 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3808 | (_keyword = _PyPegen_expect_token(p, 500)) // token='return' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3809 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3810 | (a = star_expressions_rule(p), 1) // star_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3811 | ) |
| 3812 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3813 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3814 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3815 | return NULL; |
| 3816 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3817 | int _end_lineno = _token->end_lineno; |
| 3818 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3819 | int _end_col_offset = _token->end_col_offset; |
| 3820 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3821 | _res = _Py_Return ( a , EXTRA ); |
| 3822 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3823 | p->error_indicator = 1; |
| 3824 | return NULL; |
| 3825 | } |
| 3826 | goto done; |
| 3827 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3828 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3829 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3830 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3831 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3832 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3833 | } |
| 3834 | |
| 3835 | // raise_stmt: 'raise' expression ['from' expression] | 'raise' |
| 3836 | static stmt_ty |
| 3837 | raise_stmt_rule(Parser *p) |
| 3838 | { |
| 3839 | if (p->error_indicator) { |
| 3840 | return NULL; |
| 3841 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3842 | stmt_ty _res = NULL; |
| 3843 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3844 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3845 | p->error_indicator = 1; |
| 3846 | return NULL; |
| 3847 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3848 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3849 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3850 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3851 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3852 | { // 'raise' expression ['from' expression] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3853 | if (p->error_indicator) { |
| 3854 | return NULL; |
| 3855 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3856 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3857 | expr_ty a; |
| 3858 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3859 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3860 | (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3861 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3862 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3863 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3864 | (b = _tmp_49_rule(p), 1) // ['from' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3865 | ) |
| 3866 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3867 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3868 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3869 | return NULL; |
| 3870 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3871 | int _end_lineno = _token->end_lineno; |
| 3872 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3873 | int _end_col_offset = _token->end_col_offset; |
| 3874 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3875 | _res = _Py_Raise ( a , b , EXTRA ); |
| 3876 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3877 | p->error_indicator = 1; |
| 3878 | return NULL; |
| 3879 | } |
| 3880 | goto done; |
| 3881 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3882 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3883 | } |
| 3884 | { // 'raise' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3885 | if (p->error_indicator) { |
| 3886 | return NULL; |
| 3887 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3888 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3889 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3890 | (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3891 | ) |
| 3892 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3893 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3894 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3895 | return NULL; |
| 3896 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3897 | int _end_lineno = _token->end_lineno; |
| 3898 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3899 | int _end_col_offset = _token->end_col_offset; |
| 3900 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3901 | _res = _Py_Raise ( NULL , NULL , EXTRA ); |
| 3902 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3903 | p->error_indicator = 1; |
| 3904 | return NULL; |
| 3905 | } |
| 3906 | goto done; |
| 3907 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3908 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3909 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3910 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3911 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3912 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3913 | } |
| 3914 | |
| 3915 | // function_def: decorators function_def_raw | function_def_raw |
| 3916 | static stmt_ty |
| 3917 | function_def_rule(Parser *p) |
| 3918 | { |
| 3919 | if (p->error_indicator) { |
| 3920 | return NULL; |
| 3921 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3922 | stmt_ty _res = NULL; |
| 3923 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3924 | { // decorators function_def_raw |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3925 | if (p->error_indicator) { |
| 3926 | return NULL; |
| 3927 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3928 | asdl_seq* d; |
| 3929 | stmt_ty f; |
| 3930 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3931 | (d = decorators_rule(p)) // decorators |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3932 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3933 | (f = function_def_raw_rule(p)) // function_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3934 | ) |
| 3935 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3936 | _res = _PyPegen_function_def_decorators ( p , d , f ); |
| 3937 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3938 | p->error_indicator = 1; |
| 3939 | return NULL; |
| 3940 | } |
| 3941 | goto done; |
| 3942 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3943 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3944 | } |
| 3945 | { // function_def_raw |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3946 | if (p->error_indicator) { |
| 3947 | return NULL; |
| 3948 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3949 | stmt_ty function_def_raw_var; |
| 3950 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3951 | (function_def_raw_var = function_def_raw_rule(p)) // function_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3952 | ) |
| 3953 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3954 | _res = function_def_raw_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3955 | goto done; |
| 3956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3957 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3958 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3959 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3960 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3961 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3962 | } |
| 3963 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3964 | // function_def_raw: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3965 | // | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
| 3966 | // | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3967 | static stmt_ty |
| 3968 | function_def_raw_rule(Parser *p) |
| 3969 | { |
| 3970 | if (p->error_indicator) { |
| 3971 | return NULL; |
| 3972 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3973 | stmt_ty _res = NULL; |
| 3974 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3975 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3976 | p->error_indicator = 1; |
| 3977 | return NULL; |
| 3978 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3979 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3980 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3981 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3982 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3983 | { // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 3984 | if (p->error_indicator) { |
| 3985 | return NULL; |
| 3986 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3987 | Token * _keyword; |
| 3988 | Token * _literal; |
| 3989 | Token * _literal_1; |
| 3990 | Token * _literal_2; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3991 | void *a; |
| 3992 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3993 | expr_ty n; |
| 3994 | void *params; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3995 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3996 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3997 | (_keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3998 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3999 | (n = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4000 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4001 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4002 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4003 | (params = params_rule(p), 1) // params? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4004 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4005 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4006 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4007 | (a = _tmp_50_rule(p), 1) // ['->' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4008 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4009 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4010 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4011 | (tc = func_type_comment_rule(p), 1) // func_type_comment? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4012 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4013 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4014 | ) |
| 4015 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4016 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4017 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4018 | return NULL; |
| 4019 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4020 | int _end_lineno = _token->end_lineno; |
| 4021 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4022 | int _end_col_offset = _token->end_col_offset; |
| 4023 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4024 | _res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 4025 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4026 | p->error_indicator = 1; |
| 4027 | return NULL; |
| 4028 | } |
| 4029 | goto done; |
| 4030 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4031 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4032 | } |
| 4033 | { // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4034 | if (p->error_indicator) { |
| 4035 | return NULL; |
| 4036 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4037 | Token * _keyword; |
| 4038 | Token * _literal; |
| 4039 | Token * _literal_1; |
| 4040 | Token * _literal_2; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4041 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4042 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4043 | asdl_seq* b; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4044 | expr_ty n; |
| 4045 | void *params; |
| 4046 | void *tc; |
| 4047 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4048 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4049 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4050 | (_keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4051 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4052 | (n = _PyPegen_name_token(p)) // NAME |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4053 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4054 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4055 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4056 | (params = params_rule(p), 1) // params? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4057 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4058 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4059 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4060 | (a = _tmp_51_rule(p), 1) // ['->' expression] |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4061 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4062 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4063 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4064 | (tc = func_type_comment_rule(p), 1) // func_type_comment? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4065 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4066 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4067 | ) |
| 4068 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4069 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4070 | if (_token == NULL) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4071 | return NULL; |
| 4072 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4073 | int _end_lineno = _token->end_lineno; |
| 4074 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4075 | int _end_col_offset = _token->end_col_offset; |
| 4076 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4077 | _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 ) ); |
| 4078 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4079 | p->error_indicator = 1; |
| 4080 | return NULL; |
| 4081 | } |
| 4082 | goto done; |
| 4083 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4084 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4085 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4086 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4087 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4088 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4089 | } |
| 4090 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4091 | // func_type_comment: |
| 4092 | // | NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
| 4093 | // | invalid_double_type_comments |
| 4094 | // | TYPE_COMMENT |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 4095 | static Token* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4096 | func_type_comment_rule(Parser *p) |
| 4097 | { |
| 4098 | if (p->error_indicator) { |
| 4099 | return NULL; |
| 4100 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4101 | Token* _res = NULL; |
| 4102 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4103 | { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4104 | if (p->error_indicator) { |
| 4105 | return NULL; |
| 4106 | } |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4107 | Token * newline_var; |
| 4108 | Token * t; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4109 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4110 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4111 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4112 | (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4113 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4114 | _PyPegen_lookahead(1, _tmp_52_rule, p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4115 | ) |
| 4116 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4117 | _res = t; |
| 4118 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4119 | p->error_indicator = 1; |
| 4120 | return NULL; |
| 4121 | } |
| 4122 | goto done; |
| 4123 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4124 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4125 | } |
| 4126 | { // invalid_double_type_comments |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4127 | if (p->error_indicator) { |
| 4128 | return NULL; |
| 4129 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4130 | void *invalid_double_type_comments_var; |
| 4131 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4132 | (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] | 4133 | ) |
| 4134 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4135 | _res = invalid_double_type_comments_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4136 | goto done; |
| 4137 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4138 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4139 | } |
| 4140 | { // TYPE_COMMENT |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4141 | if (p->error_indicator) { |
| 4142 | return NULL; |
| 4143 | } |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4144 | Token * type_comment_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4145 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4146 | (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] | 4147 | ) |
| 4148 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4149 | _res = type_comment_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4150 | goto done; |
| 4151 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4152 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4153 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4154 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4155 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4156 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4157 | } |
| 4158 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4159 | // params: invalid_parameters | parameters |
| 4160 | static arguments_ty |
| 4161 | params_rule(Parser *p) |
| 4162 | { |
| 4163 | if (p->error_indicator) { |
| 4164 | return NULL; |
| 4165 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4166 | arguments_ty _res = NULL; |
| 4167 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4168 | { // invalid_parameters |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4169 | if (p->error_indicator) { |
| 4170 | return NULL; |
| 4171 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4172 | void *invalid_parameters_var; |
| 4173 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4174 | (invalid_parameters_var = invalid_parameters_rule(p)) // invalid_parameters |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4175 | ) |
| 4176 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4177 | _res = invalid_parameters_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4178 | goto done; |
| 4179 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4180 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4181 | } |
| 4182 | { // parameters |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4183 | if (p->error_indicator) { |
| 4184 | return NULL; |
| 4185 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4186 | arguments_ty parameters_var; |
| 4187 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4188 | (parameters_var = parameters_rule(p)) // parameters |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4189 | ) |
| 4190 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4191 | _res = parameters_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4192 | goto done; |
| 4193 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4194 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4195 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4196 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4197 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4198 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4199 | } |
| 4200 | |
| 4201 | // parameters: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4202 | // | slash_no_default param_no_default* param_with_default* star_etc? |
| 4203 | // | slash_with_default param_with_default* star_etc? |
| 4204 | // | param_no_default+ param_with_default* star_etc? |
| 4205 | // | param_with_default+ star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4206 | // | star_etc |
| 4207 | static arguments_ty |
| 4208 | parameters_rule(Parser *p) |
| 4209 | { |
| 4210 | if (p->error_indicator) { |
| 4211 | return NULL; |
| 4212 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4213 | arguments_ty _res = NULL; |
| 4214 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4215 | { // slash_no_default param_no_default* param_with_default* star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4216 | if (p->error_indicator) { |
| 4217 | return NULL; |
| 4218 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4219 | asdl_seq* a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4220 | asdl_seq * b; |
| 4221 | asdl_seq * c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4222 | void *d; |
| 4223 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4224 | (a = slash_no_default_rule(p)) // slash_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4225 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4226 | (b = _loop0_53_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4227 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4228 | (c = _loop0_54_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4229 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4230 | (d = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4231 | ) |
| 4232 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4233 | _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 4234 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4235 | p->error_indicator = 1; |
| 4236 | return NULL; |
| 4237 | } |
| 4238 | goto done; |
| 4239 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4240 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4241 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4242 | { // slash_with_default param_with_default* star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4243 | if (p->error_indicator) { |
| 4244 | return NULL; |
| 4245 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4246 | SlashWithDefault* a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4247 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4248 | void *c; |
| 4249 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4250 | (a = slash_with_default_rule(p)) // slash_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4251 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4252 | (b = _loop0_55_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4253 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4254 | (c = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4255 | ) |
| 4256 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4257 | _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 4258 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4259 | p->error_indicator = 1; |
| 4260 | return NULL; |
| 4261 | } |
| 4262 | goto done; |
| 4263 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4264 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4265 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4266 | { // param_no_default+ param_with_default* star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4267 | if (p->error_indicator) { |
| 4268 | return NULL; |
| 4269 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4270 | asdl_seq * a; |
| 4271 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4272 | void *c; |
| 4273 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4274 | (a = _loop1_56_rule(p)) // param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4275 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4276 | (b = _loop0_57_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4277 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4278 | (c = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4279 | ) |
| 4280 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4281 | _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 4282 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4283 | p->error_indicator = 1; |
| 4284 | return NULL; |
| 4285 | } |
| 4286 | goto done; |
| 4287 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4288 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4289 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4290 | { // param_with_default+ star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4291 | if (p->error_indicator) { |
| 4292 | return NULL; |
| 4293 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4294 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4295 | void *b; |
| 4296 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4297 | (a = _loop1_58_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4298 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4299 | (b = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4300 | ) |
| 4301 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4302 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 4303 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4304 | p->error_indicator = 1; |
| 4305 | return NULL; |
| 4306 | } |
| 4307 | goto done; |
| 4308 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4309 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4310 | } |
| 4311 | { // star_etc |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4312 | if (p->error_indicator) { |
| 4313 | return NULL; |
| 4314 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4315 | StarEtc* a; |
| 4316 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4317 | (a = star_etc_rule(p)) // star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4318 | ) |
| 4319 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4320 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 4321 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4322 | p->error_indicator = 1; |
| 4323 | return NULL; |
| 4324 | } |
| 4325 | goto done; |
| 4326 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4327 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4328 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4329 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4330 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4331 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4332 | } |
| 4333 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4334 | // slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4335 | static asdl_seq* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4336 | slash_no_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4337 | { |
| 4338 | if (p->error_indicator) { |
| 4339 | return NULL; |
| 4340 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4341 | asdl_seq* _res = NULL; |
| 4342 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4343 | { // param_no_default+ '/' ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4344 | if (p->error_indicator) { |
| 4345 | return NULL; |
| 4346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4347 | Token * _literal; |
| 4348 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4349 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4350 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4351 | (a = _loop1_59_rule(p)) // param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4352 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4353 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4354 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4355 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4356 | ) |
| 4357 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4358 | _res = a; |
| 4359 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4360 | p->error_indicator = 1; |
| 4361 | return NULL; |
| 4362 | } |
| 4363 | goto done; |
| 4364 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4365 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4366 | } |
| 4367 | { // param_no_default+ '/' &')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4368 | if (p->error_indicator) { |
| 4369 | return NULL; |
| 4370 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4371 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4372 | asdl_seq * a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4373 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4374 | (a = _loop1_60_rule(p)) // param_no_default+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4375 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4376 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4377 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4378 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4379 | ) |
| 4380 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4381 | _res = a; |
| 4382 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4383 | p->error_indicator = 1; |
| 4384 | return NULL; |
| 4385 | } |
| 4386 | goto done; |
| 4387 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4388 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4389 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4390 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4391 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4392 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4393 | } |
| 4394 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4395 | // slash_with_default: |
| 4396 | // | param_no_default* param_with_default+ '/' ',' |
| 4397 | // | param_no_default* param_with_default+ '/' &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4398 | static SlashWithDefault* |
| 4399 | slash_with_default_rule(Parser *p) |
| 4400 | { |
| 4401 | if (p->error_indicator) { |
| 4402 | return NULL; |
| 4403 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4404 | SlashWithDefault* _res = NULL; |
| 4405 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4406 | { // param_no_default* param_with_default+ '/' ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4407 | if (p->error_indicator) { |
| 4408 | return NULL; |
| 4409 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4410 | Token * _literal; |
| 4411 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4412 | asdl_seq * a; |
| 4413 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4414 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4415 | (a = _loop0_61_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4416 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4417 | (b = _loop1_62_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4418 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4419 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4420 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4421 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4422 | ) |
| 4423 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4424 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 4425 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4426 | p->error_indicator = 1; |
| 4427 | return NULL; |
| 4428 | } |
| 4429 | goto done; |
| 4430 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4431 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4432 | } |
| 4433 | { // param_no_default* param_with_default+ '/' &')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4434 | if (p->error_indicator) { |
| 4435 | return NULL; |
| 4436 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4437 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4438 | asdl_seq * a; |
| 4439 | asdl_seq * b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4440 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4441 | (a = _loop0_63_rule(p)) // param_no_default* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4442 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4443 | (b = _loop1_64_rule(p)) // param_with_default+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4444 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4445 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4446 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4447 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4448 | ) |
| 4449 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4450 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 4451 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4452 | p->error_indicator = 1; |
| 4453 | return NULL; |
| 4454 | } |
| 4455 | goto done; |
| 4456 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4457 | p->mark = _mark; |
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 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4460 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4461 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4462 | } |
| 4463 | |
| 4464 | // star_etc: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4465 | // | '*' param_no_default param_maybe_default* kwds? |
| 4466 | // | '*' ',' param_maybe_default+ kwds? |
| 4467 | // | kwds |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4468 | // | invalid_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4469 | static StarEtc* |
| 4470 | star_etc_rule(Parser *p) |
| 4471 | { |
| 4472 | if (p->error_indicator) { |
| 4473 | return NULL; |
| 4474 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4475 | StarEtc* _res = NULL; |
| 4476 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4477 | { // '*' param_no_default param_maybe_default* kwds? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4478 | if (p->error_indicator) { |
| 4479 | return NULL; |
| 4480 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4481 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4482 | arg_ty a; |
| 4483 | asdl_seq * b; |
| 4484 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4485 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4486 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4487 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4488 | (a = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4489 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4490 | (b = _loop0_65_rule(p)) // param_maybe_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4491 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4492 | (c = kwds_rule(p), 1) // kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4493 | ) |
| 4494 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4495 | _res = _PyPegen_star_etc ( p , a , b , c ); |
| 4496 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4497 | p->error_indicator = 1; |
| 4498 | return NULL; |
| 4499 | } |
| 4500 | goto done; |
| 4501 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4502 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4503 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4504 | { // '*' ',' param_maybe_default+ kwds? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4505 | if (p->error_indicator) { |
| 4506 | return NULL; |
| 4507 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4508 | Token * _literal; |
| 4509 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4510 | asdl_seq * b; |
| 4511 | void *c; |
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 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
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_1 = _PyPegen_expect_token(p, 12)) // 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 | (b = _loop1_66_rule(p)) // param_maybe_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4518 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4519 | (c = kwds_rule(p), 1) // kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4520 | ) |
| 4521 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4522 | _res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 4523 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4524 | p->error_indicator = 1; |
| 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 | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4530 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4531 | { // kwds |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4532 | if (p->error_indicator) { |
| 4533 | return NULL; |
| 4534 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4535 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4536 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4537 | (a = kwds_rule(p)) // kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4538 | ) |
| 4539 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4540 | _res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 4541 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4542 | p->error_indicator = 1; |
| 4543 | return NULL; |
| 4544 | } |
| 4545 | goto done; |
| 4546 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4547 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4548 | } |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4549 | { // invalid_star_etc |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4550 | if (p->error_indicator) { |
| 4551 | return NULL; |
| 4552 | } |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4553 | void *invalid_star_etc_var; |
| 4554 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4555 | (invalid_star_etc_var = invalid_star_etc_rule(p)) // invalid_star_etc |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4556 | ) |
| 4557 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4558 | _res = invalid_star_etc_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4559 | goto done; |
| 4560 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4561 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4562 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4563 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4564 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4565 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4566 | } |
| 4567 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4568 | // kwds: '**' param_no_default |
| 4569 | static arg_ty |
| 4570 | kwds_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4571 | { |
| 4572 | if (p->error_indicator) { |
| 4573 | return NULL; |
| 4574 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4575 | arg_ty _res = NULL; |
| 4576 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4577 | { // '**' param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4578 | if (p->error_indicator) { |
| 4579 | return NULL; |
| 4580 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4581 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4582 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4583 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4584 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4585 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4586 | (a = param_no_default_rule(p)) // param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4587 | ) |
| 4588 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4589 | _res = a; |
| 4590 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4591 | p->error_indicator = 1; |
| 4592 | return NULL; |
| 4593 | } |
| 4594 | goto done; |
| 4595 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4596 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4597 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4598 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4599 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4600 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4601 | } |
| 4602 | |
| 4603 | // param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')' |
| 4604 | static arg_ty |
| 4605 | param_no_default_rule(Parser *p) |
| 4606 | { |
| 4607 | if (p->error_indicator) { |
| 4608 | return NULL; |
| 4609 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4610 | arg_ty _res = NULL; |
| 4611 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4612 | { // param ',' TYPE_COMMENT? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4613 | if (p->error_indicator) { |
| 4614 | return NULL; |
| 4615 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4616 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4617 | arg_ty a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4618 | void *tc; |
| 4619 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4620 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4621 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4622 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4623 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4624 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4625 | ) |
| 4626 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4627 | _res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
| 4628 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4629 | p->error_indicator = 1; |
| 4630 | return NULL; |
| 4631 | } |
| 4632 | goto done; |
| 4633 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4634 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4635 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4636 | { // param TYPE_COMMENT? &')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4637 | if (p->error_indicator) { |
| 4638 | return NULL; |
| 4639 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4640 | arg_ty a; |
| 4641 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4642 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4643 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4644 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4645 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4646 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4647 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4648 | ) |
| 4649 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4650 | _res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
| 4651 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4652 | p->error_indicator = 1; |
| 4653 | return NULL; |
| 4654 | } |
| 4655 | goto done; |
| 4656 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4657 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4658 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4659 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4660 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4661 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4662 | } |
| 4663 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4664 | // param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4665 | static NameDefaultPair* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4666 | param_with_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4667 | { |
| 4668 | if (p->error_indicator) { |
| 4669 | return NULL; |
| 4670 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4671 | NameDefaultPair* _res = NULL; |
| 4672 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4673 | { // param default ',' TYPE_COMMENT? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4674 | if (p->error_indicator) { |
| 4675 | return NULL; |
| 4676 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4677 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4678 | arg_ty a; |
| 4679 | expr_ty c; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4680 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4681 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4682 | (a = param_rule(p)) // param |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4683 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4684 | (c = default_rule(p)) // default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4685 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4686 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4687 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4688 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4689 | ) |
| 4690 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4691 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4692 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4693 | p->error_indicator = 1; |
| 4694 | return NULL; |
| 4695 | } |
| 4696 | goto done; |
| 4697 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4698 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4699 | } |
| 4700 | { // param default TYPE_COMMENT? &')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4701 | if (p->error_indicator) { |
| 4702 | return NULL; |
| 4703 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4704 | arg_ty a; |
| 4705 | expr_ty c; |
| 4706 | void *tc; |
| 4707 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4708 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4709 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4710 | (c = default_rule(p)) // default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4711 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4712 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4713 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4714 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4715 | ) |
| 4716 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4717 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4718 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4719 | p->error_indicator = 1; |
| 4720 | return NULL; |
| 4721 | } |
| 4722 | goto done; |
| 4723 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4724 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4725 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4726 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4727 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4728 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4729 | } |
| 4730 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4731 | // param_maybe_default: |
| 4732 | // | param default? ',' TYPE_COMMENT? |
| 4733 | // | param default? TYPE_COMMENT? &')' |
| 4734 | static NameDefaultPair* |
| 4735 | param_maybe_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4736 | { |
| 4737 | if (p->error_indicator) { |
| 4738 | return NULL; |
| 4739 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4740 | NameDefaultPair* _res = NULL; |
| 4741 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4742 | { // param default? ',' TYPE_COMMENT? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4743 | if (p->error_indicator) { |
| 4744 | return NULL; |
| 4745 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4746 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4747 | arg_ty a; |
| 4748 | void *c; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4749 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4750 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4751 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4752 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4753 | (c = default_rule(p), 1) // default? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4754 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4755 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4756 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4757 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4758 | ) |
| 4759 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4760 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4761 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4762 | p->error_indicator = 1; |
| 4763 | return NULL; |
| 4764 | } |
| 4765 | goto done; |
| 4766 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4767 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4768 | } |
| 4769 | { // param default? TYPE_COMMENT? &')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4770 | if (p->error_indicator) { |
| 4771 | return NULL; |
| 4772 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4773 | arg_ty a; |
| 4774 | void *c; |
| 4775 | void *tc; |
| 4776 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4777 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4778 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4779 | (c = default_rule(p), 1) // default? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4780 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4781 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4782 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4783 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4784 | ) |
| 4785 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4786 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4787 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4788 | p->error_indicator = 1; |
| 4789 | return NULL; |
| 4790 | } |
| 4791 | goto done; |
| 4792 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4793 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4794 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4795 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4796 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4797 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4798 | } |
| 4799 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4800 | // param: NAME annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4801 | static arg_ty |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4802 | param_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4803 | { |
| 4804 | if (p->error_indicator) { |
| 4805 | return NULL; |
| 4806 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4807 | arg_ty _res = NULL; |
| 4808 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4809 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4810 | p->error_indicator = 1; |
| 4811 | return NULL; |
| 4812 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4813 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4814 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4815 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4816 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4817 | { // NAME annotation? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4818 | if (p->error_indicator) { |
| 4819 | return NULL; |
| 4820 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4821 | expr_ty a; |
| 4822 | void *b; |
| 4823 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4824 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4825 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4826 | (b = annotation_rule(p), 1) // annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4827 | ) |
| 4828 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4829 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4830 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4831 | return NULL; |
| 4832 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4833 | int _end_lineno = _token->end_lineno; |
| 4834 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4835 | int _end_col_offset = _token->end_col_offset; |
| 4836 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4837 | _res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA ); |
| 4838 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4839 | p->error_indicator = 1; |
| 4840 | return NULL; |
| 4841 | } |
| 4842 | goto done; |
| 4843 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4844 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4845 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4846 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4847 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4848 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4849 | } |
| 4850 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4851 | // annotation: ':' expression |
| 4852 | static expr_ty |
| 4853 | annotation_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4854 | { |
| 4855 | if (p->error_indicator) { |
| 4856 | return NULL; |
| 4857 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4858 | expr_ty _res = NULL; |
| 4859 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4860 | { // ':' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4861 | if (p->error_indicator) { |
| 4862 | return NULL; |
| 4863 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4864 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4865 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4866 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4867 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4868 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4869 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4870 | ) |
| 4871 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4872 | _res = a; |
| 4873 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4874 | p->error_indicator = 1; |
| 4875 | return NULL; |
| 4876 | } |
| 4877 | goto done; |
| 4878 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4879 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4880 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4881 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4882 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4883 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4884 | } |
| 4885 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4886 | // default: '=' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4887 | static expr_ty |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4888 | default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4889 | { |
| 4890 | if (p->error_indicator) { |
| 4891 | return NULL; |
| 4892 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4893 | expr_ty _res = NULL; |
| 4894 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4895 | { // '=' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4896 | if (p->error_indicator) { |
| 4897 | return NULL; |
| 4898 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4899 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4900 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4901 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4902 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4903 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4904 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4905 | ) |
| 4906 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4907 | _res = a; |
| 4908 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4909 | p->error_indicator = 1; |
| 4910 | return NULL; |
| 4911 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4912 | goto done; |
| 4913 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4914 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4915 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4916 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4917 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4918 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4919 | } |
| 4920 | |
| 4921 | // decorators: (('@' named_expression NEWLINE))+ |
| 4922 | static asdl_seq* |
| 4923 | decorators_rule(Parser *p) |
| 4924 | { |
| 4925 | if (p->error_indicator) { |
| 4926 | return NULL; |
| 4927 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4928 | asdl_seq* _res = NULL; |
| 4929 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4930 | { // (('@' named_expression NEWLINE))+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4931 | if (p->error_indicator) { |
| 4932 | return NULL; |
| 4933 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4934 | asdl_seq * a; |
| 4935 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4936 | (a = _loop1_67_rule(p)) // (('@' named_expression NEWLINE))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4937 | ) |
| 4938 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4939 | _res = a; |
| 4940 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4941 | p->error_indicator = 1; |
| 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 | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4947 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4948 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4949 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4950 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4951 | } |
| 4952 | |
| 4953 | // class_def: decorators class_def_raw | class_def_raw |
| 4954 | static stmt_ty |
| 4955 | class_def_rule(Parser *p) |
| 4956 | { |
| 4957 | if (p->error_indicator) { |
| 4958 | return NULL; |
| 4959 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4960 | stmt_ty _res = NULL; |
| 4961 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4962 | { // decorators class_def_raw |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4963 | if (p->error_indicator) { |
| 4964 | return NULL; |
| 4965 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4966 | asdl_seq* a; |
| 4967 | stmt_ty b; |
| 4968 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4969 | (a = decorators_rule(p)) // decorators |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4970 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4971 | (b = class_def_raw_rule(p)) // class_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4972 | ) |
| 4973 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4974 | _res = _PyPegen_class_def_decorators ( p , a , b ); |
| 4975 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4976 | p->error_indicator = 1; |
| 4977 | return NULL; |
| 4978 | } |
| 4979 | goto done; |
| 4980 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4981 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4982 | } |
| 4983 | { // class_def_raw |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 4984 | if (p->error_indicator) { |
| 4985 | return NULL; |
| 4986 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4987 | stmt_ty class_def_raw_var; |
| 4988 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4989 | (class_def_raw_var = class_def_raw_rule(p)) // class_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4990 | ) |
| 4991 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4992 | _res = class_def_raw_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4993 | goto done; |
| 4994 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4995 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4996 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4997 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4998 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4999 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5000 | } |
| 5001 | |
| 5002 | // class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block |
| 5003 | static stmt_ty |
| 5004 | class_def_raw_rule(Parser *p) |
| 5005 | { |
| 5006 | if (p->error_indicator) { |
| 5007 | return NULL; |
| 5008 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5009 | stmt_ty _res = NULL; |
| 5010 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5011 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5012 | p->error_indicator = 1; |
| 5013 | return NULL; |
| 5014 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5015 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5016 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5017 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5018 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5019 | { // 'class' NAME ['(' arguments? ')'] ':' block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5020 | if (p->error_indicator) { |
| 5021 | return NULL; |
| 5022 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5023 | Token * _keyword; |
| 5024 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5025 | expr_ty a; |
| 5026 | void *b; |
| 5027 | asdl_seq* c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5028 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5029 | (_keyword = _PyPegen_expect_token(p, 523)) // token='class' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5030 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5031 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5032 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5033 | (b = _tmp_68_rule(p), 1) // ['(' arguments? ')'] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5034 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5035 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5036 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5037 | (c = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5038 | ) |
| 5039 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5040 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5041 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5042 | return NULL; |
| 5043 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5044 | int _end_lineno = _token->end_lineno; |
| 5045 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5046 | int _end_col_offset = _token->end_col_offset; |
| 5047 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5048 | _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 ); |
| 5049 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5050 | p->error_indicator = 1; |
| 5051 | return NULL; |
| 5052 | } |
| 5053 | goto done; |
| 5054 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5055 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5056 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5057 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5058 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5059 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5060 | } |
| 5061 | |
| 5062 | // block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block |
| 5063 | static asdl_seq* |
| 5064 | block_rule(Parser *p) |
| 5065 | { |
| 5066 | if (p->error_indicator) { |
| 5067 | return NULL; |
| 5068 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5069 | asdl_seq* _res = NULL; |
| 5070 | if (_PyPegen_is_memoized(p, block_type, &_res)) |
| 5071 | return _res; |
| 5072 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5073 | { // NEWLINE INDENT statements DEDENT |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5074 | if (p->error_indicator) { |
| 5075 | return NULL; |
| 5076 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5077 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5078 | Token * dedent_var; |
| 5079 | Token * indent_var; |
| 5080 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5081 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5082 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5083 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5084 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5085 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5086 | (a = statements_rule(p)) // statements |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5087 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5088 | (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5089 | ) |
| 5090 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5091 | _res = a; |
| 5092 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5093 | p->error_indicator = 1; |
| 5094 | return NULL; |
| 5095 | } |
| 5096 | goto done; |
| 5097 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5098 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5099 | } |
| 5100 | { // simple_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5101 | if (p->error_indicator) { |
| 5102 | return NULL; |
| 5103 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5104 | asdl_seq* simple_stmt_var; |
| 5105 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5106 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5107 | ) |
| 5108 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5109 | _res = simple_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5110 | goto done; |
| 5111 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5112 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5113 | } |
| 5114 | { // invalid_block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5115 | if (p->error_indicator) { |
| 5116 | return NULL; |
| 5117 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5118 | void *invalid_block_var; |
| 5119 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5120 | (invalid_block_var = invalid_block_rule(p)) // invalid_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5121 | ) |
| 5122 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5123 | _res = invalid_block_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5124 | goto done; |
| 5125 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5126 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5127 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5128 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5129 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5130 | _PyPegen_insert_memo(p, _mark, block_type, _res); |
| 5131 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5132 | } |
| 5133 | |
| 5134 | // expressions_list: ','.star_expression+ ','? |
| 5135 | static asdl_seq* |
| 5136 | expressions_list_rule(Parser *p) |
| 5137 | { |
| 5138 | if (p->error_indicator) { |
| 5139 | return NULL; |
| 5140 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5141 | asdl_seq* _res = NULL; |
| 5142 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5143 | { // ','.star_expression+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5144 | if (p->error_indicator) { |
| 5145 | return NULL; |
| 5146 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5147 | void *_opt_var; |
| 5148 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5149 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5150 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5151 | (a = _gather_69_rule(p)) // ','.star_expression+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5152 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5153 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5154 | ) |
| 5155 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5156 | _res = a; |
| 5157 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5158 | p->error_indicator = 1; |
| 5159 | return NULL; |
| 5160 | } |
| 5161 | goto done; |
| 5162 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5163 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5164 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5165 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5166 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5167 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5168 | } |
| 5169 | |
| 5170 | // star_expressions: |
| 5171 | // | star_expression ((',' star_expression))+ ','? |
| 5172 | // | star_expression ',' |
| 5173 | // | star_expression |
| 5174 | static expr_ty |
| 5175 | star_expressions_rule(Parser *p) |
| 5176 | { |
| 5177 | if (p->error_indicator) { |
| 5178 | return NULL; |
| 5179 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5180 | expr_ty _res = NULL; |
| 5181 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5182 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5183 | p->error_indicator = 1; |
| 5184 | return NULL; |
| 5185 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5186 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5187 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5188 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5189 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5190 | { // star_expression ((',' star_expression))+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5191 | if (p->error_indicator) { |
| 5192 | return NULL; |
| 5193 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5194 | void *_opt_var; |
| 5195 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5196 | expr_ty a; |
| 5197 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5198 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5199 | (a = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5200 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5201 | (b = _loop1_71_rule(p)) // ((',' star_expression))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5202 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5203 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5204 | ) |
| 5205 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5206 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5207 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5208 | return NULL; |
| 5209 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5210 | int _end_lineno = _token->end_lineno; |
| 5211 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5212 | int _end_col_offset = _token->end_col_offset; |
| 5213 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5214 | _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
| 5215 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5216 | p->error_indicator = 1; |
| 5217 | return NULL; |
| 5218 | } |
| 5219 | goto done; |
| 5220 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5221 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5222 | } |
| 5223 | { // star_expression ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5224 | if (p->error_indicator) { |
| 5225 | return NULL; |
| 5226 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5227 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5228 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5229 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5230 | (a = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5231 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5232 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5233 | ) |
| 5234 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5235 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5236 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5237 | return NULL; |
| 5238 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5239 | int _end_lineno = _token->end_lineno; |
| 5240 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5241 | int _end_col_offset = _token->end_col_offset; |
| 5242 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5243 | _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
| 5244 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5245 | p->error_indicator = 1; |
| 5246 | return NULL; |
| 5247 | } |
| 5248 | goto done; |
| 5249 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5250 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5251 | } |
| 5252 | { // star_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5253 | if (p->error_indicator) { |
| 5254 | return NULL; |
| 5255 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5256 | expr_ty star_expression_var; |
| 5257 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5258 | (star_expression_var = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5259 | ) |
| 5260 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5261 | _res = star_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5262 | goto done; |
| 5263 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5264 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5266 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5267 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5268 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5269 | } |
| 5270 | |
| 5271 | // star_expression: '*' bitwise_or | expression |
| 5272 | static expr_ty |
| 5273 | star_expression_rule(Parser *p) |
| 5274 | { |
| 5275 | if (p->error_indicator) { |
| 5276 | return NULL; |
| 5277 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5278 | expr_ty _res = NULL; |
| 5279 | if (_PyPegen_is_memoized(p, star_expression_type, &_res)) |
| 5280 | return _res; |
| 5281 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5282 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5283 | p->error_indicator = 1; |
| 5284 | return NULL; |
| 5285 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5286 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5287 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5288 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5289 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5290 | { // '*' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5291 | if (p->error_indicator) { |
| 5292 | return NULL; |
| 5293 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5294 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5295 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5296 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5297 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5298 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5299 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5300 | ) |
| 5301 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5302 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5303 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5304 | return NULL; |
| 5305 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5306 | int _end_lineno = _token->end_lineno; |
| 5307 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5308 | int _end_col_offset = _token->end_col_offset; |
| 5309 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5310 | _res = _Py_Starred ( a , Load , EXTRA ); |
| 5311 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5312 | p->error_indicator = 1; |
| 5313 | return NULL; |
| 5314 | } |
| 5315 | goto done; |
| 5316 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5317 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5318 | } |
| 5319 | { // expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5320 | if (p->error_indicator) { |
| 5321 | return NULL; |
| 5322 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5323 | expr_ty expression_var; |
| 5324 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5325 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5326 | ) |
| 5327 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5328 | _res = expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5329 | goto done; |
| 5330 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5331 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5332 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5333 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5334 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5335 | _PyPegen_insert_memo(p, _mark, star_expression_type, _res); |
| 5336 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5337 | } |
| 5338 | |
| 5339 | // star_named_expressions: ','.star_named_expression+ ','? |
| 5340 | static asdl_seq* |
| 5341 | star_named_expressions_rule(Parser *p) |
| 5342 | { |
| 5343 | if (p->error_indicator) { |
| 5344 | return NULL; |
| 5345 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5346 | asdl_seq* _res = NULL; |
| 5347 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5348 | { // ','.star_named_expression+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5349 | if (p->error_indicator) { |
| 5350 | return NULL; |
| 5351 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5352 | void *_opt_var; |
| 5353 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5354 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5355 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5356 | (a = _gather_72_rule(p)) // ','.star_named_expression+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5357 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5358 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5359 | ) |
| 5360 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5361 | _res = a; |
| 5362 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5363 | p->error_indicator = 1; |
| 5364 | return NULL; |
| 5365 | } |
| 5366 | goto done; |
| 5367 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5368 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5369 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5370 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5371 | done: |
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_named_expression: '*' bitwise_or | named_expression |
| 5376 | static expr_ty |
| 5377 | star_named_expression_rule(Parser *p) |
| 5378 | { |
| 5379 | if (p->error_indicator) { |
| 5380 | return NULL; |
| 5381 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5382 | expr_ty _res = NULL; |
| 5383 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5384 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5385 | p->error_indicator = 1; |
| 5386 | return NULL; |
| 5387 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5388 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5389 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5390 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5391 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5392 | { // '*' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5393 | if (p->error_indicator) { |
| 5394 | return NULL; |
| 5395 | } |
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 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5398 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5399 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5400 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5401 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5402 | ) |
| 5403 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5404 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5405 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5406 | return NULL; |
| 5407 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5408 | int _end_lineno = _token->end_lineno; |
| 5409 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5410 | int _end_col_offset = _token->end_col_offset; |
| 5411 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5412 | _res = _Py_Starred ( a , Load , EXTRA ); |
| 5413 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5414 | p->error_indicator = 1; |
| 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 | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5420 | } |
| 5421 | { // named_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5422 | if (p->error_indicator) { |
| 5423 | return NULL; |
| 5424 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5425 | expr_ty named_expression_var; |
| 5426 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5427 | (named_expression_var = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5428 | ) |
| 5429 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5430 | _res = named_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5431 | goto done; |
| 5432 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5433 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5434 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5435 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5436 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5437 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5438 | } |
| 5439 | |
| 5440 | // named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression |
| 5441 | static expr_ty |
| 5442 | named_expression_rule(Parser *p) |
| 5443 | { |
| 5444 | if (p->error_indicator) { |
| 5445 | return NULL; |
| 5446 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5447 | expr_ty _res = NULL; |
| 5448 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5449 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5450 | p->error_indicator = 1; |
| 5451 | return NULL; |
| 5452 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5453 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5454 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5455 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5456 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5457 | { // NAME ':=' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5458 | if (p->error_indicator) { |
| 5459 | return NULL; |
| 5460 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5461 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5462 | expr_ty a; |
| 5463 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5464 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5465 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5466 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5467 | (_literal = _PyPegen_expect_token(p, 53)) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5468 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5469 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5470 | ) |
| 5471 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5472 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5473 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5474 | return NULL; |
| 5475 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5476 | int _end_lineno = _token->end_lineno; |
| 5477 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5478 | int _end_col_offset = _token->end_col_offset; |
| 5479 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5480 | _res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA ); |
| 5481 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5482 | p->error_indicator = 1; |
| 5483 | return NULL; |
| 5484 | } |
| 5485 | goto done; |
| 5486 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5487 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5488 | } |
| 5489 | { // expression !':=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5490 | if (p->error_indicator) { |
| 5491 | return NULL; |
| 5492 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5493 | expr_ty expression_var; |
| 5494 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5495 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5496 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5497 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5498 | ) |
| 5499 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5500 | _res = expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5501 | goto done; |
| 5502 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5503 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5504 | } |
| 5505 | { // invalid_named_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5506 | if (p->error_indicator) { |
| 5507 | return NULL; |
| 5508 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5509 | void *invalid_named_expression_var; |
| 5510 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5511 | (invalid_named_expression_var = invalid_named_expression_rule(p)) // invalid_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5512 | ) |
| 5513 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5514 | _res = invalid_named_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5515 | goto done; |
| 5516 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5517 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5518 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5519 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5520 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5521 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5522 | } |
| 5523 | |
| 5524 | // annotated_rhs: yield_expr | star_expressions |
| 5525 | static expr_ty |
| 5526 | annotated_rhs_rule(Parser *p) |
| 5527 | { |
| 5528 | if (p->error_indicator) { |
| 5529 | return NULL; |
| 5530 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5531 | expr_ty _res = NULL; |
| 5532 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5533 | { // yield_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5534 | if (p->error_indicator) { |
| 5535 | return NULL; |
| 5536 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5537 | expr_ty yield_expr_var; |
| 5538 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5539 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5540 | ) |
| 5541 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5542 | _res = yield_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5543 | goto done; |
| 5544 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5545 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5546 | } |
| 5547 | { // star_expressions |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5548 | if (p->error_indicator) { |
| 5549 | return NULL; |
| 5550 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5551 | expr_ty star_expressions_var; |
| 5552 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5553 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5554 | ) |
| 5555 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5556 | _res = star_expressions_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5557 | goto done; |
| 5558 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5559 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5560 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5561 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5562 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5563 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5564 | } |
| 5565 | |
| 5566 | // expressions: expression ((',' expression))+ ','? | expression ',' | expression |
| 5567 | static expr_ty |
| 5568 | expressions_rule(Parser *p) |
| 5569 | { |
| 5570 | if (p->error_indicator) { |
| 5571 | return NULL; |
| 5572 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5573 | expr_ty _res = NULL; |
| 5574 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5575 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5576 | p->error_indicator = 1; |
| 5577 | return NULL; |
| 5578 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5579 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5580 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5581 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5582 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5583 | { // expression ((',' expression))+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5584 | if (p->error_indicator) { |
| 5585 | return NULL; |
| 5586 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5587 | void *_opt_var; |
| 5588 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5589 | expr_ty a; |
| 5590 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5591 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5592 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5593 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5594 | (b = _loop1_74_rule(p)) // ((',' expression))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5595 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5596 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5597 | ) |
| 5598 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5599 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5600 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5601 | return NULL; |
| 5602 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5603 | int _end_lineno = _token->end_lineno; |
| 5604 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5605 | int _end_col_offset = _token->end_col_offset; |
| 5606 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5607 | _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
| 5608 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5609 | p->error_indicator = 1; |
| 5610 | return NULL; |
| 5611 | } |
| 5612 | goto done; |
| 5613 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5614 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5615 | } |
| 5616 | { // expression ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5617 | if (p->error_indicator) { |
| 5618 | return NULL; |
| 5619 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5620 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5621 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5622 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5623 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5624 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5625 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5626 | ) |
| 5627 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5628 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5629 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5630 | return NULL; |
| 5631 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5632 | int _end_lineno = _token->end_lineno; |
| 5633 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5634 | int _end_col_offset = _token->end_col_offset; |
| 5635 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5636 | _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
| 5637 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5638 | p->error_indicator = 1; |
| 5639 | return NULL; |
| 5640 | } |
| 5641 | goto done; |
| 5642 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5643 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5644 | } |
| 5645 | { // expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5646 | if (p->error_indicator) { |
| 5647 | return NULL; |
| 5648 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5649 | expr_ty expression_var; |
| 5650 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5651 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5652 | ) |
| 5653 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5654 | _res = expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5655 | goto done; |
| 5656 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5657 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5658 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5659 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5660 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5661 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5662 | } |
| 5663 | |
| 5664 | // expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef |
| 5665 | static expr_ty |
| 5666 | expression_rule(Parser *p) |
| 5667 | { |
| 5668 | if (p->error_indicator) { |
| 5669 | return NULL; |
| 5670 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5671 | expr_ty _res = NULL; |
| 5672 | if (_PyPegen_is_memoized(p, expression_type, &_res)) |
| 5673 | return _res; |
| 5674 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5675 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5676 | p->error_indicator = 1; |
| 5677 | return NULL; |
| 5678 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5679 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5680 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5681 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5682 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5683 | { // disjunction 'if' disjunction 'else' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5684 | if (p->error_indicator) { |
| 5685 | return NULL; |
| 5686 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5687 | Token * _keyword; |
| 5688 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5689 | expr_ty a; |
| 5690 | expr_ty b; |
| 5691 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5692 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5693 | (a = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5694 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5695 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5696 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5697 | (b = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5698 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5699 | (_keyword_1 = _PyPegen_expect_token(p, 516)) // token='else' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5700 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5701 | (c = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5702 | ) |
| 5703 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5704 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5705 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5706 | return NULL; |
| 5707 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5708 | int _end_lineno = _token->end_lineno; |
| 5709 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5710 | int _end_col_offset = _token->end_col_offset; |
| 5711 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5712 | _res = _Py_IfExp ( b , a , c , EXTRA ); |
| 5713 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5714 | p->error_indicator = 1; |
| 5715 | return NULL; |
| 5716 | } |
| 5717 | goto done; |
| 5718 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5719 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5720 | } |
| 5721 | { // disjunction |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5722 | if (p->error_indicator) { |
| 5723 | return NULL; |
| 5724 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5725 | expr_ty disjunction_var; |
| 5726 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5727 | (disjunction_var = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5728 | ) |
| 5729 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5730 | _res = disjunction_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5731 | goto done; |
| 5732 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5733 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5734 | } |
| 5735 | { // lambdef |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5736 | if (p->error_indicator) { |
| 5737 | return NULL; |
| 5738 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5739 | expr_ty lambdef_var; |
| 5740 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5741 | (lambdef_var = lambdef_rule(p)) // lambdef |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5742 | ) |
| 5743 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5744 | _res = lambdef_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5745 | goto done; |
| 5746 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5747 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5748 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5749 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5750 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5751 | _PyPegen_insert_memo(p, _mark, expression_type, _res); |
| 5752 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5753 | } |
| 5754 | |
| 5755 | // lambdef: 'lambda' lambda_parameters? ':' expression |
| 5756 | static expr_ty |
| 5757 | lambdef_rule(Parser *p) |
| 5758 | { |
| 5759 | if (p->error_indicator) { |
| 5760 | return NULL; |
| 5761 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5762 | expr_ty _res = NULL; |
| 5763 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5764 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5765 | p->error_indicator = 1; |
| 5766 | return NULL; |
| 5767 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5768 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5769 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5770 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5771 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5772 | { // 'lambda' lambda_parameters? ':' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5773 | if (p->error_indicator) { |
| 5774 | return NULL; |
| 5775 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5776 | Token * _keyword; |
| 5777 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5778 | void *a; |
| 5779 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5780 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5781 | (_keyword = _PyPegen_expect_token(p, 524)) // token='lambda' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5782 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5783 | (a = lambda_parameters_rule(p), 1) // lambda_parameters? |
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 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5786 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5787 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5788 | ) |
| 5789 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5790 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5791 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5792 | return NULL; |
| 5793 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5794 | int _end_lineno = _token->end_lineno; |
| 5795 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5796 | int _end_col_offset = _token->end_col_offset; |
| 5797 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5798 | _res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA ); |
| 5799 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5800 | p->error_indicator = 1; |
| 5801 | return NULL; |
| 5802 | } |
| 5803 | goto done; |
| 5804 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5805 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5806 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5807 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5808 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5809 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5810 | } |
| 5811 | |
| 5812 | // lambda_parameters: |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5813 | // | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? |
| 5814 | // | lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
| 5815 | // | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
| 5816 | // | lambda_param_with_default+ lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5817 | // | lambda_star_etc |
| 5818 | static arguments_ty |
| 5819 | lambda_parameters_rule(Parser *p) |
| 5820 | { |
| 5821 | if (p->error_indicator) { |
| 5822 | return NULL; |
| 5823 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5824 | arguments_ty _res = NULL; |
| 5825 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5826 | { // 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] | 5827 | if (p->error_indicator) { |
| 5828 | return NULL; |
| 5829 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5830 | asdl_seq* a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5831 | asdl_seq * b; |
| 5832 | asdl_seq * c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5833 | void *d; |
| 5834 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5835 | (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5836 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5837 | (b = _loop0_75_rule(p)) // lambda_param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5838 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5839 | (c = _loop0_76_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5840 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5841 | (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5842 | ) |
| 5843 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5844 | _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 5845 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5846 | p->error_indicator = 1; |
| 5847 | return NULL; |
| 5848 | } |
| 5849 | goto done; |
| 5850 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5851 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5852 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5853 | { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5854 | if (p->error_indicator) { |
| 5855 | return NULL; |
| 5856 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5857 | SlashWithDefault* a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5858 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5859 | void *c; |
| 5860 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5861 | (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5862 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5863 | (b = _loop0_77_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5864 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5865 | (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5866 | ) |
| 5867 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5868 | _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 5869 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5870 | p->error_indicator = 1; |
| 5871 | return NULL; |
| 5872 | } |
| 5873 | goto done; |
| 5874 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5875 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5876 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5877 | { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5878 | if (p->error_indicator) { |
| 5879 | return NULL; |
| 5880 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5881 | asdl_seq * a; |
| 5882 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5883 | void *c; |
| 5884 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5885 | (a = _loop1_78_rule(p)) // lambda_param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5886 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5887 | (b = _loop0_79_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5888 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5889 | (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5890 | ) |
| 5891 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5892 | _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 5893 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5894 | p->error_indicator = 1; |
| 5895 | return NULL; |
| 5896 | } |
| 5897 | goto done; |
| 5898 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5899 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5900 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5901 | { // lambda_param_with_default+ lambda_star_etc? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5902 | if (p->error_indicator) { |
| 5903 | return NULL; |
| 5904 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5905 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5906 | void *b; |
| 5907 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5908 | (a = _loop1_80_rule(p)) // lambda_param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5909 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5910 | (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5911 | ) |
| 5912 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5913 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 5914 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5915 | p->error_indicator = 1; |
| 5916 | return NULL; |
| 5917 | } |
| 5918 | goto done; |
| 5919 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5920 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5921 | } |
| 5922 | { // lambda_star_etc |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5923 | if (p->error_indicator) { |
| 5924 | return NULL; |
| 5925 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5926 | StarEtc* a; |
| 5927 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5928 | (a = lambda_star_etc_rule(p)) // lambda_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5929 | ) |
| 5930 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5931 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 5932 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5933 | p->error_indicator = 1; |
| 5934 | return NULL; |
| 5935 | } |
| 5936 | goto done; |
| 5937 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5938 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5939 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5940 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5941 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5942 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5943 | } |
| 5944 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5945 | // lambda_slash_no_default: |
| 5946 | // | lambda_param_no_default+ '/' ',' |
| 5947 | // | lambda_param_no_default+ '/' &':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5948 | static asdl_seq* |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5949 | lambda_slash_no_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5950 | { |
| 5951 | if (p->error_indicator) { |
| 5952 | return NULL; |
| 5953 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5954 | asdl_seq* _res = NULL; |
| 5955 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5956 | { // lambda_param_no_default+ '/' ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5957 | if (p->error_indicator) { |
| 5958 | return NULL; |
| 5959 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5960 | Token * _literal; |
| 5961 | Token * _literal_1; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5962 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5963 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5964 | (a = _loop1_81_rule(p)) // lambda_param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5965 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5966 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5967 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5968 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5969 | ) |
| 5970 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5971 | _res = a; |
| 5972 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5973 | p->error_indicator = 1; |
| 5974 | return NULL; |
| 5975 | } |
| 5976 | goto done; |
| 5977 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5978 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5979 | } |
| 5980 | { // lambda_param_no_default+ '/' &':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 5981 | if (p->error_indicator) { |
| 5982 | return NULL; |
| 5983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5984 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5985 | asdl_seq * a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5986 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5987 | (a = _loop1_82_rule(p)) // lambda_param_no_default+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5988 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5989 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5990 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5991 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5992 | ) |
| 5993 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5994 | _res = a; |
| 5995 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5996 | p->error_indicator = 1; |
| 5997 | return NULL; |
| 5998 | } |
| 5999 | goto done; |
| 6000 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6001 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6002 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6003 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6004 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6005 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6006 | } |
| 6007 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6008 | // lambda_slash_with_default: |
| 6009 | // | lambda_param_no_default* lambda_param_with_default+ '/' ',' |
| 6010 | // | lambda_param_no_default* lambda_param_with_default+ '/' &':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6011 | static SlashWithDefault* |
| 6012 | lambda_slash_with_default_rule(Parser *p) |
| 6013 | { |
| 6014 | if (p->error_indicator) { |
| 6015 | return NULL; |
| 6016 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6017 | SlashWithDefault* _res = NULL; |
| 6018 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6019 | { // lambda_param_no_default* lambda_param_with_default+ '/' ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6020 | if (p->error_indicator) { |
| 6021 | return NULL; |
| 6022 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6023 | Token * _literal; |
| 6024 | Token * _literal_1; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6025 | asdl_seq * a; |
| 6026 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6027 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6028 | (a = _loop0_83_rule(p)) // lambda_param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6029 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6030 | (b = _loop1_84_rule(p)) // lambda_param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6031 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6032 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6033 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6034 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6035 | ) |
| 6036 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6037 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 6038 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6039 | p->error_indicator = 1; |
| 6040 | return NULL; |
| 6041 | } |
| 6042 | goto done; |
| 6043 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6044 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6045 | } |
| 6046 | { // lambda_param_no_default* lambda_param_with_default+ '/' &':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6047 | if (p->error_indicator) { |
| 6048 | return NULL; |
| 6049 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6050 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6051 | asdl_seq * a; |
| 6052 | asdl_seq * b; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6053 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6054 | (a = _loop0_85_rule(p)) // lambda_param_no_default* |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6055 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6056 | (b = _loop1_86_rule(p)) // lambda_param_with_default+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6057 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6058 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6059 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6060 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6061 | ) |
| 6062 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6063 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 6064 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6065 | p->error_indicator = 1; |
| 6066 | return NULL; |
| 6067 | } |
| 6068 | goto done; |
| 6069 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6070 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6071 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6072 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6073 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6074 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6075 | } |
| 6076 | |
| 6077 | // lambda_star_etc: |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6078 | // | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
| 6079 | // | '*' ',' lambda_param_maybe_default+ lambda_kwds? |
| 6080 | // | lambda_kwds |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 6081 | // | invalid_lambda_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6082 | static StarEtc* |
| 6083 | lambda_star_etc_rule(Parser *p) |
| 6084 | { |
| 6085 | if (p->error_indicator) { |
| 6086 | return NULL; |
| 6087 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6088 | StarEtc* _res = NULL; |
| 6089 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6090 | { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6091 | if (p->error_indicator) { |
| 6092 | return NULL; |
| 6093 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6094 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6095 | arg_ty a; |
| 6096 | asdl_seq * b; |
| 6097 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6098 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6099 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6100 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6101 | (a = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6102 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6103 | (b = _loop0_87_rule(p)) // lambda_param_maybe_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6104 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6105 | (c = lambda_kwds_rule(p), 1) // lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6106 | ) |
| 6107 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6108 | _res = _PyPegen_star_etc ( p , a , b , c ); |
| 6109 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6110 | p->error_indicator = 1; |
| 6111 | return NULL; |
| 6112 | } |
| 6113 | goto done; |
| 6114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6115 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6116 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6117 | { // '*' ',' lambda_param_maybe_default+ lambda_kwds? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6118 | if (p->error_indicator) { |
| 6119 | return NULL; |
| 6120 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6121 | Token * _literal; |
| 6122 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6123 | asdl_seq * b; |
| 6124 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6125 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6126 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6127 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6128 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6129 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6130 | (b = _loop1_88_rule(p)) // lambda_param_maybe_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6131 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6132 | (c = lambda_kwds_rule(p), 1) // lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6133 | ) |
| 6134 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6135 | _res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 6136 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6137 | p->error_indicator = 1; |
| 6138 | return NULL; |
| 6139 | } |
| 6140 | goto done; |
| 6141 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6142 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6143 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6144 | { // lambda_kwds |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6145 | if (p->error_indicator) { |
| 6146 | return NULL; |
| 6147 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6148 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6149 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6150 | (a = lambda_kwds_rule(p)) // lambda_kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6151 | ) |
| 6152 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6153 | _res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 6154 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6155 | p->error_indicator = 1; |
| 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 | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6161 | } |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 6162 | { // invalid_lambda_star_etc |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6163 | if (p->error_indicator) { |
| 6164 | return NULL; |
| 6165 | } |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 6166 | void *invalid_lambda_star_etc_var; |
| 6167 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6168 | (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] | 6169 | ) |
| 6170 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6171 | _res = invalid_lambda_star_etc_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 6172 | goto done; |
| 6173 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6174 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 6175 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6176 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6177 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6178 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6179 | } |
| 6180 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6181 | // lambda_kwds: '**' lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6182 | static arg_ty |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6183 | lambda_kwds_rule(Parser *p) |
| 6184 | { |
| 6185 | if (p->error_indicator) { |
| 6186 | return NULL; |
| 6187 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6188 | arg_ty _res = NULL; |
| 6189 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6190 | { // '**' lambda_param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6191 | if (p->error_indicator) { |
| 6192 | return NULL; |
| 6193 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6194 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6195 | arg_ty a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6196 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6197 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6198 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6199 | (a = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6200 | ) |
| 6201 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6202 | _res = a; |
| 6203 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6204 | p->error_indicator = 1; |
| 6205 | return NULL; |
| 6206 | } |
| 6207 | goto done; |
| 6208 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6209 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6210 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6211 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6212 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6213 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6214 | } |
| 6215 | |
| 6216 | // lambda_param_no_default: lambda_param ',' | lambda_param &':' |
| 6217 | static arg_ty |
| 6218 | lambda_param_no_default_rule(Parser *p) |
| 6219 | { |
| 6220 | if (p->error_indicator) { |
| 6221 | return NULL; |
| 6222 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6223 | arg_ty _res = NULL; |
| 6224 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6225 | { // lambda_param ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6226 | if (p->error_indicator) { |
| 6227 | return NULL; |
| 6228 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6229 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6230 | arg_ty a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6231 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6232 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6233 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6234 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6235 | ) |
| 6236 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6237 | _res = a; |
| 6238 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6239 | p->error_indicator = 1; |
| 6240 | return NULL; |
| 6241 | } |
| 6242 | goto done; |
| 6243 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6244 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6245 | } |
| 6246 | { // lambda_param &':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6247 | if (p->error_indicator) { |
| 6248 | return NULL; |
| 6249 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6250 | arg_ty a; |
| 6251 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6252 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6253 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6254 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6255 | ) |
| 6256 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6257 | _res = a; |
| 6258 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6259 | p->error_indicator = 1; |
| 6260 | return NULL; |
| 6261 | } |
| 6262 | goto done; |
| 6263 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6264 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6266 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6267 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6268 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6269 | } |
| 6270 | |
| 6271 | // lambda_param_with_default: lambda_param default ',' | lambda_param default &':' |
| 6272 | static NameDefaultPair* |
| 6273 | lambda_param_with_default_rule(Parser *p) |
| 6274 | { |
| 6275 | if (p->error_indicator) { |
| 6276 | return NULL; |
| 6277 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6278 | NameDefaultPair* _res = NULL; |
| 6279 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6280 | { // lambda_param default ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6281 | if (p->error_indicator) { |
| 6282 | return NULL; |
| 6283 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6284 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6285 | arg_ty a; |
| 6286 | expr_ty c; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6287 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6288 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6289 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6290 | (c = default_rule(p)) // default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6291 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6292 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6293 | ) |
| 6294 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6295 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 6296 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6297 | p->error_indicator = 1; |
| 6298 | return NULL; |
| 6299 | } |
| 6300 | goto done; |
| 6301 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6302 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6303 | } |
| 6304 | { // lambda_param default &':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6305 | if (p->error_indicator) { |
| 6306 | return NULL; |
| 6307 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6308 | arg_ty a; |
| 6309 | expr_ty c; |
| 6310 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6311 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6312 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6313 | (c = default_rule(p)) // default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6314 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6315 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6316 | ) |
| 6317 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6318 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 6319 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6320 | p->error_indicator = 1; |
| 6321 | return NULL; |
| 6322 | } |
| 6323 | goto done; |
| 6324 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6325 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6326 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6327 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6328 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6329 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6330 | } |
| 6331 | |
| 6332 | // lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':' |
| 6333 | static NameDefaultPair* |
| 6334 | lambda_param_maybe_default_rule(Parser *p) |
| 6335 | { |
| 6336 | if (p->error_indicator) { |
| 6337 | return NULL; |
| 6338 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6339 | NameDefaultPair* _res = NULL; |
| 6340 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6341 | { // lambda_param default? ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6342 | if (p->error_indicator) { |
| 6343 | return NULL; |
| 6344 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6345 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6346 | arg_ty a; |
| 6347 | void *c; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6348 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6349 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6350 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6351 | (c = default_rule(p), 1) // default? |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6352 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6353 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6354 | ) |
| 6355 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6356 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 6357 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6358 | p->error_indicator = 1; |
| 6359 | return NULL; |
| 6360 | } |
| 6361 | goto done; |
| 6362 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6363 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6364 | } |
| 6365 | { // lambda_param default? &':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6366 | if (p->error_indicator) { |
| 6367 | return NULL; |
| 6368 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6369 | arg_ty a; |
| 6370 | void *c; |
| 6371 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6372 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6373 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6374 | (c = default_rule(p), 1) // default? |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6375 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6376 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6377 | ) |
| 6378 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6379 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 6380 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6381 | p->error_indicator = 1; |
| 6382 | return NULL; |
| 6383 | } |
| 6384 | goto done; |
| 6385 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6386 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6387 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6388 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6389 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6390 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6391 | } |
| 6392 | |
| 6393 | // lambda_param: NAME |
| 6394 | static arg_ty |
| 6395 | lambda_param_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6396 | { |
| 6397 | if (p->error_indicator) { |
| 6398 | return NULL; |
| 6399 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6400 | arg_ty _res = NULL; |
| 6401 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6402 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6403 | p->error_indicator = 1; |
| 6404 | return NULL; |
| 6405 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6406 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6407 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6408 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6409 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6410 | { // NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6411 | if (p->error_indicator) { |
| 6412 | return NULL; |
| 6413 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6414 | expr_ty a; |
| 6415 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6416 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6417 | ) |
| 6418 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6419 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6420 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6421 | return NULL; |
| 6422 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6423 | int _end_lineno = _token->end_lineno; |
| 6424 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6425 | int _end_col_offset = _token->end_col_offset; |
| 6426 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6427 | _res = _Py_arg ( a -> v . Name . id , NULL , NULL , EXTRA ); |
| 6428 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6429 | p->error_indicator = 1; |
| 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 | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6435 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6436 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6437 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6438 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6439 | } |
| 6440 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6441 | // disjunction: conjunction (('or' conjunction))+ | conjunction |
| 6442 | static expr_ty |
| 6443 | disjunction_rule(Parser *p) |
| 6444 | { |
| 6445 | if (p->error_indicator) { |
| 6446 | return NULL; |
| 6447 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6448 | expr_ty _res = NULL; |
| 6449 | if (_PyPegen_is_memoized(p, disjunction_type, &_res)) |
| 6450 | return _res; |
| 6451 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6452 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6453 | p->error_indicator = 1; |
| 6454 | return NULL; |
| 6455 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6456 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6457 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6458 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6459 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6460 | { // conjunction (('or' conjunction))+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6461 | if (p->error_indicator) { |
| 6462 | return NULL; |
| 6463 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6464 | expr_ty a; |
| 6465 | asdl_seq * b; |
| 6466 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6467 | (a = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6468 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6469 | (b = _loop1_89_rule(p)) // (('or' conjunction))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6470 | ) |
| 6471 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6472 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6473 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6474 | return NULL; |
| 6475 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6476 | int _end_lineno = _token->end_lineno; |
| 6477 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6478 | int _end_col_offset = _token->end_col_offset; |
| 6479 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6480 | _res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
| 6481 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6482 | p->error_indicator = 1; |
| 6483 | return NULL; |
| 6484 | } |
| 6485 | goto done; |
| 6486 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6487 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6488 | } |
| 6489 | { // conjunction |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6490 | if (p->error_indicator) { |
| 6491 | return NULL; |
| 6492 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6493 | expr_ty conjunction_var; |
| 6494 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6495 | (conjunction_var = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6496 | ) |
| 6497 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6498 | _res = conjunction_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6499 | goto done; |
| 6500 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6501 | p->mark = _mark; |
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 | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6505 | _PyPegen_insert_memo(p, _mark, disjunction_type, _res); |
| 6506 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6507 | } |
| 6508 | |
| 6509 | // conjunction: inversion (('and' inversion))+ | inversion |
| 6510 | static expr_ty |
| 6511 | conjunction_rule(Parser *p) |
| 6512 | { |
| 6513 | if (p->error_indicator) { |
| 6514 | return NULL; |
| 6515 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6516 | expr_ty _res = NULL; |
| 6517 | if (_PyPegen_is_memoized(p, conjunction_type, &_res)) |
| 6518 | return _res; |
| 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; |
| 6522 | return NULL; |
| 6523 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6524 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6525 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6526 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6527 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6528 | { // inversion (('and' inversion))+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6529 | if (p->error_indicator) { |
| 6530 | return NULL; |
| 6531 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6532 | expr_ty a; |
| 6533 | asdl_seq * b; |
| 6534 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6535 | (a = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6536 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6537 | (b = _loop1_90_rule(p)) // (('and' inversion))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6538 | ) |
| 6539 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6540 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6541 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6542 | return NULL; |
| 6543 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6544 | int _end_lineno = _token->end_lineno; |
| 6545 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6546 | int _end_col_offset = _token->end_col_offset; |
| 6547 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6548 | _res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
| 6549 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6550 | p->error_indicator = 1; |
| 6551 | return NULL; |
| 6552 | } |
| 6553 | goto done; |
| 6554 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6555 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6556 | } |
| 6557 | { // inversion |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6558 | if (p->error_indicator) { |
| 6559 | return NULL; |
| 6560 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6561 | expr_ty inversion_var; |
| 6562 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6563 | (inversion_var = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6564 | ) |
| 6565 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6566 | _res = inversion_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6567 | goto done; |
| 6568 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6569 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6570 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6571 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6572 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6573 | _PyPegen_insert_memo(p, _mark, conjunction_type, _res); |
| 6574 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6575 | } |
| 6576 | |
| 6577 | // inversion: 'not' inversion | comparison |
| 6578 | static expr_ty |
| 6579 | inversion_rule(Parser *p) |
| 6580 | { |
| 6581 | if (p->error_indicator) { |
| 6582 | return NULL; |
| 6583 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6584 | expr_ty _res = NULL; |
| 6585 | if (_PyPegen_is_memoized(p, inversion_type, &_res)) |
| 6586 | return _res; |
| 6587 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6588 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6589 | p->error_indicator = 1; |
| 6590 | return NULL; |
| 6591 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6592 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6593 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6594 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6595 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6596 | { // 'not' inversion |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6597 | if (p->error_indicator) { |
| 6598 | return NULL; |
| 6599 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6600 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6601 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6602 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6603 | (_keyword = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6604 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6605 | (a = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6606 | ) |
| 6607 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6608 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6609 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6610 | return NULL; |
| 6611 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6612 | int _end_lineno = _token->end_lineno; |
| 6613 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6614 | int _end_col_offset = _token->end_col_offset; |
| 6615 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6616 | _res = _Py_UnaryOp ( Not , a , EXTRA ); |
| 6617 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6618 | p->error_indicator = 1; |
| 6619 | return NULL; |
| 6620 | } |
| 6621 | goto done; |
| 6622 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6623 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6624 | } |
| 6625 | { // comparison |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6626 | if (p->error_indicator) { |
| 6627 | return NULL; |
| 6628 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6629 | expr_ty comparison_var; |
| 6630 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6631 | (comparison_var = comparison_rule(p)) // comparison |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6632 | ) |
| 6633 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6634 | _res = comparison_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6635 | goto done; |
| 6636 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6637 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6638 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6639 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6640 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6641 | _PyPegen_insert_memo(p, _mark, inversion_type, _res); |
| 6642 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6643 | } |
| 6644 | |
| 6645 | // comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or |
| 6646 | static expr_ty |
| 6647 | comparison_rule(Parser *p) |
| 6648 | { |
| 6649 | if (p->error_indicator) { |
| 6650 | return NULL; |
| 6651 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6652 | expr_ty _res = NULL; |
| 6653 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6654 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6655 | p->error_indicator = 1; |
| 6656 | return NULL; |
| 6657 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6658 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6659 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6660 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6661 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6662 | { // bitwise_or compare_op_bitwise_or_pair+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6663 | if (p->error_indicator) { |
| 6664 | return NULL; |
| 6665 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6666 | expr_ty a; |
| 6667 | asdl_seq * b; |
| 6668 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6669 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6670 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6671 | (b = _loop1_91_rule(p)) // compare_op_bitwise_or_pair+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6672 | ) |
| 6673 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6674 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6675 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6676 | return NULL; |
| 6677 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6678 | int _end_lineno = _token->end_lineno; |
| 6679 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6680 | int _end_col_offset = _token->end_col_offset; |
| 6681 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6682 | _res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA ); |
| 6683 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6684 | p->error_indicator = 1; |
| 6685 | return NULL; |
| 6686 | } |
| 6687 | goto done; |
| 6688 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6689 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6690 | } |
| 6691 | { // bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6692 | if (p->error_indicator) { |
| 6693 | return NULL; |
| 6694 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6695 | expr_ty bitwise_or_var; |
| 6696 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6697 | (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6698 | ) |
| 6699 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6700 | _res = bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6701 | goto done; |
| 6702 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6703 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6704 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6705 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6706 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6707 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6708 | } |
| 6709 | |
| 6710 | // compare_op_bitwise_or_pair: |
| 6711 | // | eq_bitwise_or |
| 6712 | // | noteq_bitwise_or |
| 6713 | // | lte_bitwise_or |
| 6714 | // | lt_bitwise_or |
| 6715 | // | gte_bitwise_or |
| 6716 | // | gt_bitwise_or |
| 6717 | // | notin_bitwise_or |
| 6718 | // | in_bitwise_or |
| 6719 | // | isnot_bitwise_or |
| 6720 | // | is_bitwise_or |
| 6721 | static CmpopExprPair* |
| 6722 | compare_op_bitwise_or_pair_rule(Parser *p) |
| 6723 | { |
| 6724 | if (p->error_indicator) { |
| 6725 | return NULL; |
| 6726 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6727 | CmpopExprPair* _res = NULL; |
| 6728 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6729 | { // eq_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6730 | if (p->error_indicator) { |
| 6731 | return NULL; |
| 6732 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6733 | CmpopExprPair* eq_bitwise_or_var; |
| 6734 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6735 | (eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6736 | ) |
| 6737 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6738 | _res = eq_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6739 | goto done; |
| 6740 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6741 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6742 | } |
| 6743 | { // noteq_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6744 | if (p->error_indicator) { |
| 6745 | return NULL; |
| 6746 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6747 | CmpopExprPair* noteq_bitwise_or_var; |
| 6748 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6749 | (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6750 | ) |
| 6751 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6752 | _res = noteq_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6753 | goto done; |
| 6754 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6755 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6756 | } |
| 6757 | { // lte_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6758 | if (p->error_indicator) { |
| 6759 | return NULL; |
| 6760 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6761 | CmpopExprPair* lte_bitwise_or_var; |
| 6762 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6763 | (lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6764 | ) |
| 6765 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6766 | _res = lte_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6767 | goto done; |
| 6768 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6769 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6770 | } |
| 6771 | { // lt_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6772 | if (p->error_indicator) { |
| 6773 | return NULL; |
| 6774 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6775 | CmpopExprPair* lt_bitwise_or_var; |
| 6776 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6777 | (lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6778 | ) |
| 6779 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6780 | _res = lt_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6781 | goto done; |
| 6782 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6783 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6784 | } |
| 6785 | { // gte_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6786 | if (p->error_indicator) { |
| 6787 | return NULL; |
| 6788 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6789 | CmpopExprPair* gte_bitwise_or_var; |
| 6790 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6791 | (gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6792 | ) |
| 6793 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6794 | _res = gte_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6795 | goto done; |
| 6796 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6797 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6798 | } |
| 6799 | { // gt_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6800 | if (p->error_indicator) { |
| 6801 | return NULL; |
| 6802 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6803 | CmpopExprPair* gt_bitwise_or_var; |
| 6804 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6805 | (gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6806 | ) |
| 6807 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6808 | _res = gt_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6809 | goto done; |
| 6810 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6811 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6812 | } |
| 6813 | { // notin_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6814 | if (p->error_indicator) { |
| 6815 | return NULL; |
| 6816 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6817 | CmpopExprPair* notin_bitwise_or_var; |
| 6818 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6819 | (notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6820 | ) |
| 6821 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6822 | _res = notin_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6823 | goto done; |
| 6824 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6825 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6826 | } |
| 6827 | { // in_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6828 | if (p->error_indicator) { |
| 6829 | return NULL; |
| 6830 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6831 | CmpopExprPair* in_bitwise_or_var; |
| 6832 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6833 | (in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6834 | ) |
| 6835 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6836 | _res = in_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6837 | goto done; |
| 6838 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6839 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6840 | } |
| 6841 | { // isnot_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6842 | if (p->error_indicator) { |
| 6843 | return NULL; |
| 6844 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6845 | CmpopExprPair* isnot_bitwise_or_var; |
| 6846 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6847 | (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6848 | ) |
| 6849 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6850 | _res = isnot_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6851 | goto done; |
| 6852 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6853 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6854 | } |
| 6855 | { // is_bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6856 | if (p->error_indicator) { |
| 6857 | return NULL; |
| 6858 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6859 | CmpopExprPair* is_bitwise_or_var; |
| 6860 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6861 | (is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6862 | ) |
| 6863 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6864 | _res = is_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6865 | goto done; |
| 6866 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6867 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6868 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6869 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6870 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6871 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6872 | } |
| 6873 | |
| 6874 | // eq_bitwise_or: '==' bitwise_or |
| 6875 | static CmpopExprPair* |
| 6876 | eq_bitwise_or_rule(Parser *p) |
| 6877 | { |
| 6878 | if (p->error_indicator) { |
| 6879 | return NULL; |
| 6880 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6881 | CmpopExprPair* _res = NULL; |
| 6882 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6883 | { // '==' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6884 | if (p->error_indicator) { |
| 6885 | return NULL; |
| 6886 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6887 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6888 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6889 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6890 | (_literal = _PyPegen_expect_token(p, 27)) // token='==' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6891 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6892 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6893 | ) |
| 6894 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6895 | _res = _PyPegen_cmpop_expr_pair ( p , Eq , a ); |
| 6896 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6897 | p->error_indicator = 1; |
| 6898 | return NULL; |
| 6899 | } |
| 6900 | goto done; |
| 6901 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6902 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6903 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6904 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6905 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6906 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6907 | } |
| 6908 | |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 6909 | // noteq_bitwise_or: ('!=') bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6910 | static CmpopExprPair* |
| 6911 | noteq_bitwise_or_rule(Parser *p) |
| 6912 | { |
| 6913 | if (p->error_indicator) { |
| 6914 | return NULL; |
| 6915 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6916 | CmpopExprPair* _res = NULL; |
| 6917 | int _mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 6918 | { // ('!=') bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6919 | if (p->error_indicator) { |
| 6920 | return NULL; |
| 6921 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6922 | void *_tmp_92_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6923 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6924 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6925 | (_tmp_92_var = _tmp_92_rule(p)) // '!=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6926 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6927 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6928 | ) |
| 6929 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6930 | _res = _PyPegen_cmpop_expr_pair ( p , NotEq , a ); |
| 6931 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6932 | p->error_indicator = 1; |
| 6933 | return NULL; |
| 6934 | } |
| 6935 | goto done; |
| 6936 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6937 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6938 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6939 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6940 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6941 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6942 | } |
| 6943 | |
| 6944 | // lte_bitwise_or: '<=' bitwise_or |
| 6945 | static CmpopExprPair* |
| 6946 | lte_bitwise_or_rule(Parser *p) |
| 6947 | { |
| 6948 | if (p->error_indicator) { |
| 6949 | return NULL; |
| 6950 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6951 | CmpopExprPair* _res = NULL; |
| 6952 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6953 | { // '<=' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6954 | if (p->error_indicator) { |
| 6955 | return NULL; |
| 6956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6957 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6958 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6959 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6960 | (_literal = _PyPegen_expect_token(p, 29)) // token='<=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6961 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6962 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6963 | ) |
| 6964 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6965 | _res = _PyPegen_cmpop_expr_pair ( p , LtE , a ); |
| 6966 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6967 | p->error_indicator = 1; |
| 6968 | return NULL; |
| 6969 | } |
| 6970 | goto done; |
| 6971 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6972 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6973 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6974 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6975 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6976 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6977 | } |
| 6978 | |
| 6979 | // lt_bitwise_or: '<' bitwise_or |
| 6980 | static CmpopExprPair* |
| 6981 | lt_bitwise_or_rule(Parser *p) |
| 6982 | { |
| 6983 | if (p->error_indicator) { |
| 6984 | return NULL; |
| 6985 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6986 | CmpopExprPair* _res = NULL; |
| 6987 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6988 | { // '<' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 6989 | if (p->error_indicator) { |
| 6990 | return NULL; |
| 6991 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6992 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6993 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6994 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6995 | (_literal = _PyPegen_expect_token(p, 20)) // token='<' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6996 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6997 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6998 | ) |
| 6999 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7000 | _res = _PyPegen_cmpop_expr_pair ( p , Lt , a ); |
| 7001 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7002 | p->error_indicator = 1; |
| 7003 | return NULL; |
| 7004 | } |
| 7005 | goto done; |
| 7006 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7007 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7008 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7009 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7010 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7011 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7012 | } |
| 7013 | |
| 7014 | // gte_bitwise_or: '>=' bitwise_or |
| 7015 | static CmpopExprPair* |
| 7016 | gte_bitwise_or_rule(Parser *p) |
| 7017 | { |
| 7018 | if (p->error_indicator) { |
| 7019 | return NULL; |
| 7020 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7021 | CmpopExprPair* _res = NULL; |
| 7022 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7023 | { // '>=' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7024 | if (p->error_indicator) { |
| 7025 | return NULL; |
| 7026 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7027 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7028 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7029 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7030 | (_literal = _PyPegen_expect_token(p, 30)) // token='>=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7031 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7032 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7033 | ) |
| 7034 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7035 | _res = _PyPegen_cmpop_expr_pair ( p , GtE , a ); |
| 7036 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7037 | p->error_indicator = 1; |
| 7038 | return NULL; |
| 7039 | } |
| 7040 | goto done; |
| 7041 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7042 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7043 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7044 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7045 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7046 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7047 | } |
| 7048 | |
| 7049 | // gt_bitwise_or: '>' bitwise_or |
| 7050 | static CmpopExprPair* |
| 7051 | gt_bitwise_or_rule(Parser *p) |
| 7052 | { |
| 7053 | if (p->error_indicator) { |
| 7054 | return NULL; |
| 7055 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7056 | CmpopExprPair* _res = NULL; |
| 7057 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7058 | { // '>' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7059 | if (p->error_indicator) { |
| 7060 | return NULL; |
| 7061 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7062 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7063 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7064 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7065 | (_literal = _PyPegen_expect_token(p, 21)) // token='>' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7066 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7067 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7068 | ) |
| 7069 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7070 | _res = _PyPegen_cmpop_expr_pair ( p , Gt , a ); |
| 7071 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7072 | p->error_indicator = 1; |
| 7073 | return NULL; |
| 7074 | } |
| 7075 | goto done; |
| 7076 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7077 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7078 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7079 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7080 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7081 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7082 | } |
| 7083 | |
| 7084 | // notin_bitwise_or: 'not' 'in' bitwise_or |
| 7085 | static CmpopExprPair* |
| 7086 | notin_bitwise_or_rule(Parser *p) |
| 7087 | { |
| 7088 | if (p->error_indicator) { |
| 7089 | return NULL; |
| 7090 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7091 | CmpopExprPair* _res = NULL; |
| 7092 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7093 | { // 'not' 'in' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7094 | if (p->error_indicator) { |
| 7095 | return NULL; |
| 7096 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7097 | Token * _keyword; |
| 7098 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7099 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7100 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7101 | (_keyword = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7102 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7103 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7104 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7105 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7106 | ) |
| 7107 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7108 | _res = _PyPegen_cmpop_expr_pair ( p , NotIn , a ); |
| 7109 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7110 | p->error_indicator = 1; |
| 7111 | return NULL; |
| 7112 | } |
| 7113 | goto done; |
| 7114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7115 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7116 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7117 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7118 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7119 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7120 | } |
| 7121 | |
| 7122 | // in_bitwise_or: 'in' bitwise_or |
| 7123 | static CmpopExprPair* |
| 7124 | in_bitwise_or_rule(Parser *p) |
| 7125 | { |
| 7126 | if (p->error_indicator) { |
| 7127 | return NULL; |
| 7128 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7129 | CmpopExprPair* _res = NULL; |
| 7130 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7131 | { // 'in' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7132 | if (p->error_indicator) { |
| 7133 | return NULL; |
| 7134 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7135 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7136 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7137 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7138 | (_keyword = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7139 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7140 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7141 | ) |
| 7142 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7143 | _res = _PyPegen_cmpop_expr_pair ( p , In , a ); |
| 7144 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7145 | p->error_indicator = 1; |
| 7146 | return NULL; |
| 7147 | } |
| 7148 | goto done; |
| 7149 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7150 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7151 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7152 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7153 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7154 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7155 | } |
| 7156 | |
| 7157 | // isnot_bitwise_or: 'is' 'not' bitwise_or |
| 7158 | static CmpopExprPair* |
| 7159 | isnot_bitwise_or_rule(Parser *p) |
| 7160 | { |
| 7161 | if (p->error_indicator) { |
| 7162 | return NULL; |
| 7163 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7164 | CmpopExprPair* _res = NULL; |
| 7165 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7166 | { // 'is' 'not' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7167 | if (p->error_indicator) { |
| 7168 | return NULL; |
| 7169 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7170 | Token * _keyword; |
| 7171 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7172 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7173 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7174 | (_keyword = _PyPegen_expect_token(p, 526)) // token='is' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7175 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7176 | (_keyword_1 = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7177 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7178 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7179 | ) |
| 7180 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7181 | _res = _PyPegen_cmpop_expr_pair ( p , IsNot , a ); |
| 7182 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7183 | p->error_indicator = 1; |
| 7184 | return NULL; |
| 7185 | } |
| 7186 | goto done; |
| 7187 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7188 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7189 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7190 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7191 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7192 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7193 | } |
| 7194 | |
| 7195 | // is_bitwise_or: 'is' bitwise_or |
| 7196 | static CmpopExprPair* |
| 7197 | is_bitwise_or_rule(Parser *p) |
| 7198 | { |
| 7199 | if (p->error_indicator) { |
| 7200 | return NULL; |
| 7201 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7202 | CmpopExprPair* _res = NULL; |
| 7203 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7204 | { // 'is' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7205 | if (p->error_indicator) { |
| 7206 | return NULL; |
| 7207 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7208 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7209 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7210 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7211 | (_keyword = _PyPegen_expect_token(p, 526)) // token='is' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7212 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7213 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7214 | ) |
| 7215 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7216 | _res = _PyPegen_cmpop_expr_pair ( p , Is , a ); |
| 7217 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7218 | p->error_indicator = 1; |
| 7219 | return NULL; |
| 7220 | } |
| 7221 | goto done; |
| 7222 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7223 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7224 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7225 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7226 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7227 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7228 | } |
| 7229 | |
| 7230 | // Left-recursive |
| 7231 | // bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor |
| 7232 | static expr_ty bitwise_or_raw(Parser *); |
| 7233 | static expr_ty |
| 7234 | bitwise_or_rule(Parser *p) |
| 7235 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7236 | expr_ty _res = NULL; |
| 7237 | if (_PyPegen_is_memoized(p, bitwise_or_type, &_res)) |
| 7238 | return _res; |
| 7239 | int _mark = p->mark; |
| 7240 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7241 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7242 | int tmpvar_1 = _PyPegen_update_memo(p, _mark, bitwise_or_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7243 | if (tmpvar_1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7244 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7245 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7246 | p->mark = _mark; |
| 7247 | void *_raw = bitwise_or_raw(p); |
| 7248 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7249 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7250 | _resmark = p->mark; |
| 7251 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7252 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7253 | p->mark = _resmark; |
| 7254 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7255 | } |
| 7256 | static expr_ty |
| 7257 | bitwise_or_raw(Parser *p) |
| 7258 | { |
| 7259 | if (p->error_indicator) { |
| 7260 | return NULL; |
| 7261 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7262 | expr_ty _res = NULL; |
| 7263 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7264 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7265 | p->error_indicator = 1; |
| 7266 | return NULL; |
| 7267 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7268 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7269 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7270 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7271 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7272 | { // bitwise_or '|' bitwise_xor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7273 | if (p->error_indicator) { |
| 7274 | return NULL; |
| 7275 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7276 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7277 | expr_ty a; |
| 7278 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7279 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7280 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7281 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7282 | (_literal = _PyPegen_expect_token(p, 18)) // token='|' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7283 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7284 | (b = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7285 | ) |
| 7286 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7287 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7288 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7289 | return NULL; |
| 7290 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7291 | int _end_lineno = _token->end_lineno; |
| 7292 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7293 | int _end_col_offset = _token->end_col_offset; |
| 7294 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7295 | _res = _Py_BinOp ( a , BitOr , b , EXTRA ); |
| 7296 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7297 | p->error_indicator = 1; |
| 7298 | return NULL; |
| 7299 | } |
| 7300 | goto done; |
| 7301 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7302 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7303 | } |
| 7304 | { // bitwise_xor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7305 | if (p->error_indicator) { |
| 7306 | return NULL; |
| 7307 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7308 | expr_ty bitwise_xor_var; |
| 7309 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7310 | (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7311 | ) |
| 7312 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7313 | _res = bitwise_xor_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7314 | goto done; |
| 7315 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7316 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7317 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7318 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7319 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7320 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7321 | } |
| 7322 | |
| 7323 | // Left-recursive |
| 7324 | // bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and |
| 7325 | static expr_ty bitwise_xor_raw(Parser *); |
| 7326 | static expr_ty |
| 7327 | bitwise_xor_rule(Parser *p) |
| 7328 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7329 | expr_ty _res = NULL; |
| 7330 | if (_PyPegen_is_memoized(p, bitwise_xor_type, &_res)) |
| 7331 | return _res; |
| 7332 | int _mark = p->mark; |
| 7333 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7334 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7335 | int tmpvar_2 = _PyPegen_update_memo(p, _mark, bitwise_xor_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7336 | if (tmpvar_2) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7337 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7338 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7339 | p->mark = _mark; |
| 7340 | void *_raw = bitwise_xor_raw(p); |
| 7341 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7342 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7343 | _resmark = p->mark; |
| 7344 | _res = _raw; |
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 | p->mark = _resmark; |
| 7347 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7348 | } |
| 7349 | static expr_ty |
| 7350 | bitwise_xor_raw(Parser *p) |
| 7351 | { |
| 7352 | if (p->error_indicator) { |
| 7353 | return NULL; |
| 7354 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7355 | expr_ty _res = NULL; |
| 7356 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7357 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7358 | p->error_indicator = 1; |
| 7359 | return NULL; |
| 7360 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7361 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7362 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7363 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7364 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7365 | { // bitwise_xor '^' bitwise_and |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7366 | if (p->error_indicator) { |
| 7367 | return NULL; |
| 7368 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7369 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7370 | expr_ty a; |
| 7371 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7372 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7373 | (a = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7374 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7375 | (_literal = _PyPegen_expect_token(p, 32)) // token='^' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7376 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7377 | (b = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7378 | ) |
| 7379 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7380 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7381 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7382 | return NULL; |
| 7383 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7384 | int _end_lineno = _token->end_lineno; |
| 7385 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7386 | int _end_col_offset = _token->end_col_offset; |
| 7387 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7388 | _res = _Py_BinOp ( a , BitXor , b , EXTRA ); |
| 7389 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7390 | p->error_indicator = 1; |
| 7391 | return NULL; |
| 7392 | } |
| 7393 | goto done; |
| 7394 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7395 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7396 | } |
| 7397 | { // bitwise_and |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7398 | if (p->error_indicator) { |
| 7399 | return NULL; |
| 7400 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7401 | expr_ty bitwise_and_var; |
| 7402 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7403 | (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7404 | ) |
| 7405 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7406 | _res = bitwise_and_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7407 | goto done; |
| 7408 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7409 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7410 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7411 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7412 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7413 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7414 | } |
| 7415 | |
| 7416 | // Left-recursive |
| 7417 | // bitwise_and: bitwise_and '&' shift_expr | shift_expr |
| 7418 | static expr_ty bitwise_and_raw(Parser *); |
| 7419 | static expr_ty |
| 7420 | bitwise_and_rule(Parser *p) |
| 7421 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7422 | expr_ty _res = NULL; |
| 7423 | if (_PyPegen_is_memoized(p, bitwise_and_type, &_res)) |
| 7424 | return _res; |
| 7425 | int _mark = p->mark; |
| 7426 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7427 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7428 | int tmpvar_3 = _PyPegen_update_memo(p, _mark, bitwise_and_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7429 | if (tmpvar_3) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7430 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7431 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7432 | p->mark = _mark; |
| 7433 | void *_raw = bitwise_and_raw(p); |
| 7434 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7435 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7436 | _resmark = p->mark; |
| 7437 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7438 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7439 | p->mark = _resmark; |
| 7440 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7441 | } |
| 7442 | static expr_ty |
| 7443 | bitwise_and_raw(Parser *p) |
| 7444 | { |
| 7445 | if (p->error_indicator) { |
| 7446 | return NULL; |
| 7447 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7448 | expr_ty _res = NULL; |
| 7449 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7450 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7451 | p->error_indicator = 1; |
| 7452 | return NULL; |
| 7453 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7454 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7455 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7456 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7457 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7458 | { // bitwise_and '&' shift_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7459 | if (p->error_indicator) { |
| 7460 | return NULL; |
| 7461 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7462 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7463 | expr_ty a; |
| 7464 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7465 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7466 | (a = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7467 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7468 | (_literal = _PyPegen_expect_token(p, 19)) // token='&' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7469 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7470 | (b = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7471 | ) |
| 7472 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7473 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7474 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7475 | return NULL; |
| 7476 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7477 | int _end_lineno = _token->end_lineno; |
| 7478 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7479 | int _end_col_offset = _token->end_col_offset; |
| 7480 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7481 | _res = _Py_BinOp ( a , BitAnd , b , EXTRA ); |
| 7482 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7483 | p->error_indicator = 1; |
| 7484 | return NULL; |
| 7485 | } |
| 7486 | goto done; |
| 7487 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7488 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7489 | } |
| 7490 | { // shift_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7491 | if (p->error_indicator) { |
| 7492 | return NULL; |
| 7493 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7494 | expr_ty shift_expr_var; |
| 7495 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7496 | (shift_expr_var = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7497 | ) |
| 7498 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7499 | _res = shift_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7500 | goto done; |
| 7501 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7502 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7503 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7504 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7505 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7506 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7507 | } |
| 7508 | |
| 7509 | // Left-recursive |
| 7510 | // shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum |
| 7511 | static expr_ty shift_expr_raw(Parser *); |
| 7512 | static expr_ty |
| 7513 | shift_expr_rule(Parser *p) |
| 7514 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7515 | expr_ty _res = NULL; |
| 7516 | if (_PyPegen_is_memoized(p, shift_expr_type, &_res)) |
| 7517 | return _res; |
| 7518 | int _mark = p->mark; |
| 7519 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7520 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7521 | int tmpvar_4 = _PyPegen_update_memo(p, _mark, shift_expr_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7522 | if (tmpvar_4) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7523 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7524 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7525 | p->mark = _mark; |
| 7526 | void *_raw = shift_expr_raw(p); |
| 7527 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7528 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7529 | _resmark = p->mark; |
| 7530 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7531 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7532 | p->mark = _resmark; |
| 7533 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7534 | } |
| 7535 | static expr_ty |
| 7536 | shift_expr_raw(Parser *p) |
| 7537 | { |
| 7538 | if (p->error_indicator) { |
| 7539 | return NULL; |
| 7540 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7541 | expr_ty _res = NULL; |
| 7542 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7543 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7544 | p->error_indicator = 1; |
| 7545 | return NULL; |
| 7546 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7547 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7548 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7549 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7550 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7551 | { // shift_expr '<<' sum |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7552 | if (p->error_indicator) { |
| 7553 | return NULL; |
| 7554 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7555 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7556 | expr_ty a; |
| 7557 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7558 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7559 | (a = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7560 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7561 | (_literal = _PyPegen_expect_token(p, 33)) // token='<<' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7562 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7563 | (b = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7564 | ) |
| 7565 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7566 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7567 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7568 | return NULL; |
| 7569 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7570 | int _end_lineno = _token->end_lineno; |
| 7571 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7572 | int _end_col_offset = _token->end_col_offset; |
| 7573 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7574 | _res = _Py_BinOp ( a , LShift , b , EXTRA ); |
| 7575 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7576 | p->error_indicator = 1; |
| 7577 | return NULL; |
| 7578 | } |
| 7579 | goto done; |
| 7580 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7581 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7582 | } |
| 7583 | { // shift_expr '>>' sum |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7584 | if (p->error_indicator) { |
| 7585 | return NULL; |
| 7586 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7587 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7588 | expr_ty a; |
| 7589 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7590 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7591 | (a = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7592 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7593 | (_literal = _PyPegen_expect_token(p, 34)) // token='>>' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7594 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7595 | (b = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7596 | ) |
| 7597 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7598 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7599 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7600 | return NULL; |
| 7601 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7602 | int _end_lineno = _token->end_lineno; |
| 7603 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7604 | int _end_col_offset = _token->end_col_offset; |
| 7605 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7606 | _res = _Py_BinOp ( a , RShift , b , EXTRA ); |
| 7607 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7608 | p->error_indicator = 1; |
| 7609 | return NULL; |
| 7610 | } |
| 7611 | goto done; |
| 7612 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7613 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7614 | } |
| 7615 | { // sum |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7616 | if (p->error_indicator) { |
| 7617 | return NULL; |
| 7618 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7619 | expr_ty sum_var; |
| 7620 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7621 | (sum_var = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7622 | ) |
| 7623 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7624 | _res = sum_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7625 | goto done; |
| 7626 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7627 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7628 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7629 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7630 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7631 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7632 | } |
| 7633 | |
| 7634 | // Left-recursive |
| 7635 | // sum: sum '+' term | sum '-' term | term |
| 7636 | static expr_ty sum_raw(Parser *); |
| 7637 | static expr_ty |
| 7638 | sum_rule(Parser *p) |
| 7639 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7640 | expr_ty _res = NULL; |
| 7641 | if (_PyPegen_is_memoized(p, sum_type, &_res)) |
| 7642 | return _res; |
| 7643 | int _mark = p->mark; |
| 7644 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7645 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7646 | int tmpvar_5 = _PyPegen_update_memo(p, _mark, sum_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7647 | if (tmpvar_5) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7648 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7649 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7650 | p->mark = _mark; |
| 7651 | void *_raw = sum_raw(p); |
| 7652 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7653 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7654 | _resmark = p->mark; |
| 7655 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7656 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7657 | p->mark = _resmark; |
| 7658 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7659 | } |
| 7660 | static expr_ty |
| 7661 | sum_raw(Parser *p) |
| 7662 | { |
| 7663 | if (p->error_indicator) { |
| 7664 | return NULL; |
| 7665 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7666 | expr_ty _res = NULL; |
| 7667 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7668 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7669 | p->error_indicator = 1; |
| 7670 | return NULL; |
| 7671 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7672 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7673 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7674 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7675 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7676 | { // sum '+' term |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7677 | if (p->error_indicator) { |
| 7678 | return NULL; |
| 7679 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7680 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7681 | expr_ty a; |
| 7682 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7683 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7684 | (a = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7685 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7686 | (_literal = _PyPegen_expect_token(p, 14)) // token='+' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7687 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7688 | (b = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7689 | ) |
| 7690 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7691 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7692 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7693 | return NULL; |
| 7694 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7695 | int _end_lineno = _token->end_lineno; |
| 7696 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7697 | int _end_col_offset = _token->end_col_offset; |
| 7698 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7699 | _res = _Py_BinOp ( a , Add , b , EXTRA ); |
| 7700 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7701 | p->error_indicator = 1; |
| 7702 | return NULL; |
| 7703 | } |
| 7704 | goto done; |
| 7705 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7706 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7707 | } |
| 7708 | { // sum '-' term |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7709 | if (p->error_indicator) { |
| 7710 | return NULL; |
| 7711 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7712 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7713 | expr_ty a; |
| 7714 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7715 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7716 | (a = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7717 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7718 | (_literal = _PyPegen_expect_token(p, 15)) // token='-' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7719 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7720 | (b = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7721 | ) |
| 7722 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7723 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7724 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7725 | return NULL; |
| 7726 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7727 | int _end_lineno = _token->end_lineno; |
| 7728 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7729 | int _end_col_offset = _token->end_col_offset; |
| 7730 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7731 | _res = _Py_BinOp ( a , Sub , b , EXTRA ); |
| 7732 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7733 | p->error_indicator = 1; |
| 7734 | return NULL; |
| 7735 | } |
| 7736 | goto done; |
| 7737 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7738 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7739 | } |
| 7740 | { // term |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7741 | if (p->error_indicator) { |
| 7742 | return NULL; |
| 7743 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7744 | expr_ty term_var; |
| 7745 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7746 | (term_var = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7747 | ) |
| 7748 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7749 | _res = term_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7750 | goto done; |
| 7751 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7752 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7753 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7754 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7755 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7756 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7757 | } |
| 7758 | |
| 7759 | // Left-recursive |
| 7760 | // term: |
| 7761 | // | term '*' factor |
| 7762 | // | term '/' factor |
| 7763 | // | term '//' factor |
| 7764 | // | term '%' factor |
| 7765 | // | term '@' factor |
| 7766 | // | factor |
| 7767 | static expr_ty term_raw(Parser *); |
| 7768 | static expr_ty |
| 7769 | term_rule(Parser *p) |
| 7770 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7771 | expr_ty _res = NULL; |
| 7772 | if (_PyPegen_is_memoized(p, term_type, &_res)) |
| 7773 | return _res; |
| 7774 | int _mark = p->mark; |
| 7775 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7776 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7777 | int tmpvar_6 = _PyPegen_update_memo(p, _mark, term_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7778 | if (tmpvar_6) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7779 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7780 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7781 | p->mark = _mark; |
| 7782 | void *_raw = term_raw(p); |
| 7783 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7784 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7785 | _resmark = p->mark; |
| 7786 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7787 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7788 | p->mark = _resmark; |
| 7789 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7790 | } |
| 7791 | static expr_ty |
| 7792 | term_raw(Parser *p) |
| 7793 | { |
| 7794 | if (p->error_indicator) { |
| 7795 | return NULL; |
| 7796 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7797 | expr_ty _res = NULL; |
| 7798 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7799 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7800 | p->error_indicator = 1; |
| 7801 | return NULL; |
| 7802 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7803 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7804 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7805 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7806 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7807 | { // term '*' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7808 | if (p->error_indicator) { |
| 7809 | return NULL; |
| 7810 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7811 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7812 | expr_ty a; |
| 7813 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7814 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7815 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7816 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7817 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7818 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7819 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7820 | ) |
| 7821 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7822 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7823 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7824 | return NULL; |
| 7825 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7826 | int _end_lineno = _token->end_lineno; |
| 7827 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7828 | int _end_col_offset = _token->end_col_offset; |
| 7829 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7830 | _res = _Py_BinOp ( a , Mult , b , EXTRA ); |
| 7831 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7832 | p->error_indicator = 1; |
| 7833 | return NULL; |
| 7834 | } |
| 7835 | goto done; |
| 7836 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7837 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7838 | } |
| 7839 | { // term '/' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7840 | if (p->error_indicator) { |
| 7841 | return NULL; |
| 7842 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7843 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7844 | expr_ty a; |
| 7845 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7846 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7847 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7848 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7849 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7850 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7851 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7852 | ) |
| 7853 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7854 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7855 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7856 | return NULL; |
| 7857 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7858 | int _end_lineno = _token->end_lineno; |
| 7859 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7860 | int _end_col_offset = _token->end_col_offset; |
| 7861 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7862 | _res = _Py_BinOp ( a , Div , b , EXTRA ); |
| 7863 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7864 | p->error_indicator = 1; |
| 7865 | return NULL; |
| 7866 | } |
| 7867 | goto done; |
| 7868 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7869 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7870 | } |
| 7871 | { // term '//' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7872 | if (p->error_indicator) { |
| 7873 | return NULL; |
| 7874 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7875 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7876 | expr_ty a; |
| 7877 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7878 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7879 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7880 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7881 | (_literal = _PyPegen_expect_token(p, 47)) // token='//' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7882 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7883 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7884 | ) |
| 7885 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7886 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7887 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7888 | return NULL; |
| 7889 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7890 | int _end_lineno = _token->end_lineno; |
| 7891 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7892 | int _end_col_offset = _token->end_col_offset; |
| 7893 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7894 | _res = _Py_BinOp ( a , FloorDiv , b , EXTRA ); |
| 7895 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7896 | p->error_indicator = 1; |
| 7897 | return NULL; |
| 7898 | } |
| 7899 | goto done; |
| 7900 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7901 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7902 | } |
| 7903 | { // term '%' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7904 | if (p->error_indicator) { |
| 7905 | return NULL; |
| 7906 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7907 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7908 | expr_ty a; |
| 7909 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7910 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7911 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7912 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7913 | (_literal = _PyPegen_expect_token(p, 24)) // token='%' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7914 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7915 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7916 | ) |
| 7917 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7918 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7919 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7920 | return NULL; |
| 7921 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7922 | int _end_lineno = _token->end_lineno; |
| 7923 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7924 | int _end_col_offset = _token->end_col_offset; |
| 7925 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7926 | _res = _Py_BinOp ( a , Mod , b , EXTRA ); |
| 7927 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7928 | p->error_indicator = 1; |
| 7929 | return NULL; |
| 7930 | } |
| 7931 | goto done; |
| 7932 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7933 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7934 | } |
| 7935 | { // term '@' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7936 | if (p->error_indicator) { |
| 7937 | return NULL; |
| 7938 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7939 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7940 | expr_ty a; |
| 7941 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7942 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7943 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7944 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7945 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7946 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7947 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7948 | ) |
| 7949 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7950 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7951 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7952 | return NULL; |
| 7953 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7954 | int _end_lineno = _token->end_lineno; |
| 7955 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7956 | int _end_col_offset = _token->end_col_offset; |
| 7957 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7958 | _res = CHECK_VERSION ( 5 , "The '@' operator is" , _Py_BinOp ( a , MatMult , b , EXTRA ) ); |
| 7959 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7960 | p->error_indicator = 1; |
| 7961 | return NULL; |
| 7962 | } |
| 7963 | goto done; |
| 7964 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7965 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7966 | } |
| 7967 | { // factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 7968 | if (p->error_indicator) { |
| 7969 | return NULL; |
| 7970 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7971 | expr_ty factor_var; |
| 7972 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7973 | (factor_var = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7974 | ) |
| 7975 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7976 | _res = factor_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7977 | goto done; |
| 7978 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7979 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7980 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7981 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7982 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7983 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7984 | } |
| 7985 | |
| 7986 | // factor: '+' factor | '-' factor | '~' factor | power |
| 7987 | static expr_ty |
| 7988 | factor_rule(Parser *p) |
| 7989 | { |
| 7990 | if (p->error_indicator) { |
| 7991 | return NULL; |
| 7992 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7993 | expr_ty _res = NULL; |
| 7994 | if (_PyPegen_is_memoized(p, factor_type, &_res)) |
| 7995 | return _res; |
| 7996 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7997 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7998 | p->error_indicator = 1; |
| 7999 | return NULL; |
| 8000 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8001 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8002 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8003 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8004 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8005 | { // '+' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8006 | if (p->error_indicator) { |
| 8007 | return NULL; |
| 8008 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8009 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8010 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8011 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8012 | (_literal = _PyPegen_expect_token(p, 14)) // token='+' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8013 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8014 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8015 | ) |
| 8016 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8017 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8018 | if (_token == NULL) { |
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_UnaryOp ( UAdd , a , EXTRA ); |
| 8026 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8027 | p->error_indicator = 1; |
| 8028 | return NULL; |
| 8029 | } |
| 8030 | goto done; |
| 8031 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8032 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8033 | } |
| 8034 | { // '-' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8035 | if (p->error_indicator) { |
| 8036 | return NULL; |
| 8037 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8038 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8039 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8040 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8041 | (_literal = _PyPegen_expect_token(p, 15)) // token='-' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8042 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8043 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8044 | ) |
| 8045 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8046 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8047 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8048 | return NULL; |
| 8049 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8050 | int _end_lineno = _token->end_lineno; |
| 8051 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8052 | int _end_col_offset = _token->end_col_offset; |
| 8053 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8054 | _res = _Py_UnaryOp ( USub , a , EXTRA ); |
| 8055 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8056 | p->error_indicator = 1; |
| 8057 | return NULL; |
| 8058 | } |
| 8059 | goto done; |
| 8060 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8061 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8062 | } |
| 8063 | { // '~' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8064 | if (p->error_indicator) { |
| 8065 | return NULL; |
| 8066 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8067 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8068 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8069 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8070 | (_literal = _PyPegen_expect_token(p, 31)) // token='~' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8071 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8072 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8073 | ) |
| 8074 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8075 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8076 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8077 | return NULL; |
| 8078 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8079 | int _end_lineno = _token->end_lineno; |
| 8080 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8081 | int _end_col_offset = _token->end_col_offset; |
| 8082 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8083 | _res = _Py_UnaryOp ( Invert , a , EXTRA ); |
| 8084 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8085 | p->error_indicator = 1; |
| 8086 | return NULL; |
| 8087 | } |
| 8088 | goto done; |
| 8089 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8090 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8091 | } |
| 8092 | { // power |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8093 | if (p->error_indicator) { |
| 8094 | return NULL; |
| 8095 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8096 | expr_ty power_var; |
| 8097 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8098 | (power_var = power_rule(p)) // power |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8099 | ) |
| 8100 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8101 | _res = power_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8102 | goto done; |
| 8103 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8104 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8105 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8106 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8107 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8108 | _PyPegen_insert_memo(p, _mark, factor_type, _res); |
| 8109 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8110 | } |
| 8111 | |
| 8112 | // power: await_primary '**' factor | await_primary |
| 8113 | static expr_ty |
| 8114 | power_rule(Parser *p) |
| 8115 | { |
| 8116 | if (p->error_indicator) { |
| 8117 | return NULL; |
| 8118 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8119 | expr_ty _res = NULL; |
| 8120 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8121 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8122 | p->error_indicator = 1; |
| 8123 | return NULL; |
| 8124 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8125 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8126 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8127 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8128 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8129 | { // await_primary '**' factor |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8130 | if (p->error_indicator) { |
| 8131 | return NULL; |
| 8132 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8133 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8134 | expr_ty a; |
| 8135 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8136 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8137 | (a = await_primary_rule(p)) // await_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8138 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8139 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8140 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8141 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8142 | ) |
| 8143 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8144 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8145 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8146 | return NULL; |
| 8147 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8148 | int _end_lineno = _token->end_lineno; |
| 8149 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8150 | int _end_col_offset = _token->end_col_offset; |
| 8151 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8152 | _res = _Py_BinOp ( a , Pow , b , EXTRA ); |
| 8153 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8154 | p->error_indicator = 1; |
| 8155 | return NULL; |
| 8156 | } |
| 8157 | goto done; |
| 8158 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8159 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8160 | } |
| 8161 | { // await_primary |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8162 | if (p->error_indicator) { |
| 8163 | return NULL; |
| 8164 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8165 | expr_ty await_primary_var; |
| 8166 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8167 | (await_primary_var = await_primary_rule(p)) // await_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8168 | ) |
| 8169 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8170 | _res = await_primary_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8171 | goto done; |
| 8172 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8173 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8174 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8175 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8176 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8177 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8178 | } |
| 8179 | |
| 8180 | // await_primary: AWAIT primary | primary |
| 8181 | static expr_ty |
| 8182 | await_primary_rule(Parser *p) |
| 8183 | { |
| 8184 | if (p->error_indicator) { |
| 8185 | return NULL; |
| 8186 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8187 | expr_ty _res = NULL; |
| 8188 | if (_PyPegen_is_memoized(p, await_primary_type, &_res)) |
| 8189 | return _res; |
| 8190 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8191 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8192 | p->error_indicator = 1; |
| 8193 | return NULL; |
| 8194 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8195 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8196 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8197 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8198 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8199 | { // AWAIT primary |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8200 | if (p->error_indicator) { |
| 8201 | return NULL; |
| 8202 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8203 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8204 | Token * await_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8205 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8206 | (await_var = _PyPegen_expect_token(p, AWAIT)) // token='AWAIT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8207 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8208 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8209 | ) |
| 8210 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8211 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8212 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8213 | return NULL; |
| 8214 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8215 | int _end_lineno = _token->end_lineno; |
| 8216 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8217 | int _end_col_offset = _token->end_col_offset; |
| 8218 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8219 | _res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) ); |
| 8220 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8221 | p->error_indicator = 1; |
| 8222 | return NULL; |
| 8223 | } |
| 8224 | goto done; |
| 8225 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8226 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8227 | } |
| 8228 | { // primary |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8229 | if (p->error_indicator) { |
| 8230 | return NULL; |
| 8231 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8232 | expr_ty primary_var; |
| 8233 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8234 | (primary_var = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8235 | ) |
| 8236 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8237 | _res = primary_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8238 | goto done; |
| 8239 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8240 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8241 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8242 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8243 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8244 | _PyPegen_insert_memo(p, _mark, await_primary_type, _res); |
| 8245 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8246 | } |
| 8247 | |
| 8248 | // Left-recursive |
| 8249 | // primary: |
| 8250 | // | primary '.' NAME |
| 8251 | // | primary genexp |
| 8252 | // | primary '(' arguments? ')' |
| 8253 | // | primary '[' slices ']' |
| 8254 | // | atom |
| 8255 | static expr_ty primary_raw(Parser *); |
| 8256 | static expr_ty |
| 8257 | primary_rule(Parser *p) |
| 8258 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8259 | expr_ty _res = NULL; |
| 8260 | if (_PyPegen_is_memoized(p, primary_type, &_res)) |
| 8261 | return _res; |
| 8262 | int _mark = p->mark; |
| 8263 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8264 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8265 | int tmpvar_7 = _PyPegen_update_memo(p, _mark, primary_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8266 | if (tmpvar_7) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8267 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8268 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8269 | p->mark = _mark; |
| 8270 | void *_raw = primary_raw(p); |
| 8271 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8272 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8273 | _resmark = p->mark; |
| 8274 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8275 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8276 | p->mark = _resmark; |
| 8277 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8278 | } |
| 8279 | static expr_ty |
| 8280 | primary_raw(Parser *p) |
| 8281 | { |
| 8282 | if (p->error_indicator) { |
| 8283 | return NULL; |
| 8284 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8285 | expr_ty _res = NULL; |
| 8286 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8287 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8288 | p->error_indicator = 1; |
| 8289 | return NULL; |
| 8290 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8291 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8292 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8293 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8294 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8295 | { // primary '.' NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8296 | if (p->error_indicator) { |
| 8297 | return NULL; |
| 8298 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8299 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8300 | expr_ty a; |
| 8301 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8302 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8303 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8304 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8305 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8306 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8307 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8308 | ) |
| 8309 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8310 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8311 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8312 | return NULL; |
| 8313 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8314 | int _end_lineno = _token->end_lineno; |
| 8315 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8316 | int _end_col_offset = _token->end_col_offset; |
| 8317 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8318 | _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
| 8319 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8320 | p->error_indicator = 1; |
| 8321 | return NULL; |
| 8322 | } |
| 8323 | goto done; |
| 8324 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8325 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8326 | } |
| 8327 | { // primary genexp |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8328 | if (p->error_indicator) { |
| 8329 | return NULL; |
| 8330 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8331 | expr_ty a; |
| 8332 | expr_ty b; |
| 8333 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8334 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8335 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8336 | (b = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8337 | ) |
| 8338 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8339 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8340 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8341 | return NULL; |
| 8342 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8343 | int _end_lineno = _token->end_lineno; |
| 8344 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8345 | int _end_col_offset = _token->end_col_offset; |
| 8346 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8347 | _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
| 8348 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8349 | p->error_indicator = 1; |
| 8350 | return NULL; |
| 8351 | } |
| 8352 | goto done; |
| 8353 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8354 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8355 | } |
| 8356 | { // primary '(' arguments? ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8357 | if (p->error_indicator) { |
| 8358 | return NULL; |
| 8359 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8360 | Token * _literal; |
| 8361 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8362 | expr_ty a; |
| 8363 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8364 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8365 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8366 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8367 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8368 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8369 | (b = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8370 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8371 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8372 | ) |
| 8373 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8374 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8375 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8376 | return NULL; |
| 8377 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8378 | int _end_lineno = _token->end_lineno; |
| 8379 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8380 | int _end_col_offset = _token->end_col_offset; |
| 8381 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8382 | _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 8383 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8384 | p->error_indicator = 1; |
| 8385 | return NULL; |
| 8386 | } |
| 8387 | goto done; |
| 8388 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8389 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8390 | } |
| 8391 | { // primary '[' slices ']' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8392 | if (p->error_indicator) { |
| 8393 | return NULL; |
| 8394 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8395 | Token * _literal; |
| 8396 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8397 | expr_ty a; |
| 8398 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8399 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8400 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8401 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8402 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8403 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8404 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8405 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8406 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8407 | ) |
| 8408 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8409 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8410 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8411 | return NULL; |
| 8412 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8413 | int _end_lineno = _token->end_lineno; |
| 8414 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8415 | int _end_col_offset = _token->end_col_offset; |
| 8416 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8417 | _res = _Py_Subscript ( a , b , Load , EXTRA ); |
| 8418 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8419 | p->error_indicator = 1; |
| 8420 | return NULL; |
| 8421 | } |
| 8422 | goto done; |
| 8423 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8424 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8425 | } |
| 8426 | { // atom |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8427 | if (p->error_indicator) { |
| 8428 | return NULL; |
| 8429 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8430 | expr_ty atom_var; |
| 8431 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8432 | (atom_var = atom_rule(p)) // atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8433 | ) |
| 8434 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8435 | _res = atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8436 | goto done; |
| 8437 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8438 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8439 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8440 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8441 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8442 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8443 | } |
| 8444 | |
| 8445 | // slices: slice !',' | ','.slice+ ','? |
| 8446 | static expr_ty |
| 8447 | slices_rule(Parser *p) |
| 8448 | { |
| 8449 | if (p->error_indicator) { |
| 8450 | return NULL; |
| 8451 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8452 | expr_ty _res = NULL; |
| 8453 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8454 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8455 | p->error_indicator = 1; |
| 8456 | return NULL; |
| 8457 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8458 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8459 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8460 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8461 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8462 | { // slice !',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8463 | if (p->error_indicator) { |
| 8464 | return NULL; |
| 8465 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8466 | expr_ty a; |
| 8467 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8468 | (a = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8469 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8470 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8471 | ) |
| 8472 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8473 | _res = a; |
| 8474 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8475 | p->error_indicator = 1; |
| 8476 | return NULL; |
| 8477 | } |
| 8478 | goto done; |
| 8479 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8480 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8481 | } |
| 8482 | { // ','.slice+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8483 | if (p->error_indicator) { |
| 8484 | return NULL; |
| 8485 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8486 | void *_opt_var; |
| 8487 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8488 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8489 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8490 | (a = _gather_93_rule(p)) // ','.slice+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8491 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8492 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8493 | ) |
| 8494 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8495 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8496 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8497 | return NULL; |
| 8498 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8499 | int _end_lineno = _token->end_lineno; |
| 8500 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8501 | int _end_col_offset = _token->end_col_offset; |
| 8502 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8503 | _res = _Py_Tuple ( a , Load , EXTRA ); |
| 8504 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8505 | p->error_indicator = 1; |
| 8506 | return NULL; |
| 8507 | } |
| 8508 | goto done; |
| 8509 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8510 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8511 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8512 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8513 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8514 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8515 | } |
| 8516 | |
| 8517 | // slice: expression? ':' expression? [':' expression?] | expression |
| 8518 | static expr_ty |
| 8519 | slice_rule(Parser *p) |
| 8520 | { |
| 8521 | if (p->error_indicator) { |
| 8522 | return NULL; |
| 8523 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8524 | expr_ty _res = NULL; |
| 8525 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8526 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8527 | p->error_indicator = 1; |
| 8528 | return NULL; |
| 8529 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8530 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8531 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8532 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8533 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8534 | { // expression? ':' expression? [':' expression?] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8535 | if (p->error_indicator) { |
| 8536 | return NULL; |
| 8537 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8538 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8539 | void *a; |
| 8540 | void *b; |
| 8541 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8542 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8543 | (a = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8544 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8545 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8546 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8547 | (b = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8548 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8549 | (c = _tmp_95_rule(p), 1) // [':' expression?] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8550 | ) |
| 8551 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8552 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8553 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8554 | return NULL; |
| 8555 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8556 | int _end_lineno = _token->end_lineno; |
| 8557 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8558 | int _end_col_offset = _token->end_col_offset; |
| 8559 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8560 | _res = _Py_Slice ( a , b , c , EXTRA ); |
| 8561 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8562 | p->error_indicator = 1; |
| 8563 | return NULL; |
| 8564 | } |
| 8565 | goto done; |
| 8566 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8567 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8568 | } |
| 8569 | { // expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8570 | if (p->error_indicator) { |
| 8571 | return NULL; |
| 8572 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8573 | expr_ty a; |
| 8574 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8575 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8576 | ) |
| 8577 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8578 | _res = a; |
| 8579 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8580 | p->error_indicator = 1; |
| 8581 | return NULL; |
| 8582 | } |
| 8583 | goto done; |
| 8584 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8585 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8586 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8587 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8588 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8589 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8590 | } |
| 8591 | |
| 8592 | // atom: |
| 8593 | // | NAME |
| 8594 | // | 'True' |
| 8595 | // | 'False' |
| 8596 | // | 'None' |
| 8597 | // | '__new_parser__' |
| 8598 | // | &STRING strings |
| 8599 | // | NUMBER |
| 8600 | // | &'(' (tuple | group | genexp) |
| 8601 | // | &'[' (list | listcomp) |
| 8602 | // | &'{' (dict | set | dictcomp | setcomp) |
| 8603 | // | '...' |
| 8604 | static expr_ty |
| 8605 | atom_rule(Parser *p) |
| 8606 | { |
| 8607 | if (p->error_indicator) { |
| 8608 | return NULL; |
| 8609 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8610 | expr_ty _res = NULL; |
| 8611 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8612 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8613 | p->error_indicator = 1; |
| 8614 | return NULL; |
| 8615 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8616 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8617 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8618 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8619 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8620 | { // NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8621 | if (p->error_indicator) { |
| 8622 | return NULL; |
| 8623 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8624 | expr_ty name_var; |
| 8625 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8626 | (name_var = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8627 | ) |
| 8628 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8629 | _res = name_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8630 | goto done; |
| 8631 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8632 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8633 | } |
| 8634 | { // 'True' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8635 | if (p->error_indicator) { |
| 8636 | return NULL; |
| 8637 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8638 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8639 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8640 | (_keyword = _PyPegen_expect_token(p, 527)) // token='True' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8641 | ) |
| 8642 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8643 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8644 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8645 | return NULL; |
| 8646 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8647 | int _end_lineno = _token->end_lineno; |
| 8648 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8649 | int _end_col_offset = _token->end_col_offset; |
| 8650 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8651 | _res = _Py_Constant ( Py_True , NULL , EXTRA ); |
| 8652 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8653 | p->error_indicator = 1; |
| 8654 | return NULL; |
| 8655 | } |
| 8656 | goto done; |
| 8657 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8658 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8659 | } |
| 8660 | { // 'False' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8661 | if (p->error_indicator) { |
| 8662 | return NULL; |
| 8663 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8664 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8665 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8666 | (_keyword = _PyPegen_expect_token(p, 528)) // token='False' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8667 | ) |
| 8668 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8669 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8670 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8671 | return NULL; |
| 8672 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8673 | int _end_lineno = _token->end_lineno; |
| 8674 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8675 | int _end_col_offset = _token->end_col_offset; |
| 8676 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8677 | _res = _Py_Constant ( Py_False , NULL , EXTRA ); |
| 8678 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8679 | p->error_indicator = 1; |
| 8680 | return NULL; |
| 8681 | } |
| 8682 | goto done; |
| 8683 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8684 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8685 | } |
| 8686 | { // 'None' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8687 | if (p->error_indicator) { |
| 8688 | return NULL; |
| 8689 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8690 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8691 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8692 | (_keyword = _PyPegen_expect_token(p, 529)) // token='None' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8693 | ) |
| 8694 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8695 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8696 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8697 | return NULL; |
| 8698 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8699 | int _end_lineno = _token->end_lineno; |
| 8700 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8701 | int _end_col_offset = _token->end_col_offset; |
| 8702 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8703 | _res = _Py_Constant ( Py_None , NULL , EXTRA ); |
| 8704 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8705 | p->error_indicator = 1; |
| 8706 | return NULL; |
| 8707 | } |
| 8708 | goto done; |
| 8709 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8710 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8711 | } |
| 8712 | { // '__new_parser__' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8713 | if (p->error_indicator) { |
| 8714 | return NULL; |
| 8715 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8716 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8717 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8718 | (_keyword = _PyPegen_expect_token(p, 530)) // token='__new_parser__' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8719 | ) |
| 8720 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8721 | _res = RAISE_SYNTAX_ERROR ( "You found it!" ); |
| 8722 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8723 | p->error_indicator = 1; |
| 8724 | return NULL; |
| 8725 | } |
| 8726 | goto done; |
| 8727 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8728 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8729 | } |
| 8730 | { // &STRING strings |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8731 | if (p->error_indicator) { |
| 8732 | return NULL; |
| 8733 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8734 | expr_ty strings_var; |
| 8735 | if ( |
| 8736 | _PyPegen_lookahead(1, _PyPegen_string_token, p) |
| 8737 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8738 | (strings_var = strings_rule(p)) // strings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8739 | ) |
| 8740 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8741 | _res = strings_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8742 | goto done; |
| 8743 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8744 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8745 | } |
| 8746 | { // NUMBER |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8747 | if (p->error_indicator) { |
| 8748 | return NULL; |
| 8749 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8750 | expr_ty number_var; |
| 8751 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8752 | (number_var = _PyPegen_number_token(p)) // NUMBER |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8753 | ) |
| 8754 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8755 | _res = number_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8756 | goto done; |
| 8757 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8758 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8759 | } |
| 8760 | { // &'(' (tuple | group | genexp) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8761 | if (p->error_indicator) { |
| 8762 | return NULL; |
| 8763 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8764 | void *_tmp_96_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8765 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8766 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8767 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8768 | (_tmp_96_var = _tmp_96_rule(p)) // tuple | group | genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8769 | ) |
| 8770 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8771 | _res = _tmp_96_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8772 | goto done; |
| 8773 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8774 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8775 | } |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8776 | { // &'[' (list | listcomp) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8777 | if (p->error_indicator) { |
| 8778 | return NULL; |
| 8779 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8780 | void *_tmp_97_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8781 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8782 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8783 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8784 | (_tmp_97_var = _tmp_97_rule(p)) // list | listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8785 | ) |
| 8786 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8787 | _res = _tmp_97_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8788 | goto done; |
| 8789 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8790 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8791 | } |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8792 | { // &'{' (dict | set | dictcomp | setcomp) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8793 | if (p->error_indicator) { |
| 8794 | return NULL; |
| 8795 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8796 | void *_tmp_98_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8797 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8798 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8799 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8800 | (_tmp_98_var = _tmp_98_rule(p)) // dict | set | dictcomp | setcomp |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8801 | ) |
| 8802 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8803 | _res = _tmp_98_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8804 | goto done; |
| 8805 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8806 | p->mark = _mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8807 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8808 | { // '...' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8809 | if (p->error_indicator) { |
| 8810 | return NULL; |
| 8811 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8812 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8813 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8814 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8815 | ) |
| 8816 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8817 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8818 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8819 | return NULL; |
| 8820 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8821 | int _end_lineno = _token->end_lineno; |
| 8822 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8823 | int _end_col_offset = _token->end_col_offset; |
| 8824 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8825 | _res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA ); |
| 8826 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8827 | p->error_indicator = 1; |
| 8828 | return NULL; |
| 8829 | } |
| 8830 | goto done; |
| 8831 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8832 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8833 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8834 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8835 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8836 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8837 | } |
| 8838 | |
| 8839 | // strings: STRING+ |
| 8840 | static expr_ty |
| 8841 | strings_rule(Parser *p) |
| 8842 | { |
| 8843 | if (p->error_indicator) { |
| 8844 | return NULL; |
| 8845 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8846 | expr_ty _res = NULL; |
| 8847 | if (_PyPegen_is_memoized(p, strings_type, &_res)) |
| 8848 | return _res; |
| 8849 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8850 | { // STRING+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8851 | if (p->error_indicator) { |
| 8852 | return NULL; |
| 8853 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8854 | asdl_seq * a; |
| 8855 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8856 | (a = _loop1_99_rule(p)) // STRING+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8857 | ) |
| 8858 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8859 | _res = _PyPegen_concatenate_strings ( p , a ); |
| 8860 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8861 | p->error_indicator = 1; |
| 8862 | return NULL; |
| 8863 | } |
| 8864 | goto done; |
| 8865 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8866 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8867 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8868 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8869 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8870 | _PyPegen_insert_memo(p, _mark, strings_type, _res); |
| 8871 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8872 | } |
| 8873 | |
| 8874 | // list: '[' star_named_expressions? ']' |
| 8875 | static expr_ty |
| 8876 | list_rule(Parser *p) |
| 8877 | { |
| 8878 | if (p->error_indicator) { |
| 8879 | return NULL; |
| 8880 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8881 | expr_ty _res = NULL; |
| 8882 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8883 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8884 | p->error_indicator = 1; |
| 8885 | return NULL; |
| 8886 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8887 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8888 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8889 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8890 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8891 | { // '[' star_named_expressions? ']' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8892 | if (p->error_indicator) { |
| 8893 | return NULL; |
| 8894 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8895 | Token * _literal; |
| 8896 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8897 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8898 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8899 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8900 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8901 | (a = star_named_expressions_rule(p), 1) // star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8902 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8903 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8904 | ) |
| 8905 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8906 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8907 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8908 | return NULL; |
| 8909 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8910 | int _end_lineno = _token->end_lineno; |
| 8911 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8912 | int _end_col_offset = _token->end_col_offset; |
| 8913 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8914 | _res = _Py_List ( a , Load , EXTRA ); |
| 8915 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8916 | p->error_indicator = 1; |
| 8917 | return NULL; |
| 8918 | } |
| 8919 | goto done; |
| 8920 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8921 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8922 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8923 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8924 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8925 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8926 | } |
| 8927 | |
| 8928 | // listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension |
| 8929 | static expr_ty |
| 8930 | listcomp_rule(Parser *p) |
| 8931 | { |
| 8932 | if (p->error_indicator) { |
| 8933 | return NULL; |
| 8934 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8935 | expr_ty _res = NULL; |
| 8936 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8937 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8938 | p->error_indicator = 1; |
| 8939 | return NULL; |
| 8940 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8941 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8942 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8943 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8944 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8945 | { // '[' named_expression for_if_clauses ']' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8946 | if (p->error_indicator) { |
| 8947 | return NULL; |
| 8948 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8949 | Token * _literal; |
| 8950 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8951 | expr_ty a; |
| 8952 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8953 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8954 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8955 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8956 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8957 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8958 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8959 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8960 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8961 | ) |
| 8962 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8963 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8964 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8965 | return NULL; |
| 8966 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8967 | int _end_lineno = _token->end_lineno; |
| 8968 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8969 | int _end_col_offset = _token->end_col_offset; |
| 8970 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8971 | _res = _Py_ListComp ( a , b , EXTRA ); |
| 8972 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8973 | p->error_indicator = 1; |
| 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 | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8979 | } |
| 8980 | { // invalid_comprehension |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 8981 | if (p->error_indicator) { |
| 8982 | return NULL; |
| 8983 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8984 | void *invalid_comprehension_var; |
| 8985 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8986 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8987 | ) |
| 8988 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8989 | _res = invalid_comprehension_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8990 | goto done; |
| 8991 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8992 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8993 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8994 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8995 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8996 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8997 | } |
| 8998 | |
| 8999 | // tuple: '(' [star_named_expression ',' star_named_expressions?] ')' |
| 9000 | static expr_ty |
| 9001 | tuple_rule(Parser *p) |
| 9002 | { |
| 9003 | if (p->error_indicator) { |
| 9004 | return NULL; |
| 9005 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9006 | expr_ty _res = NULL; |
| 9007 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9008 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9009 | p->error_indicator = 1; |
| 9010 | return NULL; |
| 9011 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9012 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9013 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9014 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9015 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9016 | { // '(' [star_named_expression ',' star_named_expressions?] ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9017 | if (p->error_indicator) { |
| 9018 | return NULL; |
| 9019 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9020 | Token * _literal; |
| 9021 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9022 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9023 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9024 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9025 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9026 | (a = _tmp_100_rule(p), 1) // [star_named_expression ',' star_named_expressions?] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9027 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9028 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9029 | ) |
| 9030 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9031 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9032 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9033 | return NULL; |
| 9034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9035 | int _end_lineno = _token->end_lineno; |
| 9036 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9037 | int _end_col_offset = _token->end_col_offset; |
| 9038 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9039 | _res = _Py_Tuple ( a , Load , EXTRA ); |
| 9040 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9041 | p->error_indicator = 1; |
| 9042 | return NULL; |
| 9043 | } |
| 9044 | goto done; |
| 9045 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9046 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9047 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9048 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9049 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9050 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9051 | } |
| 9052 | |
| 9053 | // group: '(' (yield_expr | named_expression) ')' |
| 9054 | static expr_ty |
| 9055 | group_rule(Parser *p) |
| 9056 | { |
| 9057 | if (p->error_indicator) { |
| 9058 | return NULL; |
| 9059 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9060 | expr_ty _res = NULL; |
| 9061 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9062 | { // '(' (yield_expr | named_expression) ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9063 | if (p->error_indicator) { |
| 9064 | return NULL; |
| 9065 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9066 | Token * _literal; |
| 9067 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9068 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9069 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9070 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9071 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9072 | (a = _tmp_101_rule(p)) // yield_expr | named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9073 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9074 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9075 | ) |
| 9076 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9077 | _res = a; |
| 9078 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9079 | p->error_indicator = 1; |
| 9080 | return NULL; |
| 9081 | } |
| 9082 | goto done; |
| 9083 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9084 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9085 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9086 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9087 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9088 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9089 | } |
| 9090 | |
| 9091 | // genexp: '(' expression for_if_clauses ')' | invalid_comprehension |
| 9092 | static expr_ty |
| 9093 | genexp_rule(Parser *p) |
| 9094 | { |
| 9095 | if (p->error_indicator) { |
| 9096 | return NULL; |
| 9097 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9098 | expr_ty _res = NULL; |
| 9099 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9100 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9101 | p->error_indicator = 1; |
| 9102 | return NULL; |
| 9103 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9104 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9105 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9106 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9107 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9108 | { // '(' expression for_if_clauses ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9109 | if (p->error_indicator) { |
| 9110 | return NULL; |
| 9111 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9112 | Token * _literal; |
| 9113 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9114 | expr_ty a; |
| 9115 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9116 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9117 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9118 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9119 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9120 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9121 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9122 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9123 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9124 | ) |
| 9125 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9126 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9127 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9128 | return NULL; |
| 9129 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9130 | int _end_lineno = _token->end_lineno; |
| 9131 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9132 | int _end_col_offset = _token->end_col_offset; |
| 9133 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9134 | _res = _Py_GeneratorExp ( a , b , EXTRA ); |
| 9135 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9136 | p->error_indicator = 1; |
| 9137 | return NULL; |
| 9138 | } |
| 9139 | goto done; |
| 9140 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9141 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9142 | } |
| 9143 | { // invalid_comprehension |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9144 | if (p->error_indicator) { |
| 9145 | return NULL; |
| 9146 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9147 | void *invalid_comprehension_var; |
| 9148 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9149 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9150 | ) |
| 9151 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9152 | _res = invalid_comprehension_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9153 | goto done; |
| 9154 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9155 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9156 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9157 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9158 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9159 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9160 | } |
| 9161 | |
| 9162 | // set: '{' expressions_list '}' |
| 9163 | static expr_ty |
| 9164 | set_rule(Parser *p) |
| 9165 | { |
| 9166 | if (p->error_indicator) { |
| 9167 | return NULL; |
| 9168 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9169 | expr_ty _res = NULL; |
| 9170 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9171 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9172 | p->error_indicator = 1; |
| 9173 | return NULL; |
| 9174 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9175 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9176 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9177 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9178 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9179 | { // '{' expressions_list '}' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9180 | if (p->error_indicator) { |
| 9181 | return NULL; |
| 9182 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9183 | Token * _literal; |
| 9184 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9185 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9186 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9187 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9188 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9189 | (a = expressions_list_rule(p)) // expressions_list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9190 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9191 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9192 | ) |
| 9193 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9194 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9195 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9196 | return NULL; |
| 9197 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9198 | int _end_lineno = _token->end_lineno; |
| 9199 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9200 | int _end_col_offset = _token->end_col_offset; |
| 9201 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9202 | _res = _Py_Set ( a , EXTRA ); |
| 9203 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9204 | p->error_indicator = 1; |
| 9205 | return NULL; |
| 9206 | } |
| 9207 | goto done; |
| 9208 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9209 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9210 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9211 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9212 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9213 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9214 | } |
| 9215 | |
| 9216 | // setcomp: '{' expression for_if_clauses '}' | invalid_comprehension |
| 9217 | static expr_ty |
| 9218 | setcomp_rule(Parser *p) |
| 9219 | { |
| 9220 | if (p->error_indicator) { |
| 9221 | return NULL; |
| 9222 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9223 | expr_ty _res = NULL; |
| 9224 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9225 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9226 | p->error_indicator = 1; |
| 9227 | return NULL; |
| 9228 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9229 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9230 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9231 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9232 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9233 | { // '{' expression for_if_clauses '}' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9234 | if (p->error_indicator) { |
| 9235 | return NULL; |
| 9236 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9237 | Token * _literal; |
| 9238 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9239 | expr_ty a; |
| 9240 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9241 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9242 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9243 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9244 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9245 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9246 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9247 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9248 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9249 | ) |
| 9250 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9251 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9252 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9253 | return NULL; |
| 9254 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9255 | int _end_lineno = _token->end_lineno; |
| 9256 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9257 | int _end_col_offset = _token->end_col_offset; |
| 9258 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9259 | _res = _Py_SetComp ( a , b , EXTRA ); |
| 9260 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9261 | p->error_indicator = 1; |
| 9262 | return NULL; |
| 9263 | } |
| 9264 | goto done; |
| 9265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9266 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9267 | } |
| 9268 | { // invalid_comprehension |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9269 | if (p->error_indicator) { |
| 9270 | return NULL; |
| 9271 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9272 | void *invalid_comprehension_var; |
| 9273 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9274 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9275 | ) |
| 9276 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9277 | _res = invalid_comprehension_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9278 | goto done; |
| 9279 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9280 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9281 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9282 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9283 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9284 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9285 | } |
| 9286 | |
| 9287 | // dict: '{' kvpairs? '}' |
| 9288 | static expr_ty |
| 9289 | dict_rule(Parser *p) |
| 9290 | { |
| 9291 | if (p->error_indicator) { |
| 9292 | return NULL; |
| 9293 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9294 | expr_ty _res = NULL; |
| 9295 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9296 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9297 | p->error_indicator = 1; |
| 9298 | return NULL; |
| 9299 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9300 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9301 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9302 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9303 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9304 | { // '{' kvpairs? '}' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9305 | if (p->error_indicator) { |
| 9306 | return NULL; |
| 9307 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9308 | Token * _literal; |
| 9309 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9310 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9311 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9312 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9313 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9314 | (a = kvpairs_rule(p), 1) // kvpairs? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9315 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9316 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9317 | ) |
| 9318 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9319 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9320 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9321 | return NULL; |
| 9322 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9323 | int _end_lineno = _token->end_lineno; |
| 9324 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9325 | int _end_col_offset = _token->end_col_offset; |
| 9326 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9327 | _res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA ); |
| 9328 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9329 | p->error_indicator = 1; |
| 9330 | return NULL; |
| 9331 | } |
| 9332 | goto done; |
| 9333 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9334 | p->mark = _mark; |
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 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9337 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9338 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9339 | } |
| 9340 | |
| 9341 | // dictcomp: '{' kvpair for_if_clauses '}' |
| 9342 | static expr_ty |
| 9343 | dictcomp_rule(Parser *p) |
| 9344 | { |
| 9345 | if (p->error_indicator) { |
| 9346 | return NULL; |
| 9347 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9348 | expr_ty _res = NULL; |
| 9349 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9350 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9351 | p->error_indicator = 1; |
| 9352 | return NULL; |
| 9353 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9354 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9355 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9356 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9357 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9358 | { // '{' kvpair for_if_clauses '}' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9359 | if (p->error_indicator) { |
| 9360 | return NULL; |
| 9361 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9362 | Token * _literal; |
| 9363 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9364 | KeyValuePair* a; |
| 9365 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9366 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9367 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9368 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9369 | (a = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9370 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9371 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9372 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9373 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9374 | ) |
| 9375 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9376 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9377 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9378 | return NULL; |
| 9379 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9380 | int _end_lineno = _token->end_lineno; |
| 9381 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9382 | int _end_col_offset = _token->end_col_offset; |
| 9383 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9384 | _res = _Py_DictComp ( a -> key , a -> value , b , EXTRA ); |
| 9385 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9386 | p->error_indicator = 1; |
| 9387 | return NULL; |
| 9388 | } |
| 9389 | goto done; |
| 9390 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9391 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9392 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9393 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9394 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9395 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9396 | } |
| 9397 | |
| 9398 | // kvpairs: ','.kvpair+ ','? |
| 9399 | static asdl_seq* |
| 9400 | kvpairs_rule(Parser *p) |
| 9401 | { |
| 9402 | if (p->error_indicator) { |
| 9403 | return NULL; |
| 9404 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9405 | asdl_seq* _res = NULL; |
| 9406 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9407 | { // ','.kvpair+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9408 | if (p->error_indicator) { |
| 9409 | return NULL; |
| 9410 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9411 | void *_opt_var; |
| 9412 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9413 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9414 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9415 | (a = _gather_102_rule(p)) // ','.kvpair+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9416 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9417 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9418 | ) |
| 9419 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9420 | _res = a; |
| 9421 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9422 | p->error_indicator = 1; |
| 9423 | return NULL; |
| 9424 | } |
| 9425 | goto done; |
| 9426 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9427 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9428 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9429 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9430 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9431 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9432 | } |
| 9433 | |
| 9434 | // kvpair: '**' bitwise_or | expression ':' expression |
| 9435 | static KeyValuePair* |
| 9436 | kvpair_rule(Parser *p) |
| 9437 | { |
| 9438 | if (p->error_indicator) { |
| 9439 | return NULL; |
| 9440 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9441 | KeyValuePair* _res = NULL; |
| 9442 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9443 | { // '**' bitwise_or |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9444 | if (p->error_indicator) { |
| 9445 | return NULL; |
| 9446 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9447 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9448 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9449 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9450 | (_literal = _PyPegen_expect_token(p, 35)) // 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 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9453 | ) |
| 9454 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9455 | _res = _PyPegen_key_value_pair ( p , NULL , a ); |
| 9456 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9457 | p->error_indicator = 1; |
| 9458 | return NULL; |
| 9459 | } |
| 9460 | goto done; |
| 9461 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9462 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9463 | } |
| 9464 | { // expression ':' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9465 | if (p->error_indicator) { |
| 9466 | return NULL; |
| 9467 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9468 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9469 | expr_ty a; |
| 9470 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9471 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9472 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9473 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9474 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9475 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9476 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9477 | ) |
| 9478 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9479 | _res = _PyPegen_key_value_pair ( p , a , b ); |
| 9480 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9481 | p->error_indicator = 1; |
| 9482 | return NULL; |
| 9483 | } |
| 9484 | goto done; |
| 9485 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9486 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9487 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9488 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9489 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9490 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9491 | } |
| 9492 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9493 | // for_if_clauses: for_if_clause+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9494 | static asdl_seq* |
| 9495 | for_if_clauses_rule(Parser *p) |
| 9496 | { |
| 9497 | if (p->error_indicator) { |
| 9498 | return NULL; |
| 9499 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9500 | asdl_seq* _res = NULL; |
| 9501 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9502 | { // for_if_clause+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9503 | if (p->error_indicator) { |
| 9504 | return NULL; |
| 9505 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9506 | asdl_seq * _loop1_104_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9507 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9508 | (_loop1_104_var = _loop1_104_rule(p)) // for_if_clause+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9509 | ) |
| 9510 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9511 | _res = _loop1_104_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9512 | goto done; |
| 9513 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9514 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9515 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9516 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9517 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9518 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9519 | } |
| 9520 | |
| 9521 | // for_if_clause: |
| 9522 | // | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 9523 | // | 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 9524 | static comprehension_ty |
| 9525 | for_if_clause_rule(Parser *p) |
| 9526 | { |
| 9527 | if (p->error_indicator) { |
| 9528 | return NULL; |
| 9529 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9530 | comprehension_ty _res = NULL; |
| 9531 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9532 | { // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9533 | if (p->error_indicator) { |
| 9534 | return NULL; |
| 9535 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9536 | Token * _keyword; |
| 9537 | Token * _keyword_1; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9538 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9539 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9540 | expr_ty b; |
| 9541 | asdl_seq * c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9542 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9543 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9544 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9545 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9546 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9547 | (a = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9548 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9549 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9550 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9551 | (b = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9552 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9553 | (c = _loop0_105_rule(p)) // (('if' disjunction))* |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9554 | ) |
| 9555 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9556 | _res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) ); |
| 9557 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9558 | p->error_indicator = 1; |
| 9559 | return NULL; |
| 9560 | } |
| 9561 | goto done; |
| 9562 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9563 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9564 | } |
| 9565 | { // 'for' star_targets 'in' disjunction (('if' disjunction))* |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9566 | if (p->error_indicator) { |
| 9567 | return NULL; |
| 9568 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9569 | Token * _keyword; |
| 9570 | Token * _keyword_1; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9571 | expr_ty a; |
| 9572 | expr_ty b; |
| 9573 | asdl_seq * c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9574 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9575 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9576 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9577 | (a = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9578 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9579 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9580 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9581 | (b = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9582 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9583 | (c = _loop0_106_rule(p)) // (('if' disjunction))* |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 9584 | ) |
| 9585 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9586 | _res = _Py_comprehension ( a , b , c , 0 , p -> arena ); |
| 9587 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9588 | p->error_indicator = 1; |
| 9589 | return NULL; |
| 9590 | } |
| 9591 | goto done; |
| 9592 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9593 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9594 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9595 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9596 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9597 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9598 | } |
| 9599 | |
| 9600 | // yield_expr: 'yield' 'from' expression | 'yield' star_expressions? |
| 9601 | static expr_ty |
| 9602 | yield_expr_rule(Parser *p) |
| 9603 | { |
| 9604 | if (p->error_indicator) { |
| 9605 | return NULL; |
| 9606 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9607 | expr_ty _res = NULL; |
| 9608 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9609 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9610 | p->error_indicator = 1; |
| 9611 | return NULL; |
| 9612 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9613 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9614 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9615 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9616 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9617 | { // 'yield' 'from' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9618 | if (p->error_indicator) { |
| 9619 | return NULL; |
| 9620 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9621 | Token * _keyword; |
| 9622 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9623 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9624 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9625 | (_keyword = _PyPegen_expect_token(p, 504)) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9626 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9627 | (_keyword_1 = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9628 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9629 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9630 | ) |
| 9631 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9632 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9633 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9634 | return NULL; |
| 9635 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9636 | int _end_lineno = _token->end_lineno; |
| 9637 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9638 | int _end_col_offset = _token->end_col_offset; |
| 9639 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9640 | _res = _Py_YieldFrom ( a , EXTRA ); |
| 9641 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9642 | p->error_indicator = 1; |
| 9643 | return NULL; |
| 9644 | } |
| 9645 | goto done; |
| 9646 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9647 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9648 | } |
| 9649 | { // 'yield' star_expressions? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9650 | if (p->error_indicator) { |
| 9651 | return NULL; |
| 9652 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9653 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9654 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9655 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9656 | (_keyword = _PyPegen_expect_token(p, 504)) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9657 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9658 | (a = star_expressions_rule(p), 1) // star_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9659 | ) |
| 9660 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9661 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9662 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9663 | return NULL; |
| 9664 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9665 | int _end_lineno = _token->end_lineno; |
| 9666 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9667 | int _end_col_offset = _token->end_col_offset; |
| 9668 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9669 | _res = _Py_Yield ( a , EXTRA ); |
| 9670 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9671 | p->error_indicator = 1; |
| 9672 | return NULL; |
| 9673 | } |
| 9674 | goto done; |
| 9675 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9676 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9677 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9678 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9679 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9680 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9681 | } |
| 9682 | |
| 9683 | // arguments: args ','? &')' | incorrect_arguments |
| 9684 | static expr_ty |
| 9685 | arguments_rule(Parser *p) |
| 9686 | { |
| 9687 | if (p->error_indicator) { |
| 9688 | return NULL; |
| 9689 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9690 | expr_ty _res = NULL; |
| 9691 | if (_PyPegen_is_memoized(p, arguments_type, &_res)) |
| 9692 | return _res; |
| 9693 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9694 | { // args ','? &')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9695 | if (p->error_indicator) { |
| 9696 | return NULL; |
| 9697 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9698 | void *_opt_var; |
| 9699 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9700 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9701 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9702 | (a = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9703 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9704 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9705 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9706 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9707 | ) |
| 9708 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9709 | _res = a; |
| 9710 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9711 | p->error_indicator = 1; |
| 9712 | return NULL; |
| 9713 | } |
| 9714 | goto done; |
| 9715 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9716 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9717 | } |
| 9718 | { // incorrect_arguments |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9719 | if (p->error_indicator) { |
| 9720 | return NULL; |
| 9721 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9722 | void *incorrect_arguments_var; |
| 9723 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9724 | (incorrect_arguments_var = incorrect_arguments_rule(p)) // incorrect_arguments |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9725 | ) |
| 9726 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9727 | _res = incorrect_arguments_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9728 | goto done; |
| 9729 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9730 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9731 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9732 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9733 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9734 | _PyPegen_insert_memo(p, _mark, arguments_type, _res); |
| 9735 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9736 | } |
| 9737 | |
| 9738 | // args: starred_expression [',' args] | kwargs | named_expression [',' args] |
| 9739 | static expr_ty |
| 9740 | args_rule(Parser *p) |
| 9741 | { |
| 9742 | if (p->error_indicator) { |
| 9743 | return NULL; |
| 9744 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9745 | expr_ty _res = NULL; |
| 9746 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9747 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9748 | p->error_indicator = 1; |
| 9749 | return NULL; |
| 9750 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9751 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9752 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9753 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9754 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9755 | { // starred_expression [',' args] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9756 | if (p->error_indicator) { |
| 9757 | return NULL; |
| 9758 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9759 | expr_ty a; |
| 9760 | void *b; |
| 9761 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9762 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9763 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9764 | (b = _tmp_107_rule(p), 1) // [',' args] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9765 | ) |
| 9766 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9767 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9768 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9769 | return NULL; |
| 9770 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9771 | int _end_lineno = _token->end_lineno; |
| 9772 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9773 | int _end_col_offset = _token->end_col_offset; |
| 9774 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9775 | _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 ); |
| 9776 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9777 | p->error_indicator = 1; |
| 9778 | return NULL; |
| 9779 | } |
| 9780 | goto done; |
| 9781 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9782 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9783 | } |
| 9784 | { // kwargs |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9785 | if (p->error_indicator) { |
| 9786 | return NULL; |
| 9787 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9788 | asdl_seq* a; |
| 9789 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9790 | (a = kwargs_rule(p)) // kwargs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9791 | ) |
| 9792 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9793 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9794 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9795 | return NULL; |
| 9796 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9797 | int _end_lineno = _token->end_lineno; |
| 9798 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9799 | int _end_col_offset = _token->end_col_offset; |
| 9800 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9801 | _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 ); |
| 9802 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9803 | p->error_indicator = 1; |
| 9804 | return NULL; |
| 9805 | } |
| 9806 | goto done; |
| 9807 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9808 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9809 | } |
| 9810 | { // named_expression [',' args] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9811 | if (p->error_indicator) { |
| 9812 | return NULL; |
| 9813 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9814 | expr_ty a; |
| 9815 | void *b; |
| 9816 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9817 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9818 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9819 | (b = _tmp_108_rule(p), 1) // [',' args] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9820 | ) |
| 9821 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9822 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9823 | if (_token == NULL) { |
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 | int _end_lineno = _token->end_lineno; |
| 9827 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9828 | int _end_col_offset = _token->end_col_offset; |
| 9829 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9830 | _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 ); |
| 9831 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9832 | p->error_indicator = 1; |
| 9833 | return NULL; |
| 9834 | } |
| 9835 | goto done; |
| 9836 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9837 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9838 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9839 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9840 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9841 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9842 | } |
| 9843 | |
| 9844 | // kwargs: |
| 9845 | // | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
| 9846 | // | ','.kwarg_or_starred+ |
| 9847 | // | ','.kwarg_or_double_starred+ |
| 9848 | static asdl_seq* |
| 9849 | kwargs_rule(Parser *p) |
| 9850 | { |
| 9851 | if (p->error_indicator) { |
| 9852 | return NULL; |
| 9853 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9854 | asdl_seq* _res = NULL; |
| 9855 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9856 | { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9857 | if (p->error_indicator) { |
| 9858 | return NULL; |
| 9859 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9860 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9861 | asdl_seq * a; |
| 9862 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9863 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9864 | (a = _gather_109_rule(p)) // ','.kwarg_or_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9865 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9866 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9867 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9868 | (b = _gather_111_rule(p)) // ','.kwarg_or_double_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9869 | ) |
| 9870 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9871 | _res = _PyPegen_join_sequences ( p , a , b ); |
| 9872 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9873 | p->error_indicator = 1; |
| 9874 | return NULL; |
| 9875 | } |
| 9876 | goto done; |
| 9877 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9878 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9879 | } |
| 9880 | { // ','.kwarg_or_starred+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9881 | if (p->error_indicator) { |
| 9882 | return NULL; |
| 9883 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9884 | asdl_seq * _gather_113_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9885 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9886 | (_gather_113_var = _gather_113_rule(p)) // ','.kwarg_or_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9887 | ) |
| 9888 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9889 | _res = _gather_113_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9890 | goto done; |
| 9891 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9892 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9893 | } |
| 9894 | { // ','.kwarg_or_double_starred+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9895 | if (p->error_indicator) { |
| 9896 | return NULL; |
| 9897 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9898 | asdl_seq * _gather_115_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9899 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9900 | (_gather_115_var = _gather_115_rule(p)) // ','.kwarg_or_double_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9901 | ) |
| 9902 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9903 | _res = _gather_115_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9904 | goto done; |
| 9905 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9906 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9907 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9908 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9909 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9910 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9911 | } |
| 9912 | |
| 9913 | // starred_expression: '*' expression |
| 9914 | static expr_ty |
| 9915 | starred_expression_rule(Parser *p) |
| 9916 | { |
| 9917 | if (p->error_indicator) { |
| 9918 | return NULL; |
| 9919 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9920 | expr_ty _res = NULL; |
| 9921 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9922 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9923 | p->error_indicator = 1; |
| 9924 | return NULL; |
| 9925 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9926 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9927 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9928 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9929 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9930 | { // '*' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9931 | if (p->error_indicator) { |
| 9932 | return NULL; |
| 9933 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9934 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9935 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9936 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9937 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9938 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9939 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9940 | ) |
| 9941 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9942 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9943 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9944 | return NULL; |
| 9945 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9946 | int _end_lineno = _token->end_lineno; |
| 9947 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9948 | int _end_col_offset = _token->end_col_offset; |
| 9949 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9950 | _res = _Py_Starred ( a , Load , EXTRA ); |
| 9951 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9952 | p->error_indicator = 1; |
| 9953 | return NULL; |
| 9954 | } |
| 9955 | goto done; |
| 9956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9957 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9958 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9959 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9960 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9961 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9962 | } |
| 9963 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9964 | // kwarg_or_starred: NAME '=' expression | starred_expression | invalid_kwarg |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9965 | static KeywordOrStarred* |
| 9966 | kwarg_or_starred_rule(Parser *p) |
| 9967 | { |
| 9968 | if (p->error_indicator) { |
| 9969 | return NULL; |
| 9970 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9971 | KeywordOrStarred* _res = NULL; |
| 9972 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9973 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9974 | p->error_indicator = 1; |
| 9975 | return NULL; |
| 9976 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9977 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9978 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9979 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9980 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9981 | { // NAME '=' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 9982 | if (p->error_indicator) { |
| 9983 | return NULL; |
| 9984 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9985 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9986 | expr_ty a; |
| 9987 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9988 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9989 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9990 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9991 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9992 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9993 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9994 | ) |
| 9995 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9996 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9997 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9998 | return NULL; |
| 9999 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10000 | int _end_lineno = _token->end_lineno; |
| 10001 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10002 | int _end_col_offset = _token->end_col_offset; |
| 10003 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10004 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
| 10005 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10006 | p->error_indicator = 1; |
| 10007 | return NULL; |
| 10008 | } |
| 10009 | goto done; |
| 10010 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10011 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10012 | } |
| 10013 | { // starred_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10014 | if (p->error_indicator) { |
| 10015 | return NULL; |
| 10016 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10017 | expr_ty a; |
| 10018 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10019 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10020 | ) |
| 10021 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10022 | _res = _PyPegen_keyword_or_starred ( p , a , 0 ); |
| 10023 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10024 | p->error_indicator = 1; |
| 10025 | return NULL; |
| 10026 | } |
| 10027 | goto done; |
| 10028 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10029 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10030 | } |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10031 | { // invalid_kwarg |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10032 | if (p->error_indicator) { |
| 10033 | return NULL; |
| 10034 | } |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10035 | void *invalid_kwarg_var; |
| 10036 | if ( |
| 10037 | (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg |
| 10038 | ) |
| 10039 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10040 | _res = invalid_kwarg_var; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10041 | goto done; |
| 10042 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10043 | p->mark = _mark; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10044 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10045 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10046 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10047 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10048 | } |
| 10049 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10050 | // kwarg_or_double_starred: NAME '=' expression | '**' expression | invalid_kwarg |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10051 | static KeywordOrStarred* |
| 10052 | kwarg_or_double_starred_rule(Parser *p) |
| 10053 | { |
| 10054 | if (p->error_indicator) { |
| 10055 | return NULL; |
| 10056 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10057 | KeywordOrStarred* _res = NULL; |
| 10058 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10059 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10060 | p->error_indicator = 1; |
| 10061 | return NULL; |
| 10062 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10063 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10064 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10065 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10066 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10067 | { // NAME '=' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10068 | if (p->error_indicator) { |
| 10069 | return NULL; |
| 10070 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10071 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10072 | expr_ty a; |
| 10073 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10074 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10075 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10076 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10077 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10078 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10079 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10080 | ) |
| 10081 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10082 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10083 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10084 | return NULL; |
| 10085 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10086 | int _end_lineno = _token->end_lineno; |
| 10087 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10088 | int _end_col_offset = _token->end_col_offset; |
| 10089 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10090 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
| 10091 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10092 | p->error_indicator = 1; |
| 10093 | return NULL; |
| 10094 | } |
| 10095 | goto done; |
| 10096 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10097 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10098 | } |
| 10099 | { // '**' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10100 | if (p->error_indicator) { |
| 10101 | return NULL; |
| 10102 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10103 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10104 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10105 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10106 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10107 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10108 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10109 | ) |
| 10110 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10111 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10112 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10113 | return NULL; |
| 10114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10115 | int _end_lineno = _token->end_lineno; |
| 10116 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10117 | int _end_col_offset = _token->end_col_offset; |
| 10118 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10119 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 ); |
| 10120 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10121 | p->error_indicator = 1; |
| 10122 | return NULL; |
| 10123 | } |
| 10124 | goto done; |
| 10125 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10126 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10127 | } |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10128 | { // invalid_kwarg |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10129 | if (p->error_indicator) { |
| 10130 | return NULL; |
| 10131 | } |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10132 | void *invalid_kwarg_var; |
| 10133 | if ( |
| 10134 | (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg |
| 10135 | ) |
| 10136 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10137 | _res = invalid_kwarg_var; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10138 | goto done; |
| 10139 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10140 | p->mark = _mark; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10141 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10142 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10143 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10144 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10145 | } |
| 10146 | |
| 10147 | // star_targets: star_target !',' | star_target ((',' star_target))* ','? |
| 10148 | static expr_ty |
| 10149 | star_targets_rule(Parser *p) |
| 10150 | { |
| 10151 | if (p->error_indicator) { |
| 10152 | return NULL; |
| 10153 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10154 | expr_ty _res = NULL; |
| 10155 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10156 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10157 | p->error_indicator = 1; |
| 10158 | return NULL; |
| 10159 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10160 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10161 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10162 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10163 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10164 | { // star_target !',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10165 | if (p->error_indicator) { |
| 10166 | return NULL; |
| 10167 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10168 | expr_ty a; |
| 10169 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10170 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10171 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10172 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10173 | ) |
| 10174 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10175 | _res = a; |
| 10176 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10177 | p->error_indicator = 1; |
| 10178 | return NULL; |
| 10179 | } |
| 10180 | goto done; |
| 10181 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10182 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10183 | } |
| 10184 | { // star_target ((',' star_target))* ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10185 | if (p->error_indicator) { |
| 10186 | return NULL; |
| 10187 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10188 | void *_opt_var; |
| 10189 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10190 | expr_ty a; |
| 10191 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10192 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10193 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10194 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10195 | (b = _loop0_117_rule(p)) // ((',' star_target))* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10196 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10197 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10198 | ) |
| 10199 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10200 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10201 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10202 | return NULL; |
| 10203 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10204 | int _end_lineno = _token->end_lineno; |
| 10205 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10206 | int _end_col_offset = _token->end_col_offset; |
| 10207 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10208 | _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA ); |
| 10209 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10210 | p->error_indicator = 1; |
| 10211 | return NULL; |
| 10212 | } |
| 10213 | goto done; |
| 10214 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10215 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10216 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10217 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10218 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10219 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10220 | } |
| 10221 | |
| 10222 | // star_targets_seq: ','.star_target+ ','? |
| 10223 | static asdl_seq* |
| 10224 | star_targets_seq_rule(Parser *p) |
| 10225 | { |
| 10226 | if (p->error_indicator) { |
| 10227 | return NULL; |
| 10228 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10229 | asdl_seq* _res = NULL; |
| 10230 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10231 | { // ','.star_target+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10232 | if (p->error_indicator) { |
| 10233 | return NULL; |
| 10234 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10235 | void *_opt_var; |
| 10236 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10237 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10238 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10239 | (a = _gather_118_rule(p)) // ','.star_target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10240 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10241 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10242 | ) |
| 10243 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10244 | _res = a; |
| 10245 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10246 | p->error_indicator = 1; |
| 10247 | return NULL; |
| 10248 | } |
| 10249 | goto done; |
| 10250 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10251 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10252 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10253 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10254 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10255 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10256 | } |
| 10257 | |
| 10258 | // star_target: |
| 10259 | // | '*' (!'*' star_target) |
| 10260 | // | t_primary '.' NAME !t_lookahead |
| 10261 | // | t_primary '[' slices ']' !t_lookahead |
| 10262 | // | star_atom |
| 10263 | static expr_ty |
| 10264 | star_target_rule(Parser *p) |
| 10265 | { |
| 10266 | if (p->error_indicator) { |
| 10267 | return NULL; |
| 10268 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10269 | expr_ty _res = NULL; |
| 10270 | if (_PyPegen_is_memoized(p, star_target_type, &_res)) |
| 10271 | return _res; |
| 10272 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10273 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10274 | p->error_indicator = 1; |
| 10275 | return NULL; |
| 10276 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10277 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10278 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10279 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10280 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10281 | { // '*' (!'*' star_target) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10282 | if (p->error_indicator) { |
| 10283 | return NULL; |
| 10284 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10285 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10286 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10287 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10288 | (_literal = _PyPegen_expect_token(p, 16)) // 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 | (a = _tmp_120_rule(p)) // !'*' star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10291 | ) |
| 10292 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10293 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10294 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10295 | return NULL; |
| 10296 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10297 | int _end_lineno = _token->end_lineno; |
| 10298 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10299 | int _end_col_offset = _token->end_col_offset; |
| 10300 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10301 | _res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA ); |
| 10302 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10303 | p->error_indicator = 1; |
| 10304 | return NULL; |
| 10305 | } |
| 10306 | goto done; |
| 10307 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10308 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10309 | } |
| 10310 | { // t_primary '.' NAME !t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10311 | if (p->error_indicator) { |
| 10312 | return NULL; |
| 10313 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10314 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10315 | expr_ty a; |
| 10316 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10317 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10318 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10319 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10320 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10321 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10322 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10323 | && |
| 10324 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 10325 | ) |
| 10326 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10327 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10328 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10329 | return NULL; |
| 10330 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10331 | int _end_lineno = _token->end_lineno; |
| 10332 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10333 | int _end_col_offset = _token->end_col_offset; |
| 10334 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10335 | _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 10336 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10337 | p->error_indicator = 1; |
| 10338 | return NULL; |
| 10339 | } |
| 10340 | goto done; |
| 10341 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10342 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10343 | } |
| 10344 | { // t_primary '[' slices ']' !t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10345 | if (p->error_indicator) { |
| 10346 | return NULL; |
| 10347 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10348 | Token * _literal; |
| 10349 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10350 | expr_ty a; |
| 10351 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10352 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10353 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10354 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10355 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10356 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10357 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10358 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10359 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10360 | && |
| 10361 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 10362 | ) |
| 10363 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10364 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10365 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10366 | return NULL; |
| 10367 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10368 | int _end_lineno = _token->end_lineno; |
| 10369 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10370 | int _end_col_offset = _token->end_col_offset; |
| 10371 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10372 | _res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 10373 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10374 | p->error_indicator = 1; |
| 10375 | return NULL; |
| 10376 | } |
| 10377 | goto done; |
| 10378 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10379 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10380 | } |
| 10381 | { // star_atom |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10382 | if (p->error_indicator) { |
| 10383 | return NULL; |
| 10384 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10385 | expr_ty star_atom_var; |
| 10386 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10387 | (star_atom_var = star_atom_rule(p)) // star_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10388 | ) |
| 10389 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10390 | _res = star_atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10391 | goto done; |
| 10392 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10393 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10394 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10395 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10396 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10397 | _PyPegen_insert_memo(p, _mark, star_target_type, _res); |
| 10398 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10399 | } |
| 10400 | |
| 10401 | // star_atom: |
| 10402 | // | NAME |
| 10403 | // | '(' star_target ')' |
| 10404 | // | '(' star_targets_seq? ')' |
| 10405 | // | '[' star_targets_seq? ']' |
| 10406 | static expr_ty |
| 10407 | star_atom_rule(Parser *p) |
| 10408 | { |
| 10409 | if (p->error_indicator) { |
| 10410 | return NULL; |
| 10411 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10412 | expr_ty _res = NULL; |
| 10413 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10414 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10415 | p->error_indicator = 1; |
| 10416 | return NULL; |
| 10417 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10418 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10419 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10420 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10421 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10422 | { // NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10423 | if (p->error_indicator) { |
| 10424 | return NULL; |
| 10425 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10426 | expr_ty a; |
| 10427 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10428 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10429 | ) |
| 10430 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10431 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 10432 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10433 | p->error_indicator = 1; |
| 10434 | return NULL; |
| 10435 | } |
| 10436 | goto done; |
| 10437 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10438 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10439 | } |
| 10440 | { // '(' star_target ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10441 | if (p->error_indicator) { |
| 10442 | return NULL; |
| 10443 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10444 | Token * _literal; |
| 10445 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10446 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10447 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10448 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10449 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10450 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10451 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10452 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10453 | ) |
| 10454 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10455 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 10456 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10457 | p->error_indicator = 1; |
| 10458 | return NULL; |
| 10459 | } |
| 10460 | goto done; |
| 10461 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10462 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10463 | } |
| 10464 | { // '(' star_targets_seq? ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10465 | if (p->error_indicator) { |
| 10466 | return NULL; |
| 10467 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10468 | Token * _literal; |
| 10469 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10470 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10471 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10472 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10473 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10474 | (a = star_targets_seq_rule(p), 1) // star_targets_seq? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10475 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10476 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10477 | ) |
| 10478 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10479 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10480 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10481 | return NULL; |
| 10482 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10483 | int _end_lineno = _token->end_lineno; |
| 10484 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10485 | int _end_col_offset = _token->end_col_offset; |
| 10486 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10487 | _res = _Py_Tuple ( a , Store , EXTRA ); |
| 10488 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10489 | p->error_indicator = 1; |
| 10490 | return NULL; |
| 10491 | } |
| 10492 | goto done; |
| 10493 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10494 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10495 | } |
| 10496 | { // '[' star_targets_seq? ']' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10497 | if (p->error_indicator) { |
| 10498 | return NULL; |
| 10499 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10500 | Token * _literal; |
| 10501 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10502 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10503 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10504 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10505 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10506 | (a = star_targets_seq_rule(p), 1) // star_targets_seq? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10507 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10508 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10509 | ) |
| 10510 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10511 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10512 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10513 | return NULL; |
| 10514 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10515 | int _end_lineno = _token->end_lineno; |
| 10516 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10517 | int _end_col_offset = _token->end_col_offset; |
| 10518 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10519 | _res = _Py_List ( a , Store , EXTRA ); |
| 10520 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10521 | p->error_indicator = 1; |
| 10522 | return NULL; |
| 10523 | } |
| 10524 | goto done; |
| 10525 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10526 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10527 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10528 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10529 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10530 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10531 | } |
| 10532 | |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 10533 | // single_target: single_subscript_attribute_target | NAME | '(' single_target ')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10534 | static expr_ty |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 10535 | single_target_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10536 | { |
| 10537 | if (p->error_indicator) { |
| 10538 | return NULL; |
| 10539 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10540 | expr_ty _res = NULL; |
| 10541 | int _mark = p->mark; |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 10542 | { // single_subscript_attribute_target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10543 | if (p->error_indicator) { |
| 10544 | return NULL; |
| 10545 | } |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 10546 | expr_ty single_subscript_attribute_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10547 | if ( |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 10548 | (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] | 10549 | ) |
| 10550 | { |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 10551 | _res = single_subscript_attribute_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10552 | goto done; |
| 10553 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10554 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10555 | } |
| 10556 | { // NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10557 | if (p->error_indicator) { |
| 10558 | return NULL; |
| 10559 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10560 | expr_ty a; |
| 10561 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10562 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10563 | ) |
| 10564 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10565 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 10566 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10567 | p->error_indicator = 1; |
| 10568 | return NULL; |
| 10569 | } |
| 10570 | goto done; |
| 10571 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10572 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10573 | } |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 10574 | { // '(' single_target ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10575 | if (p->error_indicator) { |
| 10576 | return NULL; |
| 10577 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10578 | Token * _literal; |
| 10579 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10580 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10581 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10582 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10583 | && |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 10584 | (a = single_target_rule(p)) // single_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10585 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10586 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10587 | ) |
| 10588 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10589 | _res = a; |
| 10590 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10591 | p->error_indicator = 1; |
| 10592 | return NULL; |
| 10593 | } |
| 10594 | goto done; |
| 10595 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10596 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10597 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10598 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10599 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10600 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10601 | } |
| 10602 | |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 10603 | // single_subscript_attribute_target: |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10604 | // | t_primary '.' NAME !t_lookahead |
| 10605 | // | t_primary '[' slices ']' !t_lookahead |
| 10606 | static expr_ty |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 10607 | single_subscript_attribute_target_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10608 | { |
| 10609 | if (p->error_indicator) { |
| 10610 | return NULL; |
| 10611 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10612 | expr_ty _res = NULL; |
| 10613 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10614 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10615 | p->error_indicator = 1; |
| 10616 | return NULL; |
| 10617 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10618 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10619 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10620 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10621 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10622 | { // t_primary '.' NAME !t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10623 | if (p->error_indicator) { |
| 10624 | return NULL; |
| 10625 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10626 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10627 | expr_ty a; |
| 10628 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10629 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10630 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10631 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10632 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10633 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10634 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10635 | && |
| 10636 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 10637 | ) |
| 10638 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10639 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10640 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10641 | return NULL; |
| 10642 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10643 | int _end_lineno = _token->end_lineno; |
| 10644 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10645 | int _end_col_offset = _token->end_col_offset; |
| 10646 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10647 | _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 10648 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10649 | p->error_indicator = 1; |
| 10650 | return NULL; |
| 10651 | } |
| 10652 | goto done; |
| 10653 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10654 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10655 | } |
| 10656 | { // t_primary '[' slices ']' !t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10657 | if (p->error_indicator) { |
| 10658 | return NULL; |
| 10659 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10660 | Token * _literal; |
| 10661 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10662 | expr_ty a; |
| 10663 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10664 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10665 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10666 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10667 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10668 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10669 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10670 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10671 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10672 | && |
| 10673 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 10674 | ) |
| 10675 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10676 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10677 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10678 | return NULL; |
| 10679 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10680 | int _end_lineno = _token->end_lineno; |
| 10681 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10682 | int _end_col_offset = _token->end_col_offset; |
| 10683 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10684 | _res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 10685 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10686 | p->error_indicator = 1; |
| 10687 | return NULL; |
| 10688 | } |
| 10689 | goto done; |
| 10690 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10691 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10692 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10693 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10694 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10695 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10696 | } |
| 10697 | |
| 10698 | // del_targets: ','.del_target+ ','? |
| 10699 | static asdl_seq* |
| 10700 | del_targets_rule(Parser *p) |
| 10701 | { |
| 10702 | if (p->error_indicator) { |
| 10703 | return NULL; |
| 10704 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10705 | asdl_seq* _res = NULL; |
| 10706 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10707 | { // ','.del_target+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10708 | if (p->error_indicator) { |
| 10709 | return NULL; |
| 10710 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10711 | void *_opt_var; |
| 10712 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10713 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10714 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10715 | (a = _gather_121_rule(p)) // ','.del_target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10716 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10717 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10718 | ) |
| 10719 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10720 | _res = a; |
| 10721 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10722 | p->error_indicator = 1; |
| 10723 | return NULL; |
| 10724 | } |
| 10725 | goto done; |
| 10726 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10727 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10728 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10729 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10730 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10731 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10732 | } |
| 10733 | |
| 10734 | // del_target: |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 10735 | // | t_primary '.' NAME &del_target_end |
| 10736 | // | t_primary '[' slices ']' &del_target_end |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10737 | // | del_t_atom |
| 10738 | static expr_ty |
| 10739 | del_target_rule(Parser *p) |
| 10740 | { |
| 10741 | if (p->error_indicator) { |
| 10742 | return NULL; |
| 10743 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10744 | expr_ty _res = NULL; |
| 10745 | if (_PyPegen_is_memoized(p, del_target_type, &_res)) |
| 10746 | return _res; |
| 10747 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10748 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10749 | p->error_indicator = 1; |
| 10750 | return NULL; |
| 10751 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10752 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10753 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10754 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10755 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 10756 | { // t_primary '.' NAME &del_target_end |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10757 | if (p->error_indicator) { |
| 10758 | return NULL; |
| 10759 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10760 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10761 | expr_ty a; |
| 10762 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10763 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10764 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10765 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10766 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10767 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10768 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10769 | && |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 10770 | _PyPegen_lookahead(1, del_target_end_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10771 | ) |
| 10772 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10773 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10774 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10775 | return NULL; |
| 10776 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10777 | int _end_lineno = _token->end_lineno; |
| 10778 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10779 | int _end_col_offset = _token->end_col_offset; |
| 10780 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10781 | _res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA ); |
| 10782 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10783 | p->error_indicator = 1; |
| 10784 | return NULL; |
| 10785 | } |
| 10786 | goto done; |
| 10787 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10788 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10789 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 10790 | { // t_primary '[' slices ']' &del_target_end |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10791 | if (p->error_indicator) { |
| 10792 | return NULL; |
| 10793 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10794 | Token * _literal; |
| 10795 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10796 | expr_ty a; |
| 10797 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10798 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10799 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10800 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10801 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10802 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10803 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10804 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10805 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10806 | && |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 10807 | _PyPegen_lookahead(1, del_target_end_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10808 | ) |
| 10809 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10810 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10811 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10812 | return NULL; |
| 10813 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10814 | int _end_lineno = _token->end_lineno; |
| 10815 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10816 | int _end_col_offset = _token->end_col_offset; |
| 10817 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10818 | _res = _Py_Subscript ( a , b , Del , EXTRA ); |
| 10819 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10820 | p->error_indicator = 1; |
| 10821 | return NULL; |
| 10822 | } |
| 10823 | goto done; |
| 10824 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10825 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10826 | } |
| 10827 | { // del_t_atom |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10828 | if (p->error_indicator) { |
| 10829 | return NULL; |
| 10830 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10831 | expr_ty del_t_atom_var; |
| 10832 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10833 | (del_t_atom_var = del_t_atom_rule(p)) // del_t_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10834 | ) |
| 10835 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10836 | _res = del_t_atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10837 | goto done; |
| 10838 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10839 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10841 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10842 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10843 | _PyPegen_insert_memo(p, _mark, del_target_type, _res); |
| 10844 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10845 | } |
| 10846 | |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 10847 | // del_t_atom: |
| 10848 | // | NAME &del_target_end |
| 10849 | // | '(' del_target ')' |
| 10850 | // | '(' del_targets? ')' |
| 10851 | // | '[' del_targets? ']' |
| 10852 | // | invalid_del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10853 | static expr_ty |
| 10854 | del_t_atom_rule(Parser *p) |
| 10855 | { |
| 10856 | if (p->error_indicator) { |
| 10857 | return NULL; |
| 10858 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10859 | expr_ty _res = NULL; |
| 10860 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10861 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10862 | p->error_indicator = 1; |
| 10863 | return NULL; |
| 10864 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10865 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10866 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10867 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10868 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 10869 | { // NAME &del_target_end |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10870 | if (p->error_indicator) { |
| 10871 | return NULL; |
| 10872 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10873 | expr_ty a; |
| 10874 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10875 | (a = _PyPegen_name_token(p)) // NAME |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 10876 | && |
| 10877 | _PyPegen_lookahead(1, del_target_end_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10878 | ) |
| 10879 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10880 | _res = _PyPegen_set_expr_context ( p , a , Del ); |
| 10881 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10882 | p->error_indicator = 1; |
| 10883 | return NULL; |
| 10884 | } |
| 10885 | goto done; |
| 10886 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10887 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10888 | } |
| 10889 | { // '(' del_target ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10890 | if (p->error_indicator) { |
| 10891 | return NULL; |
| 10892 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10893 | Token * _literal; |
| 10894 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10895 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10896 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10897 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10898 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10899 | (a = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10900 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10901 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10902 | ) |
| 10903 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10904 | _res = _PyPegen_set_expr_context ( p , a , Del ); |
| 10905 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10906 | p->error_indicator = 1; |
| 10907 | return NULL; |
| 10908 | } |
| 10909 | goto done; |
| 10910 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10911 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10912 | } |
| 10913 | { // '(' del_targets? ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10914 | if (p->error_indicator) { |
| 10915 | return NULL; |
| 10916 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10917 | Token * _literal; |
| 10918 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10919 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10920 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10921 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10922 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10923 | (a = del_targets_rule(p), 1) // del_targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10924 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10925 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10926 | ) |
| 10927 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10928 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10929 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10930 | return NULL; |
| 10931 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10932 | int _end_lineno = _token->end_lineno; |
| 10933 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10934 | int _end_col_offset = _token->end_col_offset; |
| 10935 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10936 | _res = _Py_Tuple ( a , Del , EXTRA ); |
| 10937 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10938 | p->error_indicator = 1; |
| 10939 | return NULL; |
| 10940 | } |
| 10941 | goto done; |
| 10942 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10943 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10944 | } |
| 10945 | { // '[' del_targets? ']' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10946 | if (p->error_indicator) { |
| 10947 | return NULL; |
| 10948 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10949 | Token * _literal; |
| 10950 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10951 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10952 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10953 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10954 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10955 | (a = del_targets_rule(p), 1) // del_targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10956 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10957 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10958 | ) |
| 10959 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10960 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10961 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10962 | return NULL; |
| 10963 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10964 | int _end_lineno = _token->end_lineno; |
| 10965 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10966 | int _end_col_offset = _token->end_col_offset; |
| 10967 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10968 | _res = _Py_List ( a , Del , EXTRA ); |
| 10969 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10970 | p->error_indicator = 1; |
| 10971 | return NULL; |
| 10972 | } |
| 10973 | goto done; |
| 10974 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10975 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10976 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 10977 | { // invalid_del_target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 10978 | if (p->error_indicator) { |
| 10979 | return NULL; |
| 10980 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 10981 | void *invalid_del_target_var; |
| 10982 | if ( |
| 10983 | (invalid_del_target_var = invalid_del_target_rule(p)) // invalid_del_target |
| 10984 | ) |
| 10985 | { |
| 10986 | _res = invalid_del_target_var; |
| 10987 | goto done; |
| 10988 | } |
| 10989 | p->mark = _mark; |
| 10990 | } |
| 10991 | _res = NULL; |
| 10992 | done: |
| 10993 | return _res; |
| 10994 | } |
| 10995 | |
| 10996 | // del_target_end: ')' | ']' | ',' | ';' | NEWLINE |
| 10997 | static void * |
| 10998 | del_target_end_rule(Parser *p) |
| 10999 | { |
| 11000 | if (p->error_indicator) { |
| 11001 | return NULL; |
| 11002 | } |
| 11003 | void * _res = NULL; |
| 11004 | int _mark = p->mark; |
| 11005 | { // ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11006 | if (p->error_indicator) { |
| 11007 | return NULL; |
| 11008 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 11009 | Token * _literal; |
| 11010 | if ( |
| 11011 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
| 11012 | ) |
| 11013 | { |
| 11014 | _res = _literal; |
| 11015 | goto done; |
| 11016 | } |
| 11017 | p->mark = _mark; |
| 11018 | } |
| 11019 | { // ']' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11020 | if (p->error_indicator) { |
| 11021 | return NULL; |
| 11022 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 11023 | Token * _literal; |
| 11024 | if ( |
| 11025 | (_literal = _PyPegen_expect_token(p, 10)) // token=']' |
| 11026 | ) |
| 11027 | { |
| 11028 | _res = _literal; |
| 11029 | goto done; |
| 11030 | } |
| 11031 | p->mark = _mark; |
| 11032 | } |
| 11033 | { // ',' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11034 | if (p->error_indicator) { |
| 11035 | return NULL; |
| 11036 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 11037 | Token * _literal; |
| 11038 | if ( |
| 11039 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 11040 | ) |
| 11041 | { |
| 11042 | _res = _literal; |
| 11043 | goto done; |
| 11044 | } |
| 11045 | p->mark = _mark; |
| 11046 | } |
| 11047 | { // ';' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11048 | if (p->error_indicator) { |
| 11049 | return NULL; |
| 11050 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 11051 | Token * _literal; |
| 11052 | if ( |
| 11053 | (_literal = _PyPegen_expect_token(p, 13)) // token=';' |
| 11054 | ) |
| 11055 | { |
| 11056 | _res = _literal; |
| 11057 | goto done; |
| 11058 | } |
| 11059 | p->mark = _mark; |
| 11060 | } |
| 11061 | { // NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11062 | if (p->error_indicator) { |
| 11063 | return NULL; |
| 11064 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 11065 | Token * newline_var; |
| 11066 | if ( |
| 11067 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 11068 | ) |
| 11069 | { |
| 11070 | _res = newline_var; |
| 11071 | goto done; |
| 11072 | } |
| 11073 | p->mark = _mark; |
| 11074 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11075 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11076 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11077 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11078 | } |
| 11079 | |
| 11080 | // targets: ','.target+ ','? |
| 11081 | static asdl_seq* |
| 11082 | targets_rule(Parser *p) |
| 11083 | { |
| 11084 | if (p->error_indicator) { |
| 11085 | return NULL; |
| 11086 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11087 | asdl_seq* _res = NULL; |
| 11088 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11089 | { // ','.target+ ','? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11090 | if (p->error_indicator) { |
| 11091 | return NULL; |
| 11092 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11093 | void *_opt_var; |
| 11094 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11095 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11096 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11097 | (a = _gather_123_rule(p)) // ','.target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11098 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11099 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11100 | ) |
| 11101 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11102 | _res = a; |
| 11103 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11104 | p->error_indicator = 1; |
| 11105 | return NULL; |
| 11106 | } |
| 11107 | goto done; |
| 11108 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11109 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11110 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11111 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11112 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11113 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11114 | } |
| 11115 | |
| 11116 | // target: |
| 11117 | // | t_primary '.' NAME !t_lookahead |
| 11118 | // | t_primary '[' slices ']' !t_lookahead |
| 11119 | // | t_atom |
| 11120 | static expr_ty |
| 11121 | target_rule(Parser *p) |
| 11122 | { |
| 11123 | if (p->error_indicator) { |
| 11124 | return NULL; |
| 11125 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11126 | expr_ty _res = NULL; |
| 11127 | if (_PyPegen_is_memoized(p, target_type, &_res)) |
| 11128 | return _res; |
| 11129 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11130 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 11131 | p->error_indicator = 1; |
| 11132 | return NULL; |
| 11133 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11134 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11135 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11136 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11137 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11138 | { // t_primary '.' NAME !t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11139 | if (p->error_indicator) { |
| 11140 | return NULL; |
| 11141 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11142 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11143 | expr_ty a; |
| 11144 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11145 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11146 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11147 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11148 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11149 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11150 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11151 | && |
| 11152 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 11153 | ) |
| 11154 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11155 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11156 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11157 | return NULL; |
| 11158 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11159 | int _end_lineno = _token->end_lineno; |
| 11160 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11161 | int _end_col_offset = _token->end_col_offset; |
| 11162 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11163 | _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 11164 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11165 | p->error_indicator = 1; |
| 11166 | return NULL; |
| 11167 | } |
| 11168 | goto done; |
| 11169 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11170 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11171 | } |
| 11172 | { // t_primary '[' slices ']' !t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11173 | if (p->error_indicator) { |
| 11174 | return NULL; |
| 11175 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11176 | Token * _literal; |
| 11177 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11178 | expr_ty a; |
| 11179 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11180 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11181 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11182 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11183 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11184 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11185 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11186 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11187 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11188 | && |
| 11189 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 11190 | ) |
| 11191 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11192 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11193 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11194 | return NULL; |
| 11195 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11196 | int _end_lineno = _token->end_lineno; |
| 11197 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11198 | int _end_col_offset = _token->end_col_offset; |
| 11199 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11200 | _res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 11201 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11202 | p->error_indicator = 1; |
| 11203 | return NULL; |
| 11204 | } |
| 11205 | goto done; |
| 11206 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11207 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11208 | } |
| 11209 | { // t_atom |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11210 | if (p->error_indicator) { |
| 11211 | return NULL; |
| 11212 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11213 | expr_ty t_atom_var; |
| 11214 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11215 | (t_atom_var = t_atom_rule(p)) // t_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11216 | ) |
| 11217 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11218 | _res = t_atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11219 | goto done; |
| 11220 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11221 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11222 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11223 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11224 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11225 | _PyPegen_insert_memo(p, _mark, target_type, _res); |
| 11226 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11227 | } |
| 11228 | |
| 11229 | // Left-recursive |
| 11230 | // t_primary: |
| 11231 | // | t_primary '.' NAME &t_lookahead |
| 11232 | // | t_primary '[' slices ']' &t_lookahead |
| 11233 | // | t_primary genexp &t_lookahead |
| 11234 | // | t_primary '(' arguments? ')' &t_lookahead |
| 11235 | // | atom &t_lookahead |
| 11236 | static expr_ty t_primary_raw(Parser *); |
| 11237 | static expr_ty |
| 11238 | t_primary_rule(Parser *p) |
| 11239 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11240 | expr_ty _res = NULL; |
| 11241 | if (_PyPegen_is_memoized(p, t_primary_type, &_res)) |
| 11242 | return _res; |
| 11243 | int _mark = p->mark; |
| 11244 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11245 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11246 | int tmpvar_8 = _PyPegen_update_memo(p, _mark, t_primary_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11247 | if (tmpvar_8) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11248 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11249 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11250 | p->mark = _mark; |
| 11251 | void *_raw = t_primary_raw(p); |
| 11252 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11253 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11254 | _resmark = p->mark; |
| 11255 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11256 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11257 | p->mark = _resmark; |
| 11258 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11259 | } |
| 11260 | static expr_ty |
| 11261 | t_primary_raw(Parser *p) |
| 11262 | { |
| 11263 | if (p->error_indicator) { |
| 11264 | return NULL; |
| 11265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11266 | expr_ty _res = NULL; |
| 11267 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11268 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 11269 | p->error_indicator = 1; |
| 11270 | return NULL; |
| 11271 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11272 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11273 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11274 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11275 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11276 | { // t_primary '.' NAME &t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11277 | if (p->error_indicator) { |
| 11278 | return NULL; |
| 11279 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11280 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11281 | expr_ty a; |
| 11282 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11283 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11284 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11285 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11286 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11287 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11288 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11289 | && |
| 11290 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 11291 | ) |
| 11292 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11293 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11294 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11295 | return NULL; |
| 11296 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11297 | int _end_lineno = _token->end_lineno; |
| 11298 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11299 | int _end_col_offset = _token->end_col_offset; |
| 11300 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11301 | _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
| 11302 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11303 | p->error_indicator = 1; |
| 11304 | return NULL; |
| 11305 | } |
| 11306 | goto done; |
| 11307 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11308 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11309 | } |
| 11310 | { // t_primary '[' slices ']' &t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11311 | if (p->error_indicator) { |
| 11312 | return NULL; |
| 11313 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11314 | Token * _literal; |
| 11315 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11316 | expr_ty a; |
| 11317 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11318 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11319 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11320 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11321 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11322 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11323 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11324 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11325 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11326 | && |
| 11327 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 11328 | ) |
| 11329 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11330 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11331 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11332 | return NULL; |
| 11333 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11334 | int _end_lineno = _token->end_lineno; |
| 11335 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11336 | int _end_col_offset = _token->end_col_offset; |
| 11337 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11338 | _res = _Py_Subscript ( a , b , Load , EXTRA ); |
| 11339 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11340 | p->error_indicator = 1; |
| 11341 | return NULL; |
| 11342 | } |
| 11343 | goto done; |
| 11344 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11345 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11346 | } |
| 11347 | { // t_primary genexp &t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11348 | if (p->error_indicator) { |
| 11349 | return NULL; |
| 11350 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11351 | expr_ty a; |
| 11352 | expr_ty b; |
| 11353 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11354 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11355 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11356 | (b = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11357 | && |
| 11358 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 11359 | ) |
| 11360 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11361 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11362 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11363 | return NULL; |
| 11364 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11365 | int _end_lineno = _token->end_lineno; |
| 11366 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11367 | int _end_col_offset = _token->end_col_offset; |
| 11368 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11369 | _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
| 11370 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11371 | p->error_indicator = 1; |
| 11372 | return NULL; |
| 11373 | } |
| 11374 | goto done; |
| 11375 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11376 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11377 | } |
| 11378 | { // t_primary '(' arguments? ')' &t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11379 | if (p->error_indicator) { |
| 11380 | return NULL; |
| 11381 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11382 | Token * _literal; |
| 11383 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11384 | expr_ty a; |
| 11385 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11386 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11387 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11388 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11389 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11390 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11391 | (b = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11392 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11393 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11394 | && |
| 11395 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 11396 | ) |
| 11397 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11398 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11399 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11400 | return NULL; |
| 11401 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11402 | int _end_lineno = _token->end_lineno; |
| 11403 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11404 | int _end_col_offset = _token->end_col_offset; |
| 11405 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11406 | _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 11407 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11408 | p->error_indicator = 1; |
| 11409 | return NULL; |
| 11410 | } |
| 11411 | goto done; |
| 11412 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11413 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11414 | } |
| 11415 | { // atom &t_lookahead |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11416 | if (p->error_indicator) { |
| 11417 | return NULL; |
| 11418 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11419 | expr_ty a; |
| 11420 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11421 | (a = atom_rule(p)) // atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11422 | && |
| 11423 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 11424 | ) |
| 11425 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11426 | _res = a; |
| 11427 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11428 | p->error_indicator = 1; |
| 11429 | return NULL; |
| 11430 | } |
| 11431 | goto done; |
| 11432 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11433 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11434 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11435 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11436 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11437 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11438 | } |
| 11439 | |
| 11440 | // t_lookahead: '(' | '[' | '.' |
| 11441 | static void * |
| 11442 | t_lookahead_rule(Parser *p) |
| 11443 | { |
| 11444 | if (p->error_indicator) { |
| 11445 | return NULL; |
| 11446 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11447 | void * _res = NULL; |
| 11448 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11449 | { // '(' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11450 | if (p->error_indicator) { |
| 11451 | return NULL; |
| 11452 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11453 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11454 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11455 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11456 | ) |
| 11457 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11458 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11459 | goto done; |
| 11460 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11461 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11462 | } |
| 11463 | { // '[' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11464 | if (p->error_indicator) { |
| 11465 | return NULL; |
| 11466 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11467 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11468 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11469 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11470 | ) |
| 11471 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11472 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11473 | goto done; |
| 11474 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11475 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11476 | } |
| 11477 | { // '.' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11478 | if (p->error_indicator) { |
| 11479 | return NULL; |
| 11480 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11481 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11482 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11483 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11484 | ) |
| 11485 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11486 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11487 | goto done; |
| 11488 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11489 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11490 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11491 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11492 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11493 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11494 | } |
| 11495 | |
| 11496 | // t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']' |
| 11497 | static expr_ty |
| 11498 | t_atom_rule(Parser *p) |
| 11499 | { |
| 11500 | if (p->error_indicator) { |
| 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; |
| 11507 | return NULL; |
| 11508 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11509 | int _start_lineno = p->tokens[_mark]->lineno; |
| 11510 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 11511 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 11512 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11513 | { // NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11514 | if (p->error_indicator) { |
| 11515 | return NULL; |
| 11516 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11517 | expr_ty a; |
| 11518 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11519 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11520 | ) |
| 11521 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11522 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 11523 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11524 | p->error_indicator = 1; |
| 11525 | return NULL; |
| 11526 | } |
| 11527 | goto done; |
| 11528 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11529 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11530 | } |
| 11531 | { // '(' target ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11532 | if (p->error_indicator) { |
| 11533 | return NULL; |
| 11534 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11535 | Token * _literal; |
| 11536 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11537 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11538 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11539 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11540 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11541 | (a = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11542 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11543 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11544 | ) |
| 11545 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11546 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 11547 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11548 | p->error_indicator = 1; |
| 11549 | return NULL; |
| 11550 | } |
| 11551 | goto done; |
| 11552 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11553 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11554 | } |
| 11555 | { // '(' targets? ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11556 | if (p->error_indicator) { |
| 11557 | return NULL; |
| 11558 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11559 | Token * _literal; |
| 11560 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11561 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11562 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11563 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11564 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11565 | (b = targets_rule(p), 1) // targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11566 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11567 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11568 | ) |
| 11569 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11570 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11571 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11572 | return NULL; |
| 11573 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11574 | int _end_lineno = _token->end_lineno; |
| 11575 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11576 | int _end_col_offset = _token->end_col_offset; |
| 11577 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11578 | _res = _Py_Tuple ( b , Store , EXTRA ); |
| 11579 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11580 | p->error_indicator = 1; |
| 11581 | return NULL; |
| 11582 | } |
| 11583 | goto done; |
| 11584 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11585 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11586 | } |
| 11587 | { // '[' targets? ']' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11588 | if (p->error_indicator) { |
| 11589 | return NULL; |
| 11590 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11591 | Token * _literal; |
| 11592 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11593 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11594 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11595 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11596 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11597 | (b = targets_rule(p), 1) // targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11598 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11599 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11600 | ) |
| 11601 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11602 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 11603 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11604 | return NULL; |
| 11605 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11606 | int _end_lineno = _token->end_lineno; |
| 11607 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 11608 | int _end_col_offset = _token->end_col_offset; |
| 11609 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 11610 | _res = _Py_List ( b , Store , EXTRA ); |
| 11611 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11612 | p->error_indicator = 1; |
| 11613 | return NULL; |
| 11614 | } |
| 11615 | goto done; |
| 11616 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11617 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11618 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11619 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11620 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11621 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11622 | } |
| 11623 | |
| 11624 | // incorrect_arguments: |
| 11625 | // | args ',' '*' |
| 11626 | // | expression for_if_clauses ',' [args | expression for_if_clauses] |
| 11627 | // | args ',' args |
| 11628 | static void * |
| 11629 | incorrect_arguments_rule(Parser *p) |
| 11630 | { |
| 11631 | if (p->error_indicator) { |
| 11632 | return NULL; |
| 11633 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11634 | void * _res = NULL; |
| 11635 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11636 | { // args ',' '*' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11637 | if (p->error_indicator) { |
| 11638 | return NULL; |
| 11639 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11640 | Token * _literal; |
| 11641 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11642 | expr_ty args_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11643 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11644 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11645 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11646 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11647 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11648 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11649 | ) |
| 11650 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11651 | _res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" ); |
| 11652 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11653 | p->error_indicator = 1; |
| 11654 | return NULL; |
| 11655 | } |
| 11656 | goto done; |
| 11657 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11658 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11659 | } |
| 11660 | { // expression for_if_clauses ',' [args | expression for_if_clauses] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11661 | if (p->error_indicator) { |
| 11662 | return NULL; |
| 11663 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11664 | Token * _literal; |
| 11665 | void *_opt_var; |
| 11666 | UNUSED(_opt_var); // Silence compiler warnings |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11667 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11668 | asdl_seq* for_if_clauses_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11669 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11670 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11671 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11672 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11673 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11674 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11675 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11676 | (_opt_var = _tmp_125_rule(p), 1) // [args | expression for_if_clauses] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11677 | ) |
| 11678 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11679 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "Generator expression must be parenthesized" ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11680 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11681 | p->error_indicator = 1; |
| 11682 | return NULL; |
| 11683 | } |
| 11684 | goto done; |
| 11685 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11686 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11687 | } |
| 11688 | { // args ',' args |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11689 | if (p->error_indicator) { |
| 11690 | return NULL; |
| 11691 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11692 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11693 | expr_ty a; |
| 11694 | expr_ty args_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11695 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11696 | (a = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11697 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11698 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11699 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11700 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11701 | ) |
| 11702 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11703 | _res = _PyPegen_arguments_parsing_error ( p , a ); |
| 11704 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11705 | p->error_indicator = 1; |
| 11706 | return NULL; |
| 11707 | } |
| 11708 | goto done; |
| 11709 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11710 | p->mark = _mark; |
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 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11713 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11714 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11715 | } |
| 11716 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 11717 | // invalid_kwarg: expression '=' |
| 11718 | static void * |
| 11719 | invalid_kwarg_rule(Parser *p) |
| 11720 | { |
| 11721 | if (p->error_indicator) { |
| 11722 | return NULL; |
| 11723 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11724 | void * _res = NULL; |
| 11725 | int _mark = p->mark; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 11726 | { // expression '=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11727 | if (p->error_indicator) { |
| 11728 | return NULL; |
| 11729 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11730 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11731 | expr_ty a; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 11732 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11733 | (a = expression_rule(p)) // expression |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 11734 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11735 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 11736 | ) |
| 11737 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11738 | _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] | 11739 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 11740 | p->error_indicator = 1; |
| 11741 | return NULL; |
| 11742 | } |
| 11743 | goto done; |
| 11744 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11745 | p->mark = _mark; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 11746 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11747 | _res = NULL; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 11748 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11749 | return _res; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 11750 | } |
| 11751 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11752 | // invalid_named_expression: expression ':=' expression |
| 11753 | static void * |
| 11754 | invalid_named_expression_rule(Parser *p) |
| 11755 | { |
| 11756 | if (p->error_indicator) { |
| 11757 | return NULL; |
| 11758 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11759 | void * _res = NULL; |
| 11760 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11761 | { // expression ':=' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11762 | if (p->error_indicator) { |
| 11763 | return NULL; |
| 11764 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11765 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11766 | expr_ty a; |
| 11767 | expr_ty expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11768 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11769 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11770 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11771 | (_literal = _PyPegen_expect_token(p, 53)) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11772 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11773 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11774 | ) |
| 11775 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11776 | _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] | 11777 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11778 | p->error_indicator = 1; |
| 11779 | return NULL; |
| 11780 | } |
| 11781 | goto done; |
| 11782 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11783 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11784 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11785 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11786 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11787 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11788 | } |
| 11789 | |
| 11790 | // invalid_assignment: |
| 11791 | // | list ':' |
| 11792 | // | tuple ':' |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11793 | // | star_named_expression ',' star_named_expressions* ':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11794 | // | expression ':' expression ['=' annotated_rhs] |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 11795 | // | star_expressions '=' (yield_expr | star_expressions) |
| 11796 | // | star_expressions augassign (yield_expr | star_expressions) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11797 | static void * |
| 11798 | invalid_assignment_rule(Parser *p) |
| 11799 | { |
| 11800 | if (p->error_indicator) { |
| 11801 | return NULL; |
| 11802 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11803 | void * _res = NULL; |
| 11804 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11805 | { // list ':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11806 | if (p->error_indicator) { |
| 11807 | return NULL; |
| 11808 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11809 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11810 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11811 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11812 | (a = list_rule(p)) // list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11813 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11814 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11815 | ) |
| 11816 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11817 | _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] | 11818 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11819 | p->error_indicator = 1; |
| 11820 | return NULL; |
| 11821 | } |
| 11822 | goto done; |
| 11823 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11824 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11825 | } |
| 11826 | { // tuple ':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11827 | if (p->error_indicator) { |
| 11828 | return NULL; |
| 11829 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11830 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11831 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11832 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11833 | (a = tuple_rule(p)) // tuple |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11834 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11835 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11836 | ) |
| 11837 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11838 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "only single target (not tuple) can be annotated" ); |
| 11839 | if (_res == NULL && PyErr_Occurred()) { |
| 11840 | p->error_indicator = 1; |
| 11841 | return NULL; |
| 11842 | } |
| 11843 | goto done; |
| 11844 | } |
| 11845 | p->mark = _mark; |
| 11846 | } |
| 11847 | { // star_named_expression ',' star_named_expressions* ':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11848 | if (p->error_indicator) { |
| 11849 | return NULL; |
| 11850 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11851 | Token * _literal; |
| 11852 | Token * _literal_1; |
| 11853 | asdl_seq * _loop0_126_var; |
| 11854 | expr_ty a; |
| 11855 | if ( |
| 11856 | (a = star_named_expression_rule(p)) // star_named_expression |
| 11857 | && |
| 11858 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 11859 | && |
| 11860 | (_loop0_126_var = _loop0_126_rule(p)) // star_named_expressions* |
| 11861 | && |
| 11862 | (_literal_1 = _PyPegen_expect_token(p, 11)) // token=':' |
| 11863 | ) |
| 11864 | { |
| 11865 | _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] | 11866 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11867 | p->error_indicator = 1; |
| 11868 | return NULL; |
| 11869 | } |
| 11870 | goto done; |
| 11871 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11872 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11873 | } |
| 11874 | { // expression ':' expression ['=' annotated_rhs] |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11875 | if (p->error_indicator) { |
| 11876 | return NULL; |
| 11877 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11878 | Token * _literal; |
| 11879 | void *_opt_var; |
| 11880 | UNUSED(_opt_var); // Silence compiler warnings |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11881 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11882 | expr_ty expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11883 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11884 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11885 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11886 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11887 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11888 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11889 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11890 | (_opt_var = _tmp_127_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11891 | ) |
| 11892 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11893 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( a , "illegal target for annotation" ); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11894 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11895 | p->error_indicator = 1; |
| 11896 | return NULL; |
| 11897 | } |
| 11898 | goto done; |
| 11899 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11900 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11901 | } |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 11902 | { // star_expressions '=' (yield_expr | star_expressions) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11903 | if (p->error_indicator) { |
| 11904 | return NULL; |
| 11905 | } |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 11906 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 11907 | void *_tmp_128_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11908 | expr_ty a; |
| 11909 | if ( |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 11910 | (a = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11911 | && |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 11912 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
| 11913 | && |
| 11914 | (_tmp_128_var = _tmp_128_rule(p)) // yield_expr | star_expressions |
| 11915 | ) |
| 11916 | { |
| 11917 | _res = RAISE_SYNTAX_ERROR_KNOWN_LOCATION ( _PyPegen_get_invalid_target ( a ) , "cannot assign to %s" , _PyPegen_get_expr_name ( _PyPegen_get_invalid_target ( a ) ) ); |
| 11918 | if (_res == NULL && PyErr_Occurred()) { |
| 11919 | p->error_indicator = 1; |
| 11920 | return NULL; |
| 11921 | } |
| 11922 | goto done; |
| 11923 | } |
| 11924 | p->mark = _mark; |
| 11925 | } |
| 11926 | { // star_expressions augassign (yield_expr | star_expressions) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11927 | if (p->error_indicator) { |
| 11928 | return NULL; |
| 11929 | } |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 11930 | void *_tmp_129_var; |
| 11931 | expr_ty a; |
| 11932 | AugOperator* augassign_var; |
| 11933 | if ( |
| 11934 | (a = star_expressions_rule(p)) // star_expressions |
| 11935 | && |
| 11936 | (augassign_var = augassign_rule(p)) // augassign |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 11937 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11938 | (_tmp_129_var = _tmp_129_rule(p)) // yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11939 | ) |
| 11940 | { |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 11941 | _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] | 11942 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11943 | p->error_indicator = 1; |
| 11944 | return NULL; |
| 11945 | } |
| 11946 | goto done; |
| 11947 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11948 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11949 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11950 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11951 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11952 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11953 | } |
| 11954 | |
| 11955 | // invalid_block: NEWLINE !INDENT |
| 11956 | static void * |
| 11957 | invalid_block_rule(Parser *p) |
| 11958 | { |
| 11959 | if (p->error_indicator) { |
| 11960 | return NULL; |
| 11961 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11962 | void * _res = NULL; |
| 11963 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11964 | { // NEWLINE !INDENT |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11965 | if (p->error_indicator) { |
| 11966 | return NULL; |
| 11967 | } |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11968 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11969 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11970 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11971 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11972 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11973 | ) |
| 11974 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11975 | _res = RAISE_INDENTATION_ERROR ( "expected an indented block" ); |
| 11976 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11977 | p->error_indicator = 1; |
| 11978 | return NULL; |
| 11979 | } |
| 11980 | goto done; |
| 11981 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11982 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11984 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11985 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11986 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11987 | } |
| 11988 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11989 | // invalid_comprehension: ('[' | '(' | '{') starred_expression for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11990 | static void * |
| 11991 | invalid_comprehension_rule(Parser *p) |
| 11992 | { |
| 11993 | if (p->error_indicator) { |
| 11994 | return NULL; |
| 11995 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11996 | void * _res = NULL; |
| 11997 | int _mark = p->mark; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 11998 | { // ('[' | '(' | '{') starred_expression for_if_clauses |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 11999 | if (p->error_indicator) { |
| 12000 | return NULL; |
| 12001 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12002 | void *_tmp_130_var; |
| 12003 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12004 | asdl_seq* for_if_clauses_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12005 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12006 | (_tmp_130_var = _tmp_130_rule(p)) // '[' | '(' | '{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12007 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12008 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12009 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12010 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12011 | ) |
| 12012 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12013 | _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] | 12014 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12015 | p->error_indicator = 1; |
| 12016 | return NULL; |
| 12017 | } |
| 12018 | goto done; |
| 12019 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12020 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12021 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12022 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12023 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12024 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12025 | } |
| 12026 | |
| 12027 | // invalid_parameters: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12028 | // | param_no_default* (slash_with_default | param_with_default+) param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12029 | static void * |
| 12030 | invalid_parameters_rule(Parser *p) |
| 12031 | { |
| 12032 | if (p->error_indicator) { |
| 12033 | return NULL; |
| 12034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12035 | void * _res = NULL; |
| 12036 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12037 | { // param_no_default* (slash_with_default | param_with_default+) param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12038 | if (p->error_indicator) { |
| 12039 | return NULL; |
| 12040 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12041 | asdl_seq * _loop0_131_var; |
| 12042 | void *_tmp_132_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12043 | arg_ty param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12044 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12045 | (_loop0_131_var = _loop0_131_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12046 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12047 | (_tmp_132_var = _tmp_132_rule(p)) // slash_with_default | param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12048 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12049 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12050 | ) |
| 12051 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12052 | _res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" ); |
| 12053 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12054 | p->error_indicator = 1; |
| 12055 | return NULL; |
| 12056 | } |
| 12057 | goto done; |
| 12058 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12059 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12060 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12061 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12062 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12063 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12064 | } |
| 12065 | |
Lysandros Nikolaou | 75b863a | 2020-05-18 22:14:47 +0300 | [diff] [blame] | 12066 | // invalid_star_etc: '*' (')' | ',' (')' | '**')) | '*' ',' TYPE_COMMENT |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12067 | static void * |
| 12068 | invalid_star_etc_rule(Parser *p) |
| 12069 | { |
| 12070 | if (p->error_indicator) { |
| 12071 | return NULL; |
| 12072 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12073 | void * _res = NULL; |
| 12074 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12075 | { // '*' (')' | ',' (')' | '**')) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12076 | if (p->error_indicator) { |
| 12077 | return NULL; |
| 12078 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12079 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12080 | void *_tmp_133_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12081 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12082 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12083 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12084 | (_tmp_133_var = _tmp_133_rule(p)) // ')' | ',' (')' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12085 | ) |
| 12086 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12087 | _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); |
| 12088 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12089 | p->error_indicator = 1; |
| 12090 | return NULL; |
| 12091 | } |
| 12092 | goto done; |
| 12093 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12094 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12095 | } |
Lysandros Nikolaou | 75b863a | 2020-05-18 22:14:47 +0300 | [diff] [blame] | 12096 | { // '*' ',' TYPE_COMMENT |
Pablo Galindo | ced4e5c | 2020-05-18 22:47:51 +0100 | [diff] [blame] | 12097 | if (p->error_indicator) { |
| 12098 | return NULL; |
| 12099 | } |
Lysandros Nikolaou | 75b863a | 2020-05-18 22:14:47 +0300 | [diff] [blame] | 12100 | Token * _literal; |
| 12101 | Token * _literal_1; |
| 12102 | Token * type_comment_var; |
| 12103 | if ( |
| 12104 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
| 12105 | && |
| 12106 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
| 12107 | && |
| 12108 | (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
| 12109 | ) |
| 12110 | { |
| 12111 | _res = RAISE_SYNTAX_ERROR ( "bare * has associated type comment" ); |
| 12112 | if (_res == NULL && PyErr_Occurred()) { |
| 12113 | p->error_indicator = 1; |
| 12114 | return NULL; |
| 12115 | } |
| 12116 | goto done; |
| 12117 | } |
| 12118 | p->mark = _mark; |
| 12119 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12120 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12121 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12122 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12123 | } |
| 12124 | |
| 12125 | // invalid_lambda_star_etc: '*' (':' | ',' (':' | '**')) |
| 12126 | static void * |
| 12127 | invalid_lambda_star_etc_rule(Parser *p) |
| 12128 | { |
| 12129 | if (p->error_indicator) { |
| 12130 | return NULL; |
| 12131 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12132 | void * _res = NULL; |
| 12133 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12134 | { // '*' (':' | ',' (':' | '**')) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12135 | if (p->error_indicator) { |
| 12136 | return NULL; |
| 12137 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12138 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12139 | void *_tmp_134_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12140 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12141 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12142 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12143 | (_tmp_134_var = _tmp_134_rule(p)) // ':' | ',' (':' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12144 | ) |
| 12145 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12146 | _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); |
| 12147 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12148 | p->error_indicator = 1; |
| 12149 | return NULL; |
| 12150 | } |
| 12151 | goto done; |
| 12152 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12153 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12154 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12155 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12156 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12157 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12158 | } |
| 12159 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12160 | // invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
| 12161 | static void * |
| 12162 | invalid_double_type_comments_rule(Parser *p) |
| 12163 | { |
| 12164 | if (p->error_indicator) { |
| 12165 | return NULL; |
| 12166 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12167 | void * _res = NULL; |
| 12168 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12169 | { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12170 | if (p->error_indicator) { |
| 12171 | return NULL; |
| 12172 | } |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12173 | Token * indent_var; |
| 12174 | Token * newline_var; |
| 12175 | Token * newline_var_1; |
| 12176 | Token * type_comment_var; |
| 12177 | Token * type_comment_var_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12178 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12179 | (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] | 12180 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12181 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12182 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12183 | (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] | 12184 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12185 | (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12186 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12187 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12188 | ) |
| 12189 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12190 | _res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" ); |
| 12191 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12192 | p->error_indicator = 1; |
| 12193 | return NULL; |
| 12194 | } |
| 12195 | goto done; |
| 12196 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12197 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12198 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12199 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12200 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12201 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12202 | } |
| 12203 | |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 12204 | // invalid_del_target: star_expression &del_target_end |
| 12205 | static void * |
| 12206 | invalid_del_target_rule(Parser *p) |
| 12207 | { |
| 12208 | if (p->error_indicator) { |
| 12209 | return NULL; |
| 12210 | } |
| 12211 | void * _res = NULL; |
| 12212 | int _mark = p->mark; |
| 12213 | { // star_expression &del_target_end |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12214 | if (p->error_indicator) { |
| 12215 | return NULL; |
| 12216 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 12217 | expr_ty a; |
| 12218 | if ( |
| 12219 | (a = star_expression_rule(p)) // star_expression |
| 12220 | && |
| 12221 | _PyPegen_lookahead(1, del_target_end_rule, p) |
| 12222 | ) |
| 12223 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 12224 | _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] | 12225 | if (_res == NULL && PyErr_Occurred()) { |
| 12226 | p->error_indicator = 1; |
| 12227 | return NULL; |
| 12228 | } |
| 12229 | goto done; |
| 12230 | } |
| 12231 | p->mark = _mark; |
| 12232 | } |
| 12233 | _res = NULL; |
| 12234 | done: |
| 12235 | return _res; |
| 12236 | } |
| 12237 | |
Batuhan Taskaya | 72e0aa2 | 2020-05-21 23:41:58 +0300 | [diff] [blame^] | 12238 | // invalid_import_from_targets: import_from_as_names ',' |
| 12239 | static void * |
| 12240 | invalid_import_from_targets_rule(Parser *p) |
| 12241 | { |
| 12242 | if (p->error_indicator) { |
| 12243 | return NULL; |
| 12244 | } |
| 12245 | void * _res = NULL; |
| 12246 | int _mark = p->mark; |
| 12247 | { // import_from_as_names ',' |
| 12248 | if (p->error_indicator) { |
| 12249 | return NULL; |
| 12250 | } |
| 12251 | Token * _literal; |
| 12252 | asdl_seq* import_from_as_names_var; |
| 12253 | if ( |
| 12254 | (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names |
| 12255 | && |
| 12256 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 12257 | ) |
| 12258 | { |
| 12259 | _res = RAISE_SYNTAX_ERROR ( "trailing comma not allowed without surrounding parentheses" ); |
| 12260 | if (_res == NULL && PyErr_Occurred()) { |
| 12261 | p->error_indicator = 1; |
| 12262 | return NULL; |
| 12263 | } |
| 12264 | goto done; |
| 12265 | } |
| 12266 | p->mark = _mark; |
| 12267 | } |
| 12268 | _res = NULL; |
| 12269 | done: |
| 12270 | return _res; |
| 12271 | } |
| 12272 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12273 | // _loop0_1: NEWLINE |
| 12274 | static asdl_seq * |
| 12275 | _loop0_1_rule(Parser *p) |
| 12276 | { |
| 12277 | if (p->error_indicator) { |
| 12278 | return NULL; |
| 12279 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12280 | void *_res = NULL; |
| 12281 | int _mark = p->mark; |
| 12282 | int _start_mark = p->mark; |
| 12283 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12284 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12285 | p->error_indicator = 1; |
| 12286 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12287 | return NULL; |
| 12288 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12289 | ssize_t _children_capacity = 1; |
| 12290 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12291 | { // NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12292 | if (p->error_indicator) { |
| 12293 | return NULL; |
| 12294 | } |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12295 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12296 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12297 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12298 | ) |
| 12299 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12300 | _res = newline_var; |
| 12301 | if (_n == _children_capacity) { |
| 12302 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12303 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12304 | if (!_new_children) { |
| 12305 | p->error_indicator = 1; |
| 12306 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12307 | return NULL; |
| 12308 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12309 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12310 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12311 | _children[_n++] = _res; |
| 12312 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12313 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12314 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12315 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12316 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12317 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12318 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12319 | p->error_indicator = 1; |
| 12320 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12321 | return NULL; |
| 12322 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12323 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12324 | PyMem_Free(_children); |
| 12325 | _PyPegen_insert_memo(p, _start_mark, _loop0_1_type, _seq); |
| 12326 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12327 | } |
| 12328 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12329 | // _loop0_2: NEWLINE |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12330 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12331 | _loop0_2_rule(Parser *p) |
| 12332 | { |
| 12333 | if (p->error_indicator) { |
| 12334 | return NULL; |
| 12335 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12336 | void *_res = NULL; |
| 12337 | int _mark = p->mark; |
| 12338 | int _start_mark = p->mark; |
| 12339 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12340 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12341 | p->error_indicator = 1; |
| 12342 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12343 | return NULL; |
| 12344 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12345 | ssize_t _children_capacity = 1; |
| 12346 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12347 | { // NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12348 | if (p->error_indicator) { |
| 12349 | return NULL; |
| 12350 | } |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12351 | Token * newline_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12352 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12353 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12354 | ) |
| 12355 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12356 | _res = newline_var; |
| 12357 | if (_n == _children_capacity) { |
| 12358 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12359 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12360 | if (!_new_children) { |
| 12361 | p->error_indicator = 1; |
| 12362 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12363 | return NULL; |
| 12364 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12365 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12366 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12367 | _children[_n++] = _res; |
| 12368 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12369 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12370 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12371 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12372 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12373 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12374 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12375 | p->error_indicator = 1; |
| 12376 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12377 | return NULL; |
| 12378 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12379 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12380 | PyMem_Free(_children); |
| 12381 | _PyPegen_insert_memo(p, _start_mark, _loop0_2_type, _seq); |
| 12382 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12383 | } |
| 12384 | |
| 12385 | // _loop0_4: ',' expression |
| 12386 | static asdl_seq * |
| 12387 | _loop0_4_rule(Parser *p) |
| 12388 | { |
| 12389 | if (p->error_indicator) { |
| 12390 | return NULL; |
| 12391 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12392 | void *_res = NULL; |
| 12393 | int _mark = p->mark; |
| 12394 | int _start_mark = p->mark; |
| 12395 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12396 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12397 | p->error_indicator = 1; |
| 12398 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12399 | return NULL; |
| 12400 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12401 | ssize_t _children_capacity = 1; |
| 12402 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12403 | { // ',' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12404 | if (p->error_indicator) { |
| 12405 | return NULL; |
| 12406 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12407 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12408 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12409 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12410 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12411 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12412 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12413 | ) |
| 12414 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12415 | _res = elem; |
| 12416 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12417 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12418 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12419 | return NULL; |
| 12420 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12421 | if (_n == _children_capacity) { |
| 12422 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12423 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12424 | if (!_new_children) { |
| 12425 | p->error_indicator = 1; |
| 12426 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12427 | return NULL; |
| 12428 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12429 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12430 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12431 | _children[_n++] = _res; |
| 12432 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12433 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12434 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12435 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12436 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12437 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12438 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12439 | p->error_indicator = 1; |
| 12440 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12441 | return NULL; |
| 12442 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12443 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12444 | PyMem_Free(_children); |
| 12445 | _PyPegen_insert_memo(p, _start_mark, _loop0_4_type, _seq); |
| 12446 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12447 | } |
| 12448 | |
| 12449 | // _gather_3: expression _loop0_4 |
| 12450 | static asdl_seq * |
| 12451 | _gather_3_rule(Parser *p) |
| 12452 | { |
| 12453 | if (p->error_indicator) { |
| 12454 | return NULL; |
| 12455 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12456 | asdl_seq * _res = NULL; |
| 12457 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12458 | { // expression _loop0_4 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12459 | if (p->error_indicator) { |
| 12460 | return NULL; |
| 12461 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12462 | expr_ty elem; |
| 12463 | asdl_seq * seq; |
| 12464 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12465 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12466 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12467 | (seq = _loop0_4_rule(p)) // _loop0_4 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12468 | ) |
| 12469 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12470 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12471 | goto done; |
| 12472 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12473 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12474 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12475 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12476 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12477 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12478 | } |
| 12479 | |
| 12480 | // _loop0_6: ',' expression |
| 12481 | static asdl_seq * |
| 12482 | _loop0_6_rule(Parser *p) |
| 12483 | { |
| 12484 | if (p->error_indicator) { |
| 12485 | return NULL; |
| 12486 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12487 | void *_res = NULL; |
| 12488 | int _mark = p->mark; |
| 12489 | int _start_mark = p->mark; |
| 12490 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12491 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12492 | p->error_indicator = 1; |
| 12493 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12494 | return NULL; |
| 12495 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12496 | ssize_t _children_capacity = 1; |
| 12497 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12498 | { // ',' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12499 | if (p->error_indicator) { |
| 12500 | return NULL; |
| 12501 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12502 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12503 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12504 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12505 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12506 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12507 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12508 | ) |
| 12509 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12510 | _res = elem; |
| 12511 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12512 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12513 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12514 | return NULL; |
| 12515 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12516 | if (_n == _children_capacity) { |
| 12517 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12518 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12519 | if (!_new_children) { |
| 12520 | p->error_indicator = 1; |
| 12521 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12522 | return NULL; |
| 12523 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12524 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12525 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12526 | _children[_n++] = _res; |
| 12527 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12528 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12529 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12530 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12531 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12532 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12533 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12534 | p->error_indicator = 1; |
| 12535 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12536 | return NULL; |
| 12537 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12538 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12539 | PyMem_Free(_children); |
| 12540 | _PyPegen_insert_memo(p, _start_mark, _loop0_6_type, _seq); |
| 12541 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12542 | } |
| 12543 | |
| 12544 | // _gather_5: expression _loop0_6 |
| 12545 | static asdl_seq * |
| 12546 | _gather_5_rule(Parser *p) |
| 12547 | { |
| 12548 | if (p->error_indicator) { |
| 12549 | return NULL; |
| 12550 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12551 | asdl_seq * _res = NULL; |
| 12552 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12553 | { // expression _loop0_6 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12554 | if (p->error_indicator) { |
| 12555 | return NULL; |
| 12556 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12557 | expr_ty elem; |
| 12558 | asdl_seq * seq; |
| 12559 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12560 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12561 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12562 | (seq = _loop0_6_rule(p)) // _loop0_6 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12563 | ) |
| 12564 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12565 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12566 | goto done; |
| 12567 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12568 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12569 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12570 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12571 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12572 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12573 | } |
| 12574 | |
| 12575 | // _loop0_8: ',' expression |
| 12576 | static asdl_seq * |
| 12577 | _loop0_8_rule(Parser *p) |
| 12578 | { |
| 12579 | if (p->error_indicator) { |
| 12580 | return NULL; |
| 12581 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12582 | void *_res = NULL; |
| 12583 | int _mark = p->mark; |
| 12584 | int _start_mark = p->mark; |
| 12585 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12586 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12587 | p->error_indicator = 1; |
| 12588 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12589 | return NULL; |
| 12590 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12591 | ssize_t _children_capacity = 1; |
| 12592 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12593 | { // ',' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12594 | if (p->error_indicator) { |
| 12595 | return NULL; |
| 12596 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12597 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12598 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12599 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12600 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12601 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12602 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12603 | ) |
| 12604 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12605 | _res = elem; |
| 12606 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12607 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12608 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12609 | return NULL; |
| 12610 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12611 | if (_n == _children_capacity) { |
| 12612 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12613 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12614 | if (!_new_children) { |
| 12615 | p->error_indicator = 1; |
| 12616 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12617 | return NULL; |
| 12618 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12619 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12620 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12621 | _children[_n++] = _res; |
| 12622 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12623 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12624 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12625 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12626 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12627 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12628 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12629 | p->error_indicator = 1; |
| 12630 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12631 | return NULL; |
| 12632 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12633 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12634 | PyMem_Free(_children); |
| 12635 | _PyPegen_insert_memo(p, _start_mark, _loop0_8_type, _seq); |
| 12636 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12637 | } |
| 12638 | |
| 12639 | // _gather_7: expression _loop0_8 |
| 12640 | static asdl_seq * |
| 12641 | _gather_7_rule(Parser *p) |
| 12642 | { |
| 12643 | if (p->error_indicator) { |
| 12644 | return NULL; |
| 12645 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12646 | asdl_seq * _res = NULL; |
| 12647 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12648 | { // expression _loop0_8 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12649 | if (p->error_indicator) { |
| 12650 | return NULL; |
| 12651 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12652 | expr_ty elem; |
| 12653 | asdl_seq * seq; |
| 12654 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12655 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12656 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12657 | (seq = _loop0_8_rule(p)) // _loop0_8 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12658 | ) |
| 12659 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12660 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12661 | goto done; |
| 12662 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12663 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12664 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12665 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12666 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12667 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12668 | } |
| 12669 | |
| 12670 | // _loop0_10: ',' expression |
| 12671 | static asdl_seq * |
| 12672 | _loop0_10_rule(Parser *p) |
| 12673 | { |
| 12674 | if (p->error_indicator) { |
| 12675 | return NULL; |
| 12676 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12677 | void *_res = NULL; |
| 12678 | int _mark = p->mark; |
| 12679 | int _start_mark = p->mark; |
| 12680 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12681 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12682 | p->error_indicator = 1; |
| 12683 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12684 | return NULL; |
| 12685 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12686 | ssize_t _children_capacity = 1; |
| 12687 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12688 | { // ',' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12689 | if (p->error_indicator) { |
| 12690 | return NULL; |
| 12691 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12692 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12693 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12694 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12695 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12696 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12697 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12698 | ) |
| 12699 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12700 | _res = elem; |
| 12701 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12702 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12703 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12704 | return NULL; |
| 12705 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12706 | if (_n == _children_capacity) { |
| 12707 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12708 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12709 | if (!_new_children) { |
| 12710 | p->error_indicator = 1; |
| 12711 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12712 | return NULL; |
| 12713 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12714 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12715 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12716 | _children[_n++] = _res; |
| 12717 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12718 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12719 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12720 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12721 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12722 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12723 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12724 | p->error_indicator = 1; |
| 12725 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12726 | return NULL; |
| 12727 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12728 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12729 | PyMem_Free(_children); |
| 12730 | _PyPegen_insert_memo(p, _start_mark, _loop0_10_type, _seq); |
| 12731 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12732 | } |
| 12733 | |
| 12734 | // _gather_9: expression _loop0_10 |
| 12735 | static asdl_seq * |
| 12736 | _gather_9_rule(Parser *p) |
| 12737 | { |
| 12738 | if (p->error_indicator) { |
| 12739 | return NULL; |
| 12740 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12741 | asdl_seq * _res = NULL; |
| 12742 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12743 | { // expression _loop0_10 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12744 | if (p->error_indicator) { |
| 12745 | return NULL; |
| 12746 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12747 | expr_ty elem; |
| 12748 | asdl_seq * seq; |
| 12749 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12750 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12751 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12752 | (seq = _loop0_10_rule(p)) // _loop0_10 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12753 | ) |
| 12754 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12755 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12756 | goto done; |
| 12757 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12758 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12759 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12760 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12761 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12762 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12763 | } |
| 12764 | |
| 12765 | // _loop1_11: statement |
| 12766 | static asdl_seq * |
| 12767 | _loop1_11_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12768 | { |
| 12769 | if (p->error_indicator) { |
| 12770 | return NULL; |
| 12771 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12772 | void *_res = NULL; |
| 12773 | int _mark = p->mark; |
| 12774 | int _start_mark = p->mark; |
| 12775 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12776 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12777 | p->error_indicator = 1; |
| 12778 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12779 | return NULL; |
| 12780 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12781 | ssize_t _children_capacity = 1; |
| 12782 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12783 | { // statement |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12784 | if (p->error_indicator) { |
| 12785 | return NULL; |
| 12786 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12787 | asdl_seq* statement_var; |
| 12788 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12789 | (statement_var = statement_rule(p)) // statement |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12790 | ) |
| 12791 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12792 | _res = statement_var; |
| 12793 | if (_n == _children_capacity) { |
| 12794 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12795 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12796 | if (!_new_children) { |
| 12797 | p->error_indicator = 1; |
| 12798 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12799 | return NULL; |
| 12800 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12801 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12802 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12803 | _children[_n++] = _res; |
| 12804 | _mark = p->mark; |
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 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12807 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12808 | if (_n == 0 || p->error_indicator) { |
| 12809 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12810 | return NULL; |
| 12811 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12812 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12813 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12814 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12815 | p->error_indicator = 1; |
| 12816 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12817 | return NULL; |
| 12818 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12819 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12820 | PyMem_Free(_children); |
| 12821 | _PyPegen_insert_memo(p, _start_mark, _loop1_11_type, _seq); |
| 12822 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12823 | } |
| 12824 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12825 | // _loop0_13: ';' small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12826 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12827 | _loop0_13_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12828 | { |
| 12829 | if (p->error_indicator) { |
| 12830 | return NULL; |
| 12831 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12832 | void *_res = NULL; |
| 12833 | int _mark = p->mark; |
| 12834 | int _start_mark = p->mark; |
| 12835 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12836 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12837 | p->error_indicator = 1; |
| 12838 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12839 | return NULL; |
| 12840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12841 | ssize_t _children_capacity = 1; |
| 12842 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12843 | { // ';' small_stmt |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12844 | if (p->error_indicator) { |
| 12845 | return NULL; |
| 12846 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12847 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12848 | stmt_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12849 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12850 | (_literal = _PyPegen_expect_token(p, 13)) // token=';' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12851 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12852 | (elem = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12853 | ) |
| 12854 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12855 | _res = elem; |
| 12856 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12857 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12858 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12859 | return NULL; |
| 12860 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12861 | if (_n == _children_capacity) { |
| 12862 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12863 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12864 | if (!_new_children) { |
| 12865 | p->error_indicator = 1; |
| 12866 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12867 | return NULL; |
| 12868 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12869 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12870 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12871 | _children[_n++] = _res; |
| 12872 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12873 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12874 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12875 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12876 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12877 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12878 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 12879 | p->error_indicator = 1; |
| 12880 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12881 | return NULL; |
| 12882 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12883 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12884 | PyMem_Free(_children); |
| 12885 | _PyPegen_insert_memo(p, _start_mark, _loop0_13_type, _seq); |
| 12886 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12887 | } |
| 12888 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12889 | // _gather_12: small_stmt _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12890 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12891 | _gather_12_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12892 | { |
| 12893 | if (p->error_indicator) { |
| 12894 | return NULL; |
| 12895 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12896 | asdl_seq * _res = NULL; |
| 12897 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12898 | { // small_stmt _loop0_13 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12899 | if (p->error_indicator) { |
| 12900 | return NULL; |
| 12901 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12902 | stmt_ty elem; |
| 12903 | asdl_seq * seq; |
| 12904 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12905 | (elem = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12906 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12907 | (seq = _loop0_13_rule(p)) // _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12908 | ) |
| 12909 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12910 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12911 | goto done; |
| 12912 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12913 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12914 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12915 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12916 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12917 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12918 | } |
| 12919 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12920 | // _tmp_14: 'import' | 'from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12921 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12922 | _tmp_14_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12923 | { |
| 12924 | if (p->error_indicator) { |
| 12925 | return NULL; |
| 12926 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12927 | void * _res = NULL; |
| 12928 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12929 | { // 'import' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12930 | if (p->error_indicator) { |
| 12931 | return NULL; |
| 12932 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12933 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12934 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12935 | (_keyword = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12936 | ) |
| 12937 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12938 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12939 | goto done; |
| 12940 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12941 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12942 | } |
| 12943 | { // 'from' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12944 | if (p->error_indicator) { |
| 12945 | return NULL; |
| 12946 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12947 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12948 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12949 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12950 | ) |
| 12951 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12952 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12953 | goto done; |
| 12954 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12955 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12957 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12958 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12959 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12960 | } |
| 12961 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12962 | // _tmp_15: 'def' | '@' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12963 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12964 | _tmp_15_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12965 | { |
| 12966 | if (p->error_indicator) { |
| 12967 | return NULL; |
| 12968 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12969 | void * _res = NULL; |
| 12970 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12971 | { // 'def' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12972 | if (p->error_indicator) { |
| 12973 | return NULL; |
| 12974 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12975 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12976 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12977 | (_keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12978 | ) |
| 12979 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12980 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12981 | goto done; |
| 12982 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12983 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12984 | } |
| 12985 | { // '@' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 12986 | if (p->error_indicator) { |
| 12987 | return NULL; |
| 12988 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12989 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12990 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12991 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12992 | ) |
| 12993 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12994 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12995 | goto done; |
| 12996 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12997 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12998 | } |
| 12999 | { // ASYNC |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13000 | if (p->error_indicator) { |
| 13001 | return NULL; |
| 13002 | } |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13003 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13004 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13005 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13006 | ) |
| 13007 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13008 | _res = async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13009 | goto done; |
| 13010 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13011 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13012 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13013 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13014 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13015 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13016 | } |
| 13017 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13018 | // _tmp_16: 'class' | '@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13019 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13020 | _tmp_16_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13021 | { |
| 13022 | if (p->error_indicator) { |
| 13023 | return NULL; |
| 13024 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13025 | void * _res = NULL; |
| 13026 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13027 | { // 'class' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13028 | if (p->error_indicator) { |
| 13029 | return NULL; |
| 13030 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13031 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13032 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13033 | (_keyword = _PyPegen_expect_token(p, 523)) // token='class' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13034 | ) |
| 13035 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13036 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13037 | goto done; |
| 13038 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13039 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13040 | } |
| 13041 | { // '@' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13042 | if (p->error_indicator) { |
| 13043 | return NULL; |
| 13044 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13045 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13046 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13047 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13048 | ) |
| 13049 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13050 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13051 | goto done; |
| 13052 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13053 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13054 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13055 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13056 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13057 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13058 | } |
| 13059 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13060 | // _tmp_17: 'with' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13061 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13062 | _tmp_17_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13063 | { |
| 13064 | if (p->error_indicator) { |
| 13065 | return NULL; |
| 13066 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13067 | void * _res = NULL; |
| 13068 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13069 | { // 'with' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13070 | if (p->error_indicator) { |
| 13071 | return NULL; |
| 13072 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13073 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13074 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13075 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13076 | ) |
| 13077 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13078 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13079 | goto done; |
| 13080 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13081 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13082 | } |
| 13083 | { // ASYNC |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13084 | if (p->error_indicator) { |
| 13085 | return NULL; |
| 13086 | } |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13087 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13088 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13089 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13090 | ) |
| 13091 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13092 | _res = async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13093 | goto done; |
| 13094 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13095 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13096 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13097 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13098 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13099 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13100 | } |
| 13101 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13102 | // _tmp_18: 'for' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13103 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13104 | _tmp_18_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13105 | { |
| 13106 | if (p->error_indicator) { |
| 13107 | return NULL; |
| 13108 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13109 | void * _res = NULL; |
| 13110 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13111 | { // 'for' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13112 | if (p->error_indicator) { |
| 13113 | return NULL; |
| 13114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13115 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13116 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13117 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13118 | ) |
| 13119 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13120 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13121 | goto done; |
| 13122 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13123 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13124 | } |
| 13125 | { // ASYNC |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13126 | if (p->error_indicator) { |
| 13127 | return NULL; |
| 13128 | } |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13129 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13130 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13131 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13132 | ) |
| 13133 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13134 | _res = async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13135 | goto done; |
| 13136 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13137 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13138 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13139 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13140 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13141 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13142 | } |
| 13143 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13144 | // _tmp_19: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13145 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13146 | _tmp_19_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13147 | { |
| 13148 | if (p->error_indicator) { |
| 13149 | return NULL; |
| 13150 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13151 | void * _res = NULL; |
| 13152 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13153 | { // '=' annotated_rhs |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13154 | if (p->error_indicator) { |
| 13155 | return NULL; |
| 13156 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13157 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13158 | expr_ty d; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13159 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13160 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13161 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13162 | (d = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13163 | ) |
| 13164 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13165 | _res = d; |
| 13166 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13167 | p->error_indicator = 1; |
| 13168 | return NULL; |
| 13169 | } |
| 13170 | goto done; |
| 13171 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13172 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13173 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13174 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13175 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13176 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13177 | } |
| 13178 | |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13179 | // _tmp_20: '(' single_target ')' | single_subscript_attribute_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13180 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13181 | _tmp_20_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13182 | { |
| 13183 | if (p->error_indicator) { |
| 13184 | return NULL; |
| 13185 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13186 | void * _res = NULL; |
| 13187 | int _mark = p->mark; |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13188 | { // '(' single_target ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13189 | if (p->error_indicator) { |
| 13190 | return NULL; |
| 13191 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13192 | Token * _literal; |
| 13193 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13194 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13195 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13196 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13197 | && |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13198 | (b = single_target_rule(p)) // single_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13199 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13200 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13201 | ) |
| 13202 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13203 | _res = b; |
| 13204 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13205 | p->error_indicator = 1; |
| 13206 | return NULL; |
| 13207 | } |
| 13208 | goto done; |
| 13209 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13210 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13211 | } |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13212 | { // single_subscript_attribute_target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13213 | if (p->error_indicator) { |
| 13214 | return NULL; |
| 13215 | } |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13216 | expr_ty single_subscript_attribute_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13217 | if ( |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13218 | (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] | 13219 | ) |
| 13220 | { |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 13221 | _res = single_subscript_attribute_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13222 | goto done; |
| 13223 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13224 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13225 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13226 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13227 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13228 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13229 | } |
| 13230 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13231 | // _tmp_21: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13232 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13233 | _tmp_21_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13234 | { |
| 13235 | if (p->error_indicator) { |
| 13236 | return NULL; |
| 13237 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13238 | void * _res = NULL; |
| 13239 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13240 | { // '=' annotated_rhs |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13241 | if (p->error_indicator) { |
| 13242 | return NULL; |
| 13243 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13244 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13245 | expr_ty d; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13246 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13247 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13248 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13249 | (d = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13250 | ) |
| 13251 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13252 | _res = d; |
| 13253 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13254 | p->error_indicator = 1; |
| 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 | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13260 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13261 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13262 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13263 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13264 | } |
| 13265 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13266 | // _loop1_22: (star_targets '=') |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13267 | static asdl_seq * |
| 13268 | _loop1_22_rule(Parser *p) |
| 13269 | { |
| 13270 | if (p->error_indicator) { |
| 13271 | return NULL; |
| 13272 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13273 | void *_res = NULL; |
| 13274 | int _mark = p->mark; |
| 13275 | int _start_mark = p->mark; |
| 13276 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13277 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13278 | p->error_indicator = 1; |
| 13279 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13280 | return NULL; |
| 13281 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13282 | ssize_t _children_capacity = 1; |
| 13283 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13284 | { // (star_targets '=') |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13285 | if (p->error_indicator) { |
| 13286 | return NULL; |
| 13287 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 13288 | void *_tmp_135_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13289 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 13290 | (_tmp_135_var = _tmp_135_rule(p)) // star_targets '=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13291 | ) |
| 13292 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 13293 | _res = _tmp_135_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13294 | if (_n == _children_capacity) { |
| 13295 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13296 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13297 | if (!_new_children) { |
| 13298 | p->error_indicator = 1; |
| 13299 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13300 | return NULL; |
| 13301 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13302 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13303 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13304 | _children[_n++] = _res; |
| 13305 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13306 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13307 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13308 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13309 | if (_n == 0 || p->error_indicator) { |
| 13310 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13311 | return NULL; |
| 13312 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13313 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13314 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13315 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13316 | p->error_indicator = 1; |
| 13317 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13318 | return NULL; |
| 13319 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13320 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13321 | PyMem_Free(_children); |
| 13322 | _PyPegen_insert_memo(p, _start_mark, _loop1_22_type, _seq); |
| 13323 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13324 | } |
| 13325 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13326 | // _tmp_23: yield_expr | star_expressions |
| 13327 | static void * |
| 13328 | _tmp_23_rule(Parser *p) |
| 13329 | { |
| 13330 | if (p->error_indicator) { |
| 13331 | return NULL; |
| 13332 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13333 | void * _res = NULL; |
| 13334 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13335 | { // yield_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13336 | if (p->error_indicator) { |
| 13337 | return NULL; |
| 13338 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13339 | expr_ty yield_expr_var; |
| 13340 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13341 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13342 | ) |
| 13343 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13344 | _res = yield_expr_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13345 | goto done; |
| 13346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13347 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13348 | } |
| 13349 | { // star_expressions |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13350 | if (p->error_indicator) { |
| 13351 | return NULL; |
| 13352 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13353 | expr_ty star_expressions_var; |
| 13354 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13355 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13356 | ) |
| 13357 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13358 | _res = star_expressions_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13359 | goto done; |
| 13360 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13361 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13362 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13363 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13364 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13365 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13366 | } |
| 13367 | |
| 13368 | // _tmp_24: yield_expr | star_expressions |
| 13369 | static void * |
| 13370 | _tmp_24_rule(Parser *p) |
| 13371 | { |
| 13372 | if (p->error_indicator) { |
| 13373 | return NULL; |
| 13374 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13375 | void * _res = NULL; |
| 13376 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13377 | { // yield_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13378 | if (p->error_indicator) { |
| 13379 | return NULL; |
| 13380 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13381 | expr_ty yield_expr_var; |
| 13382 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13383 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13384 | ) |
| 13385 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13386 | _res = yield_expr_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13387 | goto done; |
| 13388 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13389 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13390 | } |
| 13391 | { // star_expressions |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13392 | if (p->error_indicator) { |
| 13393 | return NULL; |
| 13394 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13395 | expr_ty star_expressions_var; |
| 13396 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13397 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13398 | ) |
| 13399 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13400 | _res = star_expressions_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13401 | goto done; |
| 13402 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13403 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13404 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13405 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13406 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13407 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13408 | } |
| 13409 | |
| 13410 | // _loop0_26: ',' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13411 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13412 | _loop0_26_rule(Parser *p) |
| 13413 | { |
| 13414 | if (p->error_indicator) { |
| 13415 | return NULL; |
| 13416 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13417 | void *_res = NULL; |
| 13418 | int _mark = p->mark; |
| 13419 | int _start_mark = p->mark; |
| 13420 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13421 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13422 | p->error_indicator = 1; |
| 13423 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13424 | return NULL; |
| 13425 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13426 | ssize_t _children_capacity = 1; |
| 13427 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13428 | { // ',' NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13429 | if (p->error_indicator) { |
| 13430 | return NULL; |
| 13431 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13432 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13433 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13434 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13435 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13436 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13437 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13438 | ) |
| 13439 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13440 | _res = elem; |
| 13441 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13442 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13443 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13444 | return NULL; |
| 13445 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13446 | if (_n == _children_capacity) { |
| 13447 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13448 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13449 | if (!_new_children) { |
| 13450 | p->error_indicator = 1; |
| 13451 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13452 | return NULL; |
| 13453 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13454 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13455 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13456 | _children[_n++] = _res; |
| 13457 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13458 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13459 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13460 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13461 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13462 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13463 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13464 | p->error_indicator = 1; |
| 13465 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13466 | return NULL; |
| 13467 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13468 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13469 | PyMem_Free(_children); |
| 13470 | _PyPegen_insert_memo(p, _start_mark, _loop0_26_type, _seq); |
| 13471 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13472 | } |
| 13473 | |
| 13474 | // _gather_25: NAME _loop0_26 |
| 13475 | static asdl_seq * |
| 13476 | _gather_25_rule(Parser *p) |
| 13477 | { |
| 13478 | if (p->error_indicator) { |
| 13479 | return NULL; |
| 13480 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13481 | asdl_seq * _res = NULL; |
| 13482 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13483 | { // NAME _loop0_26 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13484 | if (p->error_indicator) { |
| 13485 | return NULL; |
| 13486 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13487 | expr_ty elem; |
| 13488 | asdl_seq * seq; |
| 13489 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13490 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13491 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13492 | (seq = _loop0_26_rule(p)) // _loop0_26 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13493 | ) |
| 13494 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13495 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13496 | goto done; |
| 13497 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13498 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13499 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13500 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13501 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13502 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13503 | } |
| 13504 | |
| 13505 | // _loop0_28: ',' NAME |
| 13506 | static asdl_seq * |
| 13507 | _loop0_28_rule(Parser *p) |
| 13508 | { |
| 13509 | if (p->error_indicator) { |
| 13510 | return NULL; |
| 13511 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13512 | void *_res = NULL; |
| 13513 | int _mark = p->mark; |
| 13514 | int _start_mark = p->mark; |
| 13515 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13516 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13517 | p->error_indicator = 1; |
| 13518 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13519 | return NULL; |
| 13520 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13521 | ssize_t _children_capacity = 1; |
| 13522 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13523 | { // ',' NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13524 | if (p->error_indicator) { |
| 13525 | return NULL; |
| 13526 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13527 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13528 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13529 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13530 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13531 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13532 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13533 | ) |
| 13534 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13535 | _res = elem; |
| 13536 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13537 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13538 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13539 | return NULL; |
| 13540 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13541 | if (_n == _children_capacity) { |
| 13542 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13543 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13544 | if (!_new_children) { |
| 13545 | p->error_indicator = 1; |
| 13546 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13547 | return NULL; |
| 13548 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13549 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13550 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13551 | _children[_n++] = _res; |
| 13552 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13553 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13554 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13555 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13556 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13557 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13558 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13559 | p->error_indicator = 1; |
| 13560 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13561 | return NULL; |
| 13562 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13563 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13564 | PyMem_Free(_children); |
| 13565 | _PyPegen_insert_memo(p, _start_mark, _loop0_28_type, _seq); |
| 13566 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13567 | } |
| 13568 | |
| 13569 | // _gather_27: NAME _loop0_28 |
| 13570 | static asdl_seq * |
| 13571 | _gather_27_rule(Parser *p) |
| 13572 | { |
| 13573 | if (p->error_indicator) { |
| 13574 | return NULL; |
| 13575 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13576 | asdl_seq * _res = NULL; |
| 13577 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13578 | { // NAME _loop0_28 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13579 | if (p->error_indicator) { |
| 13580 | return NULL; |
| 13581 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13582 | expr_ty elem; |
| 13583 | asdl_seq * seq; |
| 13584 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13585 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13586 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13587 | (seq = _loop0_28_rule(p)) // _loop0_28 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13588 | ) |
| 13589 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13590 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13591 | goto done; |
| 13592 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13593 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13594 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13595 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13596 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13597 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13598 | } |
| 13599 | |
| 13600 | // _tmp_29: ',' expression |
| 13601 | static void * |
| 13602 | _tmp_29_rule(Parser *p) |
| 13603 | { |
| 13604 | if (p->error_indicator) { |
| 13605 | return NULL; |
| 13606 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13607 | void * _res = NULL; |
| 13608 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13609 | { // ',' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13610 | if (p->error_indicator) { |
| 13611 | return NULL; |
| 13612 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13613 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13614 | expr_ty z; |
| 13615 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13616 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13617 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13618 | (z = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13619 | ) |
| 13620 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13621 | _res = z; |
| 13622 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13623 | p->error_indicator = 1; |
| 13624 | return NULL; |
| 13625 | } |
| 13626 | goto done; |
| 13627 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13628 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13629 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13630 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13631 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13632 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13633 | } |
| 13634 | |
| 13635 | // _loop0_30: ('.' | '...') |
| 13636 | static asdl_seq * |
| 13637 | _loop0_30_rule(Parser *p) |
| 13638 | { |
| 13639 | if (p->error_indicator) { |
| 13640 | return NULL; |
| 13641 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13642 | void *_res = NULL; |
| 13643 | int _mark = p->mark; |
| 13644 | int _start_mark = p->mark; |
| 13645 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13646 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13647 | p->error_indicator = 1; |
| 13648 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13649 | return NULL; |
| 13650 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13651 | ssize_t _children_capacity = 1; |
| 13652 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13653 | { // ('.' | '...') |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13654 | if (p->error_indicator) { |
| 13655 | return NULL; |
| 13656 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 13657 | void *_tmp_136_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13658 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 13659 | (_tmp_136_var = _tmp_136_rule(p)) // '.' | '...' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13660 | ) |
| 13661 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 13662 | _res = _tmp_136_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13663 | if (_n == _children_capacity) { |
| 13664 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13665 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13666 | if (!_new_children) { |
| 13667 | p->error_indicator = 1; |
| 13668 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13669 | return NULL; |
| 13670 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13671 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13672 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13673 | _children[_n++] = _res; |
| 13674 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13675 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13676 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13677 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13678 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13679 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13680 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13681 | p->error_indicator = 1; |
| 13682 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13683 | return NULL; |
| 13684 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13685 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13686 | PyMem_Free(_children); |
| 13687 | _PyPegen_insert_memo(p, _start_mark, _loop0_30_type, _seq); |
| 13688 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13689 | } |
| 13690 | |
| 13691 | // _loop1_31: ('.' | '...') |
| 13692 | static asdl_seq * |
| 13693 | _loop1_31_rule(Parser *p) |
| 13694 | { |
| 13695 | if (p->error_indicator) { |
| 13696 | return NULL; |
| 13697 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13698 | void *_res = NULL; |
| 13699 | int _mark = p->mark; |
| 13700 | int _start_mark = p->mark; |
| 13701 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13702 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13703 | p->error_indicator = 1; |
| 13704 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13705 | return NULL; |
| 13706 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13707 | ssize_t _children_capacity = 1; |
| 13708 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13709 | { // ('.' | '...') |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13710 | if (p->error_indicator) { |
| 13711 | return NULL; |
| 13712 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 13713 | void *_tmp_137_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13714 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 13715 | (_tmp_137_var = _tmp_137_rule(p)) // '.' | '...' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13716 | ) |
| 13717 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 13718 | _res = _tmp_137_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13719 | if (_n == _children_capacity) { |
| 13720 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13721 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13722 | if (!_new_children) { |
| 13723 | p->error_indicator = 1; |
| 13724 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13725 | return NULL; |
| 13726 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13727 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13728 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13729 | _children[_n++] = _res; |
| 13730 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13731 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13732 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13733 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13734 | if (_n == 0 || p->error_indicator) { |
| 13735 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13736 | return NULL; |
| 13737 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13738 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13739 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13740 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13741 | p->error_indicator = 1; |
| 13742 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13743 | return NULL; |
| 13744 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13745 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13746 | PyMem_Free(_children); |
| 13747 | _PyPegen_insert_memo(p, _start_mark, _loop1_31_type, _seq); |
| 13748 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13749 | } |
| 13750 | |
| 13751 | // _loop0_33: ',' import_from_as_name |
| 13752 | static asdl_seq * |
| 13753 | _loop0_33_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13754 | { |
| 13755 | if (p->error_indicator) { |
| 13756 | return NULL; |
| 13757 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13758 | void *_res = NULL; |
| 13759 | int _mark = p->mark; |
| 13760 | int _start_mark = p->mark; |
| 13761 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13762 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13763 | p->error_indicator = 1; |
| 13764 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13765 | return NULL; |
| 13766 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13767 | ssize_t _children_capacity = 1; |
| 13768 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13769 | { // ',' import_from_as_name |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13770 | if (p->error_indicator) { |
| 13771 | return NULL; |
| 13772 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13773 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13774 | alias_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13775 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13776 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13777 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13778 | (elem = import_from_as_name_rule(p)) // import_from_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13779 | ) |
| 13780 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13781 | _res = elem; |
| 13782 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13783 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13784 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13785 | return NULL; |
| 13786 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13787 | if (_n == _children_capacity) { |
| 13788 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13789 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13790 | if (!_new_children) { |
| 13791 | p->error_indicator = 1; |
| 13792 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13793 | return NULL; |
| 13794 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13795 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13796 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13797 | _children[_n++] = _res; |
| 13798 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13799 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13800 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13801 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13802 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13803 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13804 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13805 | p->error_indicator = 1; |
| 13806 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13807 | return NULL; |
| 13808 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13809 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13810 | PyMem_Free(_children); |
| 13811 | _PyPegen_insert_memo(p, _start_mark, _loop0_33_type, _seq); |
| 13812 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13813 | } |
| 13814 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13815 | // _gather_32: import_from_as_name _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13816 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13817 | _gather_32_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13818 | { |
| 13819 | if (p->error_indicator) { |
| 13820 | return NULL; |
| 13821 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13822 | asdl_seq * _res = NULL; |
| 13823 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13824 | { // import_from_as_name _loop0_33 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13825 | if (p->error_indicator) { |
| 13826 | return NULL; |
| 13827 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13828 | alias_ty elem; |
| 13829 | asdl_seq * seq; |
| 13830 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13831 | (elem = import_from_as_name_rule(p)) // import_from_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13832 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13833 | (seq = _loop0_33_rule(p)) // _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13834 | ) |
| 13835 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13836 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13837 | goto done; |
| 13838 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13839 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13841 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13842 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13843 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13844 | } |
| 13845 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13846 | // _tmp_34: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13847 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13848 | _tmp_34_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13849 | { |
| 13850 | if (p->error_indicator) { |
| 13851 | return NULL; |
| 13852 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13853 | void * _res = NULL; |
| 13854 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13855 | { // 'as' NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13856 | if (p->error_indicator) { |
| 13857 | return NULL; |
| 13858 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13859 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13860 | expr_ty z; |
| 13861 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13862 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13863 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13864 | (z = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13865 | ) |
| 13866 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13867 | _res = z; |
| 13868 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13869 | p->error_indicator = 1; |
| 13870 | return NULL; |
| 13871 | } |
| 13872 | goto done; |
| 13873 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13874 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13875 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13876 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13877 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13878 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13879 | } |
| 13880 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13881 | // _loop0_36: ',' dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13882 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13883 | _loop0_36_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13884 | { |
| 13885 | if (p->error_indicator) { |
| 13886 | return NULL; |
| 13887 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13888 | void *_res = NULL; |
| 13889 | int _mark = p->mark; |
| 13890 | int _start_mark = p->mark; |
| 13891 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13892 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13893 | p->error_indicator = 1; |
| 13894 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13895 | return NULL; |
| 13896 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13897 | ssize_t _children_capacity = 1; |
| 13898 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13899 | { // ',' dotted_as_name |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13900 | if (p->error_indicator) { |
| 13901 | return NULL; |
| 13902 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13903 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13904 | alias_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13905 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13906 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13907 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13908 | (elem = dotted_as_name_rule(p)) // dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13909 | ) |
| 13910 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13911 | _res = elem; |
| 13912 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13913 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13914 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13915 | return NULL; |
| 13916 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13917 | if (_n == _children_capacity) { |
| 13918 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13919 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13920 | if (!_new_children) { |
| 13921 | p->error_indicator = 1; |
| 13922 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13923 | return NULL; |
| 13924 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13925 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13926 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13927 | _children[_n++] = _res; |
| 13928 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13929 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13930 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13931 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13932 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13933 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13934 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 13935 | p->error_indicator = 1; |
| 13936 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13937 | return NULL; |
| 13938 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13939 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13940 | PyMem_Free(_children); |
| 13941 | _PyPegen_insert_memo(p, _start_mark, _loop0_36_type, _seq); |
| 13942 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13943 | } |
| 13944 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13945 | // _gather_35: dotted_as_name _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13946 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13947 | _gather_35_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13948 | { |
| 13949 | if (p->error_indicator) { |
| 13950 | return NULL; |
| 13951 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13952 | asdl_seq * _res = NULL; |
| 13953 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13954 | { // dotted_as_name _loop0_36 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13955 | if (p->error_indicator) { |
| 13956 | return NULL; |
| 13957 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13958 | alias_ty elem; |
| 13959 | asdl_seq * seq; |
| 13960 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13961 | (elem = dotted_as_name_rule(p)) // dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13962 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13963 | (seq = _loop0_36_rule(p)) // _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13964 | ) |
| 13965 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13966 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13967 | goto done; |
| 13968 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13969 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13970 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13971 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13972 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13973 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13974 | } |
| 13975 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13976 | // _tmp_37: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13977 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13978 | _tmp_37_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13979 | { |
| 13980 | if (p->error_indicator) { |
| 13981 | return NULL; |
| 13982 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13983 | void * _res = NULL; |
| 13984 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13985 | { // 'as' NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 13986 | if (p->error_indicator) { |
| 13987 | return NULL; |
| 13988 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13989 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13990 | expr_ty z; |
| 13991 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13992 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13993 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13994 | (z = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13995 | ) |
| 13996 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13997 | _res = z; |
| 13998 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13999 | p->error_indicator = 1; |
| 14000 | return NULL; |
| 14001 | } |
| 14002 | goto done; |
| 14003 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14004 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14005 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14006 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14007 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14008 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14009 | } |
| 14010 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14011 | // _loop0_39: ',' with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14012 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14013 | _loop0_39_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14014 | { |
| 14015 | if (p->error_indicator) { |
| 14016 | return NULL; |
| 14017 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14018 | void *_res = NULL; |
| 14019 | int _mark = p->mark; |
| 14020 | int _start_mark = p->mark; |
| 14021 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14022 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14023 | p->error_indicator = 1; |
| 14024 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14025 | return NULL; |
| 14026 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14027 | ssize_t _children_capacity = 1; |
| 14028 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14029 | { // ',' with_item |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14030 | if (p->error_indicator) { |
| 14031 | return NULL; |
| 14032 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14033 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14034 | withitem_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14035 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14036 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14037 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14038 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14039 | ) |
| 14040 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14041 | _res = elem; |
| 14042 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14043 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14044 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14045 | return NULL; |
| 14046 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14047 | if (_n == _children_capacity) { |
| 14048 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14049 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14050 | if (!_new_children) { |
| 14051 | p->error_indicator = 1; |
| 14052 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14053 | return NULL; |
| 14054 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14055 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14056 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14057 | _children[_n++] = _res; |
| 14058 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14059 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14060 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14061 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14062 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14063 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14064 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14065 | p->error_indicator = 1; |
| 14066 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14067 | return NULL; |
| 14068 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14069 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14070 | PyMem_Free(_children); |
| 14071 | _PyPegen_insert_memo(p, _start_mark, _loop0_39_type, _seq); |
| 14072 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14073 | } |
| 14074 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14075 | // _gather_38: with_item _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14076 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14077 | _gather_38_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14078 | { |
| 14079 | if (p->error_indicator) { |
| 14080 | return NULL; |
| 14081 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14082 | asdl_seq * _res = NULL; |
| 14083 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14084 | { // with_item _loop0_39 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14085 | if (p->error_indicator) { |
| 14086 | return NULL; |
| 14087 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14088 | withitem_ty elem; |
| 14089 | asdl_seq * seq; |
| 14090 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14091 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14092 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14093 | (seq = _loop0_39_rule(p)) // _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14094 | ) |
| 14095 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14096 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14097 | goto done; |
| 14098 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14099 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14100 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14101 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14102 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14103 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14104 | } |
| 14105 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14106 | // _loop0_41: ',' with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14107 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14108 | _loop0_41_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14109 | { |
| 14110 | if (p->error_indicator) { |
| 14111 | return NULL; |
| 14112 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14113 | void *_res = NULL; |
| 14114 | int _mark = p->mark; |
| 14115 | int _start_mark = p->mark; |
| 14116 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14117 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14118 | p->error_indicator = 1; |
| 14119 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14120 | return NULL; |
| 14121 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14122 | ssize_t _children_capacity = 1; |
| 14123 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14124 | { // ',' with_item |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14125 | if (p->error_indicator) { |
| 14126 | return NULL; |
| 14127 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14128 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14129 | withitem_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14130 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14131 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14132 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14133 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14134 | ) |
| 14135 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14136 | _res = elem; |
| 14137 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14138 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14139 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14140 | return NULL; |
| 14141 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14142 | if (_n == _children_capacity) { |
| 14143 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14144 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14145 | if (!_new_children) { |
| 14146 | p->error_indicator = 1; |
| 14147 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14148 | return NULL; |
| 14149 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14150 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14151 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14152 | _children[_n++] = _res; |
| 14153 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14154 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14155 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14156 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14157 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14158 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14159 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14160 | p->error_indicator = 1; |
| 14161 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14162 | return NULL; |
| 14163 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14164 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14165 | PyMem_Free(_children); |
| 14166 | _PyPegen_insert_memo(p, _start_mark, _loop0_41_type, _seq); |
| 14167 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14168 | } |
| 14169 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14170 | // _gather_40: with_item _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14171 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14172 | _gather_40_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14173 | { |
| 14174 | if (p->error_indicator) { |
| 14175 | return NULL; |
| 14176 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14177 | asdl_seq * _res = NULL; |
| 14178 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14179 | { // with_item _loop0_41 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14180 | if (p->error_indicator) { |
| 14181 | return NULL; |
| 14182 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14183 | withitem_ty elem; |
| 14184 | asdl_seq * seq; |
| 14185 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14186 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14187 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14188 | (seq = _loop0_41_rule(p)) // _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14189 | ) |
| 14190 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14191 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14192 | goto done; |
| 14193 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14194 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14195 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14196 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14197 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14198 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14199 | } |
| 14200 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14201 | // _loop0_43: ',' with_item |
| 14202 | static asdl_seq * |
| 14203 | _loop0_43_rule(Parser *p) |
| 14204 | { |
| 14205 | if (p->error_indicator) { |
| 14206 | return NULL; |
| 14207 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14208 | void *_res = NULL; |
| 14209 | int _mark = p->mark; |
| 14210 | int _start_mark = p->mark; |
| 14211 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14212 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14213 | p->error_indicator = 1; |
| 14214 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14215 | return NULL; |
| 14216 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14217 | ssize_t _children_capacity = 1; |
| 14218 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14219 | { // ',' with_item |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14220 | if (p->error_indicator) { |
| 14221 | return NULL; |
| 14222 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14223 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14224 | withitem_ty elem; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14225 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14226 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14227 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14228 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14229 | ) |
| 14230 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14231 | _res = elem; |
| 14232 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14233 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14234 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14235 | return NULL; |
| 14236 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14237 | if (_n == _children_capacity) { |
| 14238 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14239 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14240 | if (!_new_children) { |
| 14241 | p->error_indicator = 1; |
| 14242 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14243 | return NULL; |
| 14244 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14245 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14246 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14247 | _children[_n++] = _res; |
| 14248 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14249 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14250 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14251 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14252 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14253 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14254 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14255 | p->error_indicator = 1; |
| 14256 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14257 | return NULL; |
| 14258 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14259 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14260 | PyMem_Free(_children); |
| 14261 | _PyPegen_insert_memo(p, _start_mark, _loop0_43_type, _seq); |
| 14262 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14263 | } |
| 14264 | |
| 14265 | // _gather_42: with_item _loop0_43 |
| 14266 | static asdl_seq * |
| 14267 | _gather_42_rule(Parser *p) |
| 14268 | { |
| 14269 | if (p->error_indicator) { |
| 14270 | return NULL; |
| 14271 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14272 | asdl_seq * _res = NULL; |
| 14273 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14274 | { // with_item _loop0_43 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14275 | if (p->error_indicator) { |
| 14276 | return NULL; |
| 14277 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14278 | withitem_ty elem; |
| 14279 | asdl_seq * seq; |
| 14280 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14281 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14282 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14283 | (seq = _loop0_43_rule(p)) // _loop0_43 |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14284 | ) |
| 14285 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14286 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14287 | goto done; |
| 14288 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14289 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14290 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14291 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14292 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14293 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14294 | } |
| 14295 | |
| 14296 | // _loop0_45: ',' with_item |
| 14297 | static asdl_seq * |
| 14298 | _loop0_45_rule(Parser *p) |
| 14299 | { |
| 14300 | if (p->error_indicator) { |
| 14301 | return NULL; |
| 14302 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14303 | void *_res = NULL; |
| 14304 | int _mark = p->mark; |
| 14305 | int _start_mark = p->mark; |
| 14306 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14307 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14308 | p->error_indicator = 1; |
| 14309 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14310 | return NULL; |
| 14311 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14312 | ssize_t _children_capacity = 1; |
| 14313 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14314 | { // ',' with_item |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14315 | if (p->error_indicator) { |
| 14316 | return NULL; |
| 14317 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14318 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14319 | withitem_ty elem; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14320 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14321 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14322 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14323 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14324 | ) |
| 14325 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14326 | _res = elem; |
| 14327 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14328 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14329 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14330 | return NULL; |
| 14331 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14332 | if (_n == _children_capacity) { |
| 14333 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14334 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14335 | if (!_new_children) { |
| 14336 | p->error_indicator = 1; |
| 14337 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14338 | return NULL; |
| 14339 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14340 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14341 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14342 | _children[_n++] = _res; |
| 14343 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14344 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14345 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14347 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14348 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14349 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14350 | p->error_indicator = 1; |
| 14351 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14352 | return NULL; |
| 14353 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14354 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14355 | PyMem_Free(_children); |
| 14356 | _PyPegen_insert_memo(p, _start_mark, _loop0_45_type, _seq); |
| 14357 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14358 | } |
| 14359 | |
| 14360 | // _gather_44: with_item _loop0_45 |
| 14361 | static asdl_seq * |
| 14362 | _gather_44_rule(Parser *p) |
| 14363 | { |
| 14364 | if (p->error_indicator) { |
| 14365 | return NULL; |
| 14366 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14367 | asdl_seq * _res = NULL; |
| 14368 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14369 | { // with_item _loop0_45 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14370 | if (p->error_indicator) { |
| 14371 | return NULL; |
| 14372 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14373 | withitem_ty elem; |
| 14374 | asdl_seq * seq; |
| 14375 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14376 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14377 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14378 | (seq = _loop0_45_rule(p)) // _loop0_45 |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14379 | ) |
| 14380 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14381 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14382 | goto done; |
| 14383 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14384 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14385 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14386 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14387 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14388 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14389 | } |
| 14390 | |
| 14391 | // _tmp_46: 'as' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14392 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14393 | _tmp_46_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14394 | { |
| 14395 | if (p->error_indicator) { |
| 14396 | return NULL; |
| 14397 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14398 | void * _res = NULL; |
| 14399 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14400 | { // 'as' target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14401 | if (p->error_indicator) { |
| 14402 | return NULL; |
| 14403 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14404 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14405 | expr_ty t; |
| 14406 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14407 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14408 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14409 | (t = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14410 | ) |
| 14411 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14412 | _res = t; |
| 14413 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14414 | p->error_indicator = 1; |
| 14415 | return NULL; |
| 14416 | } |
| 14417 | goto done; |
| 14418 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14419 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14420 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14421 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14422 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14423 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14424 | } |
| 14425 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14426 | // _loop1_47: except_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14427 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14428 | _loop1_47_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14429 | { |
| 14430 | if (p->error_indicator) { |
| 14431 | return NULL; |
| 14432 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14433 | void *_res = NULL; |
| 14434 | int _mark = p->mark; |
| 14435 | int _start_mark = p->mark; |
| 14436 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14437 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14438 | p->error_indicator = 1; |
| 14439 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14440 | return NULL; |
| 14441 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14442 | ssize_t _children_capacity = 1; |
| 14443 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14444 | { // except_block |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14445 | if (p->error_indicator) { |
| 14446 | return NULL; |
| 14447 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14448 | excepthandler_ty except_block_var; |
| 14449 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14450 | (except_block_var = except_block_rule(p)) // except_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14451 | ) |
| 14452 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14453 | _res = except_block_var; |
| 14454 | if (_n == _children_capacity) { |
| 14455 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14456 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14457 | if (!_new_children) { |
| 14458 | p->error_indicator = 1; |
| 14459 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14460 | return NULL; |
| 14461 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14462 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14463 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14464 | _children[_n++] = _res; |
| 14465 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14466 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14467 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14468 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14469 | if (_n == 0 || p->error_indicator) { |
| 14470 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14471 | return NULL; |
| 14472 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14473 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14474 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14475 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14476 | p->error_indicator = 1; |
| 14477 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14478 | return NULL; |
| 14479 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14480 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14481 | PyMem_Free(_children); |
| 14482 | _PyPegen_insert_memo(p, _start_mark, _loop1_47_type, _seq); |
| 14483 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14484 | } |
| 14485 | |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 14486 | // _tmp_48: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14487 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14488 | _tmp_48_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14489 | { |
| 14490 | if (p->error_indicator) { |
| 14491 | return NULL; |
| 14492 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14493 | void * _res = NULL; |
| 14494 | int _mark = p->mark; |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 14495 | { // 'as' NAME |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14496 | if (p->error_indicator) { |
| 14497 | return NULL; |
| 14498 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14499 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14500 | expr_ty z; |
| 14501 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14502 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14503 | && |
Lysandros Nikolaou | ce21cfc | 2020-05-14 23:13:50 +0300 | [diff] [blame] | 14504 | (z = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14505 | ) |
| 14506 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14507 | _res = z; |
| 14508 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14509 | p->error_indicator = 1; |
| 14510 | return NULL; |
| 14511 | } |
| 14512 | goto done; |
| 14513 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14514 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14515 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14516 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14517 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14518 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14519 | } |
| 14520 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14521 | // _tmp_49: 'from' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14522 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14523 | _tmp_49_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14524 | { |
| 14525 | if (p->error_indicator) { |
| 14526 | return NULL; |
| 14527 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14528 | void * _res = NULL; |
| 14529 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14530 | { // 'from' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14531 | if (p->error_indicator) { |
| 14532 | return NULL; |
| 14533 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14534 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14535 | expr_ty z; |
| 14536 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14537 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14538 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14539 | (z = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14540 | ) |
| 14541 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14542 | _res = z; |
| 14543 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14544 | p->error_indicator = 1; |
| 14545 | return NULL; |
| 14546 | } |
| 14547 | goto done; |
| 14548 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14549 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14550 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14551 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14552 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14553 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14554 | } |
| 14555 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14556 | // _tmp_50: '->' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14557 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14558 | _tmp_50_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14559 | { |
| 14560 | if (p->error_indicator) { |
| 14561 | return NULL; |
| 14562 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14563 | void * _res = NULL; |
| 14564 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14565 | { // '->' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14566 | if (p->error_indicator) { |
| 14567 | return NULL; |
| 14568 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14569 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14570 | expr_ty z; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14571 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14572 | (_literal = _PyPegen_expect_token(p, 51)) // token='->' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14573 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14574 | (z = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14575 | ) |
| 14576 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14577 | _res = z; |
| 14578 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14579 | p->error_indicator = 1; |
| 14580 | return NULL; |
| 14581 | } |
| 14582 | goto done; |
| 14583 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14584 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14585 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14586 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14587 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14588 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14589 | } |
| 14590 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14591 | // _tmp_51: '->' expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14592 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14593 | _tmp_51_rule(Parser *p) |
| 14594 | { |
| 14595 | if (p->error_indicator) { |
| 14596 | return NULL; |
| 14597 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14598 | void * _res = NULL; |
| 14599 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14600 | { // '->' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14601 | if (p->error_indicator) { |
| 14602 | return NULL; |
| 14603 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14604 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14605 | expr_ty z; |
| 14606 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14607 | (_literal = _PyPegen_expect_token(p, 51)) // token='->' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14608 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14609 | (z = expression_rule(p)) // expression |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14610 | ) |
| 14611 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14612 | _res = z; |
| 14613 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14614 | p->error_indicator = 1; |
| 14615 | return NULL; |
| 14616 | } |
| 14617 | goto done; |
| 14618 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14619 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14620 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14621 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14622 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14623 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14624 | } |
| 14625 | |
| 14626 | // _tmp_52: NEWLINE INDENT |
| 14627 | static void * |
| 14628 | _tmp_52_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14629 | { |
| 14630 | if (p->error_indicator) { |
| 14631 | return NULL; |
| 14632 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14633 | void * _res = NULL; |
| 14634 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14635 | { // NEWLINE INDENT |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14636 | if (p->error_indicator) { |
| 14637 | return NULL; |
| 14638 | } |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 14639 | Token * indent_var; |
| 14640 | Token * newline_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14641 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14642 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14643 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14644 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14645 | ) |
| 14646 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14647 | _res = _PyPegen_dummy_name(p, newline_var, indent_var); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14648 | goto done; |
| 14649 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14650 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14651 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14652 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14653 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14654 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14655 | } |
| 14656 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14657 | // _loop0_53: param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14658 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14659 | _loop0_53_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14660 | { |
| 14661 | if (p->error_indicator) { |
| 14662 | return NULL; |
| 14663 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14664 | void *_res = NULL; |
| 14665 | int _mark = p->mark; |
| 14666 | int _start_mark = p->mark; |
| 14667 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14668 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14669 | p->error_indicator = 1; |
| 14670 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14671 | return NULL; |
| 14672 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14673 | ssize_t _children_capacity = 1; |
| 14674 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14675 | { // param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14676 | if (p->error_indicator) { |
| 14677 | return NULL; |
| 14678 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14679 | arg_ty param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14680 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14681 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14682 | ) |
| 14683 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14684 | _res = param_no_default_var; |
| 14685 | if (_n == _children_capacity) { |
| 14686 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14687 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14688 | if (!_new_children) { |
| 14689 | p->error_indicator = 1; |
| 14690 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14691 | return NULL; |
| 14692 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14693 | _children = _new_children; |
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 | _children[_n++] = _res; |
| 14696 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14697 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14698 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14699 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14700 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14701 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14702 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14703 | p->error_indicator = 1; |
| 14704 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14705 | return NULL; |
| 14706 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14707 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14708 | PyMem_Free(_children); |
| 14709 | _PyPegen_insert_memo(p, _start_mark, _loop0_53_type, _seq); |
| 14710 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14711 | } |
| 14712 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14713 | // _loop0_54: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14714 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14715 | _loop0_54_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14716 | { |
| 14717 | if (p->error_indicator) { |
| 14718 | return NULL; |
| 14719 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14720 | void *_res = NULL; |
| 14721 | int _mark = p->mark; |
| 14722 | int _start_mark = p->mark; |
| 14723 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14724 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14725 | p->error_indicator = 1; |
| 14726 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14727 | return NULL; |
| 14728 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14729 | ssize_t _children_capacity = 1; |
| 14730 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14731 | { // param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14732 | if (p->error_indicator) { |
| 14733 | return NULL; |
| 14734 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14735 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14736 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14737 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14738 | ) |
| 14739 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14740 | _res = param_with_default_var; |
| 14741 | if (_n == _children_capacity) { |
| 14742 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14743 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14744 | if (!_new_children) { |
| 14745 | p->error_indicator = 1; |
| 14746 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14747 | return NULL; |
| 14748 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14749 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14750 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14751 | _children[_n++] = _res; |
| 14752 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14753 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14754 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14755 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14756 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14757 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14758 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14759 | p->error_indicator = 1; |
| 14760 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14761 | return NULL; |
| 14762 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14763 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14764 | PyMem_Free(_children); |
| 14765 | _PyPegen_insert_memo(p, _start_mark, _loop0_54_type, _seq); |
| 14766 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14767 | } |
| 14768 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14769 | // _loop0_55: param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14770 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14771 | _loop0_55_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14772 | { |
| 14773 | if (p->error_indicator) { |
| 14774 | return NULL; |
| 14775 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14776 | void *_res = NULL; |
| 14777 | int _mark = p->mark; |
| 14778 | int _start_mark = p->mark; |
| 14779 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14780 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14781 | p->error_indicator = 1; |
| 14782 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14783 | return NULL; |
| 14784 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14785 | ssize_t _children_capacity = 1; |
| 14786 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14787 | { // param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14788 | if (p->error_indicator) { |
| 14789 | return NULL; |
| 14790 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14791 | NameDefaultPair* param_with_default_var; |
| 14792 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14793 | (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] | 14794 | ) |
| 14795 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14796 | _res = param_with_default_var; |
| 14797 | if (_n == _children_capacity) { |
| 14798 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14799 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14800 | if (!_new_children) { |
| 14801 | p->error_indicator = 1; |
| 14802 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14803 | return NULL; |
| 14804 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14805 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14806 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14807 | _children[_n++] = _res; |
| 14808 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14809 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14810 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14811 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14812 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14813 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14814 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14815 | p->error_indicator = 1; |
| 14816 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14817 | return NULL; |
| 14818 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14819 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14820 | PyMem_Free(_children); |
| 14821 | _PyPegen_insert_memo(p, _start_mark, _loop0_55_type, _seq); |
| 14822 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14823 | } |
| 14824 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14825 | // _loop1_56: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14826 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14827 | _loop1_56_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14828 | { |
| 14829 | if (p->error_indicator) { |
| 14830 | return NULL; |
| 14831 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14832 | void *_res = NULL; |
| 14833 | int _mark = p->mark; |
| 14834 | int _start_mark = p->mark; |
| 14835 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14836 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14837 | p->error_indicator = 1; |
| 14838 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14839 | return NULL; |
| 14840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14841 | ssize_t _children_capacity = 1; |
| 14842 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14843 | { // param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14844 | if (p->error_indicator) { |
| 14845 | return NULL; |
| 14846 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14847 | arg_ty param_no_default_var; |
| 14848 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14849 | (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] | 14850 | ) |
| 14851 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14852 | _res = param_no_default_var; |
| 14853 | if (_n == _children_capacity) { |
| 14854 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14855 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14856 | if (!_new_children) { |
| 14857 | p->error_indicator = 1; |
| 14858 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14859 | return NULL; |
| 14860 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14861 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14862 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14863 | _children[_n++] = _res; |
| 14864 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14865 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14866 | p->mark = _mark; |
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 | if (_n == 0 || p->error_indicator) { |
| 14869 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14870 | return NULL; |
| 14871 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14872 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14873 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14874 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14875 | p->error_indicator = 1; |
| 14876 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14877 | return NULL; |
| 14878 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14879 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14880 | PyMem_Free(_children); |
| 14881 | _PyPegen_insert_memo(p, _start_mark, _loop1_56_type, _seq); |
| 14882 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14883 | } |
| 14884 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14885 | // _loop0_57: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14886 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14887 | _loop0_57_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14888 | { |
| 14889 | if (p->error_indicator) { |
| 14890 | return NULL; |
| 14891 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14892 | void *_res = NULL; |
| 14893 | int _mark = p->mark; |
| 14894 | int _start_mark = p->mark; |
| 14895 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14896 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14897 | p->error_indicator = 1; |
| 14898 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14899 | return NULL; |
| 14900 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14901 | ssize_t _children_capacity = 1; |
| 14902 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14903 | { // param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14904 | if (p->error_indicator) { |
| 14905 | return NULL; |
| 14906 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14907 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14908 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14909 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14910 | ) |
| 14911 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14912 | _res = param_with_default_var; |
| 14913 | if (_n == _children_capacity) { |
| 14914 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14915 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14916 | if (!_new_children) { |
| 14917 | p->error_indicator = 1; |
| 14918 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14919 | return NULL; |
| 14920 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14921 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14922 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14923 | _children[_n++] = _res; |
| 14924 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14925 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14926 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14927 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14928 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14929 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14930 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14931 | p->error_indicator = 1; |
| 14932 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14933 | return NULL; |
| 14934 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14935 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14936 | PyMem_Free(_children); |
| 14937 | _PyPegen_insert_memo(p, _start_mark, _loop0_57_type, _seq); |
| 14938 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14939 | } |
| 14940 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14941 | // _loop1_58: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14942 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14943 | _loop1_58_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14944 | { |
| 14945 | if (p->error_indicator) { |
| 14946 | return NULL; |
| 14947 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14948 | void *_res = NULL; |
| 14949 | int _mark = p->mark; |
| 14950 | int _start_mark = p->mark; |
| 14951 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14952 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14953 | p->error_indicator = 1; |
| 14954 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14955 | return NULL; |
| 14956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14957 | ssize_t _children_capacity = 1; |
| 14958 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14959 | { // param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 14960 | if (p->error_indicator) { |
| 14961 | return NULL; |
| 14962 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14963 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14964 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14965 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14966 | ) |
| 14967 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14968 | _res = param_with_default_var; |
| 14969 | if (_n == _children_capacity) { |
| 14970 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14971 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14972 | if (!_new_children) { |
| 14973 | p->error_indicator = 1; |
| 14974 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14975 | return NULL; |
| 14976 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14977 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14978 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14979 | _children[_n++] = _res; |
| 14980 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14981 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14982 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14984 | if (_n == 0 || p->error_indicator) { |
| 14985 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14986 | return NULL; |
| 14987 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14988 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14989 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14990 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 14991 | p->error_indicator = 1; |
| 14992 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14993 | return NULL; |
| 14994 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14995 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14996 | PyMem_Free(_children); |
| 14997 | _PyPegen_insert_memo(p, _start_mark, _loop1_58_type, _seq); |
| 14998 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 14999 | } |
| 15000 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15001 | // _loop1_59: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15002 | static asdl_seq * |
| 15003 | _loop1_59_rule(Parser *p) |
| 15004 | { |
| 15005 | if (p->error_indicator) { |
| 15006 | return NULL; |
| 15007 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15008 | void *_res = NULL; |
| 15009 | int _mark = p->mark; |
| 15010 | int _start_mark = p->mark; |
| 15011 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15012 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15013 | p->error_indicator = 1; |
| 15014 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15015 | return NULL; |
| 15016 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15017 | ssize_t _children_capacity = 1; |
| 15018 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15019 | { // param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15020 | if (p->error_indicator) { |
| 15021 | return NULL; |
| 15022 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15023 | arg_ty param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15024 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15025 | (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] | 15026 | ) |
| 15027 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15028 | _res = param_no_default_var; |
| 15029 | if (_n == _children_capacity) { |
| 15030 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15031 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15032 | if (!_new_children) { |
| 15033 | p->error_indicator = 1; |
| 15034 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15035 | return NULL; |
| 15036 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15037 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15038 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15039 | _children[_n++] = _res; |
| 15040 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15041 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15042 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15043 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15044 | if (_n == 0 || p->error_indicator) { |
| 15045 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15046 | return NULL; |
| 15047 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15048 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15049 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15050 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15051 | p->error_indicator = 1; |
| 15052 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15053 | return NULL; |
| 15054 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15055 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15056 | PyMem_Free(_children); |
| 15057 | _PyPegen_insert_memo(p, _start_mark, _loop1_59_type, _seq); |
| 15058 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15059 | } |
| 15060 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15061 | // _loop1_60: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15062 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15063 | _loop1_60_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15064 | { |
| 15065 | if (p->error_indicator) { |
| 15066 | return NULL; |
| 15067 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15068 | void *_res = NULL; |
| 15069 | int _mark = p->mark; |
| 15070 | int _start_mark = p->mark; |
| 15071 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15072 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15073 | p->error_indicator = 1; |
| 15074 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15075 | return NULL; |
| 15076 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15077 | ssize_t _children_capacity = 1; |
| 15078 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15079 | { // param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15080 | if (p->error_indicator) { |
| 15081 | return NULL; |
| 15082 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15083 | arg_ty param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15084 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15085 | (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] | 15086 | ) |
| 15087 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15088 | _res = param_no_default_var; |
| 15089 | if (_n == _children_capacity) { |
| 15090 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15091 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15092 | if (!_new_children) { |
| 15093 | p->error_indicator = 1; |
| 15094 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15095 | return NULL; |
| 15096 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15097 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15098 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15099 | _children[_n++] = _res; |
| 15100 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15101 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15102 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15103 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15104 | if (_n == 0 || p->error_indicator) { |
| 15105 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15106 | return NULL; |
| 15107 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15108 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15109 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15110 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15111 | p->error_indicator = 1; |
| 15112 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15113 | return NULL; |
| 15114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15115 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15116 | PyMem_Free(_children); |
| 15117 | _PyPegen_insert_memo(p, _start_mark, _loop1_60_type, _seq); |
| 15118 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15119 | } |
| 15120 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15121 | // _loop0_61: param_no_default |
| 15122 | static asdl_seq * |
| 15123 | _loop0_61_rule(Parser *p) |
| 15124 | { |
| 15125 | if (p->error_indicator) { |
| 15126 | return NULL; |
| 15127 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15128 | void *_res = NULL; |
| 15129 | int _mark = p->mark; |
| 15130 | int _start_mark = p->mark; |
| 15131 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15132 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15133 | p->error_indicator = 1; |
| 15134 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15135 | return NULL; |
| 15136 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15137 | ssize_t _children_capacity = 1; |
| 15138 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15139 | { // param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15140 | if (p->error_indicator) { |
| 15141 | return NULL; |
| 15142 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15143 | arg_ty param_no_default_var; |
| 15144 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15145 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15146 | ) |
| 15147 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15148 | _res = param_no_default_var; |
| 15149 | if (_n == _children_capacity) { |
| 15150 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15151 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15152 | if (!_new_children) { |
| 15153 | p->error_indicator = 1; |
| 15154 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15155 | return NULL; |
| 15156 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15157 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15158 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15159 | _children[_n++] = _res; |
| 15160 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15161 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15162 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15163 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15164 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15165 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15166 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15167 | p->error_indicator = 1; |
| 15168 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15169 | return NULL; |
| 15170 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15171 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15172 | PyMem_Free(_children); |
| 15173 | _PyPegen_insert_memo(p, _start_mark, _loop0_61_type, _seq); |
| 15174 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15175 | } |
| 15176 | |
| 15177 | // _loop1_62: param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15178 | static asdl_seq * |
| 15179 | _loop1_62_rule(Parser *p) |
| 15180 | { |
| 15181 | if (p->error_indicator) { |
| 15182 | return NULL; |
| 15183 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15184 | void *_res = NULL; |
| 15185 | int _mark = p->mark; |
| 15186 | int _start_mark = p->mark; |
| 15187 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15188 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15189 | p->error_indicator = 1; |
| 15190 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15191 | return NULL; |
| 15192 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15193 | ssize_t _children_capacity = 1; |
| 15194 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15195 | { // param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15196 | if (p->error_indicator) { |
| 15197 | return NULL; |
| 15198 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15199 | NameDefaultPair* param_with_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15200 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15201 | (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] | 15202 | ) |
| 15203 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15204 | _res = param_with_default_var; |
| 15205 | if (_n == _children_capacity) { |
| 15206 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15207 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15208 | if (!_new_children) { |
| 15209 | p->error_indicator = 1; |
| 15210 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15211 | return NULL; |
| 15212 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15213 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15214 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15215 | _children[_n++] = _res; |
| 15216 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15217 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15218 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15219 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15220 | if (_n == 0 || p->error_indicator) { |
| 15221 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15222 | return NULL; |
| 15223 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15224 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15225 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15226 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15227 | p->error_indicator = 1; |
| 15228 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15229 | return NULL; |
| 15230 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15231 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15232 | PyMem_Free(_children); |
| 15233 | _PyPegen_insert_memo(p, _start_mark, _loop1_62_type, _seq); |
| 15234 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15235 | } |
| 15236 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15237 | // _loop0_63: param_no_default |
| 15238 | static asdl_seq * |
| 15239 | _loop0_63_rule(Parser *p) |
| 15240 | { |
| 15241 | if (p->error_indicator) { |
| 15242 | return NULL; |
| 15243 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15244 | void *_res = NULL; |
| 15245 | int _mark = p->mark; |
| 15246 | int _start_mark = p->mark; |
| 15247 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15248 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15249 | p->error_indicator = 1; |
| 15250 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15251 | return NULL; |
| 15252 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15253 | ssize_t _children_capacity = 1; |
| 15254 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15255 | { // param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15256 | if (p->error_indicator) { |
| 15257 | return NULL; |
| 15258 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15259 | arg_ty param_no_default_var; |
| 15260 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15261 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15262 | ) |
| 15263 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15264 | _res = param_no_default_var; |
| 15265 | if (_n == _children_capacity) { |
| 15266 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15267 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15268 | if (!_new_children) { |
| 15269 | p->error_indicator = 1; |
| 15270 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15271 | return NULL; |
| 15272 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15273 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15274 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15275 | _children[_n++] = _res; |
| 15276 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15277 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15278 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15279 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15280 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15281 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15282 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15283 | p->error_indicator = 1; |
| 15284 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15285 | return NULL; |
| 15286 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15287 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15288 | PyMem_Free(_children); |
| 15289 | _PyPegen_insert_memo(p, _start_mark, _loop0_63_type, _seq); |
| 15290 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15291 | } |
| 15292 | |
| 15293 | // _loop1_64: param_with_default |
| 15294 | static asdl_seq * |
| 15295 | _loop1_64_rule(Parser *p) |
| 15296 | { |
| 15297 | if (p->error_indicator) { |
| 15298 | return NULL; |
| 15299 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15300 | void *_res = NULL; |
| 15301 | int _mark = p->mark; |
| 15302 | int _start_mark = p->mark; |
| 15303 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15304 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15305 | p->error_indicator = 1; |
| 15306 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15307 | return NULL; |
| 15308 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15309 | ssize_t _children_capacity = 1; |
| 15310 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15311 | { // param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15312 | if (p->error_indicator) { |
| 15313 | return NULL; |
| 15314 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15315 | NameDefaultPair* param_with_default_var; |
| 15316 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15317 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15318 | ) |
| 15319 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15320 | _res = param_with_default_var; |
| 15321 | if (_n == _children_capacity) { |
| 15322 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15323 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15324 | if (!_new_children) { |
| 15325 | p->error_indicator = 1; |
| 15326 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15327 | return NULL; |
| 15328 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15329 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15330 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15331 | _children[_n++] = _res; |
| 15332 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15333 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15334 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15335 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15336 | if (_n == 0 || p->error_indicator) { |
| 15337 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15338 | return NULL; |
| 15339 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15340 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15341 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15342 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15343 | p->error_indicator = 1; |
| 15344 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15345 | return NULL; |
| 15346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15347 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15348 | PyMem_Free(_children); |
| 15349 | _PyPegen_insert_memo(p, _start_mark, _loop1_64_type, _seq); |
| 15350 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15351 | } |
| 15352 | |
| 15353 | // _loop0_65: param_maybe_default |
| 15354 | static asdl_seq * |
| 15355 | _loop0_65_rule(Parser *p) |
| 15356 | { |
| 15357 | if (p->error_indicator) { |
| 15358 | return NULL; |
| 15359 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15360 | void *_res = NULL; |
| 15361 | int _mark = p->mark; |
| 15362 | int _start_mark = p->mark; |
| 15363 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15364 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15365 | p->error_indicator = 1; |
| 15366 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15367 | return NULL; |
| 15368 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15369 | ssize_t _children_capacity = 1; |
| 15370 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15371 | { // param_maybe_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15372 | if (p->error_indicator) { |
| 15373 | return NULL; |
| 15374 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15375 | NameDefaultPair* param_maybe_default_var; |
| 15376 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15377 | (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15378 | ) |
| 15379 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15380 | _res = param_maybe_default_var; |
| 15381 | if (_n == _children_capacity) { |
| 15382 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15383 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15384 | if (!_new_children) { |
| 15385 | p->error_indicator = 1; |
| 15386 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15387 | return NULL; |
| 15388 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15389 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15390 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15391 | _children[_n++] = _res; |
| 15392 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15393 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15394 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15395 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15396 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15397 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15398 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15399 | p->error_indicator = 1; |
| 15400 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15401 | return NULL; |
| 15402 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15403 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15404 | PyMem_Free(_children); |
| 15405 | _PyPegen_insert_memo(p, _start_mark, _loop0_65_type, _seq); |
| 15406 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15407 | } |
| 15408 | |
| 15409 | // _loop1_66: param_maybe_default |
| 15410 | static asdl_seq * |
| 15411 | _loop1_66_rule(Parser *p) |
| 15412 | { |
| 15413 | if (p->error_indicator) { |
| 15414 | return NULL; |
| 15415 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15416 | void *_res = NULL; |
| 15417 | int _mark = p->mark; |
| 15418 | int _start_mark = p->mark; |
| 15419 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15420 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15421 | p->error_indicator = 1; |
| 15422 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15423 | return NULL; |
| 15424 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15425 | ssize_t _children_capacity = 1; |
| 15426 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15427 | { // param_maybe_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15428 | if (p->error_indicator) { |
| 15429 | return NULL; |
| 15430 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15431 | NameDefaultPair* param_maybe_default_var; |
| 15432 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15433 | (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15434 | ) |
| 15435 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15436 | _res = param_maybe_default_var; |
| 15437 | if (_n == _children_capacity) { |
| 15438 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15439 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15440 | if (!_new_children) { |
| 15441 | p->error_indicator = 1; |
| 15442 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15443 | return NULL; |
| 15444 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15445 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15446 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15447 | _children[_n++] = _res; |
| 15448 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15449 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15450 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15451 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15452 | if (_n == 0 || p->error_indicator) { |
| 15453 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15454 | return NULL; |
| 15455 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15456 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15457 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15458 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15459 | p->error_indicator = 1; |
| 15460 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15461 | return NULL; |
| 15462 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15463 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15464 | PyMem_Free(_children); |
| 15465 | _PyPegen_insert_memo(p, _start_mark, _loop1_66_type, _seq); |
| 15466 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15467 | } |
| 15468 | |
| 15469 | // _loop1_67: ('@' named_expression NEWLINE) |
| 15470 | static asdl_seq * |
| 15471 | _loop1_67_rule(Parser *p) |
| 15472 | { |
| 15473 | if (p->error_indicator) { |
| 15474 | return NULL; |
| 15475 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15476 | void *_res = NULL; |
| 15477 | int _mark = p->mark; |
| 15478 | int _start_mark = p->mark; |
| 15479 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15480 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15481 | p->error_indicator = 1; |
| 15482 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15483 | return NULL; |
| 15484 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15485 | ssize_t _children_capacity = 1; |
| 15486 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15487 | { // ('@' named_expression NEWLINE) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15488 | if (p->error_indicator) { |
| 15489 | return NULL; |
| 15490 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15491 | void *_tmp_138_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15492 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15493 | (_tmp_138_var = _tmp_138_rule(p)) // '@' named_expression NEWLINE |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15494 | ) |
| 15495 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15496 | _res = _tmp_138_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15497 | if (_n == _children_capacity) { |
| 15498 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15499 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15500 | if (!_new_children) { |
| 15501 | p->error_indicator = 1; |
| 15502 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15503 | return NULL; |
| 15504 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15505 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15506 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15507 | _children[_n++] = _res; |
| 15508 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15509 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15510 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15511 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15512 | if (_n == 0 || p->error_indicator) { |
| 15513 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15514 | return NULL; |
| 15515 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15516 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15517 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15518 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15519 | p->error_indicator = 1; |
| 15520 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15521 | return NULL; |
| 15522 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15523 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15524 | PyMem_Free(_children); |
| 15525 | _PyPegen_insert_memo(p, _start_mark, _loop1_67_type, _seq); |
| 15526 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15527 | } |
| 15528 | |
| 15529 | // _tmp_68: '(' arguments? ')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15530 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15531 | _tmp_68_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15532 | { |
| 15533 | if (p->error_indicator) { |
| 15534 | return NULL; |
| 15535 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15536 | void * _res = NULL; |
| 15537 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15538 | { // '(' arguments? ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15539 | if (p->error_indicator) { |
| 15540 | return NULL; |
| 15541 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15542 | Token * _literal; |
| 15543 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15544 | void *z; |
| 15545 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15546 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15547 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15548 | (z = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15549 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15550 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15551 | ) |
| 15552 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15553 | _res = z; |
| 15554 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15555 | p->error_indicator = 1; |
| 15556 | return NULL; |
| 15557 | } |
| 15558 | goto done; |
| 15559 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15560 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15561 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15562 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15563 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15564 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15565 | } |
| 15566 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15567 | // _loop0_70: ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15568 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15569 | _loop0_70_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15570 | { |
| 15571 | if (p->error_indicator) { |
| 15572 | return NULL; |
| 15573 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15574 | void *_res = NULL; |
| 15575 | int _mark = p->mark; |
| 15576 | int _start_mark = p->mark; |
| 15577 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15578 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15579 | p->error_indicator = 1; |
| 15580 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15581 | return NULL; |
| 15582 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15583 | ssize_t _children_capacity = 1; |
| 15584 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15585 | { // ',' star_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15586 | if (p->error_indicator) { |
| 15587 | return NULL; |
| 15588 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15589 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15590 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15591 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15592 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15593 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15594 | (elem = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15595 | ) |
| 15596 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15597 | _res = elem; |
| 15598 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15599 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15600 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15601 | return NULL; |
| 15602 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15603 | if (_n == _children_capacity) { |
| 15604 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15605 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15606 | if (!_new_children) { |
| 15607 | p->error_indicator = 1; |
| 15608 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15609 | return NULL; |
| 15610 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15611 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15612 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15613 | _children[_n++] = _res; |
| 15614 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15615 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15616 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15617 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15618 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15619 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15620 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15621 | p->error_indicator = 1; |
| 15622 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15623 | return NULL; |
| 15624 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15625 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15626 | PyMem_Free(_children); |
| 15627 | _PyPegen_insert_memo(p, _start_mark, _loop0_70_type, _seq); |
| 15628 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15629 | } |
| 15630 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15631 | // _gather_69: star_expression _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15632 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15633 | _gather_69_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15634 | { |
| 15635 | if (p->error_indicator) { |
| 15636 | return NULL; |
| 15637 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15638 | asdl_seq * _res = NULL; |
| 15639 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15640 | { // star_expression _loop0_70 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15641 | if (p->error_indicator) { |
| 15642 | return NULL; |
| 15643 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15644 | expr_ty elem; |
| 15645 | asdl_seq * seq; |
| 15646 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15647 | (elem = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15648 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15649 | (seq = _loop0_70_rule(p)) // _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15650 | ) |
| 15651 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15652 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15653 | goto done; |
| 15654 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15655 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15656 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15657 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15658 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15659 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15660 | } |
| 15661 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15662 | // _loop1_71: (',' star_expression) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15663 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15664 | _loop1_71_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15665 | { |
| 15666 | if (p->error_indicator) { |
| 15667 | return NULL; |
| 15668 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15669 | void *_res = NULL; |
| 15670 | int _mark = p->mark; |
| 15671 | int _start_mark = p->mark; |
| 15672 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15673 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15674 | p->error_indicator = 1; |
| 15675 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15676 | return NULL; |
| 15677 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15678 | ssize_t _children_capacity = 1; |
| 15679 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15680 | { // (',' star_expression) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15681 | if (p->error_indicator) { |
| 15682 | return NULL; |
| 15683 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15684 | void *_tmp_139_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15685 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15686 | (_tmp_139_var = _tmp_139_rule(p)) // ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15687 | ) |
| 15688 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15689 | _res = _tmp_139_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15690 | if (_n == _children_capacity) { |
| 15691 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15692 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15693 | if (!_new_children) { |
| 15694 | p->error_indicator = 1; |
| 15695 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15696 | return NULL; |
| 15697 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15698 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15699 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15700 | _children[_n++] = _res; |
| 15701 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15702 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15703 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15704 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15705 | if (_n == 0 || p->error_indicator) { |
| 15706 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15707 | return NULL; |
| 15708 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15709 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15710 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15711 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15712 | p->error_indicator = 1; |
| 15713 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15714 | return NULL; |
| 15715 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15716 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15717 | PyMem_Free(_children); |
| 15718 | _PyPegen_insert_memo(p, _start_mark, _loop1_71_type, _seq); |
| 15719 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15720 | } |
| 15721 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15722 | // _loop0_73: ',' star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15723 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15724 | _loop0_73_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15725 | { |
| 15726 | if (p->error_indicator) { |
| 15727 | return NULL; |
| 15728 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15729 | void *_res = NULL; |
| 15730 | int _mark = p->mark; |
| 15731 | int _start_mark = p->mark; |
| 15732 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15733 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15734 | p->error_indicator = 1; |
| 15735 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15736 | return NULL; |
| 15737 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15738 | ssize_t _children_capacity = 1; |
| 15739 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15740 | { // ',' star_named_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15741 | if (p->error_indicator) { |
| 15742 | return NULL; |
| 15743 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15744 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15745 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15746 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15747 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15748 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15749 | (elem = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15750 | ) |
| 15751 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15752 | _res = elem; |
| 15753 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15754 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15755 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15756 | return NULL; |
| 15757 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15758 | if (_n == _children_capacity) { |
| 15759 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15760 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15761 | if (!_new_children) { |
| 15762 | p->error_indicator = 1; |
| 15763 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15764 | return NULL; |
| 15765 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15766 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15767 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15768 | _children[_n++] = _res; |
| 15769 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15770 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15771 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15772 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15773 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15774 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15775 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15776 | p->error_indicator = 1; |
| 15777 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15778 | return NULL; |
| 15779 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15780 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15781 | PyMem_Free(_children); |
| 15782 | _PyPegen_insert_memo(p, _start_mark, _loop0_73_type, _seq); |
| 15783 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15784 | } |
| 15785 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15786 | // _gather_72: star_named_expression _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15787 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15788 | _gather_72_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15789 | { |
| 15790 | if (p->error_indicator) { |
| 15791 | return NULL; |
| 15792 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15793 | asdl_seq * _res = NULL; |
| 15794 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15795 | { // star_named_expression _loop0_73 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15796 | if (p->error_indicator) { |
| 15797 | return NULL; |
| 15798 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15799 | expr_ty elem; |
| 15800 | asdl_seq * seq; |
| 15801 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15802 | (elem = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15803 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15804 | (seq = _loop0_73_rule(p)) // _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15805 | ) |
| 15806 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15807 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15808 | goto done; |
| 15809 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15810 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15811 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15812 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15813 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15814 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15815 | } |
| 15816 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15817 | // _loop1_74: (',' expression) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15818 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15819 | _loop1_74_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15820 | { |
| 15821 | if (p->error_indicator) { |
| 15822 | return NULL; |
| 15823 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15824 | void *_res = NULL; |
| 15825 | int _mark = p->mark; |
| 15826 | int _start_mark = p->mark; |
| 15827 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15828 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15829 | p->error_indicator = 1; |
| 15830 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15831 | return NULL; |
| 15832 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15833 | ssize_t _children_capacity = 1; |
| 15834 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15835 | { // (',' expression) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15836 | if (p->error_indicator) { |
| 15837 | return NULL; |
| 15838 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15839 | void *_tmp_140_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15840 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15841 | (_tmp_140_var = _tmp_140_rule(p)) // ',' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15842 | ) |
| 15843 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 15844 | _res = _tmp_140_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15845 | if (_n == _children_capacity) { |
| 15846 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15847 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15848 | if (!_new_children) { |
| 15849 | p->error_indicator = 1; |
| 15850 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15851 | return NULL; |
| 15852 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15853 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15854 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15855 | _children[_n++] = _res; |
| 15856 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15857 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15858 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15859 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15860 | if (_n == 0 || p->error_indicator) { |
| 15861 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15862 | return NULL; |
| 15863 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15864 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15865 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15866 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15867 | p->error_indicator = 1; |
| 15868 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15869 | return NULL; |
| 15870 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15871 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15872 | PyMem_Free(_children); |
| 15873 | _PyPegen_insert_memo(p, _start_mark, _loop1_74_type, _seq); |
| 15874 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15875 | } |
| 15876 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15877 | // _loop0_75: lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15878 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15879 | _loop0_75_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15880 | { |
| 15881 | if (p->error_indicator) { |
| 15882 | return NULL; |
| 15883 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15884 | void *_res = NULL; |
| 15885 | int _mark = p->mark; |
| 15886 | int _start_mark = p->mark; |
| 15887 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15888 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15889 | p->error_indicator = 1; |
| 15890 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15891 | return NULL; |
| 15892 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15893 | ssize_t _children_capacity = 1; |
| 15894 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15895 | { // lambda_param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15896 | if (p->error_indicator) { |
| 15897 | return NULL; |
| 15898 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15899 | arg_ty lambda_param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15900 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15901 | (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] | 15902 | ) |
| 15903 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15904 | _res = lambda_param_no_default_var; |
| 15905 | if (_n == _children_capacity) { |
| 15906 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15907 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15908 | if (!_new_children) { |
| 15909 | p->error_indicator = 1; |
| 15910 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15911 | return NULL; |
| 15912 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15913 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15914 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15915 | _children[_n++] = _res; |
| 15916 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15917 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15918 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15919 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15920 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15921 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15922 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15923 | p->error_indicator = 1; |
| 15924 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15925 | return NULL; |
| 15926 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15927 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15928 | PyMem_Free(_children); |
| 15929 | _PyPegen_insert_memo(p, _start_mark, _loop0_75_type, _seq); |
| 15930 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15931 | } |
| 15932 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15933 | // _loop0_76: lambda_param_with_default |
| 15934 | static asdl_seq * |
| 15935 | _loop0_76_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15936 | { |
| 15937 | if (p->error_indicator) { |
| 15938 | return NULL; |
| 15939 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15940 | void *_res = NULL; |
| 15941 | int _mark = p->mark; |
| 15942 | int _start_mark = p->mark; |
| 15943 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15944 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15945 | p->error_indicator = 1; |
| 15946 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15947 | return NULL; |
| 15948 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15949 | ssize_t _children_capacity = 1; |
| 15950 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15951 | { // lambda_param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 15952 | if (p->error_indicator) { |
| 15953 | return NULL; |
| 15954 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15955 | NameDefaultPair* lambda_param_with_default_var; |
| 15956 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15957 | (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] | 15958 | ) |
| 15959 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15960 | _res = lambda_param_with_default_var; |
| 15961 | if (_n == _children_capacity) { |
| 15962 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15963 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15964 | if (!_new_children) { |
| 15965 | p->error_indicator = 1; |
| 15966 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15967 | return NULL; |
| 15968 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15969 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15970 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15971 | _children[_n++] = _res; |
| 15972 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15973 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15974 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15975 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15976 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15977 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15978 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 15979 | p->error_indicator = 1; |
| 15980 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15981 | return NULL; |
| 15982 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15983 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15984 | PyMem_Free(_children); |
| 15985 | _PyPegen_insert_memo(p, _start_mark, _loop0_76_type, _seq); |
| 15986 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15987 | } |
| 15988 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15989 | // _loop0_77: lambda_param_with_default |
| 15990 | static asdl_seq * |
| 15991 | _loop0_77_rule(Parser *p) |
| 15992 | { |
| 15993 | if (p->error_indicator) { |
| 15994 | return NULL; |
| 15995 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15996 | void *_res = NULL; |
| 15997 | int _mark = p->mark; |
| 15998 | int _start_mark = p->mark; |
| 15999 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16000 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16001 | p->error_indicator = 1; |
| 16002 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16003 | return NULL; |
| 16004 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16005 | ssize_t _children_capacity = 1; |
| 16006 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16007 | { // lambda_param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16008 | if (p->error_indicator) { |
| 16009 | return NULL; |
| 16010 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16011 | NameDefaultPair* lambda_param_with_default_var; |
| 16012 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16013 | (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] | 16014 | ) |
| 16015 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16016 | _res = lambda_param_with_default_var; |
| 16017 | if (_n == _children_capacity) { |
| 16018 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16019 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16020 | if (!_new_children) { |
| 16021 | p->error_indicator = 1; |
| 16022 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16023 | return NULL; |
| 16024 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16025 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16026 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16027 | _children[_n++] = _res; |
| 16028 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16029 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16030 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16031 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16032 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16033 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16034 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16035 | p->error_indicator = 1; |
| 16036 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16037 | return NULL; |
| 16038 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16039 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16040 | PyMem_Free(_children); |
| 16041 | _PyPegen_insert_memo(p, _start_mark, _loop0_77_type, _seq); |
| 16042 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16043 | } |
| 16044 | |
| 16045 | // _loop1_78: lambda_param_no_default |
| 16046 | static asdl_seq * |
| 16047 | _loop1_78_rule(Parser *p) |
| 16048 | { |
| 16049 | if (p->error_indicator) { |
| 16050 | return NULL; |
| 16051 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16052 | void *_res = NULL; |
| 16053 | int _mark = p->mark; |
| 16054 | int _start_mark = p->mark; |
| 16055 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16056 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16057 | p->error_indicator = 1; |
| 16058 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16059 | return NULL; |
| 16060 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16061 | ssize_t _children_capacity = 1; |
| 16062 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16063 | { // lambda_param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16064 | if (p->error_indicator) { |
| 16065 | return NULL; |
| 16066 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16067 | arg_ty lambda_param_no_default_var; |
| 16068 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16069 | (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] | 16070 | ) |
| 16071 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16072 | _res = lambda_param_no_default_var; |
| 16073 | if (_n == _children_capacity) { |
| 16074 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16075 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16076 | if (!_new_children) { |
| 16077 | p->error_indicator = 1; |
| 16078 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16079 | return NULL; |
| 16080 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16081 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16082 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16083 | _children[_n++] = _res; |
| 16084 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16085 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16086 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16087 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16088 | if (_n == 0 || p->error_indicator) { |
| 16089 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16090 | return NULL; |
| 16091 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16092 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16093 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16094 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16095 | p->error_indicator = 1; |
| 16096 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16097 | return NULL; |
| 16098 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16099 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16100 | PyMem_Free(_children); |
| 16101 | _PyPegen_insert_memo(p, _start_mark, _loop1_78_type, _seq); |
| 16102 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16103 | } |
| 16104 | |
| 16105 | // _loop0_79: lambda_param_with_default |
| 16106 | static asdl_seq * |
| 16107 | _loop0_79_rule(Parser *p) |
| 16108 | { |
| 16109 | if (p->error_indicator) { |
| 16110 | return NULL; |
| 16111 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16112 | void *_res = NULL; |
| 16113 | int _mark = p->mark; |
| 16114 | int _start_mark = p->mark; |
| 16115 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16116 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16117 | p->error_indicator = 1; |
| 16118 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16119 | return NULL; |
| 16120 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16121 | ssize_t _children_capacity = 1; |
| 16122 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16123 | { // lambda_param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16124 | if (p->error_indicator) { |
| 16125 | return NULL; |
| 16126 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16127 | NameDefaultPair* lambda_param_with_default_var; |
| 16128 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16129 | (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] | 16130 | ) |
| 16131 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16132 | _res = lambda_param_with_default_var; |
| 16133 | if (_n == _children_capacity) { |
| 16134 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16135 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16136 | if (!_new_children) { |
| 16137 | p->error_indicator = 1; |
| 16138 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16139 | return NULL; |
| 16140 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16141 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16142 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16143 | _children[_n++] = _res; |
| 16144 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16145 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16146 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16147 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16148 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16149 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16150 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16151 | p->error_indicator = 1; |
| 16152 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16153 | return NULL; |
| 16154 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16155 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16156 | PyMem_Free(_children); |
| 16157 | _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq); |
| 16158 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16159 | } |
| 16160 | |
| 16161 | // _loop1_80: lambda_param_with_default |
| 16162 | static asdl_seq * |
| 16163 | _loop1_80_rule(Parser *p) |
| 16164 | { |
| 16165 | if (p->error_indicator) { |
| 16166 | return NULL; |
| 16167 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16168 | void *_res = NULL; |
| 16169 | int _mark = p->mark; |
| 16170 | int _start_mark = p->mark; |
| 16171 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16172 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16173 | p->error_indicator = 1; |
| 16174 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16175 | return NULL; |
| 16176 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16177 | ssize_t _children_capacity = 1; |
| 16178 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16179 | { // lambda_param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16180 | if (p->error_indicator) { |
| 16181 | return NULL; |
| 16182 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16183 | NameDefaultPair* lambda_param_with_default_var; |
| 16184 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16185 | (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] | 16186 | ) |
| 16187 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16188 | _res = lambda_param_with_default_var; |
| 16189 | if (_n == _children_capacity) { |
| 16190 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16191 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16192 | if (!_new_children) { |
| 16193 | p->error_indicator = 1; |
| 16194 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16195 | return NULL; |
| 16196 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16197 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16198 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16199 | _children[_n++] = _res; |
| 16200 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16201 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16202 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16203 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16204 | if (_n == 0 || p->error_indicator) { |
| 16205 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16206 | return NULL; |
| 16207 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16208 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16209 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16210 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16211 | p->error_indicator = 1; |
| 16212 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16213 | return NULL; |
| 16214 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16215 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16216 | PyMem_Free(_children); |
| 16217 | _PyPegen_insert_memo(p, _start_mark, _loop1_80_type, _seq); |
| 16218 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16219 | } |
| 16220 | |
| 16221 | // _loop1_81: lambda_param_no_default |
| 16222 | static asdl_seq * |
| 16223 | _loop1_81_rule(Parser *p) |
| 16224 | { |
| 16225 | if (p->error_indicator) { |
| 16226 | return NULL; |
| 16227 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16228 | void *_res = NULL; |
| 16229 | int _mark = p->mark; |
| 16230 | int _start_mark = p->mark; |
| 16231 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16232 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16233 | p->error_indicator = 1; |
| 16234 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16235 | return NULL; |
| 16236 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16237 | ssize_t _children_capacity = 1; |
| 16238 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16239 | { // lambda_param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16240 | if (p->error_indicator) { |
| 16241 | return NULL; |
| 16242 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16243 | arg_ty lambda_param_no_default_var; |
| 16244 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16245 | (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] | 16246 | ) |
| 16247 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16248 | _res = lambda_param_no_default_var; |
| 16249 | if (_n == _children_capacity) { |
| 16250 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16251 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16252 | if (!_new_children) { |
| 16253 | p->error_indicator = 1; |
| 16254 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16255 | return NULL; |
| 16256 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16257 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16258 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16259 | _children[_n++] = _res; |
| 16260 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16261 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16262 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16263 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16264 | if (_n == 0 || p->error_indicator) { |
| 16265 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16266 | return NULL; |
| 16267 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16268 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16269 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16270 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16271 | p->error_indicator = 1; |
| 16272 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16273 | return NULL; |
| 16274 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16275 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16276 | PyMem_Free(_children); |
| 16277 | _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq); |
| 16278 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16279 | } |
| 16280 | |
| 16281 | // _loop1_82: lambda_param_no_default |
| 16282 | static asdl_seq * |
| 16283 | _loop1_82_rule(Parser *p) |
| 16284 | { |
| 16285 | if (p->error_indicator) { |
| 16286 | return NULL; |
| 16287 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16288 | void *_res = NULL; |
| 16289 | int _mark = p->mark; |
| 16290 | int _start_mark = p->mark; |
| 16291 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16292 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16293 | p->error_indicator = 1; |
| 16294 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16295 | return NULL; |
| 16296 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16297 | ssize_t _children_capacity = 1; |
| 16298 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16299 | { // lambda_param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16300 | if (p->error_indicator) { |
| 16301 | return NULL; |
| 16302 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16303 | arg_ty lambda_param_no_default_var; |
| 16304 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16305 | (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] | 16306 | ) |
| 16307 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16308 | _res = lambda_param_no_default_var; |
| 16309 | if (_n == _children_capacity) { |
| 16310 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16311 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16312 | if (!_new_children) { |
| 16313 | p->error_indicator = 1; |
| 16314 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16315 | return NULL; |
| 16316 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16317 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16318 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16319 | _children[_n++] = _res; |
| 16320 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16321 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16322 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16323 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16324 | if (_n == 0 || p->error_indicator) { |
| 16325 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16326 | return NULL; |
| 16327 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16328 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16329 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16330 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16331 | p->error_indicator = 1; |
| 16332 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16333 | return NULL; |
| 16334 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16335 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16336 | PyMem_Free(_children); |
| 16337 | _PyPegen_insert_memo(p, _start_mark, _loop1_82_type, _seq); |
| 16338 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16339 | } |
| 16340 | |
| 16341 | // _loop0_83: lambda_param_no_default |
| 16342 | static asdl_seq * |
| 16343 | _loop0_83_rule(Parser *p) |
| 16344 | { |
| 16345 | if (p->error_indicator) { |
| 16346 | return NULL; |
| 16347 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16348 | void *_res = NULL; |
| 16349 | int _mark = p->mark; |
| 16350 | int _start_mark = p->mark; |
| 16351 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16352 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16353 | p->error_indicator = 1; |
| 16354 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16355 | return NULL; |
| 16356 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16357 | ssize_t _children_capacity = 1; |
| 16358 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16359 | { // lambda_param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16360 | if (p->error_indicator) { |
| 16361 | return NULL; |
| 16362 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16363 | arg_ty lambda_param_no_default_var; |
| 16364 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16365 | (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] | 16366 | ) |
| 16367 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16368 | _res = lambda_param_no_default_var; |
| 16369 | if (_n == _children_capacity) { |
| 16370 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16371 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16372 | if (!_new_children) { |
| 16373 | p->error_indicator = 1; |
| 16374 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16375 | return NULL; |
| 16376 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16377 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16378 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16379 | _children[_n++] = _res; |
| 16380 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16381 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16382 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16383 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16384 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16385 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16386 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16387 | p->error_indicator = 1; |
| 16388 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16389 | return NULL; |
| 16390 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16391 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16392 | PyMem_Free(_children); |
| 16393 | _PyPegen_insert_memo(p, _start_mark, _loop0_83_type, _seq); |
| 16394 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16395 | } |
| 16396 | |
| 16397 | // _loop1_84: lambda_param_with_default |
| 16398 | static asdl_seq * |
| 16399 | _loop1_84_rule(Parser *p) |
| 16400 | { |
| 16401 | if (p->error_indicator) { |
| 16402 | return NULL; |
| 16403 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16404 | void *_res = NULL; |
| 16405 | int _mark = p->mark; |
| 16406 | int _start_mark = p->mark; |
| 16407 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16408 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16409 | p->error_indicator = 1; |
| 16410 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16411 | return NULL; |
| 16412 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16413 | ssize_t _children_capacity = 1; |
| 16414 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16415 | { // lambda_param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16416 | if (p->error_indicator) { |
| 16417 | return NULL; |
| 16418 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16419 | NameDefaultPair* lambda_param_with_default_var; |
| 16420 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16421 | (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] | 16422 | ) |
| 16423 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16424 | _res = lambda_param_with_default_var; |
| 16425 | if (_n == _children_capacity) { |
| 16426 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16427 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16428 | if (!_new_children) { |
| 16429 | p->error_indicator = 1; |
| 16430 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16431 | return NULL; |
| 16432 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16433 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16434 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16435 | _children[_n++] = _res; |
| 16436 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16437 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16438 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16439 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16440 | if (_n == 0 || p->error_indicator) { |
| 16441 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16442 | return NULL; |
| 16443 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16444 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16445 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16446 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16447 | p->error_indicator = 1; |
| 16448 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16449 | return NULL; |
| 16450 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16451 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16452 | PyMem_Free(_children); |
| 16453 | _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); |
| 16454 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16455 | } |
| 16456 | |
| 16457 | // _loop0_85: lambda_param_no_default |
| 16458 | static asdl_seq * |
| 16459 | _loop0_85_rule(Parser *p) |
| 16460 | { |
| 16461 | if (p->error_indicator) { |
| 16462 | return NULL; |
| 16463 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16464 | void *_res = NULL; |
| 16465 | int _mark = p->mark; |
| 16466 | int _start_mark = p->mark; |
| 16467 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16468 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16469 | p->error_indicator = 1; |
| 16470 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16471 | return NULL; |
| 16472 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16473 | ssize_t _children_capacity = 1; |
| 16474 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16475 | { // lambda_param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16476 | if (p->error_indicator) { |
| 16477 | return NULL; |
| 16478 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16479 | arg_ty lambda_param_no_default_var; |
| 16480 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16481 | (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] | 16482 | ) |
| 16483 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16484 | _res = lambda_param_no_default_var; |
| 16485 | if (_n == _children_capacity) { |
| 16486 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16487 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16488 | if (!_new_children) { |
| 16489 | p->error_indicator = 1; |
| 16490 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16491 | return NULL; |
| 16492 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16493 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16494 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16495 | _children[_n++] = _res; |
| 16496 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16497 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16498 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16499 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16500 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16501 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16502 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16503 | p->error_indicator = 1; |
| 16504 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16505 | return NULL; |
| 16506 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16507 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16508 | PyMem_Free(_children); |
| 16509 | _PyPegen_insert_memo(p, _start_mark, _loop0_85_type, _seq); |
| 16510 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16511 | } |
| 16512 | |
| 16513 | // _loop1_86: lambda_param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16514 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16515 | _loop1_86_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16516 | { |
| 16517 | if (p->error_indicator) { |
| 16518 | return NULL; |
| 16519 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16520 | void *_res = NULL; |
| 16521 | int _mark = p->mark; |
| 16522 | int _start_mark = p->mark; |
| 16523 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16524 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16525 | p->error_indicator = 1; |
| 16526 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16527 | return NULL; |
| 16528 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16529 | ssize_t _children_capacity = 1; |
| 16530 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16531 | { // lambda_param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16532 | if (p->error_indicator) { |
| 16533 | return NULL; |
| 16534 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16535 | NameDefaultPair* lambda_param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16536 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16537 | (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] | 16538 | ) |
| 16539 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16540 | _res = lambda_param_with_default_var; |
| 16541 | if (_n == _children_capacity) { |
| 16542 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16543 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16544 | if (!_new_children) { |
| 16545 | p->error_indicator = 1; |
| 16546 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16547 | return NULL; |
| 16548 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16549 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16550 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16551 | _children[_n++] = _res; |
| 16552 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16553 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16554 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16555 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16556 | if (_n == 0 || p->error_indicator) { |
| 16557 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16558 | return NULL; |
| 16559 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16560 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16561 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16562 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16563 | p->error_indicator = 1; |
| 16564 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16565 | return NULL; |
| 16566 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16567 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16568 | PyMem_Free(_children); |
| 16569 | _PyPegen_insert_memo(p, _start_mark, _loop1_86_type, _seq); |
| 16570 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16571 | } |
| 16572 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16573 | // _loop0_87: lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16574 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16575 | _loop0_87_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16576 | { |
| 16577 | if (p->error_indicator) { |
| 16578 | return NULL; |
| 16579 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16580 | void *_res = NULL; |
| 16581 | int _mark = p->mark; |
| 16582 | int _start_mark = p->mark; |
| 16583 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16584 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16585 | p->error_indicator = 1; |
| 16586 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16587 | return NULL; |
| 16588 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16589 | ssize_t _children_capacity = 1; |
| 16590 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16591 | { // lambda_param_maybe_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16592 | if (p->error_indicator) { |
| 16593 | return NULL; |
| 16594 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16595 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16596 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16597 | (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] | 16598 | ) |
| 16599 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16600 | _res = lambda_param_maybe_default_var; |
| 16601 | if (_n == _children_capacity) { |
| 16602 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16603 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16604 | if (!_new_children) { |
| 16605 | p->error_indicator = 1; |
| 16606 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16607 | return NULL; |
| 16608 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16609 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16610 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16611 | _children[_n++] = _res; |
| 16612 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16613 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16614 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16615 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16616 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16617 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16618 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16619 | p->error_indicator = 1; |
| 16620 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16621 | return NULL; |
| 16622 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16623 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16624 | PyMem_Free(_children); |
| 16625 | _PyPegen_insert_memo(p, _start_mark, _loop0_87_type, _seq); |
| 16626 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16627 | } |
| 16628 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16629 | // _loop1_88: lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16630 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16631 | _loop1_88_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16632 | { |
| 16633 | if (p->error_indicator) { |
| 16634 | return NULL; |
| 16635 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16636 | void *_res = NULL; |
| 16637 | int _mark = p->mark; |
| 16638 | int _start_mark = p->mark; |
| 16639 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16640 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16641 | p->error_indicator = 1; |
| 16642 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16643 | return NULL; |
| 16644 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16645 | ssize_t _children_capacity = 1; |
| 16646 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16647 | { // lambda_param_maybe_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16648 | if (p->error_indicator) { |
| 16649 | return NULL; |
| 16650 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16651 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16652 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16653 | (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] | 16654 | ) |
| 16655 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16656 | _res = lambda_param_maybe_default_var; |
| 16657 | if (_n == _children_capacity) { |
| 16658 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16659 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16660 | if (!_new_children) { |
| 16661 | p->error_indicator = 1; |
| 16662 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16663 | return NULL; |
| 16664 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16665 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16666 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16667 | _children[_n++] = _res; |
| 16668 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16669 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16670 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16671 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16672 | if (_n == 0 || p->error_indicator) { |
| 16673 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16674 | return NULL; |
| 16675 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16676 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16677 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16678 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16679 | p->error_indicator = 1; |
| 16680 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16681 | return NULL; |
| 16682 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16683 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16684 | PyMem_Free(_children); |
| 16685 | _PyPegen_insert_memo(p, _start_mark, _loop1_88_type, _seq); |
| 16686 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16687 | } |
| 16688 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16689 | // _loop1_89: ('or' conjunction) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16690 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16691 | _loop1_89_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16692 | { |
| 16693 | if (p->error_indicator) { |
| 16694 | return NULL; |
| 16695 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16696 | void *_res = NULL; |
| 16697 | int _mark = p->mark; |
| 16698 | int _start_mark = p->mark; |
| 16699 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16700 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16701 | p->error_indicator = 1; |
| 16702 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16703 | return NULL; |
| 16704 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16705 | ssize_t _children_capacity = 1; |
| 16706 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16707 | { // ('or' conjunction) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16708 | if (p->error_indicator) { |
| 16709 | return NULL; |
| 16710 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16711 | void *_tmp_141_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16712 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16713 | (_tmp_141_var = _tmp_141_rule(p)) // 'or' conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16714 | ) |
| 16715 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16716 | _res = _tmp_141_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16717 | if (_n == _children_capacity) { |
| 16718 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16719 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16720 | if (!_new_children) { |
| 16721 | p->error_indicator = 1; |
| 16722 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16723 | return NULL; |
| 16724 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16725 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16726 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16727 | _children[_n++] = _res; |
| 16728 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16729 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16730 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16731 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16732 | if (_n == 0 || p->error_indicator) { |
| 16733 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16734 | return NULL; |
| 16735 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16736 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16737 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16738 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16739 | p->error_indicator = 1; |
| 16740 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16741 | return NULL; |
| 16742 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16743 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16744 | PyMem_Free(_children); |
| 16745 | _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq); |
| 16746 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16747 | } |
| 16748 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16749 | // _loop1_90: ('and' inversion) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16750 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16751 | _loop1_90_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16752 | { |
| 16753 | if (p->error_indicator) { |
| 16754 | return NULL; |
| 16755 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16756 | void *_res = NULL; |
| 16757 | int _mark = p->mark; |
| 16758 | int _start_mark = p->mark; |
| 16759 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16760 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16761 | p->error_indicator = 1; |
| 16762 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16763 | return NULL; |
| 16764 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16765 | ssize_t _children_capacity = 1; |
| 16766 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16767 | { // ('and' inversion) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16768 | if (p->error_indicator) { |
| 16769 | return NULL; |
| 16770 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16771 | void *_tmp_142_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16772 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16773 | (_tmp_142_var = _tmp_142_rule(p)) // 'and' inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16774 | ) |
| 16775 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 16776 | _res = _tmp_142_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16777 | if (_n == _children_capacity) { |
| 16778 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16779 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16780 | if (!_new_children) { |
| 16781 | p->error_indicator = 1; |
| 16782 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16783 | return NULL; |
| 16784 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16785 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16786 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16787 | _children[_n++] = _res; |
| 16788 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16789 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16790 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16791 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16792 | if (_n == 0 || p->error_indicator) { |
| 16793 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16794 | return NULL; |
| 16795 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16796 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16797 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16798 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16799 | p->error_indicator = 1; |
| 16800 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16801 | return NULL; |
| 16802 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16803 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16804 | PyMem_Free(_children); |
| 16805 | _PyPegen_insert_memo(p, _start_mark, _loop1_90_type, _seq); |
| 16806 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16807 | } |
| 16808 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16809 | // _loop1_91: compare_op_bitwise_or_pair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16810 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16811 | _loop1_91_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16812 | { |
| 16813 | if (p->error_indicator) { |
| 16814 | return NULL; |
| 16815 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16816 | void *_res = NULL; |
| 16817 | int _mark = p->mark; |
| 16818 | int _start_mark = p->mark; |
| 16819 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16820 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16821 | p->error_indicator = 1; |
| 16822 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16823 | return NULL; |
| 16824 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16825 | ssize_t _children_capacity = 1; |
| 16826 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16827 | { // compare_op_bitwise_or_pair |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16828 | if (p->error_indicator) { |
| 16829 | return NULL; |
| 16830 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16831 | CmpopExprPair* compare_op_bitwise_or_pair_var; |
| 16832 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16833 | (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] | 16834 | ) |
| 16835 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16836 | _res = compare_op_bitwise_or_pair_var; |
| 16837 | if (_n == _children_capacity) { |
| 16838 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16839 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16840 | if (!_new_children) { |
| 16841 | p->error_indicator = 1; |
| 16842 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16843 | return NULL; |
| 16844 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16845 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16846 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16847 | _children[_n++] = _res; |
| 16848 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16849 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16850 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16851 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16852 | if (_n == 0 || p->error_indicator) { |
| 16853 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16854 | return NULL; |
| 16855 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16856 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16857 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16858 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16859 | p->error_indicator = 1; |
| 16860 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16861 | return NULL; |
| 16862 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16863 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16864 | PyMem_Free(_children); |
| 16865 | _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq); |
| 16866 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16867 | } |
| 16868 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16869 | // _tmp_92: '!=' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16870 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16871 | _tmp_92_rule(Parser *p) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16872 | { |
| 16873 | if (p->error_indicator) { |
| 16874 | return NULL; |
| 16875 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16876 | void * _res = NULL; |
| 16877 | int _mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16878 | { // '!=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16879 | if (p->error_indicator) { |
| 16880 | return NULL; |
| 16881 | } |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16882 | Token * tok; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16883 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16884 | (tok = _PyPegen_expect_token(p, 28)) // token='!=' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16885 | ) |
| 16886 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16887 | _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; |
| 16888 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16889 | p->error_indicator = 1; |
| 16890 | return NULL; |
| 16891 | } |
| 16892 | goto done; |
| 16893 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16894 | p->mark = _mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16895 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16896 | _res = NULL; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16897 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16898 | return _res; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16899 | } |
| 16900 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16901 | // _loop0_94: ',' slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16902 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16903 | _loop0_94_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16904 | { |
| 16905 | if (p->error_indicator) { |
| 16906 | return NULL; |
| 16907 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16908 | void *_res = NULL; |
| 16909 | int _mark = p->mark; |
| 16910 | int _start_mark = p->mark; |
| 16911 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16912 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16913 | p->error_indicator = 1; |
| 16914 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16915 | return NULL; |
| 16916 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16917 | ssize_t _children_capacity = 1; |
| 16918 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16919 | { // ',' slice |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16920 | if (p->error_indicator) { |
| 16921 | return NULL; |
| 16922 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16923 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16924 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16925 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16926 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16927 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16928 | (elem = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16929 | ) |
| 16930 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16931 | _res = elem; |
| 16932 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16933 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16934 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16935 | return NULL; |
| 16936 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16937 | if (_n == _children_capacity) { |
| 16938 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16939 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16940 | if (!_new_children) { |
| 16941 | p->error_indicator = 1; |
| 16942 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16943 | return NULL; |
| 16944 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16945 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16946 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16947 | _children[_n++] = _res; |
| 16948 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16949 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16950 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16951 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16952 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16953 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16954 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 16955 | p->error_indicator = 1; |
| 16956 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16957 | return NULL; |
| 16958 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16959 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16960 | PyMem_Free(_children); |
| 16961 | _PyPegen_insert_memo(p, _start_mark, _loop0_94_type, _seq); |
| 16962 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16963 | } |
| 16964 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16965 | // _gather_93: slice _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16966 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16967 | _gather_93_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16968 | { |
| 16969 | if (p->error_indicator) { |
| 16970 | return NULL; |
| 16971 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16972 | asdl_seq * _res = NULL; |
| 16973 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16974 | { // slice _loop0_94 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 16975 | if (p->error_indicator) { |
| 16976 | return NULL; |
| 16977 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16978 | expr_ty elem; |
| 16979 | asdl_seq * seq; |
| 16980 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16981 | (elem = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16982 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16983 | (seq = _loop0_94_rule(p)) // _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16984 | ) |
| 16985 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16986 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16987 | goto done; |
| 16988 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16989 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16990 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16991 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16992 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16993 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16994 | } |
| 16995 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16996 | // _tmp_95: ':' expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16997 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16998 | _tmp_95_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16999 | { |
| 17000 | if (p->error_indicator) { |
| 17001 | return NULL; |
| 17002 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17003 | void * _res = NULL; |
| 17004 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17005 | { // ':' expression? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17006 | if (p->error_indicator) { |
| 17007 | return NULL; |
| 17008 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17009 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17010 | void *d; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17011 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17012 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17013 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17014 | (d = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17015 | ) |
| 17016 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17017 | _res = d; |
| 17018 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17019 | p->error_indicator = 1; |
| 17020 | return NULL; |
| 17021 | } |
| 17022 | goto done; |
| 17023 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17024 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17025 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17026 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17027 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17028 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17029 | } |
| 17030 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17031 | // _tmp_96: tuple | group | genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17032 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17033 | _tmp_96_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17034 | { |
| 17035 | if (p->error_indicator) { |
| 17036 | return NULL; |
| 17037 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17038 | void * _res = NULL; |
| 17039 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17040 | { // tuple |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17041 | if (p->error_indicator) { |
| 17042 | return NULL; |
| 17043 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17044 | expr_ty tuple_var; |
| 17045 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17046 | (tuple_var = tuple_rule(p)) // tuple |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17047 | ) |
| 17048 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17049 | _res = tuple_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17050 | goto done; |
| 17051 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17052 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17053 | } |
| 17054 | { // group |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17055 | if (p->error_indicator) { |
| 17056 | return NULL; |
| 17057 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17058 | expr_ty group_var; |
| 17059 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17060 | (group_var = group_rule(p)) // group |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17061 | ) |
| 17062 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17063 | _res = group_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17064 | goto done; |
| 17065 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17066 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17067 | } |
| 17068 | { // genexp |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17069 | if (p->error_indicator) { |
| 17070 | return NULL; |
| 17071 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17072 | expr_ty genexp_var; |
| 17073 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17074 | (genexp_var = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17075 | ) |
| 17076 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17077 | _res = genexp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17078 | goto done; |
| 17079 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17080 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17081 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17082 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17083 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17084 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17085 | } |
| 17086 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17087 | // _tmp_97: list | listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17088 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17089 | _tmp_97_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17090 | { |
| 17091 | if (p->error_indicator) { |
| 17092 | return NULL; |
| 17093 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17094 | void * _res = NULL; |
| 17095 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17096 | { // list |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17097 | if (p->error_indicator) { |
| 17098 | return NULL; |
| 17099 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17100 | expr_ty list_var; |
| 17101 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17102 | (list_var = list_rule(p)) // list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17103 | ) |
| 17104 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17105 | _res = list_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17106 | goto done; |
| 17107 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17108 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17109 | } |
| 17110 | { // listcomp |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17111 | if (p->error_indicator) { |
| 17112 | return NULL; |
| 17113 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17114 | expr_ty listcomp_var; |
| 17115 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17116 | (listcomp_var = listcomp_rule(p)) // listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17117 | ) |
| 17118 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17119 | _res = listcomp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17120 | goto done; |
| 17121 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17122 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17123 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17124 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17125 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17126 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17127 | } |
| 17128 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17129 | // _tmp_98: dict | set | dictcomp | setcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17130 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17131 | _tmp_98_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17132 | { |
| 17133 | if (p->error_indicator) { |
| 17134 | return NULL; |
| 17135 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17136 | void * _res = NULL; |
| 17137 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17138 | { // dict |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17139 | if (p->error_indicator) { |
| 17140 | return NULL; |
| 17141 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17142 | expr_ty dict_var; |
| 17143 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17144 | (dict_var = dict_rule(p)) // dict |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17145 | ) |
| 17146 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17147 | _res = dict_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17148 | goto done; |
| 17149 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17150 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17151 | } |
| 17152 | { // set |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17153 | if (p->error_indicator) { |
| 17154 | return NULL; |
| 17155 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17156 | expr_ty set_var; |
| 17157 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17158 | (set_var = set_rule(p)) // set |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17159 | ) |
| 17160 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17161 | _res = set_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17162 | goto done; |
| 17163 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17164 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17165 | } |
| 17166 | { // dictcomp |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17167 | if (p->error_indicator) { |
| 17168 | return NULL; |
| 17169 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17170 | expr_ty dictcomp_var; |
| 17171 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17172 | (dictcomp_var = dictcomp_rule(p)) // dictcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17173 | ) |
| 17174 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17175 | _res = dictcomp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17176 | goto done; |
| 17177 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17178 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17179 | } |
| 17180 | { // setcomp |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17181 | if (p->error_indicator) { |
| 17182 | return NULL; |
| 17183 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17184 | expr_ty setcomp_var; |
| 17185 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17186 | (setcomp_var = setcomp_rule(p)) // setcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17187 | ) |
| 17188 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17189 | _res = setcomp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17190 | goto done; |
| 17191 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17192 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17193 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17194 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17195 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17196 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17197 | } |
| 17198 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17199 | // _loop1_99: STRING |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17200 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17201 | _loop1_99_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17202 | { |
| 17203 | if (p->error_indicator) { |
| 17204 | return NULL; |
| 17205 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17206 | void *_res = NULL; |
| 17207 | int _mark = p->mark; |
| 17208 | int _start_mark = p->mark; |
| 17209 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17210 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17211 | p->error_indicator = 1; |
| 17212 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17213 | return NULL; |
| 17214 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17215 | ssize_t _children_capacity = 1; |
| 17216 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17217 | { // STRING |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17218 | if (p->error_indicator) { |
| 17219 | return NULL; |
| 17220 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17221 | expr_ty string_var; |
| 17222 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17223 | (string_var = _PyPegen_string_token(p)) // STRING |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17224 | ) |
| 17225 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17226 | _res = string_var; |
| 17227 | if (_n == _children_capacity) { |
| 17228 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17229 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17230 | if (!_new_children) { |
| 17231 | p->error_indicator = 1; |
| 17232 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17233 | return NULL; |
| 17234 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17235 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17236 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17237 | _children[_n++] = _res; |
| 17238 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17239 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17240 | p->mark = _mark; |
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 | if (_n == 0 || p->error_indicator) { |
| 17243 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17244 | return NULL; |
| 17245 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17246 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17247 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17248 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17249 | p->error_indicator = 1; |
| 17250 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17251 | return NULL; |
| 17252 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17253 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17254 | PyMem_Free(_children); |
| 17255 | _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq); |
| 17256 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17257 | } |
| 17258 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17259 | // _tmp_100: star_named_expression ',' star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17260 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17261 | _tmp_100_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17262 | { |
| 17263 | if (p->error_indicator) { |
| 17264 | return NULL; |
| 17265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17266 | void * _res = NULL; |
| 17267 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17268 | { // star_named_expression ',' star_named_expressions? |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17269 | if (p->error_indicator) { |
| 17270 | return NULL; |
| 17271 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17272 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17273 | expr_ty y; |
| 17274 | void *z; |
| 17275 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17276 | (y = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17277 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17278 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17279 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17280 | (z = star_named_expressions_rule(p), 1) // star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17281 | ) |
| 17282 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17283 | _res = _PyPegen_seq_insert_in_front ( p , y , z ); |
| 17284 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17285 | p->error_indicator = 1; |
| 17286 | return NULL; |
| 17287 | } |
| 17288 | goto done; |
| 17289 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17290 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17291 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17292 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17293 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17294 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17295 | } |
| 17296 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17297 | // _tmp_101: yield_expr | named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17298 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17299 | _tmp_101_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17300 | { |
| 17301 | if (p->error_indicator) { |
| 17302 | return NULL; |
| 17303 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17304 | void * _res = NULL; |
| 17305 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17306 | { // yield_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17307 | if (p->error_indicator) { |
| 17308 | return NULL; |
| 17309 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17310 | expr_ty yield_expr_var; |
| 17311 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17312 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17313 | ) |
| 17314 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17315 | _res = yield_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17316 | goto done; |
| 17317 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17318 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17319 | } |
| 17320 | { // named_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17321 | if (p->error_indicator) { |
| 17322 | return NULL; |
| 17323 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17324 | expr_ty named_expression_var; |
| 17325 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17326 | (named_expression_var = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17327 | ) |
| 17328 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17329 | _res = named_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17330 | goto done; |
| 17331 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17332 | p->mark = _mark; |
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 | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17336 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17337 | } |
| 17338 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17339 | // _loop0_103: ',' kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17340 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17341 | _loop0_103_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17342 | { |
| 17343 | if (p->error_indicator) { |
| 17344 | return NULL; |
| 17345 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17346 | void *_res = NULL; |
| 17347 | int _mark = p->mark; |
| 17348 | int _start_mark = p->mark; |
| 17349 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17350 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17351 | p->error_indicator = 1; |
| 17352 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17353 | return NULL; |
| 17354 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17355 | ssize_t _children_capacity = 1; |
| 17356 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17357 | { // ',' kvpair |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17358 | if (p->error_indicator) { |
| 17359 | return NULL; |
| 17360 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17361 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17362 | KeyValuePair* elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17363 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17364 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17365 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17366 | (elem = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17367 | ) |
| 17368 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17369 | _res = elem; |
| 17370 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17371 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17372 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17373 | return NULL; |
| 17374 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17375 | if (_n == _children_capacity) { |
| 17376 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17377 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17378 | if (!_new_children) { |
| 17379 | p->error_indicator = 1; |
| 17380 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17381 | return NULL; |
| 17382 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17383 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17384 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17385 | _children[_n++] = _res; |
| 17386 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17387 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17388 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17389 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17390 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17391 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17392 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17393 | p->error_indicator = 1; |
| 17394 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17395 | return NULL; |
| 17396 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17397 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17398 | PyMem_Free(_children); |
| 17399 | _PyPegen_insert_memo(p, _start_mark, _loop0_103_type, _seq); |
| 17400 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17401 | } |
| 17402 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17403 | // _gather_102: kvpair _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17404 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17405 | _gather_102_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17406 | { |
| 17407 | if (p->error_indicator) { |
| 17408 | return NULL; |
| 17409 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17410 | asdl_seq * _res = NULL; |
| 17411 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17412 | { // kvpair _loop0_103 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17413 | if (p->error_indicator) { |
| 17414 | return NULL; |
| 17415 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17416 | KeyValuePair* elem; |
| 17417 | asdl_seq * seq; |
| 17418 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17419 | (elem = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17420 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17421 | (seq = _loop0_103_rule(p)) // _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17422 | ) |
| 17423 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17424 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17425 | goto done; |
| 17426 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17427 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17428 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17429 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17430 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17431 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17432 | } |
| 17433 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17434 | // _loop1_104: for_if_clause |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17435 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17436 | _loop1_104_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17437 | { |
| 17438 | if (p->error_indicator) { |
| 17439 | return NULL; |
| 17440 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17441 | void *_res = NULL; |
| 17442 | int _mark = p->mark; |
| 17443 | int _start_mark = p->mark; |
| 17444 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17445 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17446 | p->error_indicator = 1; |
| 17447 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17448 | return NULL; |
| 17449 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17450 | ssize_t _children_capacity = 1; |
| 17451 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17452 | { // for_if_clause |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17453 | if (p->error_indicator) { |
| 17454 | return NULL; |
| 17455 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17456 | comprehension_ty for_if_clause_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17457 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17458 | (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17459 | ) |
| 17460 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17461 | _res = for_if_clause_var; |
| 17462 | if (_n == _children_capacity) { |
| 17463 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17464 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17465 | if (!_new_children) { |
| 17466 | p->error_indicator = 1; |
| 17467 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17468 | return NULL; |
| 17469 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17470 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17471 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17472 | _children[_n++] = _res; |
| 17473 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17474 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17475 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17476 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17477 | if (_n == 0 || p->error_indicator) { |
| 17478 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17479 | return NULL; |
| 17480 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17481 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17482 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17483 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17484 | p->error_indicator = 1; |
| 17485 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17486 | return NULL; |
| 17487 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17488 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17489 | PyMem_Free(_children); |
| 17490 | _PyPegen_insert_memo(p, _start_mark, _loop1_104_type, _seq); |
| 17491 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17492 | } |
| 17493 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17494 | // _loop0_105: ('if' disjunction) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 17495 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17496 | _loop0_105_rule(Parser *p) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 17497 | { |
| 17498 | if (p->error_indicator) { |
| 17499 | return NULL; |
| 17500 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17501 | void *_res = NULL; |
| 17502 | int _mark = p->mark; |
| 17503 | int _start_mark = p->mark; |
| 17504 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17505 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17506 | p->error_indicator = 1; |
| 17507 | PyErr_NoMemory(); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 17508 | return NULL; |
| 17509 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17510 | ssize_t _children_capacity = 1; |
| 17511 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17512 | { // ('if' disjunction) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17513 | if (p->error_indicator) { |
| 17514 | return NULL; |
| 17515 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17516 | void *_tmp_143_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 17517 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17518 | (_tmp_143_var = _tmp_143_rule(p)) // 'if' disjunction |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 17519 | ) |
| 17520 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17521 | _res = _tmp_143_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17522 | if (_n == _children_capacity) { |
| 17523 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17524 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17525 | if (!_new_children) { |
| 17526 | p->error_indicator = 1; |
| 17527 | PyErr_NoMemory(); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 17528 | return NULL; |
| 17529 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17530 | _children = _new_children; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 17531 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17532 | _children[_n++] = _res; |
| 17533 | _mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 17534 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17535 | p->mark = _mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 17536 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17537 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17538 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17539 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17540 | p->error_indicator = 1; |
| 17541 | PyErr_NoMemory(); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 17542 | return NULL; |
| 17543 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17544 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17545 | PyMem_Free(_children); |
| 17546 | _PyPegen_insert_memo(p, _start_mark, _loop0_105_type, _seq); |
| 17547 | return _seq; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 17548 | } |
| 17549 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17550 | // _loop0_106: ('if' disjunction) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17551 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17552 | _loop0_106_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17553 | { |
| 17554 | if (p->error_indicator) { |
| 17555 | return NULL; |
| 17556 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17557 | void *_res = NULL; |
| 17558 | int _mark = p->mark; |
| 17559 | int _start_mark = p->mark; |
| 17560 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17561 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17562 | p->error_indicator = 1; |
| 17563 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17564 | return NULL; |
| 17565 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17566 | ssize_t _children_capacity = 1; |
| 17567 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17568 | { // ('if' disjunction) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17569 | if (p->error_indicator) { |
| 17570 | return NULL; |
| 17571 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17572 | void *_tmp_144_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17573 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17574 | (_tmp_144_var = _tmp_144_rule(p)) // 'if' disjunction |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17575 | ) |
| 17576 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 17577 | _res = _tmp_144_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17578 | if (_n == _children_capacity) { |
| 17579 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17580 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17581 | if (!_new_children) { |
| 17582 | p->error_indicator = 1; |
| 17583 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17584 | return NULL; |
| 17585 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17586 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17587 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17588 | _children[_n++] = _res; |
| 17589 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17590 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17591 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17592 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17593 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17594 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17595 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17596 | p->error_indicator = 1; |
| 17597 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17598 | return NULL; |
| 17599 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17600 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17601 | PyMem_Free(_children); |
| 17602 | _PyPegen_insert_memo(p, _start_mark, _loop0_106_type, _seq); |
| 17603 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17604 | } |
| 17605 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17606 | // _tmp_107: ',' args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17607 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17608 | _tmp_107_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17609 | { |
| 17610 | if (p->error_indicator) { |
| 17611 | return NULL; |
| 17612 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17613 | void * _res = NULL; |
| 17614 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17615 | { // ',' args |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17616 | if (p->error_indicator) { |
| 17617 | return NULL; |
| 17618 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17619 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17620 | expr_ty c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17621 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17622 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17623 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17624 | (c = args_rule(p)) // args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17625 | ) |
| 17626 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17627 | _res = c; |
| 17628 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17629 | p->error_indicator = 1; |
| 17630 | return NULL; |
| 17631 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17632 | goto done; |
| 17633 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17634 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17635 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17636 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17637 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17638 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17639 | } |
| 17640 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17641 | // _tmp_108: ',' args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17642 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17643 | _tmp_108_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17644 | { |
| 17645 | if (p->error_indicator) { |
| 17646 | return NULL; |
| 17647 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17648 | void * _res = NULL; |
| 17649 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17650 | { // ',' args |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17651 | if (p->error_indicator) { |
| 17652 | return NULL; |
| 17653 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17654 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17655 | expr_ty c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17656 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17657 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17658 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17659 | (c = args_rule(p)) // args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17660 | ) |
| 17661 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17662 | _res = c; |
| 17663 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17664 | p->error_indicator = 1; |
| 17665 | return NULL; |
| 17666 | } |
| 17667 | goto done; |
| 17668 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17669 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17670 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17671 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17672 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17673 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17674 | } |
| 17675 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17676 | // _loop0_110: ',' kwarg_or_starred |
| 17677 | static asdl_seq * |
| 17678 | _loop0_110_rule(Parser *p) |
| 17679 | { |
| 17680 | if (p->error_indicator) { |
| 17681 | return NULL; |
| 17682 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17683 | void *_res = NULL; |
| 17684 | int _mark = p->mark; |
| 17685 | int _start_mark = p->mark; |
| 17686 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17687 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17688 | p->error_indicator = 1; |
| 17689 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17690 | return NULL; |
| 17691 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17692 | ssize_t _children_capacity = 1; |
| 17693 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17694 | { // ',' kwarg_or_starred |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17695 | if (p->error_indicator) { |
| 17696 | return NULL; |
| 17697 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17698 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17699 | KeywordOrStarred* elem; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17700 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17701 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17702 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17703 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17704 | ) |
| 17705 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17706 | _res = elem; |
| 17707 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17708 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17709 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17710 | return NULL; |
| 17711 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17712 | if (_n == _children_capacity) { |
| 17713 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17714 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17715 | if (!_new_children) { |
| 17716 | p->error_indicator = 1; |
| 17717 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17718 | return NULL; |
| 17719 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17720 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17721 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17722 | _children[_n++] = _res; |
| 17723 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17724 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17725 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17726 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17727 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17728 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17729 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17730 | p->error_indicator = 1; |
| 17731 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17732 | return NULL; |
| 17733 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17734 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17735 | PyMem_Free(_children); |
| 17736 | _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq); |
| 17737 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17738 | } |
| 17739 | |
| 17740 | // _gather_109: kwarg_or_starred _loop0_110 |
| 17741 | static asdl_seq * |
| 17742 | _gather_109_rule(Parser *p) |
| 17743 | { |
| 17744 | if (p->error_indicator) { |
| 17745 | return NULL; |
| 17746 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17747 | asdl_seq * _res = NULL; |
| 17748 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17749 | { // kwarg_or_starred _loop0_110 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17750 | if (p->error_indicator) { |
| 17751 | return NULL; |
| 17752 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17753 | KeywordOrStarred* elem; |
| 17754 | asdl_seq * seq; |
| 17755 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17756 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17757 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17758 | (seq = _loop0_110_rule(p)) // _loop0_110 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17759 | ) |
| 17760 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17761 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17762 | goto done; |
| 17763 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17764 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17765 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17766 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17767 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17768 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17769 | } |
| 17770 | |
| 17771 | // _loop0_112: ',' kwarg_or_double_starred |
| 17772 | static asdl_seq * |
| 17773 | _loop0_112_rule(Parser *p) |
| 17774 | { |
| 17775 | if (p->error_indicator) { |
| 17776 | return NULL; |
| 17777 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17778 | void *_res = NULL; |
| 17779 | int _mark = p->mark; |
| 17780 | int _start_mark = p->mark; |
| 17781 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17782 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17783 | p->error_indicator = 1; |
| 17784 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17785 | return NULL; |
| 17786 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17787 | ssize_t _children_capacity = 1; |
| 17788 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17789 | { // ',' kwarg_or_double_starred |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17790 | if (p->error_indicator) { |
| 17791 | return NULL; |
| 17792 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17793 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17794 | KeywordOrStarred* elem; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17795 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17796 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17797 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17798 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17799 | ) |
| 17800 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17801 | _res = elem; |
| 17802 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17803 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17804 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17805 | return NULL; |
| 17806 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17807 | if (_n == _children_capacity) { |
| 17808 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17809 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17810 | if (!_new_children) { |
| 17811 | p->error_indicator = 1; |
| 17812 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17813 | return NULL; |
| 17814 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17815 | _children = _new_children; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17816 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17817 | _children[_n++] = _res; |
| 17818 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17819 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17820 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17821 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17822 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17823 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17824 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17825 | p->error_indicator = 1; |
| 17826 | PyErr_NoMemory(); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17827 | return NULL; |
| 17828 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17829 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17830 | PyMem_Free(_children); |
| 17831 | _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq); |
| 17832 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17833 | } |
| 17834 | |
| 17835 | // _gather_111: kwarg_or_double_starred _loop0_112 |
| 17836 | static asdl_seq * |
| 17837 | _gather_111_rule(Parser *p) |
| 17838 | { |
| 17839 | if (p->error_indicator) { |
| 17840 | return NULL; |
| 17841 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17842 | asdl_seq * _res = NULL; |
| 17843 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17844 | { // kwarg_or_double_starred _loop0_112 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17845 | if (p->error_indicator) { |
| 17846 | return NULL; |
| 17847 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17848 | KeywordOrStarred* elem; |
| 17849 | asdl_seq * seq; |
| 17850 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17851 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17852 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17853 | (seq = _loop0_112_rule(p)) // _loop0_112 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17854 | ) |
| 17855 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17856 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17857 | goto done; |
| 17858 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17859 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17860 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17861 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17862 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17863 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17864 | } |
| 17865 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17866 | // _loop0_114: ',' kwarg_or_starred |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 17867 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17868 | _loop0_114_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17869 | { |
| 17870 | if (p->error_indicator) { |
| 17871 | return NULL; |
| 17872 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17873 | void *_res = NULL; |
| 17874 | int _mark = p->mark; |
| 17875 | int _start_mark = p->mark; |
| 17876 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17877 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17878 | p->error_indicator = 1; |
| 17879 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17880 | return NULL; |
| 17881 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17882 | ssize_t _children_capacity = 1; |
| 17883 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17884 | { // ',' kwarg_or_starred |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17885 | if (p->error_indicator) { |
| 17886 | return NULL; |
| 17887 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17888 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17889 | KeywordOrStarred* elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17890 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17891 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17892 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17893 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17894 | ) |
| 17895 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17896 | _res = elem; |
| 17897 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17898 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17899 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17900 | return NULL; |
| 17901 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17902 | if (_n == _children_capacity) { |
| 17903 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17904 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17905 | if (!_new_children) { |
| 17906 | p->error_indicator = 1; |
| 17907 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17908 | return NULL; |
| 17909 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17910 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17911 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17912 | _children[_n++] = _res; |
| 17913 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17914 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17915 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17916 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17917 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17918 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17919 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17920 | p->error_indicator = 1; |
| 17921 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17922 | return NULL; |
| 17923 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17924 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17925 | PyMem_Free(_children); |
| 17926 | _PyPegen_insert_memo(p, _start_mark, _loop0_114_type, _seq); |
| 17927 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17928 | } |
| 17929 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17930 | // _gather_113: kwarg_or_starred _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17931 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17932 | _gather_113_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17933 | { |
| 17934 | if (p->error_indicator) { |
| 17935 | return NULL; |
| 17936 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17937 | asdl_seq * _res = NULL; |
| 17938 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17939 | { // kwarg_or_starred _loop0_114 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17940 | if (p->error_indicator) { |
| 17941 | return NULL; |
| 17942 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17943 | KeywordOrStarred* elem; |
| 17944 | asdl_seq * seq; |
| 17945 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17946 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17947 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17948 | (seq = _loop0_114_rule(p)) // _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17949 | ) |
| 17950 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17951 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17952 | goto done; |
| 17953 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17954 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17955 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17956 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17957 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17958 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17959 | } |
| 17960 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17961 | // _loop0_116: ',' kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17962 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17963 | _loop0_116_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17964 | { |
| 17965 | if (p->error_indicator) { |
| 17966 | return NULL; |
| 17967 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17968 | void *_res = NULL; |
| 17969 | int _mark = p->mark; |
| 17970 | int _start_mark = p->mark; |
| 17971 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17972 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17973 | p->error_indicator = 1; |
| 17974 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17975 | return NULL; |
| 17976 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17977 | ssize_t _children_capacity = 1; |
| 17978 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17979 | { // ',' kwarg_or_double_starred |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 17980 | if (p->error_indicator) { |
| 17981 | return NULL; |
| 17982 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17983 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17984 | KeywordOrStarred* elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17985 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17986 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17987 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17988 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17989 | ) |
| 17990 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17991 | _res = elem; |
| 17992 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17993 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17994 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17995 | return NULL; |
| 17996 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17997 | if (_n == _children_capacity) { |
| 17998 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 17999 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18000 | if (!_new_children) { |
| 18001 | p->error_indicator = 1; |
| 18002 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18003 | return NULL; |
| 18004 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18005 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18006 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18007 | _children[_n++] = _res; |
| 18008 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18009 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18010 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18011 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18012 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18013 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18014 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18015 | p->error_indicator = 1; |
| 18016 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18017 | return NULL; |
| 18018 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18019 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18020 | PyMem_Free(_children); |
| 18021 | _PyPegen_insert_memo(p, _start_mark, _loop0_116_type, _seq); |
| 18022 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18023 | } |
| 18024 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18025 | // _gather_115: kwarg_or_double_starred _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18026 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18027 | _gather_115_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18028 | { |
| 18029 | if (p->error_indicator) { |
| 18030 | return NULL; |
| 18031 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18032 | asdl_seq * _res = NULL; |
| 18033 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18034 | { // kwarg_or_double_starred _loop0_116 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18035 | if (p->error_indicator) { |
| 18036 | return NULL; |
| 18037 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18038 | KeywordOrStarred* elem; |
| 18039 | asdl_seq * seq; |
| 18040 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18041 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18042 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18043 | (seq = _loop0_116_rule(p)) // _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18044 | ) |
| 18045 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18046 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18047 | goto done; |
| 18048 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18049 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18050 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18051 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18052 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18053 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18054 | } |
| 18055 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18056 | // _loop0_117: (',' star_target) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18057 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18058 | _loop0_117_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18059 | { |
| 18060 | if (p->error_indicator) { |
| 18061 | return NULL; |
| 18062 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18063 | void *_res = NULL; |
| 18064 | int _mark = p->mark; |
| 18065 | int _start_mark = p->mark; |
| 18066 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18067 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18068 | p->error_indicator = 1; |
| 18069 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18070 | return NULL; |
| 18071 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18072 | ssize_t _children_capacity = 1; |
| 18073 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18074 | { // (',' star_target) |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18075 | if (p->error_indicator) { |
| 18076 | return NULL; |
| 18077 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18078 | void *_tmp_145_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18079 | while ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18080 | (_tmp_145_var = _tmp_145_rule(p)) // ',' star_target |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18081 | ) |
| 18082 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18083 | _res = _tmp_145_var; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18084 | if (_n == _children_capacity) { |
| 18085 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18086 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18087 | if (!_new_children) { |
| 18088 | p->error_indicator = 1; |
| 18089 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18090 | return NULL; |
| 18091 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18092 | _children = _new_children; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18093 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18094 | _children[_n++] = _res; |
| 18095 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18096 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18097 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18098 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18099 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18100 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18101 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18102 | p->error_indicator = 1; |
| 18103 | PyErr_NoMemory(); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18104 | return NULL; |
| 18105 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18106 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18107 | PyMem_Free(_children); |
| 18108 | _PyPegen_insert_memo(p, _start_mark, _loop0_117_type, _seq); |
| 18109 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18110 | } |
| 18111 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18112 | // _loop0_119: ',' star_target |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 18113 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18114 | _loop0_119_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18115 | { |
| 18116 | if (p->error_indicator) { |
| 18117 | return NULL; |
| 18118 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18119 | void *_res = NULL; |
| 18120 | int _mark = p->mark; |
| 18121 | int _start_mark = p->mark; |
| 18122 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18123 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18124 | p->error_indicator = 1; |
| 18125 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18126 | return NULL; |
| 18127 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18128 | ssize_t _children_capacity = 1; |
| 18129 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18130 | { // ',' star_target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18131 | if (p->error_indicator) { |
| 18132 | return NULL; |
| 18133 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18134 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18135 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18136 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18137 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18138 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18139 | (elem = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18140 | ) |
| 18141 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18142 | _res = elem; |
| 18143 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18144 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18145 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18146 | return NULL; |
| 18147 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18148 | if (_n == _children_capacity) { |
| 18149 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18150 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18151 | if (!_new_children) { |
| 18152 | p->error_indicator = 1; |
| 18153 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18154 | return NULL; |
| 18155 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18156 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18157 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18158 | _children[_n++] = _res; |
| 18159 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18160 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18161 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18162 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18163 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18164 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18165 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18166 | p->error_indicator = 1; |
| 18167 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18168 | return NULL; |
| 18169 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18170 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18171 | PyMem_Free(_children); |
| 18172 | _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq); |
| 18173 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18174 | } |
| 18175 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18176 | // _gather_118: star_target _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18177 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18178 | _gather_118_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18179 | { |
| 18180 | if (p->error_indicator) { |
| 18181 | return NULL; |
| 18182 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18183 | asdl_seq * _res = NULL; |
| 18184 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18185 | { // star_target _loop0_119 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18186 | if (p->error_indicator) { |
| 18187 | return NULL; |
| 18188 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18189 | expr_ty elem; |
| 18190 | asdl_seq * seq; |
| 18191 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18192 | (elem = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18193 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18194 | (seq = _loop0_119_rule(p)) // _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18195 | ) |
| 18196 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18197 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18198 | goto done; |
| 18199 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18200 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18201 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18202 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18203 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18204 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18205 | } |
| 18206 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18207 | // _tmp_120: !'*' star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18208 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18209 | _tmp_120_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18210 | { |
| 18211 | if (p->error_indicator) { |
| 18212 | return NULL; |
| 18213 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18214 | void * _res = NULL; |
| 18215 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18216 | { // !'*' star_target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18217 | if (p->error_indicator) { |
| 18218 | return NULL; |
| 18219 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18220 | expr_ty star_target_var; |
| 18221 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18222 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18223 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18224 | (star_target_var = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18225 | ) |
| 18226 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18227 | _res = star_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18228 | goto done; |
| 18229 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18230 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18231 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18232 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18233 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18234 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18235 | } |
| 18236 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18237 | // _loop0_122: ',' del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18238 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18239 | _loop0_122_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18240 | { |
| 18241 | if (p->error_indicator) { |
| 18242 | return NULL; |
| 18243 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18244 | void *_res = NULL; |
| 18245 | int _mark = p->mark; |
| 18246 | int _start_mark = p->mark; |
| 18247 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18248 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18249 | p->error_indicator = 1; |
| 18250 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18251 | return NULL; |
| 18252 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18253 | ssize_t _children_capacity = 1; |
| 18254 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18255 | { // ',' del_target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18256 | if (p->error_indicator) { |
| 18257 | return NULL; |
| 18258 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18259 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18260 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18261 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18262 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18263 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18264 | (elem = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18265 | ) |
| 18266 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18267 | _res = elem; |
| 18268 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18269 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18270 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18271 | return NULL; |
| 18272 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18273 | if (_n == _children_capacity) { |
| 18274 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18275 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18276 | if (!_new_children) { |
| 18277 | p->error_indicator = 1; |
| 18278 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18279 | return NULL; |
| 18280 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18281 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18282 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18283 | _children[_n++] = _res; |
| 18284 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18285 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18286 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18287 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18288 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18289 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18290 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18291 | p->error_indicator = 1; |
| 18292 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18293 | return NULL; |
| 18294 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18295 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18296 | PyMem_Free(_children); |
| 18297 | _PyPegen_insert_memo(p, _start_mark, _loop0_122_type, _seq); |
| 18298 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18299 | } |
| 18300 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18301 | // _gather_121: del_target _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18302 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18303 | _gather_121_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18304 | { |
| 18305 | if (p->error_indicator) { |
| 18306 | return NULL; |
| 18307 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18308 | asdl_seq * _res = NULL; |
| 18309 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18310 | { // del_target _loop0_122 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18311 | if (p->error_indicator) { |
| 18312 | return NULL; |
| 18313 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18314 | expr_ty elem; |
| 18315 | asdl_seq * seq; |
| 18316 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18317 | (elem = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18318 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18319 | (seq = _loop0_122_rule(p)) // _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18320 | ) |
| 18321 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18322 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18323 | goto done; |
| 18324 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18325 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18326 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18327 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18328 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18329 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18330 | } |
| 18331 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18332 | // _loop0_124: ',' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18333 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18334 | _loop0_124_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18335 | { |
| 18336 | if (p->error_indicator) { |
| 18337 | return NULL; |
| 18338 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18339 | void *_res = NULL; |
| 18340 | int _mark = p->mark; |
| 18341 | int _start_mark = p->mark; |
| 18342 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18343 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18344 | p->error_indicator = 1; |
| 18345 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18346 | return NULL; |
| 18347 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18348 | ssize_t _children_capacity = 1; |
| 18349 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18350 | { // ',' target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18351 | if (p->error_indicator) { |
| 18352 | return NULL; |
| 18353 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18354 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18355 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18356 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18357 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18358 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18359 | (elem = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18360 | ) |
| 18361 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18362 | _res = elem; |
| 18363 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18364 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18365 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18366 | return NULL; |
| 18367 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18368 | if (_n == _children_capacity) { |
| 18369 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18370 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18371 | if (!_new_children) { |
| 18372 | p->error_indicator = 1; |
| 18373 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18374 | return NULL; |
| 18375 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18376 | _children = _new_children; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18377 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18378 | _children[_n++] = _res; |
| 18379 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18380 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18381 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18382 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18383 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18384 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18385 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18386 | p->error_indicator = 1; |
| 18387 | PyErr_NoMemory(); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18388 | return NULL; |
| 18389 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18390 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18391 | PyMem_Free(_children); |
| 18392 | _PyPegen_insert_memo(p, _start_mark, _loop0_124_type, _seq); |
| 18393 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18394 | } |
| 18395 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18396 | // _gather_123: target _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18397 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18398 | _gather_123_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18399 | { |
| 18400 | if (p->error_indicator) { |
| 18401 | return NULL; |
| 18402 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18403 | asdl_seq * _res = NULL; |
| 18404 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18405 | { // target _loop0_124 |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18406 | if (p->error_indicator) { |
| 18407 | return NULL; |
| 18408 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18409 | expr_ty elem; |
| 18410 | asdl_seq * seq; |
| 18411 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18412 | (elem = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18413 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18414 | (seq = _loop0_124_rule(p)) // _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18415 | ) |
| 18416 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18417 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18418 | goto done; |
| 18419 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18420 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18421 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18422 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18423 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18424 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18425 | } |
| 18426 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18427 | // _tmp_125: args | expression for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18428 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 18429 | _tmp_125_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18430 | { |
| 18431 | if (p->error_indicator) { |
| 18432 | return NULL; |
| 18433 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18434 | void * _res = NULL; |
| 18435 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18436 | { // args |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18437 | if (p->error_indicator) { |
| 18438 | return NULL; |
| 18439 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18440 | expr_ty args_var; |
| 18441 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18442 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18443 | ) |
| 18444 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18445 | _res = args_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18446 | goto done; |
| 18447 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18448 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18449 | } |
| 18450 | { // expression for_if_clauses |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18451 | if (p->error_indicator) { |
| 18452 | return NULL; |
| 18453 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18454 | expr_ty expression_var; |
| 18455 | asdl_seq* for_if_clauses_var; |
| 18456 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18457 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18458 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18459 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18460 | ) |
| 18461 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18462 | _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18463 | goto done; |
| 18464 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18465 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18466 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18467 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18468 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18469 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18470 | } |
| 18471 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18472 | // _loop0_126: star_named_expressions |
| 18473 | static asdl_seq * |
| 18474 | _loop0_126_rule(Parser *p) |
| 18475 | { |
| 18476 | if (p->error_indicator) { |
| 18477 | return NULL; |
| 18478 | } |
| 18479 | void *_res = NULL; |
| 18480 | int _mark = p->mark; |
| 18481 | int _start_mark = p->mark; |
| 18482 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18483 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18484 | p->error_indicator = 1; |
| 18485 | PyErr_NoMemory(); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18486 | return NULL; |
| 18487 | } |
| 18488 | ssize_t _children_capacity = 1; |
| 18489 | ssize_t _n = 0; |
| 18490 | { // star_named_expressions |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18491 | if (p->error_indicator) { |
| 18492 | return NULL; |
| 18493 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18494 | asdl_seq* star_named_expressions_var; |
| 18495 | while ( |
| 18496 | (star_named_expressions_var = star_named_expressions_rule(p)) // star_named_expressions |
| 18497 | ) |
| 18498 | { |
| 18499 | _res = star_named_expressions_var; |
| 18500 | if (_n == _children_capacity) { |
| 18501 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18502 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18503 | if (!_new_children) { |
| 18504 | p->error_indicator = 1; |
| 18505 | PyErr_NoMemory(); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18506 | return NULL; |
| 18507 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18508 | _children = _new_children; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18509 | } |
| 18510 | _children[_n++] = _res; |
| 18511 | _mark = p->mark; |
| 18512 | } |
| 18513 | p->mark = _mark; |
| 18514 | } |
| 18515 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18516 | if (!_seq) { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18517 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18518 | p->error_indicator = 1; |
| 18519 | PyErr_NoMemory(); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18520 | return NULL; |
| 18521 | } |
| 18522 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18523 | PyMem_Free(_children); |
| 18524 | _PyPegen_insert_memo(p, _start_mark, _loop0_126_type, _seq); |
| 18525 | return _seq; |
| 18526 | } |
| 18527 | |
| 18528 | // _tmp_127: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18529 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18530 | _tmp_127_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18531 | { |
| 18532 | if (p->error_indicator) { |
| 18533 | return NULL; |
| 18534 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18535 | void * _res = NULL; |
| 18536 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18537 | { // '=' annotated_rhs |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18538 | if (p->error_indicator) { |
| 18539 | return NULL; |
| 18540 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18541 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18542 | expr_ty annotated_rhs_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18543 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18544 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18545 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18546 | (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18547 | ) |
| 18548 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18549 | _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18550 | goto done; |
| 18551 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18552 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18553 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18554 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18555 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18556 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18557 | } |
| 18558 | |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 18559 | // _tmp_128: yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18560 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18561 | _tmp_128_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18562 | { |
| 18563 | if (p->error_indicator) { |
| 18564 | return NULL; |
| 18565 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18566 | void * _res = NULL; |
| 18567 | int _mark = p->mark; |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 18568 | { // yield_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18569 | if (p->error_indicator) { |
| 18570 | return NULL; |
| 18571 | } |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 18572 | expr_ty yield_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18573 | if ( |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 18574 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18575 | ) |
| 18576 | { |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 18577 | _res = yield_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18578 | goto done; |
| 18579 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18580 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18581 | } |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 18582 | { // star_expressions |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18583 | if (p->error_indicator) { |
| 18584 | return NULL; |
| 18585 | } |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 18586 | expr_ty star_expressions_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18587 | if ( |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 18588 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18589 | ) |
| 18590 | { |
Pablo Galindo | 16ab070 | 2020-05-15 02:04:52 +0100 | [diff] [blame] | 18591 | _res = star_expressions_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18592 | goto done; |
| 18593 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18594 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18595 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18596 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18597 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18598 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18599 | } |
| 18600 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18601 | // _tmp_129: yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18602 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18603 | _tmp_129_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18604 | { |
| 18605 | if (p->error_indicator) { |
| 18606 | return NULL; |
| 18607 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18608 | void * _res = NULL; |
| 18609 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18610 | { // yield_expr |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18611 | if (p->error_indicator) { |
| 18612 | return NULL; |
| 18613 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18614 | expr_ty yield_expr_var; |
| 18615 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18616 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18617 | ) |
| 18618 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18619 | _res = yield_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18620 | goto done; |
| 18621 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18622 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18623 | } |
| 18624 | { // star_expressions |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18625 | if (p->error_indicator) { |
| 18626 | return NULL; |
| 18627 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18628 | expr_ty star_expressions_var; |
| 18629 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18630 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18631 | ) |
| 18632 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18633 | _res = star_expressions_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18634 | goto done; |
| 18635 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18636 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18637 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18638 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18639 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18640 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18641 | } |
| 18642 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18643 | // _tmp_130: '[' | '(' | '{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18644 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18645 | _tmp_130_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18646 | { |
| 18647 | if (p->error_indicator) { |
| 18648 | return NULL; |
| 18649 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18650 | void * _res = NULL; |
| 18651 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18652 | { // '[' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18653 | if (p->error_indicator) { |
| 18654 | return NULL; |
| 18655 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18656 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18657 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18658 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18659 | ) |
| 18660 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18661 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18662 | goto done; |
| 18663 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18664 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18665 | } |
| 18666 | { // '(' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18667 | if (p->error_indicator) { |
| 18668 | return NULL; |
| 18669 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18670 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18671 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18672 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18673 | ) |
| 18674 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18675 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18676 | goto done; |
| 18677 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18678 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18679 | } |
| 18680 | { // '{' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18681 | if (p->error_indicator) { |
| 18682 | return NULL; |
| 18683 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18684 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18685 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18686 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18687 | ) |
| 18688 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18689 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18690 | goto done; |
| 18691 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18692 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18693 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18694 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18695 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18696 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18697 | } |
| 18698 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18699 | // _loop0_131: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18700 | static asdl_seq * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18701 | _loop0_131_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18702 | { |
| 18703 | if (p->error_indicator) { |
| 18704 | return NULL; |
| 18705 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18706 | void *_res = NULL; |
| 18707 | int _mark = p->mark; |
| 18708 | int _start_mark = p->mark; |
| 18709 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 18710 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18711 | p->error_indicator = 1; |
| 18712 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18713 | return NULL; |
| 18714 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18715 | ssize_t _children_capacity = 1; |
| 18716 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18717 | { // param_no_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18718 | if (p->error_indicator) { |
| 18719 | return NULL; |
| 18720 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18721 | arg_ty param_no_default_var; |
| 18722 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18723 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18724 | ) |
| 18725 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18726 | _res = param_no_default_var; |
| 18727 | if (_n == _children_capacity) { |
| 18728 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18729 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 18730 | if (!_new_children) { |
| 18731 | p->error_indicator = 1; |
| 18732 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18733 | return NULL; |
| 18734 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18735 | _children = _new_children; |
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 | _children[_n++] = _res; |
| 18738 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18739 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18740 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18741 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18742 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 18743 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18744 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 18745 | p->error_indicator = 1; |
| 18746 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18747 | return NULL; |
| 18748 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18749 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 18750 | PyMem_Free(_children); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18751 | _PyPegen_insert_memo(p, _start_mark, _loop0_131_type, _seq); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18752 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18753 | } |
| 18754 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18755 | // _tmp_132: slash_with_default | param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18756 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18757 | _tmp_132_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18758 | { |
| 18759 | if (p->error_indicator) { |
| 18760 | return NULL; |
| 18761 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18762 | void * _res = NULL; |
| 18763 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18764 | { // slash_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18765 | if (p->error_indicator) { |
| 18766 | return NULL; |
| 18767 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18768 | SlashWithDefault* slash_with_default_var; |
| 18769 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18770 | (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18771 | ) |
| 18772 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18773 | _res = slash_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18774 | goto done; |
| 18775 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18776 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18777 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 18778 | { // param_with_default+ |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18779 | if (p->error_indicator) { |
| 18780 | return NULL; |
| 18781 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18782 | asdl_seq * _loop1_146_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18783 | if ( |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18784 | (_loop1_146_var = _loop1_146_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18785 | ) |
| 18786 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18787 | _res = _loop1_146_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18788 | goto done; |
| 18789 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18790 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18791 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18792 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18793 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18794 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18795 | } |
| 18796 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18797 | // _tmp_133: ')' | ',' (')' | '**') |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18798 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18799 | _tmp_133_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18800 | { |
| 18801 | if (p->error_indicator) { |
| 18802 | return NULL; |
| 18803 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18804 | void * _res = NULL; |
| 18805 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18806 | { // ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18807 | if (p->error_indicator) { |
| 18808 | return NULL; |
| 18809 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18810 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18811 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18812 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18813 | ) |
| 18814 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18815 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18816 | goto done; |
| 18817 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18818 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18819 | } |
| 18820 | { // ',' (')' | '**') |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18821 | if (p->error_indicator) { |
| 18822 | return NULL; |
| 18823 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18824 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18825 | void *_tmp_147_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18826 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18827 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18828 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18829 | (_tmp_147_var = _tmp_147_rule(p)) // ')' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18830 | ) |
| 18831 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18832 | _res = _PyPegen_dummy_name(p, _literal, _tmp_147_var); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18833 | goto done; |
| 18834 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18835 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18836 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18837 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18838 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18839 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18840 | } |
| 18841 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18842 | // _tmp_134: ':' | ',' (':' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18843 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18844 | _tmp_134_rule(Parser *p) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18845 | { |
| 18846 | if (p->error_indicator) { |
| 18847 | return NULL; |
| 18848 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18849 | void * _res = NULL; |
| 18850 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18851 | { // ':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18852 | if (p->error_indicator) { |
| 18853 | return NULL; |
| 18854 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18855 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18856 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18857 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18858 | ) |
| 18859 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18860 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18861 | goto done; |
| 18862 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18863 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18864 | } |
| 18865 | { // ',' (':' | '**') |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18866 | if (p->error_indicator) { |
| 18867 | return NULL; |
| 18868 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18869 | Token * _literal; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18870 | void *_tmp_148_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18871 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18872 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18873 | && |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18874 | (_tmp_148_var = _tmp_148_rule(p)) // ':' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18875 | ) |
| 18876 | { |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18877 | _res = _PyPegen_dummy_name(p, _literal, _tmp_148_var); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18878 | goto done; |
| 18879 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18880 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18881 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18882 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18883 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18884 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18885 | } |
| 18886 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18887 | // _tmp_135: star_targets '=' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18888 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18889 | _tmp_135_rule(Parser *p) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18890 | { |
| 18891 | if (p->error_indicator) { |
| 18892 | return NULL; |
| 18893 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18894 | void * _res = NULL; |
| 18895 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18896 | { // star_targets '=' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18897 | if (p->error_indicator) { |
| 18898 | return NULL; |
| 18899 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18900 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18901 | expr_ty z; |
| 18902 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 18903 | (z = star_targets_rule(p)) // star_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18904 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18905 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18906 | ) |
| 18907 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18908 | _res = z; |
| 18909 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18910 | p->error_indicator = 1; |
| 18911 | return NULL; |
| 18912 | } |
| 18913 | goto done; |
| 18914 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18915 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18916 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18917 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18918 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18919 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 18920 | } |
| 18921 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18922 | // _tmp_136: '.' | '...' |
| 18923 | static void * |
| 18924 | _tmp_136_rule(Parser *p) |
| 18925 | { |
| 18926 | if (p->error_indicator) { |
| 18927 | return NULL; |
| 18928 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18929 | void * _res = NULL; |
| 18930 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18931 | { // '.' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18932 | if (p->error_indicator) { |
| 18933 | return NULL; |
| 18934 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18935 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18936 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18937 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18938 | ) |
| 18939 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18940 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18941 | goto done; |
| 18942 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18943 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18944 | } |
| 18945 | { // '...' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18946 | if (p->error_indicator) { |
| 18947 | return NULL; |
| 18948 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18949 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18950 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18951 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18952 | ) |
| 18953 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18954 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18955 | goto done; |
| 18956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18957 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18958 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18959 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18960 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18961 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18962 | } |
| 18963 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18964 | // _tmp_137: '.' | '...' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 18965 | static void * |
| 18966 | _tmp_137_rule(Parser *p) |
| 18967 | { |
| 18968 | if (p->error_indicator) { |
| 18969 | return NULL; |
| 18970 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 18971 | void * _res = NULL; |
| 18972 | int _mark = p->mark; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18973 | { // '.' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18974 | if (p->error_indicator) { |
| 18975 | return NULL; |
| 18976 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18977 | Token * _literal; |
| 18978 | if ( |
| 18979 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
| 18980 | ) |
| 18981 | { |
| 18982 | _res = _literal; |
| 18983 | goto done; |
| 18984 | } |
| 18985 | p->mark = _mark; |
| 18986 | } |
| 18987 | { // '...' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 18988 | if (p->error_indicator) { |
| 18989 | return NULL; |
| 18990 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 18991 | Token * _literal; |
| 18992 | if ( |
| 18993 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
| 18994 | ) |
| 18995 | { |
| 18996 | _res = _literal; |
| 18997 | goto done; |
| 18998 | } |
| 18999 | p->mark = _mark; |
| 19000 | } |
| 19001 | _res = NULL; |
| 19002 | done: |
| 19003 | return _res; |
| 19004 | } |
| 19005 | |
| 19006 | // _tmp_138: '@' named_expression NEWLINE |
| 19007 | static void * |
| 19008 | _tmp_138_rule(Parser *p) |
| 19009 | { |
| 19010 | if (p->error_indicator) { |
| 19011 | return NULL; |
| 19012 | } |
| 19013 | void * _res = NULL; |
| 19014 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19015 | { // '@' named_expression NEWLINE |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19016 | if (p->error_indicator) { |
| 19017 | return NULL; |
| 19018 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19019 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19020 | expr_ty f; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 19021 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19022 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19023 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19024 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19025 | (f = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19026 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19027 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19028 | ) |
| 19029 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19030 | _res = f; |
| 19031 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19032 | p->error_indicator = 1; |
| 19033 | return NULL; |
| 19034 | } |
| 19035 | goto done; |
| 19036 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19037 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19038 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19039 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19040 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19041 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19042 | } |
| 19043 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19044 | // _tmp_139: ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19045 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19046 | _tmp_139_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19047 | { |
| 19048 | if (p->error_indicator) { |
| 19049 | return NULL; |
| 19050 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19051 | void * _res = NULL; |
| 19052 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19053 | { // ',' star_expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19054 | if (p->error_indicator) { |
| 19055 | return NULL; |
| 19056 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19057 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19058 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19059 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19060 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19061 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19062 | (c = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19063 | ) |
| 19064 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19065 | _res = c; |
| 19066 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19067 | p->error_indicator = 1; |
| 19068 | return NULL; |
| 19069 | } |
| 19070 | goto done; |
| 19071 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19072 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19073 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19074 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19075 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19076 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19077 | } |
| 19078 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19079 | // _tmp_140: ',' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19080 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19081 | _tmp_140_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19082 | { |
| 19083 | if (p->error_indicator) { |
| 19084 | return NULL; |
| 19085 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19086 | void * _res = NULL; |
| 19087 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19088 | { // ',' expression |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19089 | if (p->error_indicator) { |
| 19090 | return NULL; |
| 19091 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19092 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19093 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19094 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19095 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19096 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19097 | (c = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19098 | ) |
| 19099 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19100 | _res = c; |
| 19101 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19102 | p->error_indicator = 1; |
| 19103 | return NULL; |
| 19104 | } |
| 19105 | goto done; |
| 19106 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19107 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19108 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19109 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19110 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19111 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19112 | } |
| 19113 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19114 | // _tmp_141: 'or' conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19115 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19116 | _tmp_141_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19117 | { |
| 19118 | if (p->error_indicator) { |
| 19119 | return NULL; |
| 19120 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19121 | void * _res = NULL; |
| 19122 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19123 | { // 'or' conjunction |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19124 | if (p->error_indicator) { |
| 19125 | return NULL; |
| 19126 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19127 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19128 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19129 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19130 | (_keyword = _PyPegen_expect_token(p, 532)) // token='or' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19131 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19132 | (c = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19133 | ) |
| 19134 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19135 | _res = c; |
| 19136 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19137 | p->error_indicator = 1; |
| 19138 | return NULL; |
| 19139 | } |
| 19140 | goto done; |
| 19141 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19142 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19143 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19144 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19145 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19146 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19147 | } |
| 19148 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19149 | // _tmp_142: 'and' inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19150 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19151 | _tmp_142_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19152 | { |
| 19153 | if (p->error_indicator) { |
| 19154 | return NULL; |
| 19155 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19156 | void * _res = NULL; |
| 19157 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19158 | { // 'and' inversion |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19159 | if (p->error_indicator) { |
| 19160 | return NULL; |
| 19161 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19162 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19163 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19164 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19165 | (_keyword = _PyPegen_expect_token(p, 533)) // token='and' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19166 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19167 | (c = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19168 | ) |
| 19169 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19170 | _res = c; |
| 19171 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19172 | p->error_indicator = 1; |
| 19173 | return NULL; |
| 19174 | } |
| 19175 | goto done; |
| 19176 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19177 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19178 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19179 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19180 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19181 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19182 | } |
| 19183 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19184 | // _tmp_143: 'if' disjunction |
| 19185 | static void * |
| 19186 | _tmp_143_rule(Parser *p) |
| 19187 | { |
| 19188 | if (p->error_indicator) { |
| 19189 | return NULL; |
| 19190 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19191 | void * _res = NULL; |
| 19192 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19193 | { // 'if' disjunction |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19194 | if (p->error_indicator) { |
| 19195 | return NULL; |
| 19196 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19197 | Token * _keyword; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19198 | expr_ty z; |
| 19199 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19200 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19201 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19202 | (z = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19203 | ) |
| 19204 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19205 | _res = z; |
| 19206 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19207 | p->error_indicator = 1; |
| 19208 | return NULL; |
| 19209 | } |
| 19210 | goto done; |
| 19211 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19212 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19213 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19214 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19215 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19216 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19217 | } |
| 19218 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19219 | // _tmp_144: 'if' disjunction |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19220 | static void * |
| 19221 | _tmp_144_rule(Parser *p) |
| 19222 | { |
| 19223 | if (p->error_indicator) { |
| 19224 | return NULL; |
| 19225 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19226 | void * _res = NULL; |
| 19227 | int _mark = p->mark; |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19228 | { // 'if' disjunction |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19229 | if (p->error_indicator) { |
| 19230 | return NULL; |
| 19231 | } |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19232 | Token * _keyword; |
| 19233 | expr_ty z; |
| 19234 | if ( |
| 19235 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
| 19236 | && |
| 19237 | (z = disjunction_rule(p)) // disjunction |
| 19238 | ) |
| 19239 | { |
| 19240 | _res = z; |
| 19241 | if (_res == NULL && PyErr_Occurred()) { |
| 19242 | p->error_indicator = 1; |
| 19243 | return NULL; |
| 19244 | } |
| 19245 | goto done; |
| 19246 | } |
| 19247 | p->mark = _mark; |
| 19248 | } |
| 19249 | _res = NULL; |
| 19250 | done: |
| 19251 | return _res; |
| 19252 | } |
| 19253 | |
| 19254 | // _tmp_145: ',' star_target |
| 19255 | static void * |
| 19256 | _tmp_145_rule(Parser *p) |
| 19257 | { |
| 19258 | if (p->error_indicator) { |
| 19259 | return NULL; |
| 19260 | } |
| 19261 | void * _res = NULL; |
| 19262 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19263 | { // ',' star_target |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19264 | if (p->error_indicator) { |
| 19265 | return NULL; |
| 19266 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19267 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19268 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19269 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19270 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19271 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19272 | (c = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19273 | ) |
| 19274 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19275 | _res = c; |
| 19276 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19277 | p->error_indicator = 1; |
| 19278 | return NULL; |
| 19279 | } |
| 19280 | goto done; |
| 19281 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19282 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19283 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19284 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19285 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19286 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19287 | } |
| 19288 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19289 | // _loop1_146: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19290 | static asdl_seq * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19291 | _loop1_146_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 19292 | { |
| 19293 | if (p->error_indicator) { |
| 19294 | return NULL; |
| 19295 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19296 | void *_res = NULL; |
| 19297 | int _mark = p->mark; |
| 19298 | int _start_mark = p->mark; |
| 19299 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 19300 | if (!_children) { |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19301 | p->error_indicator = 1; |
| 19302 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 19303 | return NULL; |
| 19304 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19305 | ssize_t _children_capacity = 1; |
| 19306 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 19307 | { // param_with_default |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19308 | if (p->error_indicator) { |
| 19309 | return NULL; |
| 19310 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 19311 | NameDefaultPair* param_with_default_var; |
| 19312 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 19313 | (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] | 19314 | ) |
| 19315 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19316 | _res = param_with_default_var; |
| 19317 | if (_n == _children_capacity) { |
| 19318 | _children_capacity *= 2; |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19319 | void **_new_children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 19320 | if (!_new_children) { |
| 19321 | p->error_indicator = 1; |
| 19322 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 19323 | return NULL; |
| 19324 | } |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19325 | _children = _new_children; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 19326 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19327 | _children[_n++] = _res; |
| 19328 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 19329 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19330 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 19331 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19332 | if (_n == 0 || p->error_indicator) { |
| 19333 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 19334 | return NULL; |
| 19335 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19336 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 19337 | if (!_seq) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19338 | PyMem_Free(_children); |
Lysandros Nikolaou | 2c8cd06 | 2020-05-17 06:19:23 +0300 | [diff] [blame] | 19339 | p->error_indicator = 1; |
| 19340 | PyErr_NoMemory(); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 19341 | return NULL; |
| 19342 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19343 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 19344 | PyMem_Free(_children); |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19345 | _PyPegen_insert_memo(p, _start_mark, _loop1_146_type, _seq); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19346 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 19347 | } |
| 19348 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19349 | // _tmp_147: ')' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19350 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19351 | _tmp_147_rule(Parser *p) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19352 | { |
| 19353 | if (p->error_indicator) { |
| 19354 | return NULL; |
| 19355 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19356 | void * _res = NULL; |
| 19357 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19358 | { // ')' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19359 | if (p->error_indicator) { |
| 19360 | return NULL; |
| 19361 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19362 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19363 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19364 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19365 | ) |
| 19366 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19367 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19368 | goto done; |
| 19369 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19370 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19371 | } |
| 19372 | { // '**' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19373 | if (p->error_indicator) { |
| 19374 | return NULL; |
| 19375 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19376 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19377 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19378 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19379 | ) |
| 19380 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19381 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19382 | goto done; |
| 19383 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19384 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19385 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19386 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19387 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19388 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19389 | } |
| 19390 | |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19391 | // _tmp_148: ':' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19392 | static void * |
Lysandros Nikolaou | a15c9b3 | 2020-05-13 22:36:27 +0300 | [diff] [blame] | 19393 | _tmp_148_rule(Parser *p) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19394 | { |
| 19395 | if (p->error_indicator) { |
| 19396 | return NULL; |
| 19397 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19398 | void * _res = NULL; |
| 19399 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19400 | { // ':' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19401 | if (p->error_indicator) { |
| 19402 | return NULL; |
| 19403 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19404 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19405 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19406 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19407 | ) |
| 19408 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19409 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19410 | goto done; |
| 19411 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19412 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19413 | } |
| 19414 | { // '**' |
Lysandros Nikolaou | 7b7a21b | 2020-05-18 20:32:03 +0300 | [diff] [blame] | 19415 | if (p->error_indicator) { |
| 19416 | return NULL; |
| 19417 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19418 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19419 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19420 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19421 | ) |
| 19422 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19423 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19424 | goto done; |
| 19425 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19426 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19427 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19428 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19429 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 19430 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 19431 | } |
| 19432 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19433 | void * |
| 19434 | _PyPegen_parse(Parser *p) |
| 19435 | { |
| 19436 | // Initialize keywords |
| 19437 | p->keywords = reserved_keywords; |
| 19438 | p->n_keyword_lists = n_keyword_lists; |
| 19439 | |
| 19440 | // Run parser |
| 19441 | void *result = NULL; |
| 19442 | if (p->start_rule == Py_file_input) { |
| 19443 | result = file_rule(p); |
| 19444 | } else if (p->start_rule == Py_single_input) { |
| 19445 | result = interactive_rule(p); |
| 19446 | } else if (p->start_rule == Py_eval_input) { |
| 19447 | result = eval_rule(p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 19448 | } else if (p->start_rule == Py_func_type_input) { |
| 19449 | result = func_type_rule(p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 19450 | } else if (p->start_rule == Py_fstring_input) { |
| 19451 | result = fstring_rule(p); |
| 19452 | } |
| 19453 | |
| 19454 | return result; |
| 19455 | } |
| 19456 | |
| 19457 | // The end |