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 |
| 202 | #define inside_paren_ann_assign_target_type 1131 |
| 203 | #define ann_assign_subscript_attribute_target_type 1132 |
| 204 | #define del_targets_type 1133 |
| 205 | #define del_target_type 1134 |
| 206 | #define del_t_atom_type 1135 |
| 207 | #define targets_type 1136 |
| 208 | #define target_type 1137 |
| 209 | #define t_primary_type 1138 // Left-recursive |
| 210 | #define t_lookahead_type 1139 |
| 211 | #define t_atom_type 1140 |
| 212 | #define incorrect_arguments_type 1141 |
| 213 | #define invalid_named_expression_type 1142 |
| 214 | #define invalid_assignment_type 1143 |
| 215 | #define invalid_block_type 1144 |
| 216 | #define invalid_comprehension_type 1145 |
| 217 | #define invalid_parameters_type 1146 |
| 218 | #define invalid_double_type_comments_type 1147 |
| 219 | #define _loop0_1_type 1148 |
| 220 | #define _loop0_2_type 1149 |
| 221 | #define _loop0_4_type 1150 |
| 222 | #define _gather_3_type 1151 |
| 223 | #define _loop0_6_type 1152 |
| 224 | #define _gather_5_type 1153 |
| 225 | #define _loop0_8_type 1154 |
| 226 | #define _gather_7_type 1155 |
| 227 | #define _loop0_10_type 1156 |
| 228 | #define _gather_9_type 1157 |
| 229 | #define _loop1_11_type 1158 |
| 230 | #define _loop0_13_type 1159 |
| 231 | #define _gather_12_type 1160 |
| 232 | #define _tmp_14_type 1161 |
| 233 | #define _tmp_15_type 1162 |
| 234 | #define _tmp_16_type 1163 |
| 235 | #define _tmp_17_type 1164 |
| 236 | #define _tmp_18_type 1165 |
| 237 | #define _tmp_19_type 1166 |
| 238 | #define _tmp_20_type 1167 |
| 239 | #define _tmp_21_type 1168 |
| 240 | #define _loop1_22_type 1169 |
| 241 | #define _tmp_23_type 1170 |
| 242 | #define _tmp_24_type 1171 |
| 243 | #define _loop0_26_type 1172 |
| 244 | #define _gather_25_type 1173 |
| 245 | #define _loop0_28_type 1174 |
| 246 | #define _gather_27_type 1175 |
| 247 | #define _tmp_29_type 1176 |
| 248 | #define _loop0_30_type 1177 |
| 249 | #define _loop1_31_type 1178 |
| 250 | #define _loop0_33_type 1179 |
| 251 | #define _gather_32_type 1180 |
| 252 | #define _tmp_34_type 1181 |
| 253 | #define _loop0_36_type 1182 |
| 254 | #define _gather_35_type 1183 |
| 255 | #define _tmp_37_type 1184 |
| 256 | #define _loop0_39_type 1185 |
| 257 | #define _gather_38_type 1186 |
| 258 | #define _loop0_41_type 1187 |
| 259 | #define _gather_40_type 1188 |
| 260 | #define _loop0_43_type 1189 |
| 261 | #define _gather_42_type 1190 |
| 262 | #define _loop0_45_type 1191 |
| 263 | #define _gather_44_type 1192 |
| 264 | #define _tmp_46_type 1193 |
| 265 | #define _loop1_47_type 1194 |
| 266 | #define _tmp_48_type 1195 |
| 267 | #define _tmp_49_type 1196 |
| 268 | #define _tmp_50_type 1197 |
| 269 | #define _tmp_51_type 1198 |
| 270 | #define _tmp_52_type 1199 |
| 271 | #define _loop0_53_type 1200 |
| 272 | #define _loop0_54_type 1201 |
| 273 | #define _loop0_55_type 1202 |
| 274 | #define _loop1_56_type 1203 |
| 275 | #define _loop0_57_type 1204 |
| 276 | #define _loop1_58_type 1205 |
| 277 | #define _loop1_59_type 1206 |
| 278 | #define _loop1_60_type 1207 |
| 279 | #define _loop0_61_type 1208 |
| 280 | #define _loop1_62_type 1209 |
| 281 | #define _loop0_63_type 1210 |
| 282 | #define _loop1_64_type 1211 |
| 283 | #define _loop0_65_type 1212 |
| 284 | #define _loop1_66_type 1213 |
| 285 | #define _loop1_67_type 1214 |
| 286 | #define _tmp_68_type 1215 |
| 287 | #define _loop0_70_type 1216 |
| 288 | #define _gather_69_type 1217 |
| 289 | #define _loop1_71_type 1218 |
| 290 | #define _loop0_73_type 1219 |
| 291 | #define _gather_72_type 1220 |
| 292 | #define _loop1_74_type 1221 |
| 293 | #define _loop0_75_type 1222 |
| 294 | #define _loop0_76_type 1223 |
| 295 | #define _loop0_77_type 1224 |
| 296 | #define _loop1_78_type 1225 |
| 297 | #define _loop0_79_type 1226 |
| 298 | #define _loop1_80_type 1227 |
| 299 | #define _loop1_81_type 1228 |
| 300 | #define _loop1_82_type 1229 |
| 301 | #define _loop0_83_type 1230 |
| 302 | #define _loop1_84_type 1231 |
| 303 | #define _loop0_85_type 1232 |
| 304 | #define _loop1_86_type 1233 |
| 305 | #define _loop0_87_type 1234 |
| 306 | #define _loop1_88_type 1235 |
| 307 | #define _loop1_89_type 1236 |
| 308 | #define _loop1_90_type 1237 |
| 309 | #define _loop1_91_type 1238 |
| 310 | #define _tmp_92_type 1239 |
| 311 | #define _loop0_94_type 1240 |
| 312 | #define _gather_93_type 1241 |
| 313 | #define _tmp_95_type 1242 |
| 314 | #define _tmp_96_type 1243 |
| 315 | #define _tmp_97_type 1244 |
| 316 | #define _tmp_98_type 1245 |
| 317 | #define _loop1_99_type 1246 |
| 318 | #define _tmp_100_type 1247 |
| 319 | #define _tmp_101_type 1248 |
| 320 | #define _loop0_103_type 1249 |
| 321 | #define _gather_102_type 1250 |
| 322 | #define _loop1_104_type 1251 |
| 323 | #define _loop0_105_type 1252 |
| 324 | #define _loop0_106_type 1253 |
| 325 | #define _tmp_107_type 1254 |
| 326 | #define _tmp_108_type 1255 |
| 327 | #define _loop0_110_type 1256 |
| 328 | #define _gather_109_type 1257 |
| 329 | #define _loop0_112_type 1258 |
| 330 | #define _gather_111_type 1259 |
| 331 | #define _loop0_114_type 1260 |
| 332 | #define _gather_113_type 1261 |
| 333 | #define _loop0_116_type 1262 |
| 334 | #define _gather_115_type 1263 |
| 335 | #define _loop0_117_type 1264 |
| 336 | #define _loop0_119_type 1265 |
| 337 | #define _gather_118_type 1266 |
| 338 | #define _tmp_120_type 1267 |
| 339 | #define _loop0_122_type 1268 |
| 340 | #define _gather_121_type 1269 |
| 341 | #define _loop0_124_type 1270 |
| 342 | #define _gather_123_type 1271 |
| 343 | #define _tmp_125_type 1272 |
| 344 | #define _tmp_126_type 1273 |
| 345 | #define _tmp_127_type 1274 |
| 346 | #define _tmp_128_type 1275 |
| 347 | #define _tmp_129_type 1276 |
| 348 | #define _loop0_130_type 1277 |
| 349 | #define _tmp_131_type 1278 |
| 350 | #define _tmp_132_type 1279 |
| 351 | #define _tmp_133_type 1280 |
| 352 | #define _tmp_134_type 1281 |
| 353 | #define _tmp_135_type 1282 |
| 354 | #define _tmp_136_type 1283 |
| 355 | #define _tmp_137_type 1284 |
| 356 | #define _tmp_138_type 1285 |
| 357 | #define _tmp_139_type 1286 |
| 358 | #define _tmp_140_type 1287 |
| 359 | #define _tmp_141_type 1288 |
| 360 | #define _tmp_142_type 1289 |
| 361 | #define _loop1_143_type 1290 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 362 | |
| 363 | static mod_ty file_rule(Parser *p); |
| 364 | static mod_ty interactive_rule(Parser *p); |
| 365 | static mod_ty eval_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 366 | static mod_ty func_type_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 367 | static expr_ty fstring_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 368 | static asdl_seq* type_expressions_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 369 | static asdl_seq* statements_rule(Parser *p); |
| 370 | static asdl_seq* statement_rule(Parser *p); |
| 371 | static asdl_seq* statement_newline_rule(Parser *p); |
| 372 | static asdl_seq* simple_stmt_rule(Parser *p); |
| 373 | static stmt_ty small_stmt_rule(Parser *p); |
| 374 | static stmt_ty compound_stmt_rule(Parser *p); |
| 375 | static void *assignment_rule(Parser *p); |
| 376 | static AugOperator* augassign_rule(Parser *p); |
| 377 | static stmt_ty global_stmt_rule(Parser *p); |
| 378 | static stmt_ty nonlocal_stmt_rule(Parser *p); |
| 379 | static stmt_ty yield_stmt_rule(Parser *p); |
| 380 | static stmt_ty assert_stmt_rule(Parser *p); |
| 381 | static stmt_ty del_stmt_rule(Parser *p); |
| 382 | static stmt_ty import_stmt_rule(Parser *p); |
| 383 | static stmt_ty import_name_rule(Parser *p); |
| 384 | static stmt_ty import_from_rule(Parser *p); |
| 385 | static asdl_seq* import_from_targets_rule(Parser *p); |
| 386 | static asdl_seq* import_from_as_names_rule(Parser *p); |
| 387 | static alias_ty import_from_as_name_rule(Parser *p); |
| 388 | static asdl_seq* dotted_as_names_rule(Parser *p); |
| 389 | static alias_ty dotted_as_name_rule(Parser *p); |
| 390 | static expr_ty dotted_name_rule(Parser *p); |
| 391 | static stmt_ty if_stmt_rule(Parser *p); |
| 392 | static stmt_ty elif_stmt_rule(Parser *p); |
| 393 | static asdl_seq* else_block_rule(Parser *p); |
| 394 | static stmt_ty while_stmt_rule(Parser *p); |
| 395 | static stmt_ty for_stmt_rule(Parser *p); |
| 396 | static stmt_ty with_stmt_rule(Parser *p); |
| 397 | static withitem_ty with_item_rule(Parser *p); |
| 398 | static stmt_ty try_stmt_rule(Parser *p); |
| 399 | static excepthandler_ty except_block_rule(Parser *p); |
| 400 | static asdl_seq* finally_block_rule(Parser *p); |
| 401 | static stmt_ty return_stmt_rule(Parser *p); |
| 402 | static stmt_ty raise_stmt_rule(Parser *p); |
| 403 | static stmt_ty function_def_rule(Parser *p); |
| 404 | static stmt_ty function_def_raw_rule(Parser *p); |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 405 | static Token* func_type_comment_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 406 | static arguments_ty params_rule(Parser *p); |
| 407 | static arguments_ty parameters_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 408 | static asdl_seq* slash_no_default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 409 | static SlashWithDefault* slash_with_default_rule(Parser *p); |
| 410 | static StarEtc* star_etc_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 411 | static arg_ty kwds_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 412 | static arg_ty param_no_default_rule(Parser *p); |
| 413 | static NameDefaultPair* param_with_default_rule(Parser *p); |
| 414 | static NameDefaultPair* param_maybe_default_rule(Parser *p); |
| 415 | static arg_ty param_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 416 | static expr_ty annotation_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 417 | static expr_ty default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 418 | static asdl_seq* decorators_rule(Parser *p); |
| 419 | static stmt_ty class_def_rule(Parser *p); |
| 420 | static stmt_ty class_def_raw_rule(Parser *p); |
| 421 | static asdl_seq* block_rule(Parser *p); |
| 422 | static asdl_seq* expressions_list_rule(Parser *p); |
| 423 | static expr_ty star_expressions_rule(Parser *p); |
| 424 | static expr_ty star_expression_rule(Parser *p); |
| 425 | static asdl_seq* star_named_expressions_rule(Parser *p); |
| 426 | static expr_ty star_named_expression_rule(Parser *p); |
| 427 | static expr_ty named_expression_rule(Parser *p); |
| 428 | static expr_ty annotated_rhs_rule(Parser *p); |
| 429 | static expr_ty expressions_rule(Parser *p); |
| 430 | static expr_ty expression_rule(Parser *p); |
| 431 | static expr_ty lambdef_rule(Parser *p); |
| 432 | static arguments_ty lambda_parameters_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 433 | static asdl_seq* lambda_slash_no_default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 434 | static SlashWithDefault* lambda_slash_with_default_rule(Parser *p); |
| 435 | static StarEtc* lambda_star_etc_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 436 | static arg_ty lambda_kwds_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 437 | static arg_ty lambda_param_no_default_rule(Parser *p); |
| 438 | static NameDefaultPair* lambda_param_with_default_rule(Parser *p); |
| 439 | static NameDefaultPair* lambda_param_maybe_default_rule(Parser *p); |
| 440 | static arg_ty lambda_param_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 441 | static expr_ty disjunction_rule(Parser *p); |
| 442 | static expr_ty conjunction_rule(Parser *p); |
| 443 | static expr_ty inversion_rule(Parser *p); |
| 444 | static expr_ty comparison_rule(Parser *p); |
| 445 | static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p); |
| 446 | static CmpopExprPair* eq_bitwise_or_rule(Parser *p); |
| 447 | static CmpopExprPair* noteq_bitwise_or_rule(Parser *p); |
| 448 | static CmpopExprPair* lte_bitwise_or_rule(Parser *p); |
| 449 | static CmpopExprPair* lt_bitwise_or_rule(Parser *p); |
| 450 | static CmpopExprPair* gte_bitwise_or_rule(Parser *p); |
| 451 | static CmpopExprPair* gt_bitwise_or_rule(Parser *p); |
| 452 | static CmpopExprPair* notin_bitwise_or_rule(Parser *p); |
| 453 | static CmpopExprPair* in_bitwise_or_rule(Parser *p); |
| 454 | static CmpopExprPair* isnot_bitwise_or_rule(Parser *p); |
| 455 | static CmpopExprPair* is_bitwise_or_rule(Parser *p); |
| 456 | static expr_ty bitwise_or_rule(Parser *p); |
| 457 | static expr_ty bitwise_xor_rule(Parser *p); |
| 458 | static expr_ty bitwise_and_rule(Parser *p); |
| 459 | static expr_ty shift_expr_rule(Parser *p); |
| 460 | static expr_ty sum_rule(Parser *p); |
| 461 | static expr_ty term_rule(Parser *p); |
| 462 | static expr_ty factor_rule(Parser *p); |
| 463 | static expr_ty power_rule(Parser *p); |
| 464 | static expr_ty await_primary_rule(Parser *p); |
| 465 | static expr_ty primary_rule(Parser *p); |
| 466 | static expr_ty slices_rule(Parser *p); |
| 467 | static expr_ty slice_rule(Parser *p); |
| 468 | static expr_ty atom_rule(Parser *p); |
| 469 | static expr_ty strings_rule(Parser *p); |
| 470 | static expr_ty list_rule(Parser *p); |
| 471 | static expr_ty listcomp_rule(Parser *p); |
| 472 | static expr_ty tuple_rule(Parser *p); |
| 473 | static expr_ty group_rule(Parser *p); |
| 474 | static expr_ty genexp_rule(Parser *p); |
| 475 | static expr_ty set_rule(Parser *p); |
| 476 | static expr_ty setcomp_rule(Parser *p); |
| 477 | static expr_ty dict_rule(Parser *p); |
| 478 | static expr_ty dictcomp_rule(Parser *p); |
| 479 | static asdl_seq* kvpairs_rule(Parser *p); |
| 480 | static KeyValuePair* kvpair_rule(Parser *p); |
| 481 | static asdl_seq* for_if_clauses_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 482 | static comprehension_ty for_if_clause_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 483 | static expr_ty yield_expr_rule(Parser *p); |
| 484 | static expr_ty arguments_rule(Parser *p); |
| 485 | static expr_ty args_rule(Parser *p); |
| 486 | static asdl_seq* kwargs_rule(Parser *p); |
| 487 | static expr_ty starred_expression_rule(Parser *p); |
| 488 | static KeywordOrStarred* kwarg_or_starred_rule(Parser *p); |
| 489 | static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p); |
| 490 | static expr_ty star_targets_rule(Parser *p); |
| 491 | static asdl_seq* star_targets_seq_rule(Parser *p); |
| 492 | static expr_ty star_target_rule(Parser *p); |
| 493 | static expr_ty star_atom_rule(Parser *p); |
| 494 | static expr_ty inside_paren_ann_assign_target_rule(Parser *p); |
| 495 | static expr_ty ann_assign_subscript_attribute_target_rule(Parser *p); |
| 496 | static asdl_seq* del_targets_rule(Parser *p); |
| 497 | static expr_ty del_target_rule(Parser *p); |
| 498 | static expr_ty del_t_atom_rule(Parser *p); |
| 499 | static asdl_seq* targets_rule(Parser *p); |
| 500 | static expr_ty target_rule(Parser *p); |
| 501 | static expr_ty t_primary_rule(Parser *p); |
| 502 | static void *t_lookahead_rule(Parser *p); |
| 503 | static expr_ty t_atom_rule(Parser *p); |
| 504 | static void *incorrect_arguments_rule(Parser *p); |
| 505 | static void *invalid_named_expression_rule(Parser *p); |
| 506 | static void *invalid_assignment_rule(Parser *p); |
| 507 | static void *invalid_block_rule(Parser *p); |
| 508 | static void *invalid_comprehension_rule(Parser *p); |
| 509 | static void *invalid_parameters_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 510 | static void *invalid_double_type_comments_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 511 | static asdl_seq *_loop0_1_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 512 | static asdl_seq *_loop0_2_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 513 | static asdl_seq *_loop0_4_rule(Parser *p); |
| 514 | static asdl_seq *_gather_3_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 515 | static asdl_seq *_loop0_6_rule(Parser *p); |
| 516 | static asdl_seq *_gather_5_rule(Parser *p); |
| 517 | static asdl_seq *_loop0_8_rule(Parser *p); |
| 518 | static asdl_seq *_gather_7_rule(Parser *p); |
| 519 | static asdl_seq *_loop0_10_rule(Parser *p); |
| 520 | static asdl_seq *_gather_9_rule(Parser *p); |
| 521 | static asdl_seq *_loop1_11_rule(Parser *p); |
| 522 | static asdl_seq *_loop0_13_rule(Parser *p); |
| 523 | static asdl_seq *_gather_12_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 524 | static void *_tmp_14_rule(Parser *p); |
| 525 | static void *_tmp_15_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 526 | static void *_tmp_16_rule(Parser *p); |
| 527 | static void *_tmp_17_rule(Parser *p); |
| 528 | static void *_tmp_18_rule(Parser *p); |
| 529 | static void *_tmp_19_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 530 | static void *_tmp_20_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 531 | static void *_tmp_21_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 532 | static asdl_seq *_loop1_22_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 533 | static void *_tmp_23_rule(Parser *p); |
| 534 | static void *_tmp_24_rule(Parser *p); |
| 535 | static asdl_seq *_loop0_26_rule(Parser *p); |
| 536 | static asdl_seq *_gather_25_rule(Parser *p); |
| 537 | static asdl_seq *_loop0_28_rule(Parser *p); |
| 538 | static asdl_seq *_gather_27_rule(Parser *p); |
| 539 | static void *_tmp_29_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 540 | static asdl_seq *_loop0_30_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 541 | static asdl_seq *_loop1_31_rule(Parser *p); |
| 542 | static asdl_seq *_loop0_33_rule(Parser *p); |
| 543 | static asdl_seq *_gather_32_rule(Parser *p); |
| 544 | static void *_tmp_34_rule(Parser *p); |
| 545 | static asdl_seq *_loop0_36_rule(Parser *p); |
| 546 | static asdl_seq *_gather_35_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 547 | static void *_tmp_37_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 548 | static asdl_seq *_loop0_39_rule(Parser *p); |
| 549 | static asdl_seq *_gather_38_rule(Parser *p); |
| 550 | static asdl_seq *_loop0_41_rule(Parser *p); |
| 551 | static asdl_seq *_gather_40_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 552 | static asdl_seq *_loop0_43_rule(Parser *p); |
| 553 | static asdl_seq *_gather_42_rule(Parser *p); |
| 554 | static asdl_seq *_loop0_45_rule(Parser *p); |
| 555 | static asdl_seq *_gather_44_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 556 | static void *_tmp_46_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 557 | static asdl_seq *_loop1_47_rule(Parser *p); |
| 558 | static void *_tmp_48_rule(Parser *p); |
| 559 | static void *_tmp_49_rule(Parser *p); |
| 560 | static void *_tmp_50_rule(Parser *p); |
| 561 | static void *_tmp_51_rule(Parser *p); |
| 562 | static void *_tmp_52_rule(Parser *p); |
| 563 | static asdl_seq *_loop0_53_rule(Parser *p); |
| 564 | static asdl_seq *_loop0_54_rule(Parser *p); |
| 565 | static asdl_seq *_loop0_55_rule(Parser *p); |
| 566 | static asdl_seq *_loop1_56_rule(Parser *p); |
| 567 | static asdl_seq *_loop0_57_rule(Parser *p); |
| 568 | static asdl_seq *_loop1_58_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 569 | static asdl_seq *_loop1_59_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 570 | static asdl_seq *_loop1_60_rule(Parser *p); |
| 571 | static asdl_seq *_loop0_61_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 572 | static asdl_seq *_loop1_62_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 573 | static asdl_seq *_loop0_63_rule(Parser *p); |
| 574 | static asdl_seq *_loop1_64_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 575 | static asdl_seq *_loop0_65_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 576 | static asdl_seq *_loop1_66_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 577 | static asdl_seq *_loop1_67_rule(Parser *p); |
| 578 | static void *_tmp_68_rule(Parser *p); |
| 579 | static asdl_seq *_loop0_70_rule(Parser *p); |
| 580 | static asdl_seq *_gather_69_rule(Parser *p); |
| 581 | static asdl_seq *_loop1_71_rule(Parser *p); |
| 582 | static asdl_seq *_loop0_73_rule(Parser *p); |
| 583 | static asdl_seq *_gather_72_rule(Parser *p); |
| 584 | static asdl_seq *_loop1_74_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 585 | static asdl_seq *_loop0_75_rule(Parser *p); |
| 586 | static asdl_seq *_loop0_76_rule(Parser *p); |
| 587 | static asdl_seq *_loop0_77_rule(Parser *p); |
| 588 | static asdl_seq *_loop1_78_rule(Parser *p); |
| 589 | static asdl_seq *_loop0_79_rule(Parser *p); |
| 590 | static asdl_seq *_loop1_80_rule(Parser *p); |
| 591 | static asdl_seq *_loop1_81_rule(Parser *p); |
| 592 | static asdl_seq *_loop1_82_rule(Parser *p); |
| 593 | static asdl_seq *_loop0_83_rule(Parser *p); |
| 594 | static asdl_seq *_loop1_84_rule(Parser *p); |
| 595 | static asdl_seq *_loop0_85_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 596 | static asdl_seq *_loop1_86_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 597 | static asdl_seq *_loop0_87_rule(Parser *p); |
| 598 | static asdl_seq *_loop1_88_rule(Parser *p); |
| 599 | static asdl_seq *_loop1_89_rule(Parser *p); |
| 600 | static asdl_seq *_loop1_90_rule(Parser *p); |
| 601 | static asdl_seq *_loop1_91_rule(Parser *p); |
| 602 | static void *_tmp_92_rule(Parser *p); |
| 603 | static asdl_seq *_loop0_94_rule(Parser *p); |
| 604 | static asdl_seq *_gather_93_rule(Parser *p); |
| 605 | static void *_tmp_95_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 606 | static void *_tmp_96_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 607 | static void *_tmp_97_rule(Parser *p); |
| 608 | static void *_tmp_98_rule(Parser *p); |
| 609 | static asdl_seq *_loop1_99_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 610 | static void *_tmp_100_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 611 | static void *_tmp_101_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 612 | static asdl_seq *_loop0_103_rule(Parser *p); |
| 613 | static asdl_seq *_gather_102_rule(Parser *p); |
| 614 | static asdl_seq *_loop1_104_rule(Parser *p); |
| 615 | static asdl_seq *_loop0_105_rule(Parser *p); |
| 616 | static asdl_seq *_loop0_106_rule(Parser *p); |
| 617 | static void *_tmp_107_rule(Parser *p); |
| 618 | static void *_tmp_108_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 619 | static asdl_seq *_loop0_110_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 620 | static asdl_seq *_gather_109_rule(Parser *p); |
| 621 | static asdl_seq *_loop0_112_rule(Parser *p); |
| 622 | static asdl_seq *_gather_111_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 623 | static asdl_seq *_loop0_114_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 624 | static asdl_seq *_gather_113_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 625 | static asdl_seq *_loop0_116_rule(Parser *p); |
| 626 | static asdl_seq *_gather_115_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 627 | static asdl_seq *_loop0_117_rule(Parser *p); |
| 628 | static asdl_seq *_loop0_119_rule(Parser *p); |
| 629 | static asdl_seq *_gather_118_rule(Parser *p); |
| 630 | static void *_tmp_120_rule(Parser *p); |
| 631 | static asdl_seq *_loop0_122_rule(Parser *p); |
| 632 | static asdl_seq *_gather_121_rule(Parser *p); |
| 633 | static asdl_seq *_loop0_124_rule(Parser *p); |
| 634 | static asdl_seq *_gather_123_rule(Parser *p); |
| 635 | static void *_tmp_125_rule(Parser *p); |
| 636 | static void *_tmp_126_rule(Parser *p); |
| 637 | static void *_tmp_127_rule(Parser *p); |
| 638 | static void *_tmp_128_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 639 | static void *_tmp_129_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 640 | static asdl_seq *_loop0_130_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 641 | static void *_tmp_131_rule(Parser *p); |
| 642 | static void *_tmp_132_rule(Parser *p); |
| 643 | static void *_tmp_133_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 644 | static void *_tmp_134_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 645 | static void *_tmp_135_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 646 | static void *_tmp_136_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 647 | static void *_tmp_137_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 648 | static void *_tmp_138_rule(Parser *p); |
| 649 | static void *_tmp_139_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 650 | static void *_tmp_140_rule(Parser *p); |
| 651 | static void *_tmp_141_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 652 | static void *_tmp_142_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 653 | static asdl_seq *_loop1_143_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 654 | |
| 655 | |
| 656 | // file: statements? $ |
| 657 | static mod_ty |
| 658 | file_rule(Parser *p) |
| 659 | { |
| 660 | if (p->error_indicator) { |
| 661 | return NULL; |
| 662 | } |
| 663 | mod_ty res = NULL; |
| 664 | int mark = p->mark; |
| 665 | { // statements? $ |
| 666 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 667 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 668 | if ( |
| 669 | (a = statements_rule(p), 1) |
| 670 | && |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 671 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 672 | ) |
| 673 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 674 | res = _PyPegen_make_module ( p , a ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 675 | if (res == NULL && PyErr_Occurred()) { |
| 676 | p->error_indicator = 1; |
| 677 | return NULL; |
| 678 | } |
| 679 | goto done; |
| 680 | } |
| 681 | p->mark = mark; |
| 682 | } |
| 683 | res = NULL; |
| 684 | done: |
| 685 | return res; |
| 686 | } |
| 687 | |
| 688 | // interactive: statement_newline |
| 689 | static mod_ty |
| 690 | interactive_rule(Parser *p) |
| 691 | { |
| 692 | if (p->error_indicator) { |
| 693 | return NULL; |
| 694 | } |
| 695 | mod_ty res = NULL; |
| 696 | int mark = p->mark; |
| 697 | { // statement_newline |
| 698 | asdl_seq* a; |
| 699 | if ( |
| 700 | (a = statement_newline_rule(p)) |
| 701 | ) |
| 702 | { |
| 703 | res = Interactive ( a , p -> arena ); |
| 704 | if (res == NULL && PyErr_Occurred()) { |
| 705 | p->error_indicator = 1; |
| 706 | return NULL; |
| 707 | } |
| 708 | goto done; |
| 709 | } |
| 710 | p->mark = mark; |
| 711 | } |
| 712 | res = NULL; |
| 713 | done: |
| 714 | return res; |
| 715 | } |
| 716 | |
| 717 | // eval: expressions NEWLINE* $ |
| 718 | static mod_ty |
| 719 | eval_rule(Parser *p) |
| 720 | { |
| 721 | if (p->error_indicator) { |
| 722 | return NULL; |
| 723 | } |
| 724 | mod_ty res = NULL; |
| 725 | int mark = p->mark; |
| 726 | { // expressions NEWLINE* $ |
| 727 | asdl_seq * _loop0_1_var; |
| 728 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 729 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 730 | if ( |
| 731 | (a = expressions_rule(p)) |
| 732 | && |
| 733 | (_loop0_1_var = _loop0_1_rule(p)) |
| 734 | && |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 735 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 736 | ) |
| 737 | { |
| 738 | res = Expression ( a , p -> arena ); |
| 739 | if (res == NULL && PyErr_Occurred()) { |
| 740 | p->error_indicator = 1; |
| 741 | return NULL; |
| 742 | } |
| 743 | goto done; |
| 744 | } |
| 745 | p->mark = mark; |
| 746 | } |
| 747 | res = NULL; |
| 748 | done: |
| 749 | return res; |
| 750 | } |
| 751 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 752 | // func_type: '(' type_expressions? ')' '->' expression NEWLINE* $ |
| 753 | static mod_ty |
| 754 | func_type_rule(Parser *p) |
| 755 | { |
| 756 | if (p->error_indicator) { |
| 757 | return NULL; |
| 758 | } |
| 759 | mod_ty res = NULL; |
| 760 | int mark = p->mark; |
| 761 | { // '(' type_expressions? ')' '->' expression NEWLINE* $ |
| 762 | asdl_seq * _loop0_2_var; |
| 763 | void *a; |
| 764 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 765 | Token * endmarker_var; |
| 766 | Token * literal; |
| 767 | Token * literal_1; |
| 768 | Token * literal_2; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 769 | if ( |
| 770 | (literal = _PyPegen_expect_token(p, 7)) |
| 771 | && |
| 772 | (a = type_expressions_rule(p), 1) |
| 773 | && |
| 774 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 775 | && |
| 776 | (literal_2 = _PyPegen_expect_token(p, 51)) |
| 777 | && |
| 778 | (b = expression_rule(p)) |
| 779 | && |
| 780 | (_loop0_2_var = _loop0_2_rule(p)) |
| 781 | && |
| 782 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) |
| 783 | ) |
| 784 | { |
| 785 | res = FunctionType ( a , b , p -> arena ); |
| 786 | if (res == NULL && PyErr_Occurred()) { |
| 787 | p->error_indicator = 1; |
| 788 | return NULL; |
| 789 | } |
| 790 | goto done; |
| 791 | } |
| 792 | p->mark = mark; |
| 793 | } |
| 794 | res = NULL; |
| 795 | done: |
| 796 | return res; |
| 797 | } |
| 798 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 799 | // fstring: star_expressions |
| 800 | static expr_ty |
| 801 | fstring_rule(Parser *p) |
| 802 | { |
| 803 | if (p->error_indicator) { |
| 804 | return NULL; |
| 805 | } |
| 806 | expr_ty res = NULL; |
| 807 | int mark = p->mark; |
| 808 | { // star_expressions |
| 809 | expr_ty star_expressions_var; |
| 810 | if ( |
| 811 | (star_expressions_var = star_expressions_rule(p)) |
| 812 | ) |
| 813 | { |
| 814 | res = star_expressions_var; |
| 815 | goto done; |
| 816 | } |
| 817 | p->mark = mark; |
| 818 | } |
| 819 | res = NULL; |
| 820 | done: |
| 821 | return res; |
| 822 | } |
| 823 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 824 | // type_expressions: |
| 825 | // | ','.expression+ ',' '*' expression ',' '**' expression |
| 826 | // | ','.expression+ ',' '*' expression |
| 827 | // | ','.expression+ ',' '**' expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 828 | // | '*' expression ',' '**' expression |
| 829 | // | '*' expression |
| 830 | // | '**' expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 831 | // | ','.expression+ |
| 832 | static asdl_seq* |
| 833 | type_expressions_rule(Parser *p) |
| 834 | { |
| 835 | if (p->error_indicator) { |
| 836 | return NULL; |
| 837 | } |
| 838 | asdl_seq* res = NULL; |
| 839 | int mark = p->mark; |
| 840 | { // ','.expression+ ',' '*' expression ',' '**' expression |
| 841 | asdl_seq * a; |
| 842 | expr_ty b; |
| 843 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 844 | Token * literal; |
| 845 | Token * literal_1; |
| 846 | Token * literal_2; |
| 847 | Token * literal_3; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 848 | if ( |
| 849 | (a = _gather_3_rule(p)) |
| 850 | && |
| 851 | (literal = _PyPegen_expect_token(p, 12)) |
| 852 | && |
| 853 | (literal_1 = _PyPegen_expect_token(p, 16)) |
| 854 | && |
| 855 | (b = expression_rule(p)) |
| 856 | && |
| 857 | (literal_2 = _PyPegen_expect_token(p, 12)) |
| 858 | && |
| 859 | (literal_3 = _PyPegen_expect_token(p, 35)) |
| 860 | && |
| 861 | (c = expression_rule(p)) |
| 862 | ) |
| 863 | { |
| 864 | res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_seq_append_to_end ( p , a , b ) ) , c ); |
| 865 | if (res == NULL && PyErr_Occurred()) { |
| 866 | p->error_indicator = 1; |
| 867 | return NULL; |
| 868 | } |
| 869 | goto done; |
| 870 | } |
| 871 | p->mark = mark; |
| 872 | } |
| 873 | { // ','.expression+ ',' '*' expression |
| 874 | asdl_seq * a; |
| 875 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 876 | Token * literal; |
| 877 | Token * literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 878 | if ( |
| 879 | (a = _gather_5_rule(p)) |
| 880 | && |
| 881 | (literal = _PyPegen_expect_token(p, 12)) |
| 882 | && |
| 883 | (literal_1 = _PyPegen_expect_token(p, 16)) |
| 884 | && |
| 885 | (b = expression_rule(p)) |
| 886 | ) |
| 887 | { |
| 888 | res = _PyPegen_seq_append_to_end ( p , a , b ); |
| 889 | if (res == NULL && PyErr_Occurred()) { |
| 890 | p->error_indicator = 1; |
| 891 | return NULL; |
| 892 | } |
| 893 | goto done; |
| 894 | } |
| 895 | p->mark = mark; |
| 896 | } |
| 897 | { // ','.expression+ ',' '**' expression |
| 898 | asdl_seq * a; |
| 899 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 900 | Token * literal; |
| 901 | Token * literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 902 | if ( |
| 903 | (a = _gather_7_rule(p)) |
| 904 | && |
| 905 | (literal = _PyPegen_expect_token(p, 12)) |
| 906 | && |
| 907 | (literal_1 = _PyPegen_expect_token(p, 35)) |
| 908 | && |
| 909 | (b = expression_rule(p)) |
| 910 | ) |
| 911 | { |
| 912 | res = _PyPegen_seq_append_to_end ( p , a , b ); |
| 913 | if (res == NULL && PyErr_Occurred()) { |
| 914 | p->error_indicator = 1; |
| 915 | return NULL; |
| 916 | } |
| 917 | goto done; |
| 918 | } |
| 919 | p->mark = mark; |
| 920 | } |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 921 | { // '*' expression ',' '**' expression |
| 922 | expr_ty a; |
| 923 | expr_ty b; |
| 924 | Token * literal; |
| 925 | Token * literal_1; |
| 926 | Token * literal_2; |
| 927 | if ( |
| 928 | (literal = _PyPegen_expect_token(p, 16)) |
| 929 | && |
| 930 | (a = expression_rule(p)) |
| 931 | && |
| 932 | (literal_1 = _PyPegen_expect_token(p, 12)) |
| 933 | && |
| 934 | (literal_2 = _PyPegen_expect_token(p, 35)) |
| 935 | && |
| 936 | (b = expression_rule(p)) |
| 937 | ) |
| 938 | { |
| 939 | res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_singleton_seq ( p , a ) ) , b ); |
| 940 | if (res == NULL && PyErr_Occurred()) { |
| 941 | p->error_indicator = 1; |
| 942 | return NULL; |
| 943 | } |
| 944 | goto done; |
| 945 | } |
| 946 | p->mark = mark; |
| 947 | } |
| 948 | { // '*' expression |
| 949 | expr_ty a; |
| 950 | Token * literal; |
| 951 | if ( |
| 952 | (literal = _PyPegen_expect_token(p, 16)) |
| 953 | && |
| 954 | (a = expression_rule(p)) |
| 955 | ) |
| 956 | { |
| 957 | res = _PyPegen_singleton_seq ( p , a ); |
| 958 | if (res == NULL && PyErr_Occurred()) { |
| 959 | p->error_indicator = 1; |
| 960 | return NULL; |
| 961 | } |
| 962 | goto done; |
| 963 | } |
| 964 | p->mark = mark; |
| 965 | } |
| 966 | { // '**' expression |
| 967 | expr_ty a; |
| 968 | Token * literal; |
| 969 | if ( |
| 970 | (literal = _PyPegen_expect_token(p, 35)) |
| 971 | && |
| 972 | (a = expression_rule(p)) |
| 973 | ) |
| 974 | { |
| 975 | res = _PyPegen_singleton_seq ( p , a ); |
| 976 | if (res == NULL && PyErr_Occurred()) { |
| 977 | p->error_indicator = 1; |
| 978 | return NULL; |
| 979 | } |
| 980 | goto done; |
| 981 | } |
| 982 | p->mark = mark; |
| 983 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 984 | { // ','.expression+ |
| 985 | asdl_seq * _gather_9_var; |
| 986 | if ( |
| 987 | (_gather_9_var = _gather_9_rule(p)) |
| 988 | ) |
| 989 | { |
| 990 | res = _gather_9_var; |
| 991 | goto done; |
| 992 | } |
| 993 | p->mark = mark; |
| 994 | } |
| 995 | res = NULL; |
| 996 | done: |
| 997 | return res; |
| 998 | } |
| 999 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1000 | // statements: statement+ |
| 1001 | static asdl_seq* |
| 1002 | statements_rule(Parser *p) |
| 1003 | { |
| 1004 | if (p->error_indicator) { |
| 1005 | return NULL; |
| 1006 | } |
| 1007 | asdl_seq* res = NULL; |
| 1008 | int mark = p->mark; |
| 1009 | { // statement+ |
| 1010 | asdl_seq * a; |
| 1011 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1012 | (a = _loop1_11_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1013 | ) |
| 1014 | { |
| 1015 | res = _PyPegen_seq_flatten ( p , a ); |
| 1016 | if (res == NULL && PyErr_Occurred()) { |
| 1017 | p->error_indicator = 1; |
| 1018 | return NULL; |
| 1019 | } |
| 1020 | goto done; |
| 1021 | } |
| 1022 | p->mark = mark; |
| 1023 | } |
| 1024 | res = NULL; |
| 1025 | done: |
| 1026 | return res; |
| 1027 | } |
| 1028 | |
| 1029 | // statement: compound_stmt | simple_stmt |
| 1030 | static asdl_seq* |
| 1031 | statement_rule(Parser *p) |
| 1032 | { |
| 1033 | if (p->error_indicator) { |
| 1034 | return NULL; |
| 1035 | } |
| 1036 | asdl_seq* res = NULL; |
| 1037 | int mark = p->mark; |
| 1038 | { // compound_stmt |
| 1039 | stmt_ty a; |
| 1040 | if ( |
| 1041 | (a = compound_stmt_rule(p)) |
| 1042 | ) |
| 1043 | { |
| 1044 | res = _PyPegen_singleton_seq ( p , a ); |
| 1045 | if (res == NULL && PyErr_Occurred()) { |
| 1046 | p->error_indicator = 1; |
| 1047 | return NULL; |
| 1048 | } |
| 1049 | goto done; |
| 1050 | } |
| 1051 | p->mark = mark; |
| 1052 | } |
| 1053 | { // simple_stmt |
| 1054 | asdl_seq* simple_stmt_var; |
| 1055 | if ( |
| 1056 | (simple_stmt_var = simple_stmt_rule(p)) |
| 1057 | ) |
| 1058 | { |
| 1059 | res = simple_stmt_var; |
| 1060 | goto done; |
| 1061 | } |
| 1062 | p->mark = mark; |
| 1063 | } |
| 1064 | res = NULL; |
| 1065 | done: |
| 1066 | return res; |
| 1067 | } |
| 1068 | |
| 1069 | // statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $ |
| 1070 | static asdl_seq* |
| 1071 | statement_newline_rule(Parser *p) |
| 1072 | { |
| 1073 | if (p->error_indicator) { |
| 1074 | return NULL; |
| 1075 | } |
| 1076 | asdl_seq* res = NULL; |
| 1077 | int mark = p->mark; |
| 1078 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1079 | p->error_indicator = 1; |
| 1080 | return NULL; |
| 1081 | } |
| 1082 | int start_lineno = p->tokens[mark]->lineno; |
| 1083 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 1084 | int start_col_offset = p->tokens[mark]->col_offset; |
| 1085 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 1086 | { // compound_stmt NEWLINE |
| 1087 | stmt_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1088 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1089 | if ( |
| 1090 | (a = compound_stmt_rule(p)) |
| 1091 | && |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 1092 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1093 | ) |
| 1094 | { |
| 1095 | res = _PyPegen_singleton_seq ( p , a ); |
| 1096 | if (res == NULL && PyErr_Occurred()) { |
| 1097 | p->error_indicator = 1; |
| 1098 | return NULL; |
| 1099 | } |
| 1100 | goto done; |
| 1101 | } |
| 1102 | p->mark = mark; |
| 1103 | } |
| 1104 | { // simple_stmt |
| 1105 | asdl_seq* simple_stmt_var; |
| 1106 | if ( |
| 1107 | (simple_stmt_var = simple_stmt_rule(p)) |
| 1108 | ) |
| 1109 | { |
| 1110 | res = simple_stmt_var; |
| 1111 | goto done; |
| 1112 | } |
| 1113 | p->mark = mark; |
| 1114 | } |
| 1115 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1116 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1117 | if ( |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 1118 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1119 | ) |
| 1120 | { |
| 1121 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1122 | if (token == NULL) { |
| 1123 | return NULL; |
| 1124 | } |
| 1125 | int end_lineno = token->end_lineno; |
| 1126 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1127 | int end_col_offset = token->end_col_offset; |
| 1128 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1129 | res = _PyPegen_singleton_seq ( p , CHECK ( _Py_Pass ( EXTRA ) ) ); |
| 1130 | if (res == NULL && PyErr_Occurred()) { |
| 1131 | p->error_indicator = 1; |
| 1132 | return NULL; |
| 1133 | } |
| 1134 | goto done; |
| 1135 | } |
| 1136 | p->mark = mark; |
| 1137 | } |
| 1138 | { // $ |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1139 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1140 | if ( |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 1141 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1142 | ) |
| 1143 | { |
| 1144 | res = _PyPegen_interactive_exit ( p ); |
| 1145 | if (res == NULL && PyErr_Occurred()) { |
| 1146 | p->error_indicator = 1; |
| 1147 | return NULL; |
| 1148 | } |
| 1149 | goto done; |
| 1150 | } |
| 1151 | p->mark = mark; |
| 1152 | } |
| 1153 | res = NULL; |
| 1154 | done: |
| 1155 | return res; |
| 1156 | } |
| 1157 | |
| 1158 | // simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE |
| 1159 | static asdl_seq* |
| 1160 | simple_stmt_rule(Parser *p) |
| 1161 | { |
| 1162 | if (p->error_indicator) { |
| 1163 | return NULL; |
| 1164 | } |
| 1165 | asdl_seq* res = NULL; |
| 1166 | int mark = p->mark; |
| 1167 | { // small_stmt !';' NEWLINE |
| 1168 | stmt_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1169 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1170 | if ( |
| 1171 | (a = small_stmt_rule(p)) |
| 1172 | && |
| 1173 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) |
| 1174 | && |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 1175 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1176 | ) |
| 1177 | { |
| 1178 | res = _PyPegen_singleton_seq ( p , a ); |
| 1179 | if (res == NULL && PyErr_Occurred()) { |
| 1180 | p->error_indicator = 1; |
| 1181 | return NULL; |
| 1182 | } |
| 1183 | goto done; |
| 1184 | } |
| 1185 | p->mark = mark; |
| 1186 | } |
| 1187 | { // ';'.small_stmt+ ';'? NEWLINE |
| 1188 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1189 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1190 | void *opt_var; |
| 1191 | UNUSED(opt_var); // Silence compiler warnings |
| 1192 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1193 | (a = _gather_12_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1194 | && |
| 1195 | (opt_var = _PyPegen_expect_token(p, 13), 1) |
| 1196 | && |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 1197 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1198 | ) |
| 1199 | { |
| 1200 | res = a; |
| 1201 | if (res == NULL && PyErr_Occurred()) { |
| 1202 | p->error_indicator = 1; |
| 1203 | return NULL; |
| 1204 | } |
| 1205 | goto done; |
| 1206 | } |
| 1207 | p->mark = mark; |
| 1208 | } |
| 1209 | res = NULL; |
| 1210 | done: |
| 1211 | return res; |
| 1212 | } |
| 1213 | |
| 1214 | // small_stmt: |
| 1215 | // | assignment |
| 1216 | // | star_expressions |
| 1217 | // | &'return' return_stmt |
| 1218 | // | &('import' | 'from') import_stmt |
| 1219 | // | &'raise' raise_stmt |
| 1220 | // | 'pass' |
| 1221 | // | &'del' del_stmt |
| 1222 | // | &'yield' yield_stmt |
| 1223 | // | &'assert' assert_stmt |
| 1224 | // | 'break' |
| 1225 | // | 'continue' |
| 1226 | // | &'global' global_stmt |
| 1227 | // | &'nonlocal' nonlocal_stmt |
| 1228 | static stmt_ty |
| 1229 | small_stmt_rule(Parser *p) |
| 1230 | { |
| 1231 | if (p->error_indicator) { |
| 1232 | return NULL; |
| 1233 | } |
| 1234 | stmt_ty res = NULL; |
| 1235 | if (_PyPegen_is_memoized(p, small_stmt_type, &res)) |
| 1236 | return res; |
| 1237 | int mark = p->mark; |
| 1238 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1239 | p->error_indicator = 1; |
| 1240 | return NULL; |
| 1241 | } |
| 1242 | int start_lineno = p->tokens[mark]->lineno; |
| 1243 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 1244 | int start_col_offset = p->tokens[mark]->col_offset; |
| 1245 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 1246 | { // assignment |
| 1247 | void *assignment_var; |
| 1248 | if ( |
| 1249 | (assignment_var = assignment_rule(p)) |
| 1250 | ) |
| 1251 | { |
| 1252 | res = assignment_var; |
| 1253 | goto done; |
| 1254 | } |
| 1255 | p->mark = mark; |
| 1256 | } |
| 1257 | { // star_expressions |
| 1258 | expr_ty e; |
| 1259 | if ( |
| 1260 | (e = star_expressions_rule(p)) |
| 1261 | ) |
| 1262 | { |
| 1263 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1264 | if (token == NULL) { |
| 1265 | return NULL; |
| 1266 | } |
| 1267 | int end_lineno = token->end_lineno; |
| 1268 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1269 | int end_col_offset = token->end_col_offset; |
| 1270 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1271 | res = _Py_Expr ( e , EXTRA ); |
| 1272 | if (res == NULL && PyErr_Occurred()) { |
| 1273 | p->error_indicator = 1; |
| 1274 | return NULL; |
| 1275 | } |
| 1276 | goto done; |
| 1277 | } |
| 1278 | p->mark = mark; |
| 1279 | } |
| 1280 | { // &'return' return_stmt |
| 1281 | stmt_ty return_stmt_var; |
| 1282 | if ( |
| 1283 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) |
| 1284 | && |
| 1285 | (return_stmt_var = return_stmt_rule(p)) |
| 1286 | ) |
| 1287 | { |
| 1288 | res = return_stmt_var; |
| 1289 | goto done; |
| 1290 | } |
| 1291 | p->mark = mark; |
| 1292 | } |
| 1293 | { // &('import' | 'from') import_stmt |
| 1294 | stmt_ty import_stmt_var; |
| 1295 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1296 | _PyPegen_lookahead(1, _tmp_14_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1297 | && |
| 1298 | (import_stmt_var = import_stmt_rule(p)) |
| 1299 | ) |
| 1300 | { |
| 1301 | res = import_stmt_var; |
| 1302 | goto done; |
| 1303 | } |
| 1304 | p->mark = mark; |
| 1305 | } |
| 1306 | { // &'raise' raise_stmt |
| 1307 | stmt_ty raise_stmt_var; |
| 1308 | if ( |
| 1309 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501) |
| 1310 | && |
| 1311 | (raise_stmt_var = raise_stmt_rule(p)) |
| 1312 | ) |
| 1313 | { |
| 1314 | res = raise_stmt_var; |
| 1315 | goto done; |
| 1316 | } |
| 1317 | p->mark = mark; |
| 1318 | } |
| 1319 | { // 'pass' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1320 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1321 | if ( |
| 1322 | (keyword = _PyPegen_expect_token(p, 502)) |
| 1323 | ) |
| 1324 | { |
| 1325 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1326 | if (token == NULL) { |
| 1327 | return NULL; |
| 1328 | } |
| 1329 | int end_lineno = token->end_lineno; |
| 1330 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1331 | int end_col_offset = token->end_col_offset; |
| 1332 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1333 | res = _Py_Pass ( EXTRA ); |
| 1334 | if (res == NULL && PyErr_Occurred()) { |
| 1335 | p->error_indicator = 1; |
| 1336 | return NULL; |
| 1337 | } |
| 1338 | goto done; |
| 1339 | } |
| 1340 | p->mark = mark; |
| 1341 | } |
| 1342 | { // &'del' del_stmt |
| 1343 | stmt_ty del_stmt_var; |
| 1344 | if ( |
| 1345 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) |
| 1346 | && |
| 1347 | (del_stmt_var = del_stmt_rule(p)) |
| 1348 | ) |
| 1349 | { |
| 1350 | res = del_stmt_var; |
| 1351 | goto done; |
| 1352 | } |
| 1353 | p->mark = mark; |
| 1354 | } |
| 1355 | { // &'yield' yield_stmt |
| 1356 | stmt_ty yield_stmt_var; |
| 1357 | if ( |
| 1358 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) |
| 1359 | && |
| 1360 | (yield_stmt_var = yield_stmt_rule(p)) |
| 1361 | ) |
| 1362 | { |
| 1363 | res = yield_stmt_var; |
| 1364 | goto done; |
| 1365 | } |
| 1366 | p->mark = mark; |
| 1367 | } |
| 1368 | { // &'assert' assert_stmt |
| 1369 | stmt_ty assert_stmt_var; |
| 1370 | if ( |
| 1371 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) |
| 1372 | && |
| 1373 | (assert_stmt_var = assert_stmt_rule(p)) |
| 1374 | ) |
| 1375 | { |
| 1376 | res = assert_stmt_var; |
| 1377 | goto done; |
| 1378 | } |
| 1379 | p->mark = mark; |
| 1380 | } |
| 1381 | { // 'break' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1382 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1383 | if ( |
| 1384 | (keyword = _PyPegen_expect_token(p, 506)) |
| 1385 | ) |
| 1386 | { |
| 1387 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1388 | if (token == NULL) { |
| 1389 | return NULL; |
| 1390 | } |
| 1391 | int end_lineno = token->end_lineno; |
| 1392 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1393 | int end_col_offset = token->end_col_offset; |
| 1394 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1395 | res = _Py_Break ( EXTRA ); |
| 1396 | if (res == NULL && PyErr_Occurred()) { |
| 1397 | p->error_indicator = 1; |
| 1398 | return NULL; |
| 1399 | } |
| 1400 | goto done; |
| 1401 | } |
| 1402 | p->mark = mark; |
| 1403 | } |
| 1404 | { // 'continue' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1405 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1406 | if ( |
| 1407 | (keyword = _PyPegen_expect_token(p, 507)) |
| 1408 | ) |
| 1409 | { |
| 1410 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1411 | if (token == NULL) { |
| 1412 | return NULL; |
| 1413 | } |
| 1414 | int end_lineno = token->end_lineno; |
| 1415 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1416 | int end_col_offset = token->end_col_offset; |
| 1417 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1418 | res = _Py_Continue ( EXTRA ); |
| 1419 | if (res == NULL && PyErr_Occurred()) { |
| 1420 | p->error_indicator = 1; |
| 1421 | return NULL; |
| 1422 | } |
| 1423 | goto done; |
| 1424 | } |
| 1425 | p->mark = mark; |
| 1426 | } |
| 1427 | { // &'global' global_stmt |
| 1428 | stmt_ty global_stmt_var; |
| 1429 | if ( |
| 1430 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) |
| 1431 | && |
| 1432 | (global_stmt_var = global_stmt_rule(p)) |
| 1433 | ) |
| 1434 | { |
| 1435 | res = global_stmt_var; |
| 1436 | goto done; |
| 1437 | } |
| 1438 | p->mark = mark; |
| 1439 | } |
| 1440 | { // &'nonlocal' nonlocal_stmt |
| 1441 | stmt_ty nonlocal_stmt_var; |
| 1442 | if ( |
| 1443 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) |
| 1444 | && |
| 1445 | (nonlocal_stmt_var = nonlocal_stmt_rule(p)) |
| 1446 | ) |
| 1447 | { |
| 1448 | res = nonlocal_stmt_var; |
| 1449 | goto done; |
| 1450 | } |
| 1451 | p->mark = mark; |
| 1452 | } |
| 1453 | res = NULL; |
| 1454 | done: |
| 1455 | _PyPegen_insert_memo(p, mark, small_stmt_type, res); |
| 1456 | return res; |
| 1457 | } |
| 1458 | |
| 1459 | // compound_stmt: |
| 1460 | // | &('def' | '@' | ASYNC) function_def |
| 1461 | // | &'if' if_stmt |
| 1462 | // | &('class' | '@') class_def |
| 1463 | // | &('with' | ASYNC) with_stmt |
| 1464 | // | &('for' | ASYNC) for_stmt |
| 1465 | // | &'try' try_stmt |
| 1466 | // | &'while' while_stmt |
| 1467 | static stmt_ty |
| 1468 | compound_stmt_rule(Parser *p) |
| 1469 | { |
| 1470 | if (p->error_indicator) { |
| 1471 | return NULL; |
| 1472 | } |
| 1473 | stmt_ty res = NULL; |
| 1474 | int mark = p->mark; |
| 1475 | { // &('def' | '@' | ASYNC) function_def |
| 1476 | stmt_ty function_def_var; |
| 1477 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1478 | _PyPegen_lookahead(1, _tmp_15_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1479 | && |
| 1480 | (function_def_var = function_def_rule(p)) |
| 1481 | ) |
| 1482 | { |
| 1483 | res = function_def_var; |
| 1484 | goto done; |
| 1485 | } |
| 1486 | p->mark = mark; |
| 1487 | } |
| 1488 | { // &'if' if_stmt |
| 1489 | stmt_ty if_stmt_var; |
| 1490 | if ( |
| 1491 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 510) |
| 1492 | && |
| 1493 | (if_stmt_var = if_stmt_rule(p)) |
| 1494 | ) |
| 1495 | { |
| 1496 | res = if_stmt_var; |
| 1497 | goto done; |
| 1498 | } |
| 1499 | p->mark = mark; |
| 1500 | } |
| 1501 | { // &('class' | '@') class_def |
| 1502 | stmt_ty class_def_var; |
| 1503 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1504 | _PyPegen_lookahead(1, _tmp_16_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1505 | && |
| 1506 | (class_def_var = class_def_rule(p)) |
| 1507 | ) |
| 1508 | { |
| 1509 | res = class_def_var; |
| 1510 | goto done; |
| 1511 | } |
| 1512 | p->mark = mark; |
| 1513 | } |
| 1514 | { // &('with' | ASYNC) with_stmt |
| 1515 | stmt_ty with_stmt_var; |
| 1516 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1517 | _PyPegen_lookahead(1, _tmp_17_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1518 | && |
| 1519 | (with_stmt_var = with_stmt_rule(p)) |
| 1520 | ) |
| 1521 | { |
| 1522 | res = with_stmt_var; |
| 1523 | goto done; |
| 1524 | } |
| 1525 | p->mark = mark; |
| 1526 | } |
| 1527 | { // &('for' | ASYNC) for_stmt |
| 1528 | stmt_ty for_stmt_var; |
| 1529 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1530 | _PyPegen_lookahead(1, _tmp_18_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1531 | && |
| 1532 | (for_stmt_var = for_stmt_rule(p)) |
| 1533 | ) |
| 1534 | { |
| 1535 | res = for_stmt_var; |
| 1536 | goto done; |
| 1537 | } |
| 1538 | p->mark = mark; |
| 1539 | } |
| 1540 | { // &'try' try_stmt |
| 1541 | stmt_ty try_stmt_var; |
| 1542 | if ( |
| 1543 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 511) |
| 1544 | && |
| 1545 | (try_stmt_var = try_stmt_rule(p)) |
| 1546 | ) |
| 1547 | { |
| 1548 | res = try_stmt_var; |
| 1549 | goto done; |
| 1550 | } |
| 1551 | p->mark = mark; |
| 1552 | } |
| 1553 | { // &'while' while_stmt |
| 1554 | stmt_ty while_stmt_var; |
| 1555 | if ( |
| 1556 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 512) |
| 1557 | && |
| 1558 | (while_stmt_var = while_stmt_rule(p)) |
| 1559 | ) |
| 1560 | { |
| 1561 | res = while_stmt_var; |
| 1562 | goto done; |
| 1563 | } |
| 1564 | p->mark = mark; |
| 1565 | } |
| 1566 | res = NULL; |
| 1567 | done: |
| 1568 | return res; |
| 1569 | } |
| 1570 | |
| 1571 | // assignment: |
| 1572 | // | NAME ':' expression ['=' annotated_rhs] |
| 1573 | // | ('(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target) ':' expression ['=' annotated_rhs] |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1574 | // | ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1575 | // | target augassign (yield_expr | star_expressions) |
| 1576 | // | invalid_assignment |
| 1577 | static void * |
| 1578 | assignment_rule(Parser *p) |
| 1579 | { |
| 1580 | if (p->error_indicator) { |
| 1581 | return NULL; |
| 1582 | } |
| 1583 | void * res = NULL; |
| 1584 | int mark = p->mark; |
| 1585 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1586 | p->error_indicator = 1; |
| 1587 | return NULL; |
| 1588 | } |
| 1589 | int start_lineno = p->tokens[mark]->lineno; |
| 1590 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 1591 | int start_col_offset = p->tokens[mark]->col_offset; |
| 1592 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 1593 | { // NAME ':' expression ['=' annotated_rhs] |
| 1594 | expr_ty a; |
| 1595 | expr_ty b; |
| 1596 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1597 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1598 | if ( |
| 1599 | (a = _PyPegen_name_token(p)) |
| 1600 | && |
| 1601 | (literal = _PyPegen_expect_token(p, 11)) |
| 1602 | && |
| 1603 | (b = expression_rule(p)) |
| 1604 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1605 | (c = _tmp_19_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1606 | ) |
| 1607 | { |
| 1608 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1609 | if (token == NULL) { |
| 1610 | return NULL; |
| 1611 | } |
| 1612 | int end_lineno = token->end_lineno; |
| 1613 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1614 | int end_col_offset = token->end_col_offset; |
| 1615 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 1616 | res = CHECK_VERSION ( 6 , "Variable annotation syntax is" , _Py_AnnAssign ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , c , 1 , EXTRA ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1617 | if (res == NULL && PyErr_Occurred()) { |
| 1618 | p->error_indicator = 1; |
| 1619 | return NULL; |
| 1620 | } |
| 1621 | goto done; |
| 1622 | } |
| 1623 | p->mark = mark; |
| 1624 | } |
| 1625 | { // ('(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target) ':' expression ['=' annotated_rhs] |
| 1626 | void *a; |
| 1627 | expr_ty b; |
| 1628 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1629 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1630 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1631 | (a = _tmp_20_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1632 | && |
| 1633 | (literal = _PyPegen_expect_token(p, 11)) |
| 1634 | && |
| 1635 | (b = expression_rule(p)) |
| 1636 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1637 | (c = _tmp_21_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1638 | ) |
| 1639 | { |
| 1640 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1641 | if (token == NULL) { |
| 1642 | return NULL; |
| 1643 | } |
| 1644 | int end_lineno = token->end_lineno; |
| 1645 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1646 | int end_col_offset = token->end_col_offset; |
| 1647 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 1648 | res = CHECK_VERSION ( 6 , "Variable annotations syntax is" , _Py_AnnAssign ( a , b , c , 0 , EXTRA ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1649 | if (res == NULL && PyErr_Occurred()) { |
| 1650 | p->error_indicator = 1; |
| 1651 | return NULL; |
| 1652 | } |
| 1653 | goto done; |
| 1654 | } |
| 1655 | p->mark = mark; |
| 1656 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1657 | { // ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1658 | asdl_seq * a; |
| 1659 | void *b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1660 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1661 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1662 | (a = _loop1_22_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1663 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1664 | (b = _tmp_23_rule(p)) |
| 1665 | && |
| 1666 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1667 | ) |
| 1668 | { |
| 1669 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1670 | if (token == NULL) { |
| 1671 | return NULL; |
| 1672 | } |
| 1673 | int end_lineno = token->end_lineno; |
| 1674 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1675 | int end_col_offset = token->end_col_offset; |
| 1676 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1677 | res = _Py_Assign ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1678 | if (res == NULL && PyErr_Occurred()) { |
| 1679 | p->error_indicator = 1; |
| 1680 | return NULL; |
| 1681 | } |
| 1682 | goto done; |
| 1683 | } |
| 1684 | p->mark = mark; |
| 1685 | } |
| 1686 | { // target augassign (yield_expr | star_expressions) |
| 1687 | expr_ty a; |
| 1688 | AugOperator* b; |
| 1689 | void *c; |
| 1690 | if ( |
| 1691 | (a = target_rule(p)) |
| 1692 | && |
| 1693 | (b = augassign_rule(p)) |
| 1694 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1695 | (c = _tmp_24_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1696 | ) |
| 1697 | { |
| 1698 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1699 | if (token == NULL) { |
| 1700 | return NULL; |
| 1701 | } |
| 1702 | int end_lineno = token->end_lineno; |
| 1703 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1704 | int end_col_offset = token->end_col_offset; |
| 1705 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1706 | res = _Py_AugAssign ( a , b -> kind , c , EXTRA ); |
| 1707 | if (res == NULL && PyErr_Occurred()) { |
| 1708 | p->error_indicator = 1; |
| 1709 | return NULL; |
| 1710 | } |
| 1711 | goto done; |
| 1712 | } |
| 1713 | p->mark = mark; |
| 1714 | } |
| 1715 | { // invalid_assignment |
| 1716 | void *invalid_assignment_var; |
| 1717 | if ( |
| 1718 | (invalid_assignment_var = invalid_assignment_rule(p)) |
| 1719 | ) |
| 1720 | { |
| 1721 | res = invalid_assignment_var; |
| 1722 | goto done; |
| 1723 | } |
| 1724 | p->mark = mark; |
| 1725 | } |
| 1726 | res = NULL; |
| 1727 | done: |
| 1728 | return res; |
| 1729 | } |
| 1730 | |
| 1731 | // augassign: |
| 1732 | // | '+=' |
| 1733 | // | '-=' |
| 1734 | // | '*=' |
| 1735 | // | '@=' |
| 1736 | // | '/=' |
| 1737 | // | '%=' |
| 1738 | // | '&=' |
| 1739 | // | '|=' |
| 1740 | // | '^=' |
| 1741 | // | '<<=' |
| 1742 | // | '>>=' |
| 1743 | // | '**=' |
| 1744 | // | '//=' |
| 1745 | static AugOperator* |
| 1746 | augassign_rule(Parser *p) |
| 1747 | { |
| 1748 | if (p->error_indicator) { |
| 1749 | return NULL; |
| 1750 | } |
| 1751 | AugOperator* res = NULL; |
| 1752 | int mark = p->mark; |
| 1753 | { // '+=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1754 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1755 | if ( |
| 1756 | (literal = _PyPegen_expect_token(p, 36)) |
| 1757 | ) |
| 1758 | { |
| 1759 | res = _PyPegen_augoperator ( p , Add ); |
| 1760 | if (res == NULL && PyErr_Occurred()) { |
| 1761 | p->error_indicator = 1; |
| 1762 | return NULL; |
| 1763 | } |
| 1764 | goto done; |
| 1765 | } |
| 1766 | p->mark = mark; |
| 1767 | } |
| 1768 | { // '-=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1769 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1770 | if ( |
| 1771 | (literal = _PyPegen_expect_token(p, 37)) |
| 1772 | ) |
| 1773 | { |
| 1774 | res = _PyPegen_augoperator ( p , Sub ); |
| 1775 | if (res == NULL && PyErr_Occurred()) { |
| 1776 | p->error_indicator = 1; |
| 1777 | return NULL; |
| 1778 | } |
| 1779 | goto done; |
| 1780 | } |
| 1781 | p->mark = mark; |
| 1782 | } |
| 1783 | { // '*=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1784 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1785 | if ( |
| 1786 | (literal = _PyPegen_expect_token(p, 38)) |
| 1787 | ) |
| 1788 | { |
| 1789 | res = _PyPegen_augoperator ( p , Mult ); |
| 1790 | if (res == NULL && PyErr_Occurred()) { |
| 1791 | p->error_indicator = 1; |
| 1792 | return NULL; |
| 1793 | } |
| 1794 | goto done; |
| 1795 | } |
| 1796 | p->mark = mark; |
| 1797 | } |
| 1798 | { // '@=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1799 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1800 | if ( |
| 1801 | (literal = _PyPegen_expect_token(p, 50)) |
| 1802 | ) |
| 1803 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 1804 | res = CHECK_VERSION ( 5 , "The '@' operator is" , _PyPegen_augoperator ( p , MatMult ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1805 | if (res == NULL && PyErr_Occurred()) { |
| 1806 | p->error_indicator = 1; |
| 1807 | return NULL; |
| 1808 | } |
| 1809 | goto done; |
| 1810 | } |
| 1811 | p->mark = mark; |
| 1812 | } |
| 1813 | { // '/=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1814 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1815 | if ( |
| 1816 | (literal = _PyPegen_expect_token(p, 39)) |
| 1817 | ) |
| 1818 | { |
| 1819 | res = _PyPegen_augoperator ( p , Div ); |
| 1820 | if (res == NULL && PyErr_Occurred()) { |
| 1821 | p->error_indicator = 1; |
| 1822 | return NULL; |
| 1823 | } |
| 1824 | goto done; |
| 1825 | } |
| 1826 | p->mark = mark; |
| 1827 | } |
| 1828 | { // '%=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1829 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1830 | if ( |
| 1831 | (literal = _PyPegen_expect_token(p, 40)) |
| 1832 | ) |
| 1833 | { |
| 1834 | res = _PyPegen_augoperator ( p , Mod ); |
| 1835 | if (res == NULL && PyErr_Occurred()) { |
| 1836 | p->error_indicator = 1; |
| 1837 | return NULL; |
| 1838 | } |
| 1839 | goto done; |
| 1840 | } |
| 1841 | p->mark = mark; |
| 1842 | } |
| 1843 | { // '&=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1844 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1845 | if ( |
| 1846 | (literal = _PyPegen_expect_token(p, 41)) |
| 1847 | ) |
| 1848 | { |
| 1849 | res = _PyPegen_augoperator ( p , BitAnd ); |
| 1850 | if (res == NULL && PyErr_Occurred()) { |
| 1851 | p->error_indicator = 1; |
| 1852 | return NULL; |
| 1853 | } |
| 1854 | goto done; |
| 1855 | } |
| 1856 | p->mark = mark; |
| 1857 | } |
| 1858 | { // '|=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1859 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1860 | if ( |
| 1861 | (literal = _PyPegen_expect_token(p, 42)) |
| 1862 | ) |
| 1863 | { |
| 1864 | res = _PyPegen_augoperator ( p , BitOr ); |
| 1865 | if (res == NULL && PyErr_Occurred()) { |
| 1866 | p->error_indicator = 1; |
| 1867 | return NULL; |
| 1868 | } |
| 1869 | goto done; |
| 1870 | } |
| 1871 | p->mark = mark; |
| 1872 | } |
| 1873 | { // '^=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1874 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1875 | if ( |
| 1876 | (literal = _PyPegen_expect_token(p, 43)) |
| 1877 | ) |
| 1878 | { |
| 1879 | res = _PyPegen_augoperator ( p , BitXor ); |
| 1880 | if (res == NULL && PyErr_Occurred()) { |
| 1881 | p->error_indicator = 1; |
| 1882 | return NULL; |
| 1883 | } |
| 1884 | goto done; |
| 1885 | } |
| 1886 | p->mark = mark; |
| 1887 | } |
| 1888 | { // '<<=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1889 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1890 | if ( |
| 1891 | (literal = _PyPegen_expect_token(p, 44)) |
| 1892 | ) |
| 1893 | { |
| 1894 | res = _PyPegen_augoperator ( p , LShift ); |
| 1895 | if (res == NULL && PyErr_Occurred()) { |
| 1896 | p->error_indicator = 1; |
| 1897 | return NULL; |
| 1898 | } |
| 1899 | goto done; |
| 1900 | } |
| 1901 | p->mark = mark; |
| 1902 | } |
| 1903 | { // '>>=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1904 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1905 | if ( |
| 1906 | (literal = _PyPegen_expect_token(p, 45)) |
| 1907 | ) |
| 1908 | { |
| 1909 | res = _PyPegen_augoperator ( p , RShift ); |
| 1910 | if (res == NULL && PyErr_Occurred()) { |
| 1911 | p->error_indicator = 1; |
| 1912 | return NULL; |
| 1913 | } |
| 1914 | goto done; |
| 1915 | } |
| 1916 | p->mark = mark; |
| 1917 | } |
| 1918 | { // '**=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1919 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1920 | if ( |
| 1921 | (literal = _PyPegen_expect_token(p, 46)) |
| 1922 | ) |
| 1923 | { |
| 1924 | res = _PyPegen_augoperator ( p , Pow ); |
| 1925 | if (res == NULL && PyErr_Occurred()) { |
| 1926 | p->error_indicator = 1; |
| 1927 | return NULL; |
| 1928 | } |
| 1929 | goto done; |
| 1930 | } |
| 1931 | p->mark = mark; |
| 1932 | } |
| 1933 | { // '//=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1934 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1935 | if ( |
| 1936 | (literal = _PyPegen_expect_token(p, 48)) |
| 1937 | ) |
| 1938 | { |
| 1939 | res = _PyPegen_augoperator ( p , FloorDiv ); |
| 1940 | if (res == NULL && PyErr_Occurred()) { |
| 1941 | p->error_indicator = 1; |
| 1942 | return NULL; |
| 1943 | } |
| 1944 | goto done; |
| 1945 | } |
| 1946 | p->mark = mark; |
| 1947 | } |
| 1948 | res = NULL; |
| 1949 | done: |
| 1950 | return res; |
| 1951 | } |
| 1952 | |
| 1953 | // global_stmt: 'global' ','.NAME+ |
| 1954 | static stmt_ty |
| 1955 | global_stmt_rule(Parser *p) |
| 1956 | { |
| 1957 | if (p->error_indicator) { |
| 1958 | return NULL; |
| 1959 | } |
| 1960 | stmt_ty res = NULL; |
| 1961 | int mark = p->mark; |
| 1962 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1963 | p->error_indicator = 1; |
| 1964 | return NULL; |
| 1965 | } |
| 1966 | int start_lineno = p->tokens[mark]->lineno; |
| 1967 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 1968 | int start_col_offset = p->tokens[mark]->col_offset; |
| 1969 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 1970 | { // 'global' ','.NAME+ |
| 1971 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1972 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1973 | if ( |
| 1974 | (keyword = _PyPegen_expect_token(p, 508)) |
| 1975 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1976 | (a = _gather_25_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1977 | ) |
| 1978 | { |
| 1979 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1980 | if (token == NULL) { |
| 1981 | return NULL; |
| 1982 | } |
| 1983 | int end_lineno = token->end_lineno; |
| 1984 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 1985 | int end_col_offset = token->end_col_offset; |
| 1986 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 1987 | res = _Py_Global ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
| 1988 | if (res == NULL && PyErr_Occurred()) { |
| 1989 | p->error_indicator = 1; |
| 1990 | return NULL; |
| 1991 | } |
| 1992 | goto done; |
| 1993 | } |
| 1994 | p->mark = mark; |
| 1995 | } |
| 1996 | res = NULL; |
| 1997 | done: |
| 1998 | return res; |
| 1999 | } |
| 2000 | |
| 2001 | // nonlocal_stmt: 'nonlocal' ','.NAME+ |
| 2002 | static stmt_ty |
| 2003 | nonlocal_stmt_rule(Parser *p) |
| 2004 | { |
| 2005 | if (p->error_indicator) { |
| 2006 | return NULL; |
| 2007 | } |
| 2008 | stmt_ty res = NULL; |
| 2009 | int mark = p->mark; |
| 2010 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2011 | p->error_indicator = 1; |
| 2012 | return NULL; |
| 2013 | } |
| 2014 | int start_lineno = p->tokens[mark]->lineno; |
| 2015 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2016 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2017 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2018 | { // 'nonlocal' ','.NAME+ |
| 2019 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2020 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2021 | if ( |
| 2022 | (keyword = _PyPegen_expect_token(p, 509)) |
| 2023 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2024 | (a = _gather_27_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2025 | ) |
| 2026 | { |
| 2027 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2028 | if (token == NULL) { |
| 2029 | return NULL; |
| 2030 | } |
| 2031 | int end_lineno = token->end_lineno; |
| 2032 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2033 | int end_col_offset = token->end_col_offset; |
| 2034 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2035 | res = _Py_Nonlocal ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
| 2036 | if (res == NULL && PyErr_Occurred()) { |
| 2037 | p->error_indicator = 1; |
| 2038 | return NULL; |
| 2039 | } |
| 2040 | goto done; |
| 2041 | } |
| 2042 | p->mark = mark; |
| 2043 | } |
| 2044 | res = NULL; |
| 2045 | done: |
| 2046 | return res; |
| 2047 | } |
| 2048 | |
| 2049 | // yield_stmt: yield_expr |
| 2050 | static stmt_ty |
| 2051 | yield_stmt_rule(Parser *p) |
| 2052 | { |
| 2053 | if (p->error_indicator) { |
| 2054 | return NULL; |
| 2055 | } |
| 2056 | stmt_ty res = NULL; |
| 2057 | int mark = p->mark; |
| 2058 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2059 | p->error_indicator = 1; |
| 2060 | return NULL; |
| 2061 | } |
| 2062 | int start_lineno = p->tokens[mark]->lineno; |
| 2063 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2064 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2065 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2066 | { // yield_expr |
| 2067 | expr_ty y; |
| 2068 | if ( |
| 2069 | (y = yield_expr_rule(p)) |
| 2070 | ) |
| 2071 | { |
| 2072 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2073 | if (token == NULL) { |
| 2074 | return NULL; |
| 2075 | } |
| 2076 | int end_lineno = token->end_lineno; |
| 2077 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2078 | int end_col_offset = token->end_col_offset; |
| 2079 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2080 | res = _Py_Expr ( y , EXTRA ); |
| 2081 | if (res == NULL && PyErr_Occurred()) { |
| 2082 | p->error_indicator = 1; |
| 2083 | return NULL; |
| 2084 | } |
| 2085 | goto done; |
| 2086 | } |
| 2087 | p->mark = mark; |
| 2088 | } |
| 2089 | res = NULL; |
| 2090 | done: |
| 2091 | return res; |
| 2092 | } |
| 2093 | |
| 2094 | // assert_stmt: 'assert' expression [',' expression] |
| 2095 | static stmt_ty |
| 2096 | assert_stmt_rule(Parser *p) |
| 2097 | { |
| 2098 | if (p->error_indicator) { |
| 2099 | return NULL; |
| 2100 | } |
| 2101 | stmt_ty res = NULL; |
| 2102 | int mark = p->mark; |
| 2103 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2104 | p->error_indicator = 1; |
| 2105 | return NULL; |
| 2106 | } |
| 2107 | int start_lineno = p->tokens[mark]->lineno; |
| 2108 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2109 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2110 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2111 | { // 'assert' expression [',' expression] |
| 2112 | expr_ty a; |
| 2113 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2114 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2115 | if ( |
| 2116 | (keyword = _PyPegen_expect_token(p, 505)) |
| 2117 | && |
| 2118 | (a = expression_rule(p)) |
| 2119 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2120 | (b = _tmp_29_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2121 | ) |
| 2122 | { |
| 2123 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2124 | if (token == NULL) { |
| 2125 | return NULL; |
| 2126 | } |
| 2127 | int end_lineno = token->end_lineno; |
| 2128 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2129 | int end_col_offset = token->end_col_offset; |
| 2130 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2131 | res = _Py_Assert ( a , b , EXTRA ); |
| 2132 | if (res == NULL && PyErr_Occurred()) { |
| 2133 | p->error_indicator = 1; |
| 2134 | return NULL; |
| 2135 | } |
| 2136 | goto done; |
| 2137 | } |
| 2138 | p->mark = mark; |
| 2139 | } |
| 2140 | res = NULL; |
| 2141 | done: |
| 2142 | return res; |
| 2143 | } |
| 2144 | |
| 2145 | // del_stmt: 'del' del_targets |
| 2146 | static stmt_ty |
| 2147 | del_stmt_rule(Parser *p) |
| 2148 | { |
| 2149 | if (p->error_indicator) { |
| 2150 | return NULL; |
| 2151 | } |
| 2152 | stmt_ty res = NULL; |
| 2153 | int mark = p->mark; |
| 2154 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2155 | p->error_indicator = 1; |
| 2156 | return NULL; |
| 2157 | } |
| 2158 | int start_lineno = p->tokens[mark]->lineno; |
| 2159 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2160 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2161 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2162 | { // 'del' del_targets |
| 2163 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2164 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2165 | if ( |
| 2166 | (keyword = _PyPegen_expect_token(p, 503)) |
| 2167 | && |
| 2168 | (a = del_targets_rule(p)) |
| 2169 | ) |
| 2170 | { |
| 2171 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2172 | if (token == NULL) { |
| 2173 | return NULL; |
| 2174 | } |
| 2175 | int end_lineno = token->end_lineno; |
| 2176 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2177 | int end_col_offset = token->end_col_offset; |
| 2178 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2179 | res = _Py_Delete ( a , EXTRA ); |
| 2180 | if (res == NULL && PyErr_Occurred()) { |
| 2181 | p->error_indicator = 1; |
| 2182 | return NULL; |
| 2183 | } |
| 2184 | goto done; |
| 2185 | } |
| 2186 | p->mark = mark; |
| 2187 | } |
| 2188 | res = NULL; |
| 2189 | done: |
| 2190 | return res; |
| 2191 | } |
| 2192 | |
| 2193 | // import_stmt: import_name | import_from |
| 2194 | static stmt_ty |
| 2195 | import_stmt_rule(Parser *p) |
| 2196 | { |
| 2197 | if (p->error_indicator) { |
| 2198 | return NULL; |
| 2199 | } |
| 2200 | stmt_ty res = NULL; |
| 2201 | int mark = p->mark; |
| 2202 | { // import_name |
| 2203 | stmt_ty import_name_var; |
| 2204 | if ( |
| 2205 | (import_name_var = import_name_rule(p)) |
| 2206 | ) |
| 2207 | { |
| 2208 | res = import_name_var; |
| 2209 | goto done; |
| 2210 | } |
| 2211 | p->mark = mark; |
| 2212 | } |
| 2213 | { // import_from |
| 2214 | stmt_ty import_from_var; |
| 2215 | if ( |
| 2216 | (import_from_var = import_from_rule(p)) |
| 2217 | ) |
| 2218 | { |
| 2219 | res = import_from_var; |
| 2220 | goto done; |
| 2221 | } |
| 2222 | p->mark = mark; |
| 2223 | } |
| 2224 | res = NULL; |
| 2225 | done: |
| 2226 | return res; |
| 2227 | } |
| 2228 | |
| 2229 | // import_name: 'import' dotted_as_names |
| 2230 | static stmt_ty |
| 2231 | import_name_rule(Parser *p) |
| 2232 | { |
| 2233 | if (p->error_indicator) { |
| 2234 | return NULL; |
| 2235 | } |
| 2236 | stmt_ty res = NULL; |
| 2237 | int mark = p->mark; |
| 2238 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2239 | p->error_indicator = 1; |
| 2240 | return NULL; |
| 2241 | } |
| 2242 | int start_lineno = p->tokens[mark]->lineno; |
| 2243 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2244 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2245 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2246 | { // 'import' dotted_as_names |
| 2247 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2248 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2249 | if ( |
| 2250 | (keyword = _PyPegen_expect_token(p, 513)) |
| 2251 | && |
| 2252 | (a = dotted_as_names_rule(p)) |
| 2253 | ) |
| 2254 | { |
| 2255 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2256 | if (token == NULL) { |
| 2257 | return NULL; |
| 2258 | } |
| 2259 | int end_lineno = token->end_lineno; |
| 2260 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2261 | int end_col_offset = token->end_col_offset; |
| 2262 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2263 | res = _Py_Import ( a , EXTRA ); |
| 2264 | if (res == NULL && PyErr_Occurred()) { |
| 2265 | p->error_indicator = 1; |
| 2266 | return NULL; |
| 2267 | } |
| 2268 | goto done; |
| 2269 | } |
| 2270 | p->mark = mark; |
| 2271 | } |
| 2272 | res = NULL; |
| 2273 | done: |
| 2274 | return res; |
| 2275 | } |
| 2276 | |
| 2277 | // import_from: |
| 2278 | // | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
| 2279 | // | 'from' (('.' | '...'))+ 'import' import_from_targets |
| 2280 | static stmt_ty |
| 2281 | import_from_rule(Parser *p) |
| 2282 | { |
| 2283 | if (p->error_indicator) { |
| 2284 | return NULL; |
| 2285 | } |
| 2286 | stmt_ty res = NULL; |
| 2287 | int mark = p->mark; |
| 2288 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2289 | p->error_indicator = 1; |
| 2290 | return NULL; |
| 2291 | } |
| 2292 | int start_lineno = p->tokens[mark]->lineno; |
| 2293 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2294 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2295 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2296 | { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
| 2297 | asdl_seq * a; |
| 2298 | expr_ty b; |
| 2299 | asdl_seq* c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2300 | Token * keyword; |
| 2301 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2302 | if ( |
| 2303 | (keyword = _PyPegen_expect_token(p, 514)) |
| 2304 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2305 | (a = _loop0_30_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2306 | && |
| 2307 | (b = dotted_name_rule(p)) |
| 2308 | && |
| 2309 | (keyword_1 = _PyPegen_expect_token(p, 513)) |
| 2310 | && |
| 2311 | (c = import_from_targets_rule(p)) |
| 2312 | ) |
| 2313 | { |
| 2314 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2315 | if (token == NULL) { |
| 2316 | return NULL; |
| 2317 | } |
| 2318 | int end_lineno = token->end_lineno; |
| 2319 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2320 | int end_col_offset = token->end_col_offset; |
| 2321 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2322 | res = _Py_ImportFrom ( b -> v . Name . id , c , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
| 2323 | if (res == NULL && PyErr_Occurred()) { |
| 2324 | p->error_indicator = 1; |
| 2325 | return NULL; |
| 2326 | } |
| 2327 | goto done; |
| 2328 | } |
| 2329 | p->mark = mark; |
| 2330 | } |
| 2331 | { // 'from' (('.' | '...'))+ 'import' import_from_targets |
| 2332 | asdl_seq * a; |
| 2333 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2334 | Token * keyword; |
| 2335 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2336 | if ( |
| 2337 | (keyword = _PyPegen_expect_token(p, 514)) |
| 2338 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2339 | (a = _loop1_31_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2340 | && |
| 2341 | (keyword_1 = _PyPegen_expect_token(p, 513)) |
| 2342 | && |
| 2343 | (b = import_from_targets_rule(p)) |
| 2344 | ) |
| 2345 | { |
| 2346 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2347 | if (token == NULL) { |
| 2348 | return NULL; |
| 2349 | } |
| 2350 | int end_lineno = token->end_lineno; |
| 2351 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2352 | int end_col_offset = token->end_col_offset; |
| 2353 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2354 | res = _Py_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
| 2355 | if (res == NULL && PyErr_Occurred()) { |
| 2356 | p->error_indicator = 1; |
| 2357 | return NULL; |
| 2358 | } |
| 2359 | goto done; |
| 2360 | } |
| 2361 | p->mark = mark; |
| 2362 | } |
| 2363 | res = NULL; |
| 2364 | done: |
| 2365 | return res; |
| 2366 | } |
| 2367 | |
| 2368 | // import_from_targets: '(' import_from_as_names ','? ')' | import_from_as_names | '*' |
| 2369 | static asdl_seq* |
| 2370 | import_from_targets_rule(Parser *p) |
| 2371 | { |
| 2372 | if (p->error_indicator) { |
| 2373 | return NULL; |
| 2374 | } |
| 2375 | asdl_seq* res = NULL; |
| 2376 | int mark = p->mark; |
| 2377 | { // '(' import_from_as_names ','? ')' |
| 2378 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2379 | Token * literal; |
| 2380 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2381 | void *opt_var; |
| 2382 | UNUSED(opt_var); // Silence compiler warnings |
| 2383 | if ( |
| 2384 | (literal = _PyPegen_expect_token(p, 7)) |
| 2385 | && |
| 2386 | (a = import_from_as_names_rule(p)) |
| 2387 | && |
| 2388 | (opt_var = _PyPegen_expect_token(p, 12), 1) |
| 2389 | && |
| 2390 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 2391 | ) |
| 2392 | { |
| 2393 | res = a; |
| 2394 | if (res == NULL && PyErr_Occurred()) { |
| 2395 | p->error_indicator = 1; |
| 2396 | return NULL; |
| 2397 | } |
| 2398 | goto done; |
| 2399 | } |
| 2400 | p->mark = mark; |
| 2401 | } |
| 2402 | { // import_from_as_names |
| 2403 | asdl_seq* import_from_as_names_var; |
| 2404 | if ( |
| 2405 | (import_from_as_names_var = import_from_as_names_rule(p)) |
| 2406 | ) |
| 2407 | { |
| 2408 | res = import_from_as_names_var; |
| 2409 | goto done; |
| 2410 | } |
| 2411 | p->mark = mark; |
| 2412 | } |
| 2413 | { // '*' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2414 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2415 | if ( |
| 2416 | (literal = _PyPegen_expect_token(p, 16)) |
| 2417 | ) |
| 2418 | { |
| 2419 | res = _PyPegen_singleton_seq ( p , CHECK ( _PyPegen_alias_for_star ( p ) ) ); |
| 2420 | if (res == NULL && PyErr_Occurred()) { |
| 2421 | p->error_indicator = 1; |
| 2422 | return NULL; |
| 2423 | } |
| 2424 | goto done; |
| 2425 | } |
| 2426 | p->mark = mark; |
| 2427 | } |
| 2428 | res = NULL; |
| 2429 | done: |
| 2430 | return res; |
| 2431 | } |
| 2432 | |
| 2433 | // import_from_as_names: ','.import_from_as_name+ |
| 2434 | static asdl_seq* |
| 2435 | import_from_as_names_rule(Parser *p) |
| 2436 | { |
| 2437 | if (p->error_indicator) { |
| 2438 | return NULL; |
| 2439 | } |
| 2440 | asdl_seq* res = NULL; |
| 2441 | int mark = p->mark; |
| 2442 | { // ','.import_from_as_name+ |
| 2443 | asdl_seq * a; |
| 2444 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2445 | (a = _gather_32_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2446 | ) |
| 2447 | { |
| 2448 | res = a; |
| 2449 | if (res == NULL && PyErr_Occurred()) { |
| 2450 | p->error_indicator = 1; |
| 2451 | return NULL; |
| 2452 | } |
| 2453 | goto done; |
| 2454 | } |
| 2455 | p->mark = mark; |
| 2456 | } |
| 2457 | res = NULL; |
| 2458 | done: |
| 2459 | return res; |
| 2460 | } |
| 2461 | |
| 2462 | // import_from_as_name: NAME ['as' NAME] |
| 2463 | static alias_ty |
| 2464 | import_from_as_name_rule(Parser *p) |
| 2465 | { |
| 2466 | if (p->error_indicator) { |
| 2467 | return NULL; |
| 2468 | } |
| 2469 | alias_ty res = NULL; |
| 2470 | int mark = p->mark; |
| 2471 | { // NAME ['as' NAME] |
| 2472 | expr_ty a; |
| 2473 | void *b; |
| 2474 | if ( |
| 2475 | (a = _PyPegen_name_token(p)) |
| 2476 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2477 | (b = _tmp_34_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2478 | ) |
| 2479 | { |
| 2480 | res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena ); |
| 2481 | if (res == NULL && PyErr_Occurred()) { |
| 2482 | p->error_indicator = 1; |
| 2483 | return NULL; |
| 2484 | } |
| 2485 | goto done; |
| 2486 | } |
| 2487 | p->mark = mark; |
| 2488 | } |
| 2489 | res = NULL; |
| 2490 | done: |
| 2491 | return res; |
| 2492 | } |
| 2493 | |
| 2494 | // dotted_as_names: ','.dotted_as_name+ |
| 2495 | static asdl_seq* |
| 2496 | dotted_as_names_rule(Parser *p) |
| 2497 | { |
| 2498 | if (p->error_indicator) { |
| 2499 | return NULL; |
| 2500 | } |
| 2501 | asdl_seq* res = NULL; |
| 2502 | int mark = p->mark; |
| 2503 | { // ','.dotted_as_name+ |
| 2504 | asdl_seq * a; |
| 2505 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2506 | (a = _gather_35_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2507 | ) |
| 2508 | { |
| 2509 | res = a; |
| 2510 | if (res == NULL && PyErr_Occurred()) { |
| 2511 | p->error_indicator = 1; |
| 2512 | return NULL; |
| 2513 | } |
| 2514 | goto done; |
| 2515 | } |
| 2516 | p->mark = mark; |
| 2517 | } |
| 2518 | res = NULL; |
| 2519 | done: |
| 2520 | return res; |
| 2521 | } |
| 2522 | |
| 2523 | // dotted_as_name: dotted_name ['as' NAME] |
| 2524 | static alias_ty |
| 2525 | dotted_as_name_rule(Parser *p) |
| 2526 | { |
| 2527 | if (p->error_indicator) { |
| 2528 | return NULL; |
| 2529 | } |
| 2530 | alias_ty res = NULL; |
| 2531 | int mark = p->mark; |
| 2532 | { // dotted_name ['as' NAME] |
| 2533 | expr_ty a; |
| 2534 | void *b; |
| 2535 | if ( |
| 2536 | (a = dotted_name_rule(p)) |
| 2537 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2538 | (b = _tmp_37_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2539 | ) |
| 2540 | { |
| 2541 | res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena ); |
| 2542 | if (res == NULL && PyErr_Occurred()) { |
| 2543 | p->error_indicator = 1; |
| 2544 | return NULL; |
| 2545 | } |
| 2546 | goto done; |
| 2547 | } |
| 2548 | p->mark = mark; |
| 2549 | } |
| 2550 | res = NULL; |
| 2551 | done: |
| 2552 | return res; |
| 2553 | } |
| 2554 | |
| 2555 | // Left-recursive |
| 2556 | // dotted_name: dotted_name '.' NAME | NAME |
| 2557 | static expr_ty dotted_name_raw(Parser *); |
| 2558 | static expr_ty |
| 2559 | dotted_name_rule(Parser *p) |
| 2560 | { |
| 2561 | expr_ty res = NULL; |
| 2562 | if (_PyPegen_is_memoized(p, dotted_name_type, &res)) |
| 2563 | return res; |
| 2564 | int mark = p->mark; |
| 2565 | int resmark = p->mark; |
| 2566 | while (1) { |
| 2567 | int tmpvar_0 = _PyPegen_update_memo(p, mark, dotted_name_type, res); |
| 2568 | if (tmpvar_0) { |
| 2569 | return res; |
| 2570 | } |
| 2571 | p->mark = mark; |
| 2572 | void *raw = dotted_name_raw(p); |
| 2573 | if (raw == NULL || p->mark <= resmark) |
| 2574 | break; |
| 2575 | resmark = p->mark; |
| 2576 | res = raw; |
| 2577 | } |
| 2578 | p->mark = resmark; |
| 2579 | return res; |
| 2580 | } |
| 2581 | static expr_ty |
| 2582 | dotted_name_raw(Parser *p) |
| 2583 | { |
| 2584 | if (p->error_indicator) { |
| 2585 | return NULL; |
| 2586 | } |
| 2587 | expr_ty res = NULL; |
| 2588 | int mark = p->mark; |
| 2589 | { // dotted_name '.' NAME |
| 2590 | expr_ty a; |
| 2591 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2592 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2593 | if ( |
| 2594 | (a = dotted_name_rule(p)) |
| 2595 | && |
| 2596 | (literal = _PyPegen_expect_token(p, 23)) |
| 2597 | && |
| 2598 | (b = _PyPegen_name_token(p)) |
| 2599 | ) |
| 2600 | { |
| 2601 | res = _PyPegen_join_names_with_dot ( p , a , b ); |
| 2602 | if (res == NULL && PyErr_Occurred()) { |
| 2603 | p->error_indicator = 1; |
| 2604 | return NULL; |
| 2605 | } |
| 2606 | goto done; |
| 2607 | } |
| 2608 | p->mark = mark; |
| 2609 | } |
| 2610 | { // NAME |
| 2611 | expr_ty name_var; |
| 2612 | if ( |
| 2613 | (name_var = _PyPegen_name_token(p)) |
| 2614 | ) |
| 2615 | { |
| 2616 | res = name_var; |
| 2617 | goto done; |
| 2618 | } |
| 2619 | p->mark = mark; |
| 2620 | } |
| 2621 | res = NULL; |
| 2622 | done: |
| 2623 | return res; |
| 2624 | } |
| 2625 | |
| 2626 | // if_stmt: |
| 2627 | // | 'if' named_expression ':' block elif_stmt |
| 2628 | // | 'if' named_expression ':' block else_block? |
| 2629 | static stmt_ty |
| 2630 | if_stmt_rule(Parser *p) |
| 2631 | { |
| 2632 | if (p->error_indicator) { |
| 2633 | return NULL; |
| 2634 | } |
| 2635 | stmt_ty res = NULL; |
| 2636 | int mark = p->mark; |
| 2637 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2638 | p->error_indicator = 1; |
| 2639 | return NULL; |
| 2640 | } |
| 2641 | int start_lineno = p->tokens[mark]->lineno; |
| 2642 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2643 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2644 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2645 | { // 'if' named_expression ':' block elif_stmt |
| 2646 | expr_ty a; |
| 2647 | asdl_seq* b; |
| 2648 | stmt_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2649 | Token * keyword; |
| 2650 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2651 | if ( |
| 2652 | (keyword = _PyPegen_expect_token(p, 510)) |
| 2653 | && |
| 2654 | (a = named_expression_rule(p)) |
| 2655 | && |
| 2656 | (literal = _PyPegen_expect_token(p, 11)) |
| 2657 | && |
| 2658 | (b = block_rule(p)) |
| 2659 | && |
| 2660 | (c = elif_stmt_rule(p)) |
| 2661 | ) |
| 2662 | { |
| 2663 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2664 | if (token == NULL) { |
| 2665 | return NULL; |
| 2666 | } |
| 2667 | int end_lineno = token->end_lineno; |
| 2668 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2669 | int end_col_offset = token->end_col_offset; |
| 2670 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2671 | res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
| 2672 | if (res == NULL && PyErr_Occurred()) { |
| 2673 | p->error_indicator = 1; |
| 2674 | return NULL; |
| 2675 | } |
| 2676 | goto done; |
| 2677 | } |
| 2678 | p->mark = mark; |
| 2679 | } |
| 2680 | { // 'if' named_expression ':' block else_block? |
| 2681 | expr_ty a; |
| 2682 | asdl_seq* b; |
| 2683 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2684 | Token * keyword; |
| 2685 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2686 | if ( |
| 2687 | (keyword = _PyPegen_expect_token(p, 510)) |
| 2688 | && |
| 2689 | (a = named_expression_rule(p)) |
| 2690 | && |
| 2691 | (literal = _PyPegen_expect_token(p, 11)) |
| 2692 | && |
| 2693 | (b = block_rule(p)) |
| 2694 | && |
| 2695 | (c = else_block_rule(p), 1) |
| 2696 | ) |
| 2697 | { |
| 2698 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2699 | if (token == NULL) { |
| 2700 | return NULL; |
| 2701 | } |
| 2702 | int end_lineno = token->end_lineno; |
| 2703 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2704 | int end_col_offset = token->end_col_offset; |
| 2705 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2706 | res = _Py_If ( a , b , c , EXTRA ); |
| 2707 | if (res == NULL && PyErr_Occurred()) { |
| 2708 | p->error_indicator = 1; |
| 2709 | return NULL; |
| 2710 | } |
| 2711 | goto done; |
| 2712 | } |
| 2713 | p->mark = mark; |
| 2714 | } |
| 2715 | res = NULL; |
| 2716 | done: |
| 2717 | return res; |
| 2718 | } |
| 2719 | |
| 2720 | // elif_stmt: |
| 2721 | // | 'elif' named_expression ':' block elif_stmt |
| 2722 | // | 'elif' named_expression ':' block else_block? |
| 2723 | static stmt_ty |
| 2724 | elif_stmt_rule(Parser *p) |
| 2725 | { |
| 2726 | if (p->error_indicator) { |
| 2727 | return NULL; |
| 2728 | } |
| 2729 | stmt_ty res = NULL; |
| 2730 | int mark = p->mark; |
| 2731 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2732 | p->error_indicator = 1; |
| 2733 | return NULL; |
| 2734 | } |
| 2735 | int start_lineno = p->tokens[mark]->lineno; |
| 2736 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2737 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2738 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2739 | { // 'elif' named_expression ':' block elif_stmt |
| 2740 | expr_ty a; |
| 2741 | asdl_seq* b; |
| 2742 | stmt_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2743 | Token * keyword; |
| 2744 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2745 | if ( |
| 2746 | (keyword = _PyPegen_expect_token(p, 515)) |
| 2747 | && |
| 2748 | (a = named_expression_rule(p)) |
| 2749 | && |
| 2750 | (literal = _PyPegen_expect_token(p, 11)) |
| 2751 | && |
| 2752 | (b = block_rule(p)) |
| 2753 | && |
| 2754 | (c = elif_stmt_rule(p)) |
| 2755 | ) |
| 2756 | { |
| 2757 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2758 | if (token == NULL) { |
| 2759 | return NULL; |
| 2760 | } |
| 2761 | int end_lineno = token->end_lineno; |
| 2762 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2763 | int end_col_offset = token->end_col_offset; |
| 2764 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2765 | res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
| 2766 | if (res == NULL && PyErr_Occurred()) { |
| 2767 | p->error_indicator = 1; |
| 2768 | return NULL; |
| 2769 | } |
| 2770 | goto done; |
| 2771 | } |
| 2772 | p->mark = mark; |
| 2773 | } |
| 2774 | { // 'elif' named_expression ':' block else_block? |
| 2775 | expr_ty a; |
| 2776 | asdl_seq* b; |
| 2777 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2778 | Token * keyword; |
| 2779 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2780 | if ( |
| 2781 | (keyword = _PyPegen_expect_token(p, 515)) |
| 2782 | && |
| 2783 | (a = named_expression_rule(p)) |
| 2784 | && |
| 2785 | (literal = _PyPegen_expect_token(p, 11)) |
| 2786 | && |
| 2787 | (b = block_rule(p)) |
| 2788 | && |
| 2789 | (c = else_block_rule(p), 1) |
| 2790 | ) |
| 2791 | { |
| 2792 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2793 | if (token == NULL) { |
| 2794 | return NULL; |
| 2795 | } |
| 2796 | int end_lineno = token->end_lineno; |
| 2797 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2798 | int end_col_offset = token->end_col_offset; |
| 2799 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2800 | res = _Py_If ( a , b , c , EXTRA ); |
| 2801 | if (res == NULL && PyErr_Occurred()) { |
| 2802 | p->error_indicator = 1; |
| 2803 | return NULL; |
| 2804 | } |
| 2805 | goto done; |
| 2806 | } |
| 2807 | p->mark = mark; |
| 2808 | } |
| 2809 | res = NULL; |
| 2810 | done: |
| 2811 | return res; |
| 2812 | } |
| 2813 | |
| 2814 | // else_block: 'else' ':' block |
| 2815 | static asdl_seq* |
| 2816 | else_block_rule(Parser *p) |
| 2817 | { |
| 2818 | if (p->error_indicator) { |
| 2819 | return NULL; |
| 2820 | } |
| 2821 | asdl_seq* res = NULL; |
| 2822 | int mark = p->mark; |
| 2823 | { // 'else' ':' block |
| 2824 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2825 | Token * keyword; |
| 2826 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2827 | if ( |
| 2828 | (keyword = _PyPegen_expect_token(p, 516)) |
| 2829 | && |
| 2830 | (literal = _PyPegen_expect_token(p, 11)) |
| 2831 | && |
| 2832 | (b = block_rule(p)) |
| 2833 | ) |
| 2834 | { |
| 2835 | res = b; |
| 2836 | if (res == NULL && PyErr_Occurred()) { |
| 2837 | p->error_indicator = 1; |
| 2838 | return NULL; |
| 2839 | } |
| 2840 | goto done; |
| 2841 | } |
| 2842 | p->mark = mark; |
| 2843 | } |
| 2844 | res = NULL; |
| 2845 | done: |
| 2846 | return res; |
| 2847 | } |
| 2848 | |
| 2849 | // while_stmt: 'while' named_expression ':' block else_block? |
| 2850 | static stmt_ty |
| 2851 | while_stmt_rule(Parser *p) |
| 2852 | { |
| 2853 | if (p->error_indicator) { |
| 2854 | return NULL; |
| 2855 | } |
| 2856 | stmt_ty res = NULL; |
| 2857 | int mark = p->mark; |
| 2858 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2859 | p->error_indicator = 1; |
| 2860 | return NULL; |
| 2861 | } |
| 2862 | int start_lineno = p->tokens[mark]->lineno; |
| 2863 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2864 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2865 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 2866 | { // 'while' named_expression ':' block else_block? |
| 2867 | expr_ty a; |
| 2868 | asdl_seq* b; |
| 2869 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2870 | Token * keyword; |
| 2871 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2872 | if ( |
| 2873 | (keyword = _PyPegen_expect_token(p, 512)) |
| 2874 | && |
| 2875 | (a = named_expression_rule(p)) |
| 2876 | && |
| 2877 | (literal = _PyPegen_expect_token(p, 11)) |
| 2878 | && |
| 2879 | (b = block_rule(p)) |
| 2880 | && |
| 2881 | (c = else_block_rule(p), 1) |
| 2882 | ) |
| 2883 | { |
| 2884 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2885 | if (token == NULL) { |
| 2886 | return NULL; |
| 2887 | } |
| 2888 | int end_lineno = token->end_lineno; |
| 2889 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2890 | int end_col_offset = token->end_col_offset; |
| 2891 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2892 | res = _Py_While ( a , b , c , EXTRA ); |
| 2893 | if (res == NULL && PyErr_Occurred()) { |
| 2894 | p->error_indicator = 1; |
| 2895 | return NULL; |
| 2896 | } |
| 2897 | goto done; |
| 2898 | } |
| 2899 | p->mark = mark; |
| 2900 | } |
| 2901 | res = NULL; |
| 2902 | done: |
| 2903 | return res; |
| 2904 | } |
| 2905 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2906 | // for_stmt: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2907 | // | 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
| 2908 | // | ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2909 | static stmt_ty |
| 2910 | for_stmt_rule(Parser *p) |
| 2911 | { |
| 2912 | if (p->error_indicator) { |
| 2913 | return NULL; |
| 2914 | } |
| 2915 | stmt_ty res = NULL; |
| 2916 | int mark = p->mark; |
| 2917 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2918 | p->error_indicator = 1; |
| 2919 | return NULL; |
| 2920 | } |
| 2921 | int start_lineno = p->tokens[mark]->lineno; |
| 2922 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 2923 | int start_col_offset = p->tokens[mark]->col_offset; |
| 2924 | UNUSED(start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2925 | { // 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2926 | asdl_seq* b; |
| 2927 | void *el; |
| 2928 | expr_ty ex; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2929 | Token * keyword; |
| 2930 | Token * keyword_1; |
| 2931 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2932 | expr_ty t; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2933 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2934 | if ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2935 | (keyword = _PyPegen_expect_token(p, 517)) |
| 2936 | && |
| 2937 | (t = star_targets_rule(p)) |
| 2938 | && |
| 2939 | (keyword_1 = _PyPegen_expect_token(p, 518)) |
| 2940 | && |
| 2941 | (ex = star_expressions_rule(p)) |
| 2942 | && |
| 2943 | (literal = _PyPegen_expect_token(p, 11)) |
| 2944 | && |
| 2945 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) |
| 2946 | && |
| 2947 | (b = block_rule(p)) |
| 2948 | && |
| 2949 | (el = else_block_rule(p), 1) |
| 2950 | ) |
| 2951 | { |
| 2952 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2953 | if (token == NULL) { |
| 2954 | return NULL; |
| 2955 | } |
| 2956 | int end_lineno = token->end_lineno; |
| 2957 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 2958 | int end_col_offset = token->end_col_offset; |
| 2959 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 2960 | res = _Py_For ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 2961 | if (res == NULL && PyErr_Occurred()) { |
| 2962 | p->error_indicator = 1; |
| 2963 | return NULL; |
| 2964 | } |
| 2965 | goto done; |
| 2966 | } |
| 2967 | p->mark = mark; |
| 2968 | } |
| 2969 | { // ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2970 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2971 | asdl_seq* b; |
| 2972 | void *el; |
| 2973 | expr_ty ex; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2974 | Token * keyword; |
| 2975 | Token * keyword_1; |
| 2976 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2977 | expr_ty t; |
| 2978 | void *tc; |
| 2979 | if ( |
| 2980 | (async_var = _PyPegen_expect_token(p, ASYNC)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2981 | && |
| 2982 | (keyword = _PyPegen_expect_token(p, 517)) |
| 2983 | && |
| 2984 | (t = star_targets_rule(p)) |
| 2985 | && |
| 2986 | (keyword_1 = _PyPegen_expect_token(p, 518)) |
| 2987 | && |
| 2988 | (ex = star_expressions_rule(p)) |
| 2989 | && |
| 2990 | (literal = _PyPegen_expect_token(p, 11)) |
| 2991 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2992 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) |
| 2993 | && |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2994 | (b = block_rule(p)) |
| 2995 | && |
| 2996 | (el = else_block_rule(p), 1) |
| 2997 | ) |
| 2998 | { |
| 2999 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3000 | if (token == NULL) { |
| 3001 | return NULL; |
| 3002 | } |
| 3003 | int end_lineno = token->end_lineno; |
| 3004 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3005 | int end_col_offset = token->end_col_offset; |
| 3006 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3007 | res = CHECK_VERSION ( 5 , "Async for loops are" , _Py_AsyncFor ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3008 | if (res == NULL && PyErr_Occurred()) { |
| 3009 | p->error_indicator = 1; |
| 3010 | return NULL; |
| 3011 | } |
| 3012 | goto done; |
| 3013 | } |
| 3014 | p->mark = mark; |
| 3015 | } |
| 3016 | res = NULL; |
| 3017 | done: |
| 3018 | return res; |
| 3019 | } |
| 3020 | |
| 3021 | // with_stmt: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3022 | // | 'with' '(' ','.with_item+ ')' ':' block |
| 3023 | // | 'with' ','.with_item+ ':' TYPE_COMMENT? block |
| 3024 | // | ASYNC 'with' '(' ','.with_item+ ')' ':' block |
| 3025 | // | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3026 | static stmt_ty |
| 3027 | with_stmt_rule(Parser *p) |
| 3028 | { |
| 3029 | if (p->error_indicator) { |
| 3030 | return NULL; |
| 3031 | } |
| 3032 | stmt_ty res = NULL; |
| 3033 | int mark = p->mark; |
| 3034 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3035 | p->error_indicator = 1; |
| 3036 | return NULL; |
| 3037 | } |
| 3038 | int start_lineno = p->tokens[mark]->lineno; |
| 3039 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3040 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3041 | UNUSED(start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3042 | { // 'with' '(' ','.with_item+ ')' ':' block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3043 | asdl_seq * a; |
| 3044 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3045 | Token * keyword; |
| 3046 | Token * literal; |
| 3047 | Token * literal_1; |
| 3048 | Token * literal_2; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3049 | if ( |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3050 | (keyword = _PyPegen_expect_token(p, 519)) |
| 3051 | && |
| 3052 | (literal = _PyPegen_expect_token(p, 7)) |
| 3053 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3054 | (a = _gather_38_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3055 | && |
| 3056 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 3057 | && |
| 3058 | (literal_2 = _PyPegen_expect_token(p, 11)) |
| 3059 | && |
| 3060 | (b = block_rule(p)) |
| 3061 | ) |
| 3062 | { |
| 3063 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3064 | if (token == NULL) { |
| 3065 | return NULL; |
| 3066 | } |
| 3067 | int end_lineno = token->end_lineno; |
| 3068 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3069 | int end_col_offset = token->end_col_offset; |
| 3070 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3071 | res = _Py_With ( a , b , NULL , EXTRA ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3072 | if (res == NULL && PyErr_Occurred()) { |
| 3073 | p->error_indicator = 1; |
| 3074 | return NULL; |
| 3075 | } |
| 3076 | goto done; |
| 3077 | } |
| 3078 | p->mark = mark; |
| 3079 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3080 | { // 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3081 | asdl_seq * a; |
| 3082 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3083 | Token * keyword; |
| 3084 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3085 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3086 | if ( |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3087 | (keyword = _PyPegen_expect_token(p, 519)) |
| 3088 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3089 | (a = _gather_40_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3090 | && |
| 3091 | (literal = _PyPegen_expect_token(p, 11)) |
| 3092 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3093 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) |
| 3094 | && |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3095 | (b = block_rule(p)) |
| 3096 | ) |
| 3097 | { |
| 3098 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3099 | if (token == NULL) { |
| 3100 | return NULL; |
| 3101 | } |
| 3102 | int end_lineno = token->end_lineno; |
| 3103 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3104 | int end_col_offset = token->end_col_offset; |
| 3105 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3106 | res = _Py_With ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 3107 | if (res == NULL && PyErr_Occurred()) { |
| 3108 | p->error_indicator = 1; |
| 3109 | return NULL; |
| 3110 | } |
| 3111 | goto done; |
| 3112 | } |
| 3113 | p->mark = mark; |
| 3114 | } |
| 3115 | { // ASYNC 'with' '(' ','.with_item+ ')' ':' block |
| 3116 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3117 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3118 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3119 | Token * keyword; |
| 3120 | Token * literal; |
| 3121 | Token * literal_1; |
| 3122 | Token * literal_2; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3123 | if ( |
| 3124 | (async_var = _PyPegen_expect_token(p, ASYNC)) |
| 3125 | && |
| 3126 | (keyword = _PyPegen_expect_token(p, 519)) |
| 3127 | && |
| 3128 | (literal = _PyPegen_expect_token(p, 7)) |
| 3129 | && |
| 3130 | (a = _gather_42_rule(p)) |
| 3131 | && |
| 3132 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 3133 | && |
| 3134 | (literal_2 = _PyPegen_expect_token(p, 11)) |
| 3135 | && |
| 3136 | (b = block_rule(p)) |
| 3137 | ) |
| 3138 | { |
| 3139 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3140 | if (token == NULL) { |
| 3141 | return NULL; |
| 3142 | } |
| 3143 | int end_lineno = token->end_lineno; |
| 3144 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3145 | int end_col_offset = token->end_col_offset; |
| 3146 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3147 | res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NULL , EXTRA ) ); |
| 3148 | if (res == NULL && PyErr_Occurred()) { |
| 3149 | p->error_indicator = 1; |
| 3150 | return NULL; |
| 3151 | } |
| 3152 | goto done; |
| 3153 | } |
| 3154 | p->mark = mark; |
| 3155 | } |
| 3156 | { // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
| 3157 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3158 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3159 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3160 | Token * keyword; |
| 3161 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3162 | void *tc; |
| 3163 | if ( |
| 3164 | (async_var = _PyPegen_expect_token(p, ASYNC)) |
| 3165 | && |
| 3166 | (keyword = _PyPegen_expect_token(p, 519)) |
| 3167 | && |
| 3168 | (a = _gather_44_rule(p)) |
| 3169 | && |
| 3170 | (literal = _PyPegen_expect_token(p, 11)) |
| 3171 | && |
| 3172 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) |
| 3173 | && |
| 3174 | (b = block_rule(p)) |
| 3175 | ) |
| 3176 | { |
| 3177 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3178 | if (token == NULL) { |
| 3179 | return NULL; |
| 3180 | } |
| 3181 | int end_lineno = token->end_lineno; |
| 3182 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3183 | int end_col_offset = token->end_col_offset; |
| 3184 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3185 | res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3186 | if (res == NULL && PyErr_Occurred()) { |
| 3187 | p->error_indicator = 1; |
| 3188 | return NULL; |
| 3189 | } |
| 3190 | goto done; |
| 3191 | } |
| 3192 | p->mark = mark; |
| 3193 | } |
| 3194 | res = NULL; |
| 3195 | done: |
| 3196 | return res; |
| 3197 | } |
| 3198 | |
| 3199 | // with_item: expression ['as' target] |
| 3200 | static withitem_ty |
| 3201 | with_item_rule(Parser *p) |
| 3202 | { |
| 3203 | if (p->error_indicator) { |
| 3204 | return NULL; |
| 3205 | } |
| 3206 | withitem_ty res = NULL; |
| 3207 | int mark = p->mark; |
| 3208 | { // expression ['as' target] |
| 3209 | expr_ty e; |
| 3210 | void *o; |
| 3211 | if ( |
| 3212 | (e = expression_rule(p)) |
| 3213 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3214 | (o = _tmp_46_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3215 | ) |
| 3216 | { |
| 3217 | res = _Py_withitem ( e , o , p -> arena ); |
| 3218 | if (res == NULL && PyErr_Occurred()) { |
| 3219 | p->error_indicator = 1; |
| 3220 | return NULL; |
| 3221 | } |
| 3222 | goto done; |
| 3223 | } |
| 3224 | p->mark = mark; |
| 3225 | } |
| 3226 | res = NULL; |
| 3227 | done: |
| 3228 | return res; |
| 3229 | } |
| 3230 | |
| 3231 | // try_stmt: |
| 3232 | // | 'try' ':' block finally_block |
| 3233 | // | 'try' ':' block except_block+ else_block? finally_block? |
| 3234 | static stmt_ty |
| 3235 | try_stmt_rule(Parser *p) |
| 3236 | { |
| 3237 | if (p->error_indicator) { |
| 3238 | return NULL; |
| 3239 | } |
| 3240 | stmt_ty res = NULL; |
| 3241 | int mark = p->mark; |
| 3242 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3243 | p->error_indicator = 1; |
| 3244 | return NULL; |
| 3245 | } |
| 3246 | int start_lineno = p->tokens[mark]->lineno; |
| 3247 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3248 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3249 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 3250 | { // 'try' ':' block finally_block |
| 3251 | asdl_seq* b; |
| 3252 | asdl_seq* f; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3253 | Token * keyword; |
| 3254 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3255 | if ( |
| 3256 | (keyword = _PyPegen_expect_token(p, 511)) |
| 3257 | && |
| 3258 | (literal = _PyPegen_expect_token(p, 11)) |
| 3259 | && |
| 3260 | (b = block_rule(p)) |
| 3261 | && |
| 3262 | (f = finally_block_rule(p)) |
| 3263 | ) |
| 3264 | { |
| 3265 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3266 | if (token == NULL) { |
| 3267 | return NULL; |
| 3268 | } |
| 3269 | int end_lineno = token->end_lineno; |
| 3270 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3271 | int end_col_offset = token->end_col_offset; |
| 3272 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3273 | res = _Py_Try ( b , NULL , NULL , f , EXTRA ); |
| 3274 | if (res == NULL && PyErr_Occurred()) { |
| 3275 | p->error_indicator = 1; |
| 3276 | return NULL; |
| 3277 | } |
| 3278 | goto done; |
| 3279 | } |
| 3280 | p->mark = mark; |
| 3281 | } |
| 3282 | { // 'try' ':' block except_block+ else_block? finally_block? |
| 3283 | asdl_seq* b; |
| 3284 | void *el; |
| 3285 | asdl_seq * ex; |
| 3286 | void *f; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3287 | Token * keyword; |
| 3288 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3289 | if ( |
| 3290 | (keyword = _PyPegen_expect_token(p, 511)) |
| 3291 | && |
| 3292 | (literal = _PyPegen_expect_token(p, 11)) |
| 3293 | && |
| 3294 | (b = block_rule(p)) |
| 3295 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3296 | (ex = _loop1_47_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3297 | && |
| 3298 | (el = else_block_rule(p), 1) |
| 3299 | && |
| 3300 | (f = finally_block_rule(p), 1) |
| 3301 | ) |
| 3302 | { |
| 3303 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3304 | if (token == NULL) { |
| 3305 | return NULL; |
| 3306 | } |
| 3307 | int end_lineno = token->end_lineno; |
| 3308 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3309 | int end_col_offset = token->end_col_offset; |
| 3310 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3311 | res = _Py_Try ( b , ex , el , f , EXTRA ); |
| 3312 | if (res == NULL && PyErr_Occurred()) { |
| 3313 | p->error_indicator = 1; |
| 3314 | return NULL; |
| 3315 | } |
| 3316 | goto done; |
| 3317 | } |
| 3318 | p->mark = mark; |
| 3319 | } |
| 3320 | res = NULL; |
| 3321 | done: |
| 3322 | return res; |
| 3323 | } |
| 3324 | |
| 3325 | // except_block: 'except' expression ['as' target] ':' block | 'except' ':' block |
| 3326 | static excepthandler_ty |
| 3327 | except_block_rule(Parser *p) |
| 3328 | { |
| 3329 | if (p->error_indicator) { |
| 3330 | return NULL; |
| 3331 | } |
| 3332 | excepthandler_ty res = NULL; |
| 3333 | int mark = p->mark; |
| 3334 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3335 | p->error_indicator = 1; |
| 3336 | return NULL; |
| 3337 | } |
| 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 |
| 3342 | { // 'except' expression ['as' target] ':' block |
| 3343 | asdl_seq* b; |
| 3344 | expr_ty e; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3345 | Token * keyword; |
| 3346 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3347 | void *t; |
| 3348 | if ( |
| 3349 | (keyword = _PyPegen_expect_token(p, 520)) |
| 3350 | && |
| 3351 | (e = expression_rule(p)) |
| 3352 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3353 | (t = _tmp_48_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3354 | && |
| 3355 | (literal = _PyPegen_expect_token(p, 11)) |
| 3356 | && |
| 3357 | (b = block_rule(p)) |
| 3358 | ) |
| 3359 | { |
| 3360 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3361 | if (token == NULL) { |
| 3362 | return NULL; |
| 3363 | } |
| 3364 | int end_lineno = token->end_lineno; |
| 3365 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3366 | int end_col_offset = token->end_col_offset; |
| 3367 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3368 | res = _Py_ExceptHandler ( e , ( t ) ? ( ( expr_ty ) t ) -> v . Name . id : NULL , b , EXTRA ); |
| 3369 | if (res == NULL && PyErr_Occurred()) { |
| 3370 | p->error_indicator = 1; |
| 3371 | return NULL; |
| 3372 | } |
| 3373 | goto done; |
| 3374 | } |
| 3375 | p->mark = mark; |
| 3376 | } |
| 3377 | { // 'except' ':' block |
| 3378 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3379 | Token * keyword; |
| 3380 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3381 | if ( |
| 3382 | (keyword = _PyPegen_expect_token(p, 520)) |
| 3383 | && |
| 3384 | (literal = _PyPegen_expect_token(p, 11)) |
| 3385 | && |
| 3386 | (b = block_rule(p)) |
| 3387 | ) |
| 3388 | { |
| 3389 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3390 | if (token == NULL) { |
| 3391 | return NULL; |
| 3392 | } |
| 3393 | int end_lineno = token->end_lineno; |
| 3394 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3395 | int end_col_offset = token->end_col_offset; |
| 3396 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3397 | res = _Py_ExceptHandler ( NULL , NULL , b , EXTRA ); |
| 3398 | if (res == NULL && PyErr_Occurred()) { |
| 3399 | p->error_indicator = 1; |
| 3400 | return NULL; |
| 3401 | } |
| 3402 | goto done; |
| 3403 | } |
| 3404 | p->mark = mark; |
| 3405 | } |
| 3406 | res = NULL; |
| 3407 | done: |
| 3408 | return res; |
| 3409 | } |
| 3410 | |
| 3411 | // finally_block: 'finally' ':' block |
| 3412 | static asdl_seq* |
| 3413 | finally_block_rule(Parser *p) |
| 3414 | { |
| 3415 | if (p->error_indicator) { |
| 3416 | return NULL; |
| 3417 | } |
| 3418 | asdl_seq* res = NULL; |
| 3419 | int mark = p->mark; |
| 3420 | { // 'finally' ':' block |
| 3421 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3422 | Token * keyword; |
| 3423 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3424 | if ( |
| 3425 | (keyword = _PyPegen_expect_token(p, 521)) |
| 3426 | && |
| 3427 | (literal = _PyPegen_expect_token(p, 11)) |
| 3428 | && |
| 3429 | (a = block_rule(p)) |
| 3430 | ) |
| 3431 | { |
| 3432 | res = a; |
| 3433 | if (res == NULL && PyErr_Occurred()) { |
| 3434 | p->error_indicator = 1; |
| 3435 | return NULL; |
| 3436 | } |
| 3437 | goto done; |
| 3438 | } |
| 3439 | p->mark = mark; |
| 3440 | } |
| 3441 | res = NULL; |
| 3442 | done: |
| 3443 | return res; |
| 3444 | } |
| 3445 | |
| 3446 | // return_stmt: 'return' star_expressions? |
| 3447 | static stmt_ty |
| 3448 | return_stmt_rule(Parser *p) |
| 3449 | { |
| 3450 | if (p->error_indicator) { |
| 3451 | return NULL; |
| 3452 | } |
| 3453 | stmt_ty res = NULL; |
| 3454 | int mark = p->mark; |
| 3455 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3456 | p->error_indicator = 1; |
| 3457 | return NULL; |
| 3458 | } |
| 3459 | int start_lineno = p->tokens[mark]->lineno; |
| 3460 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3461 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3462 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 3463 | { // 'return' star_expressions? |
| 3464 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3465 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3466 | if ( |
| 3467 | (keyword = _PyPegen_expect_token(p, 500)) |
| 3468 | && |
| 3469 | (a = star_expressions_rule(p), 1) |
| 3470 | ) |
| 3471 | { |
| 3472 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3473 | if (token == NULL) { |
| 3474 | return NULL; |
| 3475 | } |
| 3476 | int end_lineno = token->end_lineno; |
| 3477 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3478 | int end_col_offset = token->end_col_offset; |
| 3479 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3480 | res = _Py_Return ( a , EXTRA ); |
| 3481 | if (res == NULL && PyErr_Occurred()) { |
| 3482 | p->error_indicator = 1; |
| 3483 | return NULL; |
| 3484 | } |
| 3485 | goto done; |
| 3486 | } |
| 3487 | p->mark = mark; |
| 3488 | } |
| 3489 | res = NULL; |
| 3490 | done: |
| 3491 | return res; |
| 3492 | } |
| 3493 | |
| 3494 | // raise_stmt: 'raise' expression ['from' expression] | 'raise' |
| 3495 | static stmt_ty |
| 3496 | raise_stmt_rule(Parser *p) |
| 3497 | { |
| 3498 | if (p->error_indicator) { |
| 3499 | return NULL; |
| 3500 | } |
| 3501 | stmt_ty res = NULL; |
| 3502 | int mark = p->mark; |
| 3503 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3504 | p->error_indicator = 1; |
| 3505 | return NULL; |
| 3506 | } |
| 3507 | int start_lineno = p->tokens[mark]->lineno; |
| 3508 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3509 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3510 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 3511 | { // 'raise' expression ['from' expression] |
| 3512 | expr_ty a; |
| 3513 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3514 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3515 | if ( |
| 3516 | (keyword = _PyPegen_expect_token(p, 501)) |
| 3517 | && |
| 3518 | (a = expression_rule(p)) |
| 3519 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3520 | (b = _tmp_49_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3521 | ) |
| 3522 | { |
| 3523 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3524 | if (token == NULL) { |
| 3525 | return NULL; |
| 3526 | } |
| 3527 | int end_lineno = token->end_lineno; |
| 3528 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3529 | int end_col_offset = token->end_col_offset; |
| 3530 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3531 | res = _Py_Raise ( a , b , EXTRA ); |
| 3532 | if (res == NULL && PyErr_Occurred()) { |
| 3533 | p->error_indicator = 1; |
| 3534 | return NULL; |
| 3535 | } |
| 3536 | goto done; |
| 3537 | } |
| 3538 | p->mark = mark; |
| 3539 | } |
| 3540 | { // 'raise' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3541 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3542 | if ( |
| 3543 | (keyword = _PyPegen_expect_token(p, 501)) |
| 3544 | ) |
| 3545 | { |
| 3546 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3547 | if (token == NULL) { |
| 3548 | return NULL; |
| 3549 | } |
| 3550 | int end_lineno = token->end_lineno; |
| 3551 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3552 | int end_col_offset = token->end_col_offset; |
| 3553 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3554 | res = _Py_Raise ( NULL , NULL , EXTRA ); |
| 3555 | if (res == NULL && PyErr_Occurred()) { |
| 3556 | p->error_indicator = 1; |
| 3557 | return NULL; |
| 3558 | } |
| 3559 | goto done; |
| 3560 | } |
| 3561 | p->mark = mark; |
| 3562 | } |
| 3563 | res = NULL; |
| 3564 | done: |
| 3565 | return res; |
| 3566 | } |
| 3567 | |
| 3568 | // function_def: decorators function_def_raw | function_def_raw |
| 3569 | static stmt_ty |
| 3570 | function_def_rule(Parser *p) |
| 3571 | { |
| 3572 | if (p->error_indicator) { |
| 3573 | return NULL; |
| 3574 | } |
| 3575 | stmt_ty res = NULL; |
| 3576 | int mark = p->mark; |
| 3577 | { // decorators function_def_raw |
| 3578 | asdl_seq* d; |
| 3579 | stmt_ty f; |
| 3580 | if ( |
| 3581 | (d = decorators_rule(p)) |
| 3582 | && |
| 3583 | (f = function_def_raw_rule(p)) |
| 3584 | ) |
| 3585 | { |
| 3586 | res = _PyPegen_function_def_decorators ( p , d , f ); |
| 3587 | if (res == NULL && PyErr_Occurred()) { |
| 3588 | p->error_indicator = 1; |
| 3589 | return NULL; |
| 3590 | } |
| 3591 | goto done; |
| 3592 | } |
| 3593 | p->mark = mark; |
| 3594 | } |
| 3595 | { // function_def_raw |
| 3596 | stmt_ty function_def_raw_var; |
| 3597 | if ( |
| 3598 | (function_def_raw_var = function_def_raw_rule(p)) |
| 3599 | ) |
| 3600 | { |
| 3601 | res = function_def_raw_var; |
| 3602 | goto done; |
| 3603 | } |
| 3604 | p->mark = mark; |
| 3605 | } |
| 3606 | res = NULL; |
| 3607 | done: |
| 3608 | return res; |
| 3609 | } |
| 3610 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3611 | // function_def_raw: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3612 | // | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
| 3613 | // | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3614 | static stmt_ty |
| 3615 | function_def_raw_rule(Parser *p) |
| 3616 | { |
| 3617 | if (p->error_indicator) { |
| 3618 | return NULL; |
| 3619 | } |
| 3620 | stmt_ty res = NULL; |
| 3621 | int mark = p->mark; |
| 3622 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3623 | p->error_indicator = 1; |
| 3624 | return NULL; |
| 3625 | } |
| 3626 | int start_lineno = p->tokens[mark]->lineno; |
| 3627 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 3628 | int start_col_offset = p->tokens[mark]->col_offset; |
| 3629 | UNUSED(start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3630 | { // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3631 | void *a; |
| 3632 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3633 | Token * keyword; |
| 3634 | Token * literal; |
| 3635 | Token * literal_1; |
| 3636 | Token * literal_2; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3637 | expr_ty n; |
| 3638 | void *params; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3639 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3640 | if ( |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3641 | (keyword = _PyPegen_expect_token(p, 522)) |
| 3642 | && |
| 3643 | (n = _PyPegen_name_token(p)) |
| 3644 | && |
| 3645 | (literal = _PyPegen_expect_token(p, 7)) |
| 3646 | && |
| 3647 | (params = params_rule(p), 1) |
| 3648 | && |
| 3649 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 3650 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3651 | (a = _tmp_50_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3652 | && |
| 3653 | (literal_2 = _PyPegen_expect_token(p, 11)) |
| 3654 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3655 | (tc = func_type_comment_rule(p), 1) |
| 3656 | && |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3657 | (b = block_rule(p)) |
| 3658 | ) |
| 3659 | { |
| 3660 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3661 | if (token == NULL) { |
| 3662 | return NULL; |
| 3663 | } |
| 3664 | int end_lineno = token->end_lineno; |
| 3665 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3666 | int end_col_offset = token->end_col_offset; |
| 3667 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3668 | res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 3669 | if (res == NULL && PyErr_Occurred()) { |
| 3670 | p->error_indicator = 1; |
| 3671 | return NULL; |
| 3672 | } |
| 3673 | goto done; |
| 3674 | } |
| 3675 | p->mark = mark; |
| 3676 | } |
| 3677 | { // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
| 3678 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3679 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3680 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3681 | Token * keyword; |
| 3682 | Token * literal; |
| 3683 | Token * literal_1; |
| 3684 | Token * literal_2; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3685 | expr_ty n; |
| 3686 | void *params; |
| 3687 | void *tc; |
| 3688 | if ( |
| 3689 | (async_var = _PyPegen_expect_token(p, ASYNC)) |
| 3690 | && |
| 3691 | (keyword = _PyPegen_expect_token(p, 522)) |
| 3692 | && |
| 3693 | (n = _PyPegen_name_token(p)) |
| 3694 | && |
| 3695 | (literal = _PyPegen_expect_token(p, 7)) |
| 3696 | && |
| 3697 | (params = params_rule(p), 1) |
| 3698 | && |
| 3699 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 3700 | && |
| 3701 | (a = _tmp_51_rule(p), 1) |
| 3702 | && |
| 3703 | (literal_2 = _PyPegen_expect_token(p, 11)) |
| 3704 | && |
| 3705 | (tc = func_type_comment_rule(p), 1) |
| 3706 | && |
| 3707 | (b = block_rule(p)) |
| 3708 | ) |
| 3709 | { |
| 3710 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3711 | if (token == NULL) { |
| 3712 | return NULL; |
| 3713 | } |
| 3714 | int end_lineno = token->end_lineno; |
| 3715 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 3716 | int end_col_offset = token->end_col_offset; |
| 3717 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 3718 | 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 ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3719 | if (res == NULL && PyErr_Occurred()) { |
| 3720 | p->error_indicator = 1; |
| 3721 | return NULL; |
| 3722 | } |
| 3723 | goto done; |
| 3724 | } |
| 3725 | p->mark = mark; |
| 3726 | } |
| 3727 | res = NULL; |
| 3728 | done: |
| 3729 | return res; |
| 3730 | } |
| 3731 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3732 | // func_type_comment: |
| 3733 | // | NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
| 3734 | // | invalid_double_type_comments |
| 3735 | // | TYPE_COMMENT |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 3736 | static Token* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3737 | func_type_comment_rule(Parser *p) |
| 3738 | { |
| 3739 | if (p->error_indicator) { |
| 3740 | return NULL; |
| 3741 | } |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 3742 | Token* res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3743 | int mark = p->mark; |
| 3744 | { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3745 | Token * newline_var; |
| 3746 | Token * t; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3747 | if ( |
| 3748 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) |
| 3749 | && |
| 3750 | (t = _PyPegen_expect_token(p, TYPE_COMMENT)) |
| 3751 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3752 | _PyPegen_lookahead(1, _tmp_52_rule, p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3753 | ) |
| 3754 | { |
| 3755 | res = t; |
| 3756 | if (res == NULL && PyErr_Occurred()) { |
| 3757 | p->error_indicator = 1; |
| 3758 | return NULL; |
| 3759 | } |
| 3760 | goto done; |
| 3761 | } |
| 3762 | p->mark = mark; |
| 3763 | } |
| 3764 | { // invalid_double_type_comments |
| 3765 | void *invalid_double_type_comments_var; |
| 3766 | if ( |
| 3767 | (invalid_double_type_comments_var = invalid_double_type_comments_rule(p)) |
| 3768 | ) |
| 3769 | { |
| 3770 | res = invalid_double_type_comments_var; |
| 3771 | goto done; |
| 3772 | } |
| 3773 | p->mark = mark; |
| 3774 | } |
| 3775 | { // TYPE_COMMENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3776 | Token * type_comment_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3777 | if ( |
| 3778 | (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) |
| 3779 | ) |
| 3780 | { |
| 3781 | res = type_comment_var; |
| 3782 | goto done; |
| 3783 | } |
| 3784 | p->mark = mark; |
| 3785 | } |
| 3786 | res = NULL; |
| 3787 | done: |
| 3788 | return res; |
| 3789 | } |
| 3790 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3791 | // params: invalid_parameters | parameters |
| 3792 | static arguments_ty |
| 3793 | params_rule(Parser *p) |
| 3794 | { |
| 3795 | if (p->error_indicator) { |
| 3796 | return NULL; |
| 3797 | } |
| 3798 | arguments_ty res = NULL; |
| 3799 | int mark = p->mark; |
| 3800 | { // invalid_parameters |
| 3801 | void *invalid_parameters_var; |
| 3802 | if ( |
| 3803 | (invalid_parameters_var = invalid_parameters_rule(p)) |
| 3804 | ) |
| 3805 | { |
| 3806 | res = invalid_parameters_var; |
| 3807 | goto done; |
| 3808 | } |
| 3809 | p->mark = mark; |
| 3810 | } |
| 3811 | { // parameters |
| 3812 | arguments_ty parameters_var; |
| 3813 | if ( |
| 3814 | (parameters_var = parameters_rule(p)) |
| 3815 | ) |
| 3816 | { |
| 3817 | res = parameters_var; |
| 3818 | goto done; |
| 3819 | } |
| 3820 | p->mark = mark; |
| 3821 | } |
| 3822 | res = NULL; |
| 3823 | done: |
| 3824 | return res; |
| 3825 | } |
| 3826 | |
| 3827 | // parameters: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3828 | // | slash_no_default param_no_default* param_with_default* star_etc? |
| 3829 | // | slash_with_default param_with_default* star_etc? |
| 3830 | // | param_no_default+ param_with_default* star_etc? |
| 3831 | // | param_with_default+ star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3832 | // | star_etc |
| 3833 | static arguments_ty |
| 3834 | parameters_rule(Parser *p) |
| 3835 | { |
| 3836 | if (p->error_indicator) { |
| 3837 | return NULL; |
| 3838 | } |
| 3839 | arguments_ty res = NULL; |
| 3840 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3841 | { // slash_no_default param_no_default* param_with_default* star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3842 | asdl_seq* a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3843 | asdl_seq * b; |
| 3844 | asdl_seq * c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3845 | void *d; |
| 3846 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3847 | (a = slash_no_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3848 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3849 | (b = _loop0_53_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3850 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3851 | (c = _loop0_54_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3852 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3853 | (d = star_etc_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3854 | ) |
| 3855 | { |
| 3856 | res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 3857 | if (res == NULL && PyErr_Occurred()) { |
| 3858 | p->error_indicator = 1; |
| 3859 | return NULL; |
| 3860 | } |
| 3861 | goto done; |
| 3862 | } |
| 3863 | p->mark = mark; |
| 3864 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3865 | { // slash_with_default param_with_default* star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3866 | SlashWithDefault* a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3867 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3868 | void *c; |
| 3869 | if ( |
| 3870 | (a = slash_with_default_rule(p)) |
| 3871 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3872 | (b = _loop0_55_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3873 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3874 | (c = star_etc_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3875 | ) |
| 3876 | { |
| 3877 | res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 3878 | if (res == NULL && PyErr_Occurred()) { |
| 3879 | p->error_indicator = 1; |
| 3880 | return NULL; |
| 3881 | } |
| 3882 | goto done; |
| 3883 | } |
| 3884 | p->mark = mark; |
| 3885 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3886 | { // param_no_default+ param_with_default* star_etc? |
| 3887 | asdl_seq * a; |
| 3888 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3889 | void *c; |
| 3890 | if ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3891 | (a = _loop1_56_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3892 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3893 | (b = _loop0_57_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3894 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3895 | (c = star_etc_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3896 | ) |
| 3897 | { |
| 3898 | res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 3899 | if (res == NULL && PyErr_Occurred()) { |
| 3900 | p->error_indicator = 1; |
| 3901 | return NULL; |
| 3902 | } |
| 3903 | goto done; |
| 3904 | } |
| 3905 | p->mark = mark; |
| 3906 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3907 | { // param_with_default+ star_etc? |
| 3908 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3909 | void *b; |
| 3910 | if ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3911 | (a = _loop1_58_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3912 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3913 | (b = star_etc_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3914 | ) |
| 3915 | { |
| 3916 | res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 3917 | if (res == NULL && PyErr_Occurred()) { |
| 3918 | p->error_indicator = 1; |
| 3919 | return NULL; |
| 3920 | } |
| 3921 | goto done; |
| 3922 | } |
| 3923 | p->mark = mark; |
| 3924 | } |
| 3925 | { // star_etc |
| 3926 | StarEtc* a; |
| 3927 | if ( |
| 3928 | (a = star_etc_rule(p)) |
| 3929 | ) |
| 3930 | { |
| 3931 | res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 3932 | if (res == NULL && PyErr_Occurred()) { |
| 3933 | p->error_indicator = 1; |
| 3934 | return NULL; |
| 3935 | } |
| 3936 | goto done; |
| 3937 | } |
| 3938 | p->mark = mark; |
| 3939 | } |
| 3940 | res = NULL; |
| 3941 | done: |
| 3942 | return res; |
| 3943 | } |
| 3944 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3945 | // slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3946 | static asdl_seq* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3947 | slash_no_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3948 | { |
| 3949 | if (p->error_indicator) { |
| 3950 | return NULL; |
| 3951 | } |
| 3952 | asdl_seq* res = NULL; |
| 3953 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3954 | { // param_no_default+ '/' ',' |
| 3955 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3956 | Token * literal; |
| 3957 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3958 | if ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3959 | (a = _loop1_59_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3960 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3961 | (literal = _PyPegen_expect_token(p, 17)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3962 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3963 | (literal_1 = _PyPegen_expect_token(p, 12)) |
| 3964 | ) |
| 3965 | { |
| 3966 | res = a; |
| 3967 | if (res == NULL && PyErr_Occurred()) { |
| 3968 | p->error_indicator = 1; |
| 3969 | return NULL; |
| 3970 | } |
| 3971 | goto done; |
| 3972 | } |
| 3973 | p->mark = mark; |
| 3974 | } |
| 3975 | { // param_no_default+ '/' &')' |
| 3976 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3977 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3978 | if ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3979 | (a = _loop1_60_rule(p)) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3980 | && |
| 3981 | (literal = _PyPegen_expect_token(p, 17)) |
| 3982 | && |
| 3983 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3984 | ) |
| 3985 | { |
| 3986 | res = a; |
| 3987 | if (res == NULL && PyErr_Occurred()) { |
| 3988 | p->error_indicator = 1; |
| 3989 | return NULL; |
| 3990 | } |
| 3991 | goto done; |
| 3992 | } |
| 3993 | p->mark = mark; |
| 3994 | } |
| 3995 | res = NULL; |
| 3996 | done: |
| 3997 | return res; |
| 3998 | } |
| 3999 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4000 | // slash_with_default: |
| 4001 | // | param_no_default* param_with_default+ '/' ',' |
| 4002 | // | param_no_default* param_with_default+ '/' &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4003 | static SlashWithDefault* |
| 4004 | slash_with_default_rule(Parser *p) |
| 4005 | { |
| 4006 | if (p->error_indicator) { |
| 4007 | return NULL; |
| 4008 | } |
| 4009 | SlashWithDefault* res = NULL; |
| 4010 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4011 | { // param_no_default* param_with_default+ '/' ',' |
| 4012 | asdl_seq * a; |
| 4013 | asdl_seq * b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4014 | Token * literal; |
| 4015 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4016 | if ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4017 | (a = _loop0_61_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4018 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4019 | (b = _loop1_62_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4020 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4021 | (literal = _PyPegen_expect_token(p, 17)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4022 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4023 | (literal_1 = _PyPegen_expect_token(p, 12)) |
| 4024 | ) |
| 4025 | { |
| 4026 | res = _PyPegen_slash_with_default ( p , a , b ); |
| 4027 | if (res == NULL && PyErr_Occurred()) { |
| 4028 | p->error_indicator = 1; |
| 4029 | return NULL; |
| 4030 | } |
| 4031 | goto done; |
| 4032 | } |
| 4033 | p->mark = mark; |
| 4034 | } |
| 4035 | { // param_no_default* param_with_default+ '/' &')' |
| 4036 | asdl_seq * a; |
| 4037 | asdl_seq * b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4038 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4039 | if ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4040 | (a = _loop0_63_rule(p)) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4041 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4042 | (b = _loop1_64_rule(p)) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4043 | && |
| 4044 | (literal = _PyPegen_expect_token(p, 17)) |
| 4045 | && |
| 4046 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4047 | ) |
| 4048 | { |
| 4049 | res = _PyPegen_slash_with_default ( p , a , b ); |
| 4050 | if (res == NULL && PyErr_Occurred()) { |
| 4051 | p->error_indicator = 1; |
| 4052 | return NULL; |
| 4053 | } |
| 4054 | goto done; |
| 4055 | } |
| 4056 | p->mark = mark; |
| 4057 | } |
| 4058 | res = NULL; |
| 4059 | done: |
| 4060 | return res; |
| 4061 | } |
| 4062 | |
| 4063 | // star_etc: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4064 | // | '*' param_no_default param_maybe_default* kwds? |
| 4065 | // | '*' ',' param_maybe_default+ kwds? |
| 4066 | // | kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4067 | static StarEtc* |
| 4068 | star_etc_rule(Parser *p) |
| 4069 | { |
| 4070 | if (p->error_indicator) { |
| 4071 | return NULL; |
| 4072 | } |
| 4073 | StarEtc* res = NULL; |
| 4074 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4075 | { // '*' param_no_default param_maybe_default* kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4076 | arg_ty a; |
| 4077 | asdl_seq * b; |
| 4078 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4079 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4080 | if ( |
| 4081 | (literal = _PyPegen_expect_token(p, 16)) |
| 4082 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4083 | (a = param_no_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4084 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4085 | (b = _loop0_65_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4086 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4087 | (c = kwds_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4088 | ) |
| 4089 | { |
| 4090 | res = _PyPegen_star_etc ( p , a , b , c ); |
| 4091 | if (res == NULL && PyErr_Occurred()) { |
| 4092 | p->error_indicator = 1; |
| 4093 | return NULL; |
| 4094 | } |
| 4095 | goto done; |
| 4096 | } |
| 4097 | p->mark = mark; |
| 4098 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4099 | { // '*' ',' param_maybe_default+ kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4100 | asdl_seq * b; |
| 4101 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4102 | Token * literal; |
| 4103 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4104 | if ( |
| 4105 | (literal = _PyPegen_expect_token(p, 16)) |
| 4106 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4107 | (literal_1 = _PyPegen_expect_token(p, 12)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4108 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4109 | (b = _loop1_66_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4110 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4111 | (c = kwds_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4112 | ) |
| 4113 | { |
| 4114 | res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 4115 | if (res == NULL && PyErr_Occurred()) { |
| 4116 | p->error_indicator = 1; |
| 4117 | return NULL; |
| 4118 | } |
| 4119 | goto done; |
| 4120 | } |
| 4121 | p->mark = mark; |
| 4122 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4123 | { // kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4124 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4125 | if ( |
| 4126 | (a = kwds_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4127 | ) |
| 4128 | { |
| 4129 | res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 4130 | if (res == NULL && PyErr_Occurred()) { |
| 4131 | p->error_indicator = 1; |
| 4132 | return NULL; |
| 4133 | } |
| 4134 | goto done; |
| 4135 | } |
| 4136 | p->mark = mark; |
| 4137 | } |
| 4138 | res = NULL; |
| 4139 | done: |
| 4140 | return res; |
| 4141 | } |
| 4142 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4143 | // kwds: '**' param_no_default |
| 4144 | static arg_ty |
| 4145 | kwds_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4146 | { |
| 4147 | if (p->error_indicator) { |
| 4148 | return NULL; |
| 4149 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4150 | arg_ty res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4151 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4152 | { // '**' param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4153 | arg_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4154 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4155 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4156 | (literal = _PyPegen_expect_token(p, 35)) |
| 4157 | && |
| 4158 | (a = param_no_default_rule(p)) |
| 4159 | ) |
| 4160 | { |
| 4161 | res = a; |
| 4162 | if (res == NULL && PyErr_Occurred()) { |
| 4163 | p->error_indicator = 1; |
| 4164 | return NULL; |
| 4165 | } |
| 4166 | goto done; |
| 4167 | } |
| 4168 | p->mark = mark; |
| 4169 | } |
| 4170 | res = NULL; |
| 4171 | done: |
| 4172 | return res; |
| 4173 | } |
| 4174 | |
| 4175 | // param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')' |
| 4176 | static arg_ty |
| 4177 | param_no_default_rule(Parser *p) |
| 4178 | { |
| 4179 | if (p->error_indicator) { |
| 4180 | return NULL; |
| 4181 | } |
| 4182 | arg_ty res = NULL; |
| 4183 | int mark = p->mark; |
| 4184 | { // param ',' TYPE_COMMENT? |
| 4185 | arg_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4186 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4187 | void *tc; |
| 4188 | if ( |
| 4189 | (a = param_rule(p)) |
| 4190 | && |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4191 | (literal = _PyPegen_expect_token(p, 12)) |
| 4192 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4193 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4194 | ) |
| 4195 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4196 | res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4197 | if (res == NULL && PyErr_Occurred()) { |
| 4198 | p->error_indicator = 1; |
| 4199 | return NULL; |
| 4200 | } |
| 4201 | goto done; |
| 4202 | } |
| 4203 | p->mark = mark; |
| 4204 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4205 | { // param TYPE_COMMENT? &')' |
| 4206 | arg_ty a; |
| 4207 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4208 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4209 | (a = param_rule(p)) |
| 4210 | && |
| 4211 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) |
| 4212 | && |
| 4213 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4214 | ) |
| 4215 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4216 | res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4217 | if (res == NULL && PyErr_Occurred()) { |
| 4218 | p->error_indicator = 1; |
| 4219 | return NULL; |
| 4220 | } |
| 4221 | goto done; |
| 4222 | } |
| 4223 | p->mark = mark; |
| 4224 | } |
| 4225 | res = NULL; |
| 4226 | done: |
| 4227 | return res; |
| 4228 | } |
| 4229 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4230 | // param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4231 | static NameDefaultPair* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4232 | param_with_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4233 | { |
| 4234 | if (p->error_indicator) { |
| 4235 | return NULL; |
| 4236 | } |
| 4237 | NameDefaultPair* res = NULL; |
| 4238 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4239 | { // param default ',' TYPE_COMMENT? |
| 4240 | arg_ty a; |
| 4241 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4242 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4243 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4244 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4245 | (a = param_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4246 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4247 | (c = default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4248 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4249 | (literal = _PyPegen_expect_token(p, 12)) |
| 4250 | && |
| 4251 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4252 | ) |
| 4253 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4254 | res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4255 | if (res == NULL && PyErr_Occurred()) { |
| 4256 | p->error_indicator = 1; |
| 4257 | return NULL; |
| 4258 | } |
| 4259 | goto done; |
| 4260 | } |
| 4261 | p->mark = mark; |
| 4262 | } |
| 4263 | { // param default TYPE_COMMENT? &')' |
| 4264 | arg_ty a; |
| 4265 | expr_ty c; |
| 4266 | void *tc; |
| 4267 | if ( |
| 4268 | (a = param_rule(p)) |
| 4269 | && |
| 4270 | (c = default_rule(p)) |
| 4271 | && |
| 4272 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) |
| 4273 | && |
| 4274 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) |
| 4275 | ) |
| 4276 | { |
| 4277 | res = _PyPegen_name_default_pair ( p , a , c , tc ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4278 | if (res == NULL && PyErr_Occurred()) { |
| 4279 | p->error_indicator = 1; |
| 4280 | return NULL; |
| 4281 | } |
| 4282 | goto done; |
| 4283 | } |
| 4284 | p->mark = mark; |
| 4285 | } |
| 4286 | res = NULL; |
| 4287 | done: |
| 4288 | return res; |
| 4289 | } |
| 4290 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4291 | // param_maybe_default: |
| 4292 | // | param default? ',' TYPE_COMMENT? |
| 4293 | // | param default? TYPE_COMMENT? &')' |
| 4294 | static NameDefaultPair* |
| 4295 | param_maybe_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4296 | { |
| 4297 | if (p->error_indicator) { |
| 4298 | return NULL; |
| 4299 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4300 | NameDefaultPair* res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4301 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4302 | { // param default? ',' TYPE_COMMENT? |
| 4303 | arg_ty a; |
| 4304 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4305 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4306 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4307 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4308 | (a = param_rule(p)) |
| 4309 | && |
| 4310 | (c = default_rule(p), 1) |
| 4311 | && |
| 4312 | (literal = _PyPegen_expect_token(p, 12)) |
| 4313 | && |
| 4314 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4315 | ) |
| 4316 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4317 | res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4318 | if (res == NULL && PyErr_Occurred()) { |
| 4319 | p->error_indicator = 1; |
| 4320 | return NULL; |
| 4321 | } |
| 4322 | goto done; |
| 4323 | } |
| 4324 | p->mark = mark; |
| 4325 | } |
| 4326 | { // param default? TYPE_COMMENT? &')' |
| 4327 | arg_ty a; |
| 4328 | void *c; |
| 4329 | void *tc; |
| 4330 | if ( |
| 4331 | (a = param_rule(p)) |
| 4332 | && |
| 4333 | (c = default_rule(p), 1) |
| 4334 | && |
| 4335 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) |
| 4336 | && |
| 4337 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) |
| 4338 | ) |
| 4339 | { |
| 4340 | res = _PyPegen_name_default_pair ( p , a , c , tc ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4341 | if (res == NULL && PyErr_Occurred()) { |
| 4342 | p->error_indicator = 1; |
| 4343 | return NULL; |
| 4344 | } |
| 4345 | goto done; |
| 4346 | } |
| 4347 | p->mark = mark; |
| 4348 | } |
| 4349 | res = NULL; |
| 4350 | done: |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4351 | return res; |
| 4352 | } |
| 4353 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4354 | // param: NAME annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4355 | static arg_ty |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4356 | param_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4357 | { |
| 4358 | if (p->error_indicator) { |
| 4359 | return NULL; |
| 4360 | } |
| 4361 | arg_ty res = NULL; |
| 4362 | int mark = p->mark; |
| 4363 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4364 | p->error_indicator = 1; |
| 4365 | return NULL; |
| 4366 | } |
| 4367 | int start_lineno = p->tokens[mark]->lineno; |
| 4368 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4369 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4370 | UNUSED(start_col_offset); // Only used by EXTRA macro |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4371 | { // NAME annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4372 | expr_ty a; |
| 4373 | void *b; |
| 4374 | if ( |
| 4375 | (a = _PyPegen_name_token(p)) |
| 4376 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4377 | (b = annotation_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4378 | ) |
| 4379 | { |
| 4380 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4381 | if (token == NULL) { |
| 4382 | return NULL; |
| 4383 | } |
| 4384 | int end_lineno = token->end_lineno; |
| 4385 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4386 | int end_col_offset = token->end_col_offset; |
| 4387 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4388 | res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA ); |
| 4389 | if (res == NULL && PyErr_Occurred()) { |
| 4390 | p->error_indicator = 1; |
| 4391 | return NULL; |
| 4392 | } |
| 4393 | goto done; |
| 4394 | } |
| 4395 | p->mark = mark; |
| 4396 | } |
| 4397 | res = NULL; |
| 4398 | done: |
| 4399 | return res; |
| 4400 | } |
| 4401 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4402 | // annotation: ':' expression |
| 4403 | static expr_ty |
| 4404 | annotation_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4405 | { |
| 4406 | if (p->error_indicator) { |
| 4407 | return NULL; |
| 4408 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4409 | expr_ty res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4410 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4411 | { // ':' expression |
| 4412 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4413 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4414 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4415 | (literal = _PyPegen_expect_token(p, 11)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4416 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4417 | (a = expression_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4418 | ) |
| 4419 | { |
| 4420 | res = a; |
| 4421 | if (res == NULL && PyErr_Occurred()) { |
| 4422 | p->error_indicator = 1; |
| 4423 | return NULL; |
| 4424 | } |
| 4425 | goto done; |
| 4426 | } |
| 4427 | p->mark = mark; |
| 4428 | } |
| 4429 | res = NULL; |
| 4430 | done: |
| 4431 | return res; |
| 4432 | } |
| 4433 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4434 | // default: '=' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4435 | static expr_ty |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4436 | default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4437 | { |
| 4438 | if (p->error_indicator) { |
| 4439 | return NULL; |
| 4440 | } |
| 4441 | expr_ty res = NULL; |
| 4442 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4443 | { // '=' expression |
| 4444 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4445 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4446 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4447 | (literal = _PyPegen_expect_token(p, 22)) |
| 4448 | && |
| 4449 | (a = expression_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4450 | ) |
| 4451 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4452 | res = a; |
| 4453 | if (res == NULL && PyErr_Occurred()) { |
| 4454 | p->error_indicator = 1; |
| 4455 | return NULL; |
| 4456 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4457 | goto done; |
| 4458 | } |
| 4459 | p->mark = mark; |
| 4460 | } |
| 4461 | res = NULL; |
| 4462 | done: |
| 4463 | return res; |
| 4464 | } |
| 4465 | |
| 4466 | // decorators: (('@' named_expression NEWLINE))+ |
| 4467 | static asdl_seq* |
| 4468 | decorators_rule(Parser *p) |
| 4469 | { |
| 4470 | if (p->error_indicator) { |
| 4471 | return NULL; |
| 4472 | } |
| 4473 | asdl_seq* res = NULL; |
| 4474 | int mark = p->mark; |
| 4475 | { // (('@' named_expression NEWLINE))+ |
| 4476 | asdl_seq * a; |
| 4477 | if ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4478 | (a = _loop1_67_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4479 | ) |
| 4480 | { |
| 4481 | res = a; |
| 4482 | if (res == NULL && PyErr_Occurred()) { |
| 4483 | p->error_indicator = 1; |
| 4484 | return NULL; |
| 4485 | } |
| 4486 | goto done; |
| 4487 | } |
| 4488 | p->mark = mark; |
| 4489 | } |
| 4490 | res = NULL; |
| 4491 | done: |
| 4492 | return res; |
| 4493 | } |
| 4494 | |
| 4495 | // class_def: decorators class_def_raw | class_def_raw |
| 4496 | static stmt_ty |
| 4497 | class_def_rule(Parser *p) |
| 4498 | { |
| 4499 | if (p->error_indicator) { |
| 4500 | return NULL; |
| 4501 | } |
| 4502 | stmt_ty res = NULL; |
| 4503 | int mark = p->mark; |
| 4504 | { // decorators class_def_raw |
| 4505 | asdl_seq* a; |
| 4506 | stmt_ty b; |
| 4507 | if ( |
| 4508 | (a = decorators_rule(p)) |
| 4509 | && |
| 4510 | (b = class_def_raw_rule(p)) |
| 4511 | ) |
| 4512 | { |
| 4513 | res = _PyPegen_class_def_decorators ( p , a , b ); |
| 4514 | if (res == NULL && PyErr_Occurred()) { |
| 4515 | p->error_indicator = 1; |
| 4516 | return NULL; |
| 4517 | } |
| 4518 | goto done; |
| 4519 | } |
| 4520 | p->mark = mark; |
| 4521 | } |
| 4522 | { // class_def_raw |
| 4523 | stmt_ty class_def_raw_var; |
| 4524 | if ( |
| 4525 | (class_def_raw_var = class_def_raw_rule(p)) |
| 4526 | ) |
| 4527 | { |
| 4528 | res = class_def_raw_var; |
| 4529 | goto done; |
| 4530 | } |
| 4531 | p->mark = mark; |
| 4532 | } |
| 4533 | res = NULL; |
| 4534 | done: |
| 4535 | return res; |
| 4536 | } |
| 4537 | |
| 4538 | // class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block |
| 4539 | static stmt_ty |
| 4540 | class_def_raw_rule(Parser *p) |
| 4541 | { |
| 4542 | if (p->error_indicator) { |
| 4543 | return NULL; |
| 4544 | } |
| 4545 | stmt_ty res = NULL; |
| 4546 | int mark = p->mark; |
| 4547 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4548 | p->error_indicator = 1; |
| 4549 | return NULL; |
| 4550 | } |
| 4551 | int start_lineno = p->tokens[mark]->lineno; |
| 4552 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4553 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4554 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4555 | { // 'class' NAME ['(' arguments? ')'] ':' block |
| 4556 | expr_ty a; |
| 4557 | void *b; |
| 4558 | asdl_seq* c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4559 | Token * keyword; |
| 4560 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4561 | if ( |
| 4562 | (keyword = _PyPegen_expect_token(p, 523)) |
| 4563 | && |
| 4564 | (a = _PyPegen_name_token(p)) |
| 4565 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4566 | (b = _tmp_68_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4567 | && |
| 4568 | (literal = _PyPegen_expect_token(p, 11)) |
| 4569 | && |
| 4570 | (c = block_rule(p)) |
| 4571 | ) |
| 4572 | { |
| 4573 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4574 | if (token == NULL) { |
| 4575 | return NULL; |
| 4576 | } |
| 4577 | int end_lineno = token->end_lineno; |
| 4578 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4579 | int end_col_offset = token->end_col_offset; |
| 4580 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4581 | 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 ); |
| 4582 | if (res == NULL && PyErr_Occurred()) { |
| 4583 | p->error_indicator = 1; |
| 4584 | return NULL; |
| 4585 | } |
| 4586 | goto done; |
| 4587 | } |
| 4588 | p->mark = mark; |
| 4589 | } |
| 4590 | res = NULL; |
| 4591 | done: |
| 4592 | return res; |
| 4593 | } |
| 4594 | |
| 4595 | // block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block |
| 4596 | static asdl_seq* |
| 4597 | block_rule(Parser *p) |
| 4598 | { |
| 4599 | if (p->error_indicator) { |
| 4600 | return NULL; |
| 4601 | } |
| 4602 | asdl_seq* res = NULL; |
| 4603 | if (_PyPegen_is_memoized(p, block_type, &res)) |
| 4604 | return res; |
| 4605 | int mark = p->mark; |
| 4606 | { // NEWLINE INDENT statements DEDENT |
| 4607 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4608 | Token * dedent_var; |
| 4609 | Token * indent_var; |
| 4610 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4611 | if ( |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 4612 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4613 | && |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 4614 | (indent_var = _PyPegen_expect_token(p, INDENT)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4615 | && |
| 4616 | (a = statements_rule(p)) |
| 4617 | && |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 4618 | (dedent_var = _PyPegen_expect_token(p, DEDENT)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4619 | ) |
| 4620 | { |
| 4621 | res = a; |
| 4622 | if (res == NULL && PyErr_Occurred()) { |
| 4623 | p->error_indicator = 1; |
| 4624 | return NULL; |
| 4625 | } |
| 4626 | goto done; |
| 4627 | } |
| 4628 | p->mark = mark; |
| 4629 | } |
| 4630 | { // simple_stmt |
| 4631 | asdl_seq* simple_stmt_var; |
| 4632 | if ( |
| 4633 | (simple_stmt_var = simple_stmt_rule(p)) |
| 4634 | ) |
| 4635 | { |
| 4636 | res = simple_stmt_var; |
| 4637 | goto done; |
| 4638 | } |
| 4639 | p->mark = mark; |
| 4640 | } |
| 4641 | { // invalid_block |
| 4642 | void *invalid_block_var; |
| 4643 | if ( |
| 4644 | (invalid_block_var = invalid_block_rule(p)) |
| 4645 | ) |
| 4646 | { |
| 4647 | res = invalid_block_var; |
| 4648 | goto done; |
| 4649 | } |
| 4650 | p->mark = mark; |
| 4651 | } |
| 4652 | res = NULL; |
| 4653 | done: |
| 4654 | _PyPegen_insert_memo(p, mark, block_type, res); |
| 4655 | return res; |
| 4656 | } |
| 4657 | |
| 4658 | // expressions_list: ','.star_expression+ ','? |
| 4659 | static asdl_seq* |
| 4660 | expressions_list_rule(Parser *p) |
| 4661 | { |
| 4662 | if (p->error_indicator) { |
| 4663 | return NULL; |
| 4664 | } |
| 4665 | asdl_seq* res = NULL; |
| 4666 | int mark = p->mark; |
| 4667 | { // ','.star_expression+ ','? |
| 4668 | asdl_seq * a; |
| 4669 | void *opt_var; |
| 4670 | UNUSED(opt_var); // Silence compiler warnings |
| 4671 | if ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4672 | (a = _gather_69_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4673 | && |
| 4674 | (opt_var = _PyPegen_expect_token(p, 12), 1) |
| 4675 | ) |
| 4676 | { |
| 4677 | res = a; |
| 4678 | if (res == NULL && PyErr_Occurred()) { |
| 4679 | p->error_indicator = 1; |
| 4680 | return NULL; |
| 4681 | } |
| 4682 | goto done; |
| 4683 | } |
| 4684 | p->mark = mark; |
| 4685 | } |
| 4686 | res = NULL; |
| 4687 | done: |
| 4688 | return res; |
| 4689 | } |
| 4690 | |
| 4691 | // star_expressions: |
| 4692 | // | star_expression ((',' star_expression))+ ','? |
| 4693 | // | star_expression ',' |
| 4694 | // | star_expression |
| 4695 | static expr_ty |
| 4696 | star_expressions_rule(Parser *p) |
| 4697 | { |
| 4698 | if (p->error_indicator) { |
| 4699 | return NULL; |
| 4700 | } |
| 4701 | expr_ty res = NULL; |
| 4702 | int mark = p->mark; |
| 4703 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4704 | p->error_indicator = 1; |
| 4705 | return NULL; |
| 4706 | } |
| 4707 | int start_lineno = p->tokens[mark]->lineno; |
| 4708 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4709 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4710 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4711 | { // star_expression ((',' star_expression))+ ','? |
| 4712 | expr_ty a; |
| 4713 | asdl_seq * b; |
| 4714 | void *opt_var; |
| 4715 | UNUSED(opt_var); // Silence compiler warnings |
| 4716 | if ( |
| 4717 | (a = star_expression_rule(p)) |
| 4718 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4719 | (b = _loop1_71_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4720 | && |
| 4721 | (opt_var = _PyPegen_expect_token(p, 12), 1) |
| 4722 | ) |
| 4723 | { |
| 4724 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4725 | if (token == NULL) { |
| 4726 | return NULL; |
| 4727 | } |
| 4728 | int end_lineno = token->end_lineno; |
| 4729 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4730 | int end_col_offset = token->end_col_offset; |
| 4731 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4732 | res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
| 4733 | if (res == NULL && PyErr_Occurred()) { |
| 4734 | p->error_indicator = 1; |
| 4735 | return NULL; |
| 4736 | } |
| 4737 | goto done; |
| 4738 | } |
| 4739 | p->mark = mark; |
| 4740 | } |
| 4741 | { // star_expression ',' |
| 4742 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4743 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4744 | if ( |
| 4745 | (a = star_expression_rule(p)) |
| 4746 | && |
| 4747 | (literal = _PyPegen_expect_token(p, 12)) |
| 4748 | ) |
| 4749 | { |
| 4750 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4751 | if (token == NULL) { |
| 4752 | return NULL; |
| 4753 | } |
| 4754 | int end_lineno = token->end_lineno; |
| 4755 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4756 | int end_col_offset = token->end_col_offset; |
| 4757 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4758 | res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
| 4759 | if (res == NULL && PyErr_Occurred()) { |
| 4760 | p->error_indicator = 1; |
| 4761 | return NULL; |
| 4762 | } |
| 4763 | goto done; |
| 4764 | } |
| 4765 | p->mark = mark; |
| 4766 | } |
| 4767 | { // star_expression |
| 4768 | expr_ty star_expression_var; |
| 4769 | if ( |
| 4770 | (star_expression_var = star_expression_rule(p)) |
| 4771 | ) |
| 4772 | { |
| 4773 | res = star_expression_var; |
| 4774 | goto done; |
| 4775 | } |
| 4776 | p->mark = mark; |
| 4777 | } |
| 4778 | res = NULL; |
| 4779 | done: |
| 4780 | return res; |
| 4781 | } |
| 4782 | |
| 4783 | // star_expression: '*' bitwise_or | expression |
| 4784 | static expr_ty |
| 4785 | star_expression_rule(Parser *p) |
| 4786 | { |
| 4787 | if (p->error_indicator) { |
| 4788 | return NULL; |
| 4789 | } |
| 4790 | expr_ty res = NULL; |
| 4791 | if (_PyPegen_is_memoized(p, star_expression_type, &res)) |
| 4792 | return res; |
| 4793 | int mark = p->mark; |
| 4794 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4795 | p->error_indicator = 1; |
| 4796 | return NULL; |
| 4797 | } |
| 4798 | int start_lineno = p->tokens[mark]->lineno; |
| 4799 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4800 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4801 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4802 | { // '*' bitwise_or |
| 4803 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4804 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4805 | if ( |
| 4806 | (literal = _PyPegen_expect_token(p, 16)) |
| 4807 | && |
| 4808 | (a = bitwise_or_rule(p)) |
| 4809 | ) |
| 4810 | { |
| 4811 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4812 | if (token == NULL) { |
| 4813 | return NULL; |
| 4814 | } |
| 4815 | int end_lineno = token->end_lineno; |
| 4816 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4817 | int end_col_offset = token->end_col_offset; |
| 4818 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4819 | res = _Py_Starred ( a , Load , EXTRA ); |
| 4820 | if (res == NULL && PyErr_Occurred()) { |
| 4821 | p->error_indicator = 1; |
| 4822 | return NULL; |
| 4823 | } |
| 4824 | goto done; |
| 4825 | } |
| 4826 | p->mark = mark; |
| 4827 | } |
| 4828 | { // expression |
| 4829 | expr_ty expression_var; |
| 4830 | if ( |
| 4831 | (expression_var = expression_rule(p)) |
| 4832 | ) |
| 4833 | { |
| 4834 | res = expression_var; |
| 4835 | goto done; |
| 4836 | } |
| 4837 | p->mark = mark; |
| 4838 | } |
| 4839 | res = NULL; |
| 4840 | done: |
| 4841 | _PyPegen_insert_memo(p, mark, star_expression_type, res); |
| 4842 | return res; |
| 4843 | } |
| 4844 | |
| 4845 | // star_named_expressions: ','.star_named_expression+ ','? |
| 4846 | static asdl_seq* |
| 4847 | star_named_expressions_rule(Parser *p) |
| 4848 | { |
| 4849 | if (p->error_indicator) { |
| 4850 | return NULL; |
| 4851 | } |
| 4852 | asdl_seq* res = NULL; |
| 4853 | int mark = p->mark; |
| 4854 | { // ','.star_named_expression+ ','? |
| 4855 | asdl_seq * a; |
| 4856 | void *opt_var; |
| 4857 | UNUSED(opt_var); // Silence compiler warnings |
| 4858 | if ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 4859 | (a = _gather_72_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4860 | && |
| 4861 | (opt_var = _PyPegen_expect_token(p, 12), 1) |
| 4862 | ) |
| 4863 | { |
| 4864 | res = a; |
| 4865 | if (res == NULL && PyErr_Occurred()) { |
| 4866 | p->error_indicator = 1; |
| 4867 | return NULL; |
| 4868 | } |
| 4869 | goto done; |
| 4870 | } |
| 4871 | p->mark = mark; |
| 4872 | } |
| 4873 | res = NULL; |
| 4874 | done: |
| 4875 | return res; |
| 4876 | } |
| 4877 | |
| 4878 | // star_named_expression: '*' bitwise_or | named_expression |
| 4879 | static expr_ty |
| 4880 | star_named_expression_rule(Parser *p) |
| 4881 | { |
| 4882 | if (p->error_indicator) { |
| 4883 | return NULL; |
| 4884 | } |
| 4885 | expr_ty res = NULL; |
| 4886 | int mark = p->mark; |
| 4887 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4888 | p->error_indicator = 1; |
| 4889 | return NULL; |
| 4890 | } |
| 4891 | int start_lineno = p->tokens[mark]->lineno; |
| 4892 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4893 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4894 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4895 | { // '*' bitwise_or |
| 4896 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4897 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4898 | if ( |
| 4899 | (literal = _PyPegen_expect_token(p, 16)) |
| 4900 | && |
| 4901 | (a = bitwise_or_rule(p)) |
| 4902 | ) |
| 4903 | { |
| 4904 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4905 | if (token == NULL) { |
| 4906 | return NULL; |
| 4907 | } |
| 4908 | int end_lineno = token->end_lineno; |
| 4909 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4910 | int end_col_offset = token->end_col_offset; |
| 4911 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4912 | res = _Py_Starred ( a , Load , EXTRA ); |
| 4913 | if (res == NULL && PyErr_Occurred()) { |
| 4914 | p->error_indicator = 1; |
| 4915 | return NULL; |
| 4916 | } |
| 4917 | goto done; |
| 4918 | } |
| 4919 | p->mark = mark; |
| 4920 | } |
| 4921 | { // named_expression |
| 4922 | expr_ty named_expression_var; |
| 4923 | if ( |
| 4924 | (named_expression_var = named_expression_rule(p)) |
| 4925 | ) |
| 4926 | { |
| 4927 | res = named_expression_var; |
| 4928 | goto done; |
| 4929 | } |
| 4930 | p->mark = mark; |
| 4931 | } |
| 4932 | res = NULL; |
| 4933 | done: |
| 4934 | return res; |
| 4935 | } |
| 4936 | |
| 4937 | // named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression |
| 4938 | static expr_ty |
| 4939 | named_expression_rule(Parser *p) |
| 4940 | { |
| 4941 | if (p->error_indicator) { |
| 4942 | return NULL; |
| 4943 | } |
| 4944 | expr_ty res = NULL; |
| 4945 | int mark = p->mark; |
| 4946 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4947 | p->error_indicator = 1; |
| 4948 | return NULL; |
| 4949 | } |
| 4950 | int start_lineno = p->tokens[mark]->lineno; |
| 4951 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 4952 | int start_col_offset = p->tokens[mark]->col_offset; |
| 4953 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 4954 | { // NAME ':=' expression |
| 4955 | expr_ty a; |
| 4956 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4957 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4958 | if ( |
| 4959 | (a = _PyPegen_name_token(p)) |
| 4960 | && |
| 4961 | (literal = _PyPegen_expect_token(p, 53)) |
| 4962 | && |
| 4963 | (b = expression_rule(p)) |
| 4964 | ) |
| 4965 | { |
| 4966 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4967 | if (token == NULL) { |
| 4968 | return NULL; |
| 4969 | } |
| 4970 | int end_lineno = token->end_lineno; |
| 4971 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 4972 | int end_col_offset = token->end_col_offset; |
| 4973 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 4974 | res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA ); |
| 4975 | if (res == NULL && PyErr_Occurred()) { |
| 4976 | p->error_indicator = 1; |
| 4977 | return NULL; |
| 4978 | } |
| 4979 | goto done; |
| 4980 | } |
| 4981 | p->mark = mark; |
| 4982 | } |
| 4983 | { // expression !':=' |
| 4984 | expr_ty expression_var; |
| 4985 | if ( |
| 4986 | (expression_var = expression_rule(p)) |
| 4987 | && |
| 4988 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) |
| 4989 | ) |
| 4990 | { |
| 4991 | res = expression_var; |
| 4992 | goto done; |
| 4993 | } |
| 4994 | p->mark = mark; |
| 4995 | } |
| 4996 | { // invalid_named_expression |
| 4997 | void *invalid_named_expression_var; |
| 4998 | if ( |
| 4999 | (invalid_named_expression_var = invalid_named_expression_rule(p)) |
| 5000 | ) |
| 5001 | { |
| 5002 | res = invalid_named_expression_var; |
| 5003 | goto done; |
| 5004 | } |
| 5005 | p->mark = mark; |
| 5006 | } |
| 5007 | res = NULL; |
| 5008 | done: |
| 5009 | return res; |
| 5010 | } |
| 5011 | |
| 5012 | // annotated_rhs: yield_expr | star_expressions |
| 5013 | static expr_ty |
| 5014 | annotated_rhs_rule(Parser *p) |
| 5015 | { |
| 5016 | if (p->error_indicator) { |
| 5017 | return NULL; |
| 5018 | } |
| 5019 | expr_ty res = NULL; |
| 5020 | int mark = p->mark; |
| 5021 | { // yield_expr |
| 5022 | expr_ty yield_expr_var; |
| 5023 | if ( |
| 5024 | (yield_expr_var = yield_expr_rule(p)) |
| 5025 | ) |
| 5026 | { |
| 5027 | res = yield_expr_var; |
| 5028 | goto done; |
| 5029 | } |
| 5030 | p->mark = mark; |
| 5031 | } |
| 5032 | { // star_expressions |
| 5033 | expr_ty star_expressions_var; |
| 5034 | if ( |
| 5035 | (star_expressions_var = star_expressions_rule(p)) |
| 5036 | ) |
| 5037 | { |
| 5038 | res = star_expressions_var; |
| 5039 | goto done; |
| 5040 | } |
| 5041 | p->mark = mark; |
| 5042 | } |
| 5043 | res = NULL; |
| 5044 | done: |
| 5045 | return res; |
| 5046 | } |
| 5047 | |
| 5048 | // expressions: expression ((',' expression))+ ','? | expression ',' | expression |
| 5049 | static expr_ty |
| 5050 | expressions_rule(Parser *p) |
| 5051 | { |
| 5052 | if (p->error_indicator) { |
| 5053 | return NULL; |
| 5054 | } |
| 5055 | expr_ty res = NULL; |
| 5056 | int mark = p->mark; |
| 5057 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5058 | p->error_indicator = 1; |
| 5059 | return NULL; |
| 5060 | } |
| 5061 | int start_lineno = p->tokens[mark]->lineno; |
| 5062 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5063 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5064 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5065 | { // expression ((',' expression))+ ','? |
| 5066 | expr_ty a; |
| 5067 | asdl_seq * b; |
| 5068 | void *opt_var; |
| 5069 | UNUSED(opt_var); // Silence compiler warnings |
| 5070 | if ( |
| 5071 | (a = expression_rule(p)) |
| 5072 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 5073 | (b = _loop1_74_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5074 | && |
| 5075 | (opt_var = _PyPegen_expect_token(p, 12), 1) |
| 5076 | ) |
| 5077 | { |
| 5078 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5079 | if (token == NULL) { |
| 5080 | return NULL; |
| 5081 | } |
| 5082 | int end_lineno = token->end_lineno; |
| 5083 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5084 | int end_col_offset = token->end_col_offset; |
| 5085 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5086 | res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
| 5087 | if (res == NULL && PyErr_Occurred()) { |
| 5088 | p->error_indicator = 1; |
| 5089 | return NULL; |
| 5090 | } |
| 5091 | goto done; |
| 5092 | } |
| 5093 | p->mark = mark; |
| 5094 | } |
| 5095 | { // expression ',' |
| 5096 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5097 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5098 | if ( |
| 5099 | (a = expression_rule(p)) |
| 5100 | && |
| 5101 | (literal = _PyPegen_expect_token(p, 12)) |
| 5102 | ) |
| 5103 | { |
| 5104 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5105 | if (token == NULL) { |
| 5106 | return NULL; |
| 5107 | } |
| 5108 | int end_lineno = token->end_lineno; |
| 5109 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5110 | int end_col_offset = token->end_col_offset; |
| 5111 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5112 | res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
| 5113 | if (res == NULL && PyErr_Occurred()) { |
| 5114 | p->error_indicator = 1; |
| 5115 | return NULL; |
| 5116 | } |
| 5117 | goto done; |
| 5118 | } |
| 5119 | p->mark = mark; |
| 5120 | } |
| 5121 | { // expression |
| 5122 | expr_ty expression_var; |
| 5123 | if ( |
| 5124 | (expression_var = expression_rule(p)) |
| 5125 | ) |
| 5126 | { |
| 5127 | res = expression_var; |
| 5128 | goto done; |
| 5129 | } |
| 5130 | p->mark = mark; |
| 5131 | } |
| 5132 | res = NULL; |
| 5133 | done: |
| 5134 | return res; |
| 5135 | } |
| 5136 | |
| 5137 | // expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef |
| 5138 | static expr_ty |
| 5139 | expression_rule(Parser *p) |
| 5140 | { |
| 5141 | if (p->error_indicator) { |
| 5142 | return NULL; |
| 5143 | } |
| 5144 | expr_ty res = NULL; |
| 5145 | if (_PyPegen_is_memoized(p, expression_type, &res)) |
| 5146 | return res; |
| 5147 | int mark = p->mark; |
| 5148 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5149 | p->error_indicator = 1; |
| 5150 | return NULL; |
| 5151 | } |
| 5152 | int start_lineno = p->tokens[mark]->lineno; |
| 5153 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5154 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5155 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5156 | { // disjunction 'if' disjunction 'else' expression |
| 5157 | expr_ty a; |
| 5158 | expr_ty b; |
| 5159 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5160 | Token * keyword; |
| 5161 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5162 | if ( |
| 5163 | (a = disjunction_rule(p)) |
| 5164 | && |
| 5165 | (keyword = _PyPegen_expect_token(p, 510)) |
| 5166 | && |
| 5167 | (b = disjunction_rule(p)) |
| 5168 | && |
| 5169 | (keyword_1 = _PyPegen_expect_token(p, 516)) |
| 5170 | && |
| 5171 | (c = expression_rule(p)) |
| 5172 | ) |
| 5173 | { |
| 5174 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5175 | if (token == NULL) { |
| 5176 | return NULL; |
| 5177 | } |
| 5178 | int end_lineno = token->end_lineno; |
| 5179 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5180 | int end_col_offset = token->end_col_offset; |
| 5181 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5182 | res = _Py_IfExp ( b , a , c , EXTRA ); |
| 5183 | if (res == NULL && PyErr_Occurred()) { |
| 5184 | p->error_indicator = 1; |
| 5185 | return NULL; |
| 5186 | } |
| 5187 | goto done; |
| 5188 | } |
| 5189 | p->mark = mark; |
| 5190 | } |
| 5191 | { // disjunction |
| 5192 | expr_ty disjunction_var; |
| 5193 | if ( |
| 5194 | (disjunction_var = disjunction_rule(p)) |
| 5195 | ) |
| 5196 | { |
| 5197 | res = disjunction_var; |
| 5198 | goto done; |
| 5199 | } |
| 5200 | p->mark = mark; |
| 5201 | } |
| 5202 | { // lambdef |
| 5203 | expr_ty lambdef_var; |
| 5204 | if ( |
| 5205 | (lambdef_var = lambdef_rule(p)) |
| 5206 | ) |
| 5207 | { |
| 5208 | res = lambdef_var; |
| 5209 | goto done; |
| 5210 | } |
| 5211 | p->mark = mark; |
| 5212 | } |
| 5213 | res = NULL; |
| 5214 | done: |
| 5215 | _PyPegen_insert_memo(p, mark, expression_type, res); |
| 5216 | return res; |
| 5217 | } |
| 5218 | |
| 5219 | // lambdef: 'lambda' lambda_parameters? ':' expression |
| 5220 | static expr_ty |
| 5221 | lambdef_rule(Parser *p) |
| 5222 | { |
| 5223 | if (p->error_indicator) { |
| 5224 | return NULL; |
| 5225 | } |
| 5226 | expr_ty res = NULL; |
| 5227 | int mark = p->mark; |
| 5228 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5229 | p->error_indicator = 1; |
| 5230 | return NULL; |
| 5231 | } |
| 5232 | int start_lineno = p->tokens[mark]->lineno; |
| 5233 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5234 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5235 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5236 | { // 'lambda' lambda_parameters? ':' expression |
| 5237 | void *a; |
| 5238 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5239 | Token * keyword; |
| 5240 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5241 | if ( |
| 5242 | (keyword = _PyPegen_expect_token(p, 524)) |
| 5243 | && |
| 5244 | (a = lambda_parameters_rule(p), 1) |
| 5245 | && |
| 5246 | (literal = _PyPegen_expect_token(p, 11)) |
| 5247 | && |
| 5248 | (b = expression_rule(p)) |
| 5249 | ) |
| 5250 | { |
| 5251 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5252 | if (token == NULL) { |
| 5253 | return NULL; |
| 5254 | } |
| 5255 | int end_lineno = token->end_lineno; |
| 5256 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5257 | int end_col_offset = token->end_col_offset; |
| 5258 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5259 | res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA ); |
| 5260 | if (res == NULL && PyErr_Occurred()) { |
| 5261 | p->error_indicator = 1; |
| 5262 | return NULL; |
| 5263 | } |
| 5264 | goto done; |
| 5265 | } |
| 5266 | p->mark = mark; |
| 5267 | } |
| 5268 | res = NULL; |
| 5269 | done: |
| 5270 | return res; |
| 5271 | } |
| 5272 | |
| 5273 | // lambda_parameters: |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5274 | // | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? |
| 5275 | // | lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
| 5276 | // | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
| 5277 | // | lambda_param_with_default+ lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5278 | // | lambda_star_etc |
| 5279 | static arguments_ty |
| 5280 | lambda_parameters_rule(Parser *p) |
| 5281 | { |
| 5282 | if (p->error_indicator) { |
| 5283 | return NULL; |
| 5284 | } |
| 5285 | arguments_ty res = NULL; |
| 5286 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5287 | { // lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5288 | asdl_seq* a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5289 | asdl_seq * b; |
| 5290 | asdl_seq * c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5291 | void *d; |
| 5292 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5293 | (a = lambda_slash_no_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5294 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5295 | (b = _loop0_75_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5296 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5297 | (c = _loop0_76_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5298 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5299 | (d = lambda_star_etc_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5300 | ) |
| 5301 | { |
| 5302 | res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 5303 | if (res == NULL && PyErr_Occurred()) { |
| 5304 | p->error_indicator = 1; |
| 5305 | return NULL; |
| 5306 | } |
| 5307 | goto done; |
| 5308 | } |
| 5309 | p->mark = mark; |
| 5310 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5311 | { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5312 | SlashWithDefault* a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5313 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5314 | void *c; |
| 5315 | if ( |
| 5316 | (a = lambda_slash_with_default_rule(p)) |
| 5317 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5318 | (b = _loop0_77_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5319 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5320 | (c = lambda_star_etc_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5321 | ) |
| 5322 | { |
| 5323 | res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 5324 | if (res == NULL && PyErr_Occurred()) { |
| 5325 | p->error_indicator = 1; |
| 5326 | return NULL; |
| 5327 | } |
| 5328 | goto done; |
| 5329 | } |
| 5330 | p->mark = mark; |
| 5331 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5332 | { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
| 5333 | asdl_seq * a; |
| 5334 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5335 | void *c; |
| 5336 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5337 | (a = _loop1_78_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5338 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5339 | (b = _loop0_79_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5340 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5341 | (c = lambda_star_etc_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5342 | ) |
| 5343 | { |
| 5344 | res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 5345 | if (res == NULL && PyErr_Occurred()) { |
| 5346 | p->error_indicator = 1; |
| 5347 | return NULL; |
| 5348 | } |
| 5349 | goto done; |
| 5350 | } |
| 5351 | p->mark = mark; |
| 5352 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5353 | { // lambda_param_with_default+ lambda_star_etc? |
| 5354 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5355 | void *b; |
| 5356 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5357 | (a = _loop1_80_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5358 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5359 | (b = lambda_star_etc_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5360 | ) |
| 5361 | { |
| 5362 | res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 5363 | if (res == NULL && PyErr_Occurred()) { |
| 5364 | p->error_indicator = 1; |
| 5365 | return NULL; |
| 5366 | } |
| 5367 | goto done; |
| 5368 | } |
| 5369 | p->mark = mark; |
| 5370 | } |
| 5371 | { // lambda_star_etc |
| 5372 | StarEtc* a; |
| 5373 | if ( |
| 5374 | (a = lambda_star_etc_rule(p)) |
| 5375 | ) |
| 5376 | { |
| 5377 | res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 5378 | if (res == NULL && PyErr_Occurred()) { |
| 5379 | p->error_indicator = 1; |
| 5380 | return NULL; |
| 5381 | } |
| 5382 | goto done; |
| 5383 | } |
| 5384 | p->mark = mark; |
| 5385 | } |
| 5386 | res = NULL; |
| 5387 | done: |
| 5388 | return res; |
| 5389 | } |
| 5390 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5391 | // lambda_slash_no_default: |
| 5392 | // | lambda_param_no_default+ '/' ',' |
| 5393 | // | lambda_param_no_default+ '/' &':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5394 | static asdl_seq* |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5395 | lambda_slash_no_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5396 | { |
| 5397 | if (p->error_indicator) { |
| 5398 | return NULL; |
| 5399 | } |
| 5400 | asdl_seq* res = NULL; |
| 5401 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5402 | { // lambda_param_no_default+ '/' ',' |
| 5403 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5404 | Token * literal; |
| 5405 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5406 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5407 | (a = _loop1_81_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5408 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5409 | (literal = _PyPegen_expect_token(p, 17)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5410 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5411 | (literal_1 = _PyPegen_expect_token(p, 12)) |
| 5412 | ) |
| 5413 | { |
| 5414 | res = a; |
| 5415 | if (res == NULL && PyErr_Occurred()) { |
| 5416 | p->error_indicator = 1; |
| 5417 | return NULL; |
| 5418 | } |
| 5419 | goto done; |
| 5420 | } |
| 5421 | p->mark = mark; |
| 5422 | } |
| 5423 | { // lambda_param_no_default+ '/' &':' |
| 5424 | asdl_seq * a; |
| 5425 | Token * literal; |
| 5426 | if ( |
| 5427 | (a = _loop1_82_rule(p)) |
| 5428 | && |
| 5429 | (literal = _PyPegen_expect_token(p, 17)) |
| 5430 | && |
| 5431 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5432 | ) |
| 5433 | { |
| 5434 | res = a; |
| 5435 | if (res == NULL && PyErr_Occurred()) { |
| 5436 | p->error_indicator = 1; |
| 5437 | return NULL; |
| 5438 | } |
| 5439 | goto done; |
| 5440 | } |
| 5441 | p->mark = mark; |
| 5442 | } |
| 5443 | res = NULL; |
| 5444 | done: |
| 5445 | return res; |
| 5446 | } |
| 5447 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5448 | // lambda_slash_with_default: |
| 5449 | // | lambda_param_no_default* lambda_param_with_default+ '/' ',' |
| 5450 | // | lambda_param_no_default* lambda_param_with_default+ '/' &':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5451 | static SlashWithDefault* |
| 5452 | lambda_slash_with_default_rule(Parser *p) |
| 5453 | { |
| 5454 | if (p->error_indicator) { |
| 5455 | return NULL; |
| 5456 | } |
| 5457 | SlashWithDefault* res = NULL; |
| 5458 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5459 | { // lambda_param_no_default* lambda_param_with_default+ '/' ',' |
| 5460 | asdl_seq * a; |
| 5461 | asdl_seq * b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5462 | Token * literal; |
| 5463 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5464 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5465 | (a = _loop0_83_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5466 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5467 | (b = _loop1_84_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5468 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5469 | (literal = _PyPegen_expect_token(p, 17)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5470 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5471 | (literal_1 = _PyPegen_expect_token(p, 12)) |
| 5472 | ) |
| 5473 | { |
| 5474 | res = _PyPegen_slash_with_default ( p , a , b ); |
| 5475 | if (res == NULL && PyErr_Occurred()) { |
| 5476 | p->error_indicator = 1; |
| 5477 | return NULL; |
| 5478 | } |
| 5479 | goto done; |
| 5480 | } |
| 5481 | p->mark = mark; |
| 5482 | } |
| 5483 | { // lambda_param_no_default* lambda_param_with_default+ '/' &':' |
| 5484 | asdl_seq * a; |
| 5485 | asdl_seq * b; |
| 5486 | Token * literal; |
| 5487 | if ( |
| 5488 | (a = _loop0_85_rule(p)) |
| 5489 | && |
| 5490 | (b = _loop1_86_rule(p)) |
| 5491 | && |
| 5492 | (literal = _PyPegen_expect_token(p, 17)) |
| 5493 | && |
| 5494 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5495 | ) |
| 5496 | { |
| 5497 | res = _PyPegen_slash_with_default ( p , a , b ); |
| 5498 | if (res == NULL && PyErr_Occurred()) { |
| 5499 | p->error_indicator = 1; |
| 5500 | return NULL; |
| 5501 | } |
| 5502 | goto done; |
| 5503 | } |
| 5504 | p->mark = mark; |
| 5505 | } |
| 5506 | res = NULL; |
| 5507 | done: |
| 5508 | return res; |
| 5509 | } |
| 5510 | |
| 5511 | // lambda_star_etc: |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5512 | // | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
| 5513 | // | '*' ',' lambda_param_maybe_default+ lambda_kwds? |
| 5514 | // | lambda_kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5515 | static StarEtc* |
| 5516 | lambda_star_etc_rule(Parser *p) |
| 5517 | { |
| 5518 | if (p->error_indicator) { |
| 5519 | return NULL; |
| 5520 | } |
| 5521 | StarEtc* res = NULL; |
| 5522 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5523 | { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5524 | arg_ty a; |
| 5525 | asdl_seq * b; |
| 5526 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5527 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5528 | if ( |
| 5529 | (literal = _PyPegen_expect_token(p, 16)) |
| 5530 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5531 | (a = lambda_param_no_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5532 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5533 | (b = _loop0_87_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5534 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5535 | (c = lambda_kwds_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5536 | ) |
| 5537 | { |
| 5538 | res = _PyPegen_star_etc ( p , a , b , c ); |
| 5539 | if (res == NULL && PyErr_Occurred()) { |
| 5540 | p->error_indicator = 1; |
| 5541 | return NULL; |
| 5542 | } |
| 5543 | goto done; |
| 5544 | } |
| 5545 | p->mark = mark; |
| 5546 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5547 | { // '*' ',' lambda_param_maybe_default+ lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5548 | asdl_seq * b; |
| 5549 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5550 | Token * literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5551 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5552 | if ( |
| 5553 | (literal = _PyPegen_expect_token(p, 16)) |
| 5554 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5555 | (literal_1 = _PyPegen_expect_token(p, 12)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5556 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5557 | (b = _loop1_88_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5558 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5559 | (c = lambda_kwds_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5560 | ) |
| 5561 | { |
| 5562 | res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 5563 | if (res == NULL && PyErr_Occurred()) { |
| 5564 | p->error_indicator = 1; |
| 5565 | return NULL; |
| 5566 | } |
| 5567 | goto done; |
| 5568 | } |
| 5569 | p->mark = mark; |
| 5570 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5571 | { // lambda_kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5572 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5573 | if ( |
| 5574 | (a = lambda_kwds_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5575 | ) |
| 5576 | { |
| 5577 | res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 5578 | if (res == NULL && PyErr_Occurred()) { |
| 5579 | p->error_indicator = 1; |
| 5580 | return NULL; |
| 5581 | } |
| 5582 | goto done; |
| 5583 | } |
| 5584 | p->mark = mark; |
| 5585 | } |
| 5586 | res = NULL; |
| 5587 | done: |
| 5588 | return res; |
| 5589 | } |
| 5590 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5591 | // lambda_kwds: '**' lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5592 | static arg_ty |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5593 | lambda_kwds_rule(Parser *p) |
| 5594 | { |
| 5595 | if (p->error_indicator) { |
| 5596 | return NULL; |
| 5597 | } |
| 5598 | arg_ty res = NULL; |
| 5599 | int mark = p->mark; |
| 5600 | { // '**' lambda_param_no_default |
| 5601 | arg_ty a; |
| 5602 | Token * literal; |
| 5603 | if ( |
| 5604 | (literal = _PyPegen_expect_token(p, 35)) |
| 5605 | && |
| 5606 | (a = lambda_param_no_default_rule(p)) |
| 5607 | ) |
| 5608 | { |
| 5609 | res = a; |
| 5610 | if (res == NULL && PyErr_Occurred()) { |
| 5611 | p->error_indicator = 1; |
| 5612 | return NULL; |
| 5613 | } |
| 5614 | goto done; |
| 5615 | } |
| 5616 | p->mark = mark; |
| 5617 | } |
| 5618 | res = NULL; |
| 5619 | done: |
| 5620 | return res; |
| 5621 | } |
| 5622 | |
| 5623 | // lambda_param_no_default: lambda_param ',' | lambda_param &':' |
| 5624 | static arg_ty |
| 5625 | lambda_param_no_default_rule(Parser *p) |
| 5626 | { |
| 5627 | if (p->error_indicator) { |
| 5628 | return NULL; |
| 5629 | } |
| 5630 | arg_ty res = NULL; |
| 5631 | int mark = p->mark; |
| 5632 | { // lambda_param ',' |
| 5633 | arg_ty a; |
| 5634 | Token * literal; |
| 5635 | if ( |
| 5636 | (a = lambda_param_rule(p)) |
| 5637 | && |
| 5638 | (literal = _PyPegen_expect_token(p, 12)) |
| 5639 | ) |
| 5640 | { |
| 5641 | res = a; |
| 5642 | if (res == NULL && PyErr_Occurred()) { |
| 5643 | p->error_indicator = 1; |
| 5644 | return NULL; |
| 5645 | } |
| 5646 | goto done; |
| 5647 | } |
| 5648 | p->mark = mark; |
| 5649 | } |
| 5650 | { // lambda_param &':' |
| 5651 | arg_ty a; |
| 5652 | if ( |
| 5653 | (a = lambda_param_rule(p)) |
| 5654 | && |
| 5655 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) |
| 5656 | ) |
| 5657 | { |
| 5658 | res = a; |
| 5659 | if (res == NULL && PyErr_Occurred()) { |
| 5660 | p->error_indicator = 1; |
| 5661 | return NULL; |
| 5662 | } |
| 5663 | goto done; |
| 5664 | } |
| 5665 | p->mark = mark; |
| 5666 | } |
| 5667 | res = NULL; |
| 5668 | done: |
| 5669 | return res; |
| 5670 | } |
| 5671 | |
| 5672 | // lambda_param_with_default: lambda_param default ',' | lambda_param default &':' |
| 5673 | static NameDefaultPair* |
| 5674 | lambda_param_with_default_rule(Parser *p) |
| 5675 | { |
| 5676 | if (p->error_indicator) { |
| 5677 | return NULL; |
| 5678 | } |
| 5679 | NameDefaultPair* res = NULL; |
| 5680 | int mark = p->mark; |
| 5681 | { // lambda_param default ',' |
| 5682 | arg_ty a; |
| 5683 | expr_ty c; |
| 5684 | Token * literal; |
| 5685 | if ( |
| 5686 | (a = lambda_param_rule(p)) |
| 5687 | && |
| 5688 | (c = default_rule(p)) |
| 5689 | && |
| 5690 | (literal = _PyPegen_expect_token(p, 12)) |
| 5691 | ) |
| 5692 | { |
| 5693 | res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5694 | if (res == NULL && PyErr_Occurred()) { |
| 5695 | p->error_indicator = 1; |
| 5696 | return NULL; |
| 5697 | } |
| 5698 | goto done; |
| 5699 | } |
| 5700 | p->mark = mark; |
| 5701 | } |
| 5702 | { // lambda_param default &':' |
| 5703 | arg_ty a; |
| 5704 | expr_ty c; |
| 5705 | if ( |
| 5706 | (a = lambda_param_rule(p)) |
| 5707 | && |
| 5708 | (c = default_rule(p)) |
| 5709 | && |
| 5710 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) |
| 5711 | ) |
| 5712 | { |
| 5713 | res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5714 | if (res == NULL && PyErr_Occurred()) { |
| 5715 | p->error_indicator = 1; |
| 5716 | return NULL; |
| 5717 | } |
| 5718 | goto done; |
| 5719 | } |
| 5720 | p->mark = mark; |
| 5721 | } |
| 5722 | res = NULL; |
| 5723 | done: |
| 5724 | return res; |
| 5725 | } |
| 5726 | |
| 5727 | // lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':' |
| 5728 | static NameDefaultPair* |
| 5729 | lambda_param_maybe_default_rule(Parser *p) |
| 5730 | { |
| 5731 | if (p->error_indicator) { |
| 5732 | return NULL; |
| 5733 | } |
| 5734 | NameDefaultPair* res = NULL; |
| 5735 | int mark = p->mark; |
| 5736 | { // lambda_param default? ',' |
| 5737 | arg_ty a; |
| 5738 | void *c; |
| 5739 | Token * literal; |
| 5740 | if ( |
| 5741 | (a = lambda_param_rule(p)) |
| 5742 | && |
| 5743 | (c = default_rule(p), 1) |
| 5744 | && |
| 5745 | (literal = _PyPegen_expect_token(p, 12)) |
| 5746 | ) |
| 5747 | { |
| 5748 | res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5749 | if (res == NULL && PyErr_Occurred()) { |
| 5750 | p->error_indicator = 1; |
| 5751 | return NULL; |
| 5752 | } |
| 5753 | goto done; |
| 5754 | } |
| 5755 | p->mark = mark; |
| 5756 | } |
| 5757 | { // lambda_param default? &':' |
| 5758 | arg_ty a; |
| 5759 | void *c; |
| 5760 | if ( |
| 5761 | (a = lambda_param_rule(p)) |
| 5762 | && |
| 5763 | (c = default_rule(p), 1) |
| 5764 | && |
| 5765 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) |
| 5766 | ) |
| 5767 | { |
| 5768 | res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5769 | if (res == NULL && PyErr_Occurred()) { |
| 5770 | p->error_indicator = 1; |
| 5771 | return NULL; |
| 5772 | } |
| 5773 | goto done; |
| 5774 | } |
| 5775 | p->mark = mark; |
| 5776 | } |
| 5777 | res = NULL; |
| 5778 | done: |
| 5779 | return res; |
| 5780 | } |
| 5781 | |
| 5782 | // lambda_param: NAME |
| 5783 | static arg_ty |
| 5784 | lambda_param_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5785 | { |
| 5786 | if (p->error_indicator) { |
| 5787 | return NULL; |
| 5788 | } |
| 5789 | arg_ty res = NULL; |
| 5790 | int mark = p->mark; |
| 5791 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5792 | p->error_indicator = 1; |
| 5793 | return NULL; |
| 5794 | } |
| 5795 | int start_lineno = p->tokens[mark]->lineno; |
| 5796 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5797 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5798 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5799 | { // NAME |
| 5800 | expr_ty a; |
| 5801 | if ( |
| 5802 | (a = _PyPegen_name_token(p)) |
| 5803 | ) |
| 5804 | { |
| 5805 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5806 | if (token == NULL) { |
| 5807 | return NULL; |
| 5808 | } |
| 5809 | int end_lineno = token->end_lineno; |
| 5810 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5811 | int end_col_offset = token->end_col_offset; |
| 5812 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5813 | res = _Py_arg ( a -> v . Name . id , NULL , NULL , EXTRA ); |
| 5814 | if (res == NULL && PyErr_Occurred()) { |
| 5815 | p->error_indicator = 1; |
| 5816 | return NULL; |
| 5817 | } |
| 5818 | goto done; |
| 5819 | } |
| 5820 | p->mark = mark; |
| 5821 | } |
| 5822 | res = NULL; |
| 5823 | done: |
| 5824 | return res; |
| 5825 | } |
| 5826 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5827 | // disjunction: conjunction (('or' conjunction))+ | conjunction |
| 5828 | static expr_ty |
| 5829 | disjunction_rule(Parser *p) |
| 5830 | { |
| 5831 | if (p->error_indicator) { |
| 5832 | return NULL; |
| 5833 | } |
| 5834 | expr_ty res = NULL; |
| 5835 | if (_PyPegen_is_memoized(p, disjunction_type, &res)) |
| 5836 | return res; |
| 5837 | int mark = p->mark; |
| 5838 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5839 | p->error_indicator = 1; |
| 5840 | return NULL; |
| 5841 | } |
| 5842 | int start_lineno = p->tokens[mark]->lineno; |
| 5843 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5844 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5845 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5846 | { // conjunction (('or' conjunction))+ |
| 5847 | expr_ty a; |
| 5848 | asdl_seq * b; |
| 5849 | if ( |
| 5850 | (a = conjunction_rule(p)) |
| 5851 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5852 | (b = _loop1_89_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5853 | ) |
| 5854 | { |
| 5855 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5856 | if (token == NULL) { |
| 5857 | return NULL; |
| 5858 | } |
| 5859 | int end_lineno = token->end_lineno; |
| 5860 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5861 | int end_col_offset = token->end_col_offset; |
| 5862 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5863 | res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
| 5864 | if (res == NULL && PyErr_Occurred()) { |
| 5865 | p->error_indicator = 1; |
| 5866 | return NULL; |
| 5867 | } |
| 5868 | goto done; |
| 5869 | } |
| 5870 | p->mark = mark; |
| 5871 | } |
| 5872 | { // conjunction |
| 5873 | expr_ty conjunction_var; |
| 5874 | if ( |
| 5875 | (conjunction_var = conjunction_rule(p)) |
| 5876 | ) |
| 5877 | { |
| 5878 | res = conjunction_var; |
| 5879 | goto done; |
| 5880 | } |
| 5881 | p->mark = mark; |
| 5882 | } |
| 5883 | res = NULL; |
| 5884 | done: |
| 5885 | _PyPegen_insert_memo(p, mark, disjunction_type, res); |
| 5886 | return res; |
| 5887 | } |
| 5888 | |
| 5889 | // conjunction: inversion (('and' inversion))+ | inversion |
| 5890 | static expr_ty |
| 5891 | conjunction_rule(Parser *p) |
| 5892 | { |
| 5893 | if (p->error_indicator) { |
| 5894 | return NULL; |
| 5895 | } |
| 5896 | expr_ty res = NULL; |
| 5897 | if (_PyPegen_is_memoized(p, conjunction_type, &res)) |
| 5898 | return res; |
| 5899 | int mark = p->mark; |
| 5900 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5901 | p->error_indicator = 1; |
| 5902 | return NULL; |
| 5903 | } |
| 5904 | int start_lineno = p->tokens[mark]->lineno; |
| 5905 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5906 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5907 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5908 | { // inversion (('and' inversion))+ |
| 5909 | expr_ty a; |
| 5910 | asdl_seq * b; |
| 5911 | if ( |
| 5912 | (a = inversion_rule(p)) |
| 5913 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5914 | (b = _loop1_90_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5915 | ) |
| 5916 | { |
| 5917 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5918 | if (token == NULL) { |
| 5919 | return NULL; |
| 5920 | } |
| 5921 | int end_lineno = token->end_lineno; |
| 5922 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5923 | int end_col_offset = token->end_col_offset; |
| 5924 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5925 | res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
| 5926 | if (res == NULL && PyErr_Occurred()) { |
| 5927 | p->error_indicator = 1; |
| 5928 | return NULL; |
| 5929 | } |
| 5930 | goto done; |
| 5931 | } |
| 5932 | p->mark = mark; |
| 5933 | } |
| 5934 | { // inversion |
| 5935 | expr_ty inversion_var; |
| 5936 | if ( |
| 5937 | (inversion_var = inversion_rule(p)) |
| 5938 | ) |
| 5939 | { |
| 5940 | res = inversion_var; |
| 5941 | goto done; |
| 5942 | } |
| 5943 | p->mark = mark; |
| 5944 | } |
| 5945 | res = NULL; |
| 5946 | done: |
| 5947 | _PyPegen_insert_memo(p, mark, conjunction_type, res); |
| 5948 | return res; |
| 5949 | } |
| 5950 | |
| 5951 | // inversion: 'not' inversion | comparison |
| 5952 | static expr_ty |
| 5953 | inversion_rule(Parser *p) |
| 5954 | { |
| 5955 | if (p->error_indicator) { |
| 5956 | return NULL; |
| 5957 | } |
| 5958 | expr_ty res = NULL; |
| 5959 | if (_PyPegen_is_memoized(p, inversion_type, &res)) |
| 5960 | return res; |
| 5961 | int mark = p->mark; |
| 5962 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5963 | p->error_indicator = 1; |
| 5964 | return NULL; |
| 5965 | } |
| 5966 | int start_lineno = p->tokens[mark]->lineno; |
| 5967 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 5968 | int start_col_offset = p->tokens[mark]->col_offset; |
| 5969 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 5970 | { // 'not' inversion |
| 5971 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 5972 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5973 | if ( |
| 5974 | (keyword = _PyPegen_expect_token(p, 525)) |
| 5975 | && |
| 5976 | (a = inversion_rule(p)) |
| 5977 | ) |
| 5978 | { |
| 5979 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5980 | if (token == NULL) { |
| 5981 | return NULL; |
| 5982 | } |
| 5983 | int end_lineno = token->end_lineno; |
| 5984 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 5985 | int end_col_offset = token->end_col_offset; |
| 5986 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 5987 | res = _Py_UnaryOp ( Not , a , EXTRA ); |
| 5988 | if (res == NULL && PyErr_Occurred()) { |
| 5989 | p->error_indicator = 1; |
| 5990 | return NULL; |
| 5991 | } |
| 5992 | goto done; |
| 5993 | } |
| 5994 | p->mark = mark; |
| 5995 | } |
| 5996 | { // comparison |
| 5997 | expr_ty comparison_var; |
| 5998 | if ( |
| 5999 | (comparison_var = comparison_rule(p)) |
| 6000 | ) |
| 6001 | { |
| 6002 | res = comparison_var; |
| 6003 | goto done; |
| 6004 | } |
| 6005 | p->mark = mark; |
| 6006 | } |
| 6007 | res = NULL; |
| 6008 | done: |
| 6009 | _PyPegen_insert_memo(p, mark, inversion_type, res); |
| 6010 | return res; |
| 6011 | } |
| 6012 | |
| 6013 | // comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or |
| 6014 | static expr_ty |
| 6015 | comparison_rule(Parser *p) |
| 6016 | { |
| 6017 | if (p->error_indicator) { |
| 6018 | return NULL; |
| 6019 | } |
| 6020 | expr_ty res = NULL; |
| 6021 | int mark = p->mark; |
| 6022 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6023 | p->error_indicator = 1; |
| 6024 | return NULL; |
| 6025 | } |
| 6026 | int start_lineno = p->tokens[mark]->lineno; |
| 6027 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6028 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6029 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6030 | { // bitwise_or compare_op_bitwise_or_pair+ |
| 6031 | expr_ty a; |
| 6032 | asdl_seq * b; |
| 6033 | if ( |
| 6034 | (a = bitwise_or_rule(p)) |
| 6035 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6036 | (b = _loop1_91_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6037 | ) |
| 6038 | { |
| 6039 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6040 | if (token == NULL) { |
| 6041 | return NULL; |
| 6042 | } |
| 6043 | int end_lineno = token->end_lineno; |
| 6044 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6045 | int end_col_offset = token->end_col_offset; |
| 6046 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6047 | res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA ); |
| 6048 | if (res == NULL && PyErr_Occurred()) { |
| 6049 | p->error_indicator = 1; |
| 6050 | return NULL; |
| 6051 | } |
| 6052 | goto done; |
| 6053 | } |
| 6054 | p->mark = mark; |
| 6055 | } |
| 6056 | { // bitwise_or |
| 6057 | expr_ty bitwise_or_var; |
| 6058 | if ( |
| 6059 | (bitwise_or_var = bitwise_or_rule(p)) |
| 6060 | ) |
| 6061 | { |
| 6062 | res = bitwise_or_var; |
| 6063 | goto done; |
| 6064 | } |
| 6065 | p->mark = mark; |
| 6066 | } |
| 6067 | res = NULL; |
| 6068 | done: |
| 6069 | return res; |
| 6070 | } |
| 6071 | |
| 6072 | // compare_op_bitwise_or_pair: |
| 6073 | // | eq_bitwise_or |
| 6074 | // | noteq_bitwise_or |
| 6075 | // | lte_bitwise_or |
| 6076 | // | lt_bitwise_or |
| 6077 | // | gte_bitwise_or |
| 6078 | // | gt_bitwise_or |
| 6079 | // | notin_bitwise_or |
| 6080 | // | in_bitwise_or |
| 6081 | // | isnot_bitwise_or |
| 6082 | // | is_bitwise_or |
| 6083 | static CmpopExprPair* |
| 6084 | compare_op_bitwise_or_pair_rule(Parser *p) |
| 6085 | { |
| 6086 | if (p->error_indicator) { |
| 6087 | return NULL; |
| 6088 | } |
| 6089 | CmpopExprPair* res = NULL; |
| 6090 | int mark = p->mark; |
| 6091 | { // eq_bitwise_or |
| 6092 | CmpopExprPair* eq_bitwise_or_var; |
| 6093 | if ( |
| 6094 | (eq_bitwise_or_var = eq_bitwise_or_rule(p)) |
| 6095 | ) |
| 6096 | { |
| 6097 | res = eq_bitwise_or_var; |
| 6098 | goto done; |
| 6099 | } |
| 6100 | p->mark = mark; |
| 6101 | } |
| 6102 | { // noteq_bitwise_or |
| 6103 | CmpopExprPair* noteq_bitwise_or_var; |
| 6104 | if ( |
| 6105 | (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) |
| 6106 | ) |
| 6107 | { |
| 6108 | res = noteq_bitwise_or_var; |
| 6109 | goto done; |
| 6110 | } |
| 6111 | p->mark = mark; |
| 6112 | } |
| 6113 | { // lte_bitwise_or |
| 6114 | CmpopExprPair* lte_bitwise_or_var; |
| 6115 | if ( |
| 6116 | (lte_bitwise_or_var = lte_bitwise_or_rule(p)) |
| 6117 | ) |
| 6118 | { |
| 6119 | res = lte_bitwise_or_var; |
| 6120 | goto done; |
| 6121 | } |
| 6122 | p->mark = mark; |
| 6123 | } |
| 6124 | { // lt_bitwise_or |
| 6125 | CmpopExprPair* lt_bitwise_or_var; |
| 6126 | if ( |
| 6127 | (lt_bitwise_or_var = lt_bitwise_or_rule(p)) |
| 6128 | ) |
| 6129 | { |
| 6130 | res = lt_bitwise_or_var; |
| 6131 | goto done; |
| 6132 | } |
| 6133 | p->mark = mark; |
| 6134 | } |
| 6135 | { // gte_bitwise_or |
| 6136 | CmpopExprPair* gte_bitwise_or_var; |
| 6137 | if ( |
| 6138 | (gte_bitwise_or_var = gte_bitwise_or_rule(p)) |
| 6139 | ) |
| 6140 | { |
| 6141 | res = gte_bitwise_or_var; |
| 6142 | goto done; |
| 6143 | } |
| 6144 | p->mark = mark; |
| 6145 | } |
| 6146 | { // gt_bitwise_or |
| 6147 | CmpopExprPair* gt_bitwise_or_var; |
| 6148 | if ( |
| 6149 | (gt_bitwise_or_var = gt_bitwise_or_rule(p)) |
| 6150 | ) |
| 6151 | { |
| 6152 | res = gt_bitwise_or_var; |
| 6153 | goto done; |
| 6154 | } |
| 6155 | p->mark = mark; |
| 6156 | } |
| 6157 | { // notin_bitwise_or |
| 6158 | CmpopExprPair* notin_bitwise_or_var; |
| 6159 | if ( |
| 6160 | (notin_bitwise_or_var = notin_bitwise_or_rule(p)) |
| 6161 | ) |
| 6162 | { |
| 6163 | res = notin_bitwise_or_var; |
| 6164 | goto done; |
| 6165 | } |
| 6166 | p->mark = mark; |
| 6167 | } |
| 6168 | { // in_bitwise_or |
| 6169 | CmpopExprPair* in_bitwise_or_var; |
| 6170 | if ( |
| 6171 | (in_bitwise_or_var = in_bitwise_or_rule(p)) |
| 6172 | ) |
| 6173 | { |
| 6174 | res = in_bitwise_or_var; |
| 6175 | goto done; |
| 6176 | } |
| 6177 | p->mark = mark; |
| 6178 | } |
| 6179 | { // isnot_bitwise_or |
| 6180 | CmpopExprPair* isnot_bitwise_or_var; |
| 6181 | if ( |
| 6182 | (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) |
| 6183 | ) |
| 6184 | { |
| 6185 | res = isnot_bitwise_or_var; |
| 6186 | goto done; |
| 6187 | } |
| 6188 | p->mark = mark; |
| 6189 | } |
| 6190 | { // is_bitwise_or |
| 6191 | CmpopExprPair* is_bitwise_or_var; |
| 6192 | if ( |
| 6193 | (is_bitwise_or_var = is_bitwise_or_rule(p)) |
| 6194 | ) |
| 6195 | { |
| 6196 | res = is_bitwise_or_var; |
| 6197 | goto done; |
| 6198 | } |
| 6199 | p->mark = mark; |
| 6200 | } |
| 6201 | res = NULL; |
| 6202 | done: |
| 6203 | return res; |
| 6204 | } |
| 6205 | |
| 6206 | // eq_bitwise_or: '==' bitwise_or |
| 6207 | static CmpopExprPair* |
| 6208 | eq_bitwise_or_rule(Parser *p) |
| 6209 | { |
| 6210 | if (p->error_indicator) { |
| 6211 | return NULL; |
| 6212 | } |
| 6213 | CmpopExprPair* res = NULL; |
| 6214 | int mark = p->mark; |
| 6215 | { // '==' bitwise_or |
| 6216 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6217 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6218 | if ( |
| 6219 | (literal = _PyPegen_expect_token(p, 27)) |
| 6220 | && |
| 6221 | (a = bitwise_or_rule(p)) |
| 6222 | ) |
| 6223 | { |
| 6224 | res = _PyPegen_cmpop_expr_pair ( p , Eq , a ); |
| 6225 | if (res == NULL && PyErr_Occurred()) { |
| 6226 | p->error_indicator = 1; |
| 6227 | return NULL; |
| 6228 | } |
| 6229 | goto done; |
| 6230 | } |
| 6231 | p->mark = mark; |
| 6232 | } |
| 6233 | res = NULL; |
| 6234 | done: |
| 6235 | return res; |
| 6236 | } |
| 6237 | |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 6238 | // noteq_bitwise_or: ('!=') bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6239 | static CmpopExprPair* |
| 6240 | noteq_bitwise_or_rule(Parser *p) |
| 6241 | { |
| 6242 | if (p->error_indicator) { |
| 6243 | return NULL; |
| 6244 | } |
| 6245 | CmpopExprPair* res = NULL; |
| 6246 | int mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 6247 | { // ('!=') bitwise_or |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6248 | void *_tmp_92_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6249 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6250 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6251 | (_tmp_92_var = _tmp_92_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6252 | && |
| 6253 | (a = bitwise_or_rule(p)) |
| 6254 | ) |
| 6255 | { |
| 6256 | res = _PyPegen_cmpop_expr_pair ( p , NotEq , a ); |
| 6257 | if (res == NULL && PyErr_Occurred()) { |
| 6258 | p->error_indicator = 1; |
| 6259 | return NULL; |
| 6260 | } |
| 6261 | goto done; |
| 6262 | } |
| 6263 | p->mark = mark; |
| 6264 | } |
| 6265 | res = NULL; |
| 6266 | done: |
| 6267 | return res; |
| 6268 | } |
| 6269 | |
| 6270 | // lte_bitwise_or: '<=' bitwise_or |
| 6271 | static CmpopExprPair* |
| 6272 | lte_bitwise_or_rule(Parser *p) |
| 6273 | { |
| 6274 | if (p->error_indicator) { |
| 6275 | return NULL; |
| 6276 | } |
| 6277 | CmpopExprPair* res = NULL; |
| 6278 | int mark = p->mark; |
| 6279 | { // '<=' bitwise_or |
| 6280 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6281 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6282 | if ( |
| 6283 | (literal = _PyPegen_expect_token(p, 29)) |
| 6284 | && |
| 6285 | (a = bitwise_or_rule(p)) |
| 6286 | ) |
| 6287 | { |
| 6288 | res = _PyPegen_cmpop_expr_pair ( p , LtE , a ); |
| 6289 | if (res == NULL && PyErr_Occurred()) { |
| 6290 | p->error_indicator = 1; |
| 6291 | return NULL; |
| 6292 | } |
| 6293 | goto done; |
| 6294 | } |
| 6295 | p->mark = mark; |
| 6296 | } |
| 6297 | res = NULL; |
| 6298 | done: |
| 6299 | return res; |
| 6300 | } |
| 6301 | |
| 6302 | // lt_bitwise_or: '<' bitwise_or |
| 6303 | static CmpopExprPair* |
| 6304 | lt_bitwise_or_rule(Parser *p) |
| 6305 | { |
| 6306 | if (p->error_indicator) { |
| 6307 | return NULL; |
| 6308 | } |
| 6309 | CmpopExprPair* res = NULL; |
| 6310 | int mark = p->mark; |
| 6311 | { // '<' bitwise_or |
| 6312 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6313 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6314 | if ( |
| 6315 | (literal = _PyPegen_expect_token(p, 20)) |
| 6316 | && |
| 6317 | (a = bitwise_or_rule(p)) |
| 6318 | ) |
| 6319 | { |
| 6320 | res = _PyPegen_cmpop_expr_pair ( p , Lt , a ); |
| 6321 | if (res == NULL && PyErr_Occurred()) { |
| 6322 | p->error_indicator = 1; |
| 6323 | return NULL; |
| 6324 | } |
| 6325 | goto done; |
| 6326 | } |
| 6327 | p->mark = mark; |
| 6328 | } |
| 6329 | res = NULL; |
| 6330 | done: |
| 6331 | return res; |
| 6332 | } |
| 6333 | |
| 6334 | // gte_bitwise_or: '>=' bitwise_or |
| 6335 | static CmpopExprPair* |
| 6336 | gte_bitwise_or_rule(Parser *p) |
| 6337 | { |
| 6338 | if (p->error_indicator) { |
| 6339 | return NULL; |
| 6340 | } |
| 6341 | CmpopExprPair* res = NULL; |
| 6342 | int mark = p->mark; |
| 6343 | { // '>=' bitwise_or |
| 6344 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6345 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6346 | if ( |
| 6347 | (literal = _PyPegen_expect_token(p, 30)) |
| 6348 | && |
| 6349 | (a = bitwise_or_rule(p)) |
| 6350 | ) |
| 6351 | { |
| 6352 | res = _PyPegen_cmpop_expr_pair ( p , GtE , a ); |
| 6353 | if (res == NULL && PyErr_Occurred()) { |
| 6354 | p->error_indicator = 1; |
| 6355 | return NULL; |
| 6356 | } |
| 6357 | goto done; |
| 6358 | } |
| 6359 | p->mark = mark; |
| 6360 | } |
| 6361 | res = NULL; |
| 6362 | done: |
| 6363 | return res; |
| 6364 | } |
| 6365 | |
| 6366 | // gt_bitwise_or: '>' bitwise_or |
| 6367 | static CmpopExprPair* |
| 6368 | gt_bitwise_or_rule(Parser *p) |
| 6369 | { |
| 6370 | if (p->error_indicator) { |
| 6371 | return NULL; |
| 6372 | } |
| 6373 | CmpopExprPair* res = NULL; |
| 6374 | int mark = p->mark; |
| 6375 | { // '>' bitwise_or |
| 6376 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6377 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6378 | if ( |
| 6379 | (literal = _PyPegen_expect_token(p, 21)) |
| 6380 | && |
| 6381 | (a = bitwise_or_rule(p)) |
| 6382 | ) |
| 6383 | { |
| 6384 | res = _PyPegen_cmpop_expr_pair ( p , Gt , a ); |
| 6385 | if (res == NULL && PyErr_Occurred()) { |
| 6386 | p->error_indicator = 1; |
| 6387 | return NULL; |
| 6388 | } |
| 6389 | goto done; |
| 6390 | } |
| 6391 | p->mark = mark; |
| 6392 | } |
| 6393 | res = NULL; |
| 6394 | done: |
| 6395 | return res; |
| 6396 | } |
| 6397 | |
| 6398 | // notin_bitwise_or: 'not' 'in' bitwise_or |
| 6399 | static CmpopExprPair* |
| 6400 | notin_bitwise_or_rule(Parser *p) |
| 6401 | { |
| 6402 | if (p->error_indicator) { |
| 6403 | return NULL; |
| 6404 | } |
| 6405 | CmpopExprPair* res = NULL; |
| 6406 | int mark = p->mark; |
| 6407 | { // 'not' 'in' bitwise_or |
| 6408 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6409 | Token * keyword; |
| 6410 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6411 | if ( |
| 6412 | (keyword = _PyPegen_expect_token(p, 525)) |
| 6413 | && |
| 6414 | (keyword_1 = _PyPegen_expect_token(p, 518)) |
| 6415 | && |
| 6416 | (a = bitwise_or_rule(p)) |
| 6417 | ) |
| 6418 | { |
| 6419 | res = _PyPegen_cmpop_expr_pair ( p , NotIn , a ); |
| 6420 | if (res == NULL && PyErr_Occurred()) { |
| 6421 | p->error_indicator = 1; |
| 6422 | return NULL; |
| 6423 | } |
| 6424 | goto done; |
| 6425 | } |
| 6426 | p->mark = mark; |
| 6427 | } |
| 6428 | res = NULL; |
| 6429 | done: |
| 6430 | return res; |
| 6431 | } |
| 6432 | |
| 6433 | // in_bitwise_or: 'in' bitwise_or |
| 6434 | static CmpopExprPair* |
| 6435 | in_bitwise_or_rule(Parser *p) |
| 6436 | { |
| 6437 | if (p->error_indicator) { |
| 6438 | return NULL; |
| 6439 | } |
| 6440 | CmpopExprPair* res = NULL; |
| 6441 | int mark = p->mark; |
| 6442 | { // 'in' bitwise_or |
| 6443 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6444 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6445 | if ( |
| 6446 | (keyword = _PyPegen_expect_token(p, 518)) |
| 6447 | && |
| 6448 | (a = bitwise_or_rule(p)) |
| 6449 | ) |
| 6450 | { |
| 6451 | res = _PyPegen_cmpop_expr_pair ( p , In , a ); |
| 6452 | if (res == NULL && PyErr_Occurred()) { |
| 6453 | p->error_indicator = 1; |
| 6454 | return NULL; |
| 6455 | } |
| 6456 | goto done; |
| 6457 | } |
| 6458 | p->mark = mark; |
| 6459 | } |
| 6460 | res = NULL; |
| 6461 | done: |
| 6462 | return res; |
| 6463 | } |
| 6464 | |
| 6465 | // isnot_bitwise_or: 'is' 'not' bitwise_or |
| 6466 | static CmpopExprPair* |
| 6467 | isnot_bitwise_or_rule(Parser *p) |
| 6468 | { |
| 6469 | if (p->error_indicator) { |
| 6470 | return NULL; |
| 6471 | } |
| 6472 | CmpopExprPair* res = NULL; |
| 6473 | int mark = p->mark; |
| 6474 | { // 'is' 'not' bitwise_or |
| 6475 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6476 | Token * keyword; |
| 6477 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6478 | if ( |
| 6479 | (keyword = _PyPegen_expect_token(p, 526)) |
| 6480 | && |
| 6481 | (keyword_1 = _PyPegen_expect_token(p, 525)) |
| 6482 | && |
| 6483 | (a = bitwise_or_rule(p)) |
| 6484 | ) |
| 6485 | { |
| 6486 | res = _PyPegen_cmpop_expr_pair ( p , IsNot , a ); |
| 6487 | if (res == NULL && PyErr_Occurred()) { |
| 6488 | p->error_indicator = 1; |
| 6489 | return NULL; |
| 6490 | } |
| 6491 | goto done; |
| 6492 | } |
| 6493 | p->mark = mark; |
| 6494 | } |
| 6495 | res = NULL; |
| 6496 | done: |
| 6497 | return res; |
| 6498 | } |
| 6499 | |
| 6500 | // is_bitwise_or: 'is' bitwise_or |
| 6501 | static CmpopExprPair* |
| 6502 | is_bitwise_or_rule(Parser *p) |
| 6503 | { |
| 6504 | if (p->error_indicator) { |
| 6505 | return NULL; |
| 6506 | } |
| 6507 | CmpopExprPair* res = NULL; |
| 6508 | int mark = p->mark; |
| 6509 | { // 'is' bitwise_or |
| 6510 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6511 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6512 | if ( |
| 6513 | (keyword = _PyPegen_expect_token(p, 526)) |
| 6514 | && |
| 6515 | (a = bitwise_or_rule(p)) |
| 6516 | ) |
| 6517 | { |
| 6518 | res = _PyPegen_cmpop_expr_pair ( p , Is , a ); |
| 6519 | if (res == NULL && PyErr_Occurred()) { |
| 6520 | p->error_indicator = 1; |
| 6521 | return NULL; |
| 6522 | } |
| 6523 | goto done; |
| 6524 | } |
| 6525 | p->mark = mark; |
| 6526 | } |
| 6527 | res = NULL; |
| 6528 | done: |
| 6529 | return res; |
| 6530 | } |
| 6531 | |
| 6532 | // Left-recursive |
| 6533 | // bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor |
| 6534 | static expr_ty bitwise_or_raw(Parser *); |
| 6535 | static expr_ty |
| 6536 | bitwise_or_rule(Parser *p) |
| 6537 | { |
| 6538 | expr_ty res = NULL; |
| 6539 | if (_PyPegen_is_memoized(p, bitwise_or_type, &res)) |
| 6540 | return res; |
| 6541 | int mark = p->mark; |
| 6542 | int resmark = p->mark; |
| 6543 | while (1) { |
| 6544 | int tmpvar_1 = _PyPegen_update_memo(p, mark, bitwise_or_type, res); |
| 6545 | if (tmpvar_1) { |
| 6546 | return res; |
| 6547 | } |
| 6548 | p->mark = mark; |
| 6549 | void *raw = bitwise_or_raw(p); |
| 6550 | if (raw == NULL || p->mark <= resmark) |
| 6551 | break; |
| 6552 | resmark = p->mark; |
| 6553 | res = raw; |
| 6554 | } |
| 6555 | p->mark = resmark; |
| 6556 | return res; |
| 6557 | } |
| 6558 | static expr_ty |
| 6559 | bitwise_or_raw(Parser *p) |
| 6560 | { |
| 6561 | if (p->error_indicator) { |
| 6562 | return NULL; |
| 6563 | } |
| 6564 | expr_ty res = NULL; |
| 6565 | int mark = p->mark; |
| 6566 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6567 | p->error_indicator = 1; |
| 6568 | return NULL; |
| 6569 | } |
| 6570 | int start_lineno = p->tokens[mark]->lineno; |
| 6571 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6572 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6573 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6574 | { // bitwise_or '|' bitwise_xor |
| 6575 | expr_ty a; |
| 6576 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6577 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6578 | if ( |
| 6579 | (a = bitwise_or_rule(p)) |
| 6580 | && |
| 6581 | (literal = _PyPegen_expect_token(p, 18)) |
| 6582 | && |
| 6583 | (b = bitwise_xor_rule(p)) |
| 6584 | ) |
| 6585 | { |
| 6586 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6587 | if (token == NULL) { |
| 6588 | return NULL; |
| 6589 | } |
| 6590 | int end_lineno = token->end_lineno; |
| 6591 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6592 | int end_col_offset = token->end_col_offset; |
| 6593 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6594 | res = _Py_BinOp ( a , BitOr , b , EXTRA ); |
| 6595 | if (res == NULL && PyErr_Occurred()) { |
| 6596 | p->error_indicator = 1; |
| 6597 | return NULL; |
| 6598 | } |
| 6599 | goto done; |
| 6600 | } |
| 6601 | p->mark = mark; |
| 6602 | } |
| 6603 | { // bitwise_xor |
| 6604 | expr_ty bitwise_xor_var; |
| 6605 | if ( |
| 6606 | (bitwise_xor_var = bitwise_xor_rule(p)) |
| 6607 | ) |
| 6608 | { |
| 6609 | res = bitwise_xor_var; |
| 6610 | goto done; |
| 6611 | } |
| 6612 | p->mark = mark; |
| 6613 | } |
| 6614 | res = NULL; |
| 6615 | done: |
| 6616 | return res; |
| 6617 | } |
| 6618 | |
| 6619 | // Left-recursive |
| 6620 | // bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and |
| 6621 | static expr_ty bitwise_xor_raw(Parser *); |
| 6622 | static expr_ty |
| 6623 | bitwise_xor_rule(Parser *p) |
| 6624 | { |
| 6625 | expr_ty res = NULL; |
| 6626 | if (_PyPegen_is_memoized(p, bitwise_xor_type, &res)) |
| 6627 | return res; |
| 6628 | int mark = p->mark; |
| 6629 | int resmark = p->mark; |
| 6630 | while (1) { |
| 6631 | int tmpvar_2 = _PyPegen_update_memo(p, mark, bitwise_xor_type, res); |
| 6632 | if (tmpvar_2) { |
| 6633 | return res; |
| 6634 | } |
| 6635 | p->mark = mark; |
| 6636 | void *raw = bitwise_xor_raw(p); |
| 6637 | if (raw == NULL || p->mark <= resmark) |
| 6638 | break; |
| 6639 | resmark = p->mark; |
| 6640 | res = raw; |
| 6641 | } |
| 6642 | p->mark = resmark; |
| 6643 | return res; |
| 6644 | } |
| 6645 | static expr_ty |
| 6646 | bitwise_xor_raw(Parser *p) |
| 6647 | { |
| 6648 | if (p->error_indicator) { |
| 6649 | return NULL; |
| 6650 | } |
| 6651 | expr_ty res = NULL; |
| 6652 | int mark = p->mark; |
| 6653 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6654 | p->error_indicator = 1; |
| 6655 | return NULL; |
| 6656 | } |
| 6657 | int start_lineno = p->tokens[mark]->lineno; |
| 6658 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6659 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6660 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6661 | { // bitwise_xor '^' bitwise_and |
| 6662 | expr_ty a; |
| 6663 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6664 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6665 | if ( |
| 6666 | (a = bitwise_xor_rule(p)) |
| 6667 | && |
| 6668 | (literal = _PyPegen_expect_token(p, 32)) |
| 6669 | && |
| 6670 | (b = bitwise_and_rule(p)) |
| 6671 | ) |
| 6672 | { |
| 6673 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6674 | if (token == NULL) { |
| 6675 | return NULL; |
| 6676 | } |
| 6677 | int end_lineno = token->end_lineno; |
| 6678 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6679 | int end_col_offset = token->end_col_offset; |
| 6680 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6681 | res = _Py_BinOp ( a , BitXor , b , EXTRA ); |
| 6682 | if (res == NULL && PyErr_Occurred()) { |
| 6683 | p->error_indicator = 1; |
| 6684 | return NULL; |
| 6685 | } |
| 6686 | goto done; |
| 6687 | } |
| 6688 | p->mark = mark; |
| 6689 | } |
| 6690 | { // bitwise_and |
| 6691 | expr_ty bitwise_and_var; |
| 6692 | if ( |
| 6693 | (bitwise_and_var = bitwise_and_rule(p)) |
| 6694 | ) |
| 6695 | { |
| 6696 | res = bitwise_and_var; |
| 6697 | goto done; |
| 6698 | } |
| 6699 | p->mark = mark; |
| 6700 | } |
| 6701 | res = NULL; |
| 6702 | done: |
| 6703 | return res; |
| 6704 | } |
| 6705 | |
| 6706 | // Left-recursive |
| 6707 | // bitwise_and: bitwise_and '&' shift_expr | shift_expr |
| 6708 | static expr_ty bitwise_and_raw(Parser *); |
| 6709 | static expr_ty |
| 6710 | bitwise_and_rule(Parser *p) |
| 6711 | { |
| 6712 | expr_ty res = NULL; |
| 6713 | if (_PyPegen_is_memoized(p, bitwise_and_type, &res)) |
| 6714 | return res; |
| 6715 | int mark = p->mark; |
| 6716 | int resmark = p->mark; |
| 6717 | while (1) { |
| 6718 | int tmpvar_3 = _PyPegen_update_memo(p, mark, bitwise_and_type, res); |
| 6719 | if (tmpvar_3) { |
| 6720 | return res; |
| 6721 | } |
| 6722 | p->mark = mark; |
| 6723 | void *raw = bitwise_and_raw(p); |
| 6724 | if (raw == NULL || p->mark <= resmark) |
| 6725 | break; |
| 6726 | resmark = p->mark; |
| 6727 | res = raw; |
| 6728 | } |
| 6729 | p->mark = resmark; |
| 6730 | return res; |
| 6731 | } |
| 6732 | static expr_ty |
| 6733 | bitwise_and_raw(Parser *p) |
| 6734 | { |
| 6735 | if (p->error_indicator) { |
| 6736 | return NULL; |
| 6737 | } |
| 6738 | expr_ty res = NULL; |
| 6739 | int mark = p->mark; |
| 6740 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6741 | p->error_indicator = 1; |
| 6742 | return NULL; |
| 6743 | } |
| 6744 | int start_lineno = p->tokens[mark]->lineno; |
| 6745 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6746 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6747 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6748 | { // bitwise_and '&' shift_expr |
| 6749 | expr_ty a; |
| 6750 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6751 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6752 | if ( |
| 6753 | (a = bitwise_and_rule(p)) |
| 6754 | && |
| 6755 | (literal = _PyPegen_expect_token(p, 19)) |
| 6756 | && |
| 6757 | (b = shift_expr_rule(p)) |
| 6758 | ) |
| 6759 | { |
| 6760 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6761 | if (token == NULL) { |
| 6762 | return NULL; |
| 6763 | } |
| 6764 | int end_lineno = token->end_lineno; |
| 6765 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6766 | int end_col_offset = token->end_col_offset; |
| 6767 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6768 | res = _Py_BinOp ( a , BitAnd , b , EXTRA ); |
| 6769 | if (res == NULL && PyErr_Occurred()) { |
| 6770 | p->error_indicator = 1; |
| 6771 | return NULL; |
| 6772 | } |
| 6773 | goto done; |
| 6774 | } |
| 6775 | p->mark = mark; |
| 6776 | } |
| 6777 | { // shift_expr |
| 6778 | expr_ty shift_expr_var; |
| 6779 | if ( |
| 6780 | (shift_expr_var = shift_expr_rule(p)) |
| 6781 | ) |
| 6782 | { |
| 6783 | res = shift_expr_var; |
| 6784 | goto done; |
| 6785 | } |
| 6786 | p->mark = mark; |
| 6787 | } |
| 6788 | res = NULL; |
| 6789 | done: |
| 6790 | return res; |
| 6791 | } |
| 6792 | |
| 6793 | // Left-recursive |
| 6794 | // shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum |
| 6795 | static expr_ty shift_expr_raw(Parser *); |
| 6796 | static expr_ty |
| 6797 | shift_expr_rule(Parser *p) |
| 6798 | { |
| 6799 | expr_ty res = NULL; |
| 6800 | if (_PyPegen_is_memoized(p, shift_expr_type, &res)) |
| 6801 | return res; |
| 6802 | int mark = p->mark; |
| 6803 | int resmark = p->mark; |
| 6804 | while (1) { |
| 6805 | int tmpvar_4 = _PyPegen_update_memo(p, mark, shift_expr_type, res); |
| 6806 | if (tmpvar_4) { |
| 6807 | return res; |
| 6808 | } |
| 6809 | p->mark = mark; |
| 6810 | void *raw = shift_expr_raw(p); |
| 6811 | if (raw == NULL || p->mark <= resmark) |
| 6812 | break; |
| 6813 | resmark = p->mark; |
| 6814 | res = raw; |
| 6815 | } |
| 6816 | p->mark = resmark; |
| 6817 | return res; |
| 6818 | } |
| 6819 | static expr_ty |
| 6820 | shift_expr_raw(Parser *p) |
| 6821 | { |
| 6822 | if (p->error_indicator) { |
| 6823 | return NULL; |
| 6824 | } |
| 6825 | expr_ty res = NULL; |
| 6826 | int mark = p->mark; |
| 6827 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6828 | p->error_indicator = 1; |
| 6829 | return NULL; |
| 6830 | } |
| 6831 | int start_lineno = p->tokens[mark]->lineno; |
| 6832 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6833 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6834 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6835 | { // shift_expr '<<' sum |
| 6836 | expr_ty a; |
| 6837 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6838 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6839 | if ( |
| 6840 | (a = shift_expr_rule(p)) |
| 6841 | && |
| 6842 | (literal = _PyPegen_expect_token(p, 33)) |
| 6843 | && |
| 6844 | (b = sum_rule(p)) |
| 6845 | ) |
| 6846 | { |
| 6847 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6848 | if (token == NULL) { |
| 6849 | return NULL; |
| 6850 | } |
| 6851 | int end_lineno = token->end_lineno; |
| 6852 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6853 | int end_col_offset = token->end_col_offset; |
| 6854 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6855 | res = _Py_BinOp ( a , LShift , b , EXTRA ); |
| 6856 | if (res == NULL && PyErr_Occurred()) { |
| 6857 | p->error_indicator = 1; |
| 6858 | return NULL; |
| 6859 | } |
| 6860 | goto done; |
| 6861 | } |
| 6862 | p->mark = mark; |
| 6863 | } |
| 6864 | { // shift_expr '>>' sum |
| 6865 | expr_ty a; |
| 6866 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6867 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6868 | if ( |
| 6869 | (a = shift_expr_rule(p)) |
| 6870 | && |
| 6871 | (literal = _PyPegen_expect_token(p, 34)) |
| 6872 | && |
| 6873 | (b = sum_rule(p)) |
| 6874 | ) |
| 6875 | { |
| 6876 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6877 | if (token == NULL) { |
| 6878 | return NULL; |
| 6879 | } |
| 6880 | int end_lineno = token->end_lineno; |
| 6881 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6882 | int end_col_offset = token->end_col_offset; |
| 6883 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6884 | res = _Py_BinOp ( a , RShift , b , EXTRA ); |
| 6885 | if (res == NULL && PyErr_Occurred()) { |
| 6886 | p->error_indicator = 1; |
| 6887 | return NULL; |
| 6888 | } |
| 6889 | goto done; |
| 6890 | } |
| 6891 | p->mark = mark; |
| 6892 | } |
| 6893 | { // sum |
| 6894 | expr_ty sum_var; |
| 6895 | if ( |
| 6896 | (sum_var = sum_rule(p)) |
| 6897 | ) |
| 6898 | { |
| 6899 | res = sum_var; |
| 6900 | goto done; |
| 6901 | } |
| 6902 | p->mark = mark; |
| 6903 | } |
| 6904 | res = NULL; |
| 6905 | done: |
| 6906 | return res; |
| 6907 | } |
| 6908 | |
| 6909 | // Left-recursive |
| 6910 | // sum: sum '+' term | sum '-' term | term |
| 6911 | static expr_ty sum_raw(Parser *); |
| 6912 | static expr_ty |
| 6913 | sum_rule(Parser *p) |
| 6914 | { |
| 6915 | expr_ty res = NULL; |
| 6916 | if (_PyPegen_is_memoized(p, sum_type, &res)) |
| 6917 | return res; |
| 6918 | int mark = p->mark; |
| 6919 | int resmark = p->mark; |
| 6920 | while (1) { |
| 6921 | int tmpvar_5 = _PyPegen_update_memo(p, mark, sum_type, res); |
| 6922 | if (tmpvar_5) { |
| 6923 | return res; |
| 6924 | } |
| 6925 | p->mark = mark; |
| 6926 | void *raw = sum_raw(p); |
| 6927 | if (raw == NULL || p->mark <= resmark) |
| 6928 | break; |
| 6929 | resmark = p->mark; |
| 6930 | res = raw; |
| 6931 | } |
| 6932 | p->mark = resmark; |
| 6933 | return res; |
| 6934 | } |
| 6935 | static expr_ty |
| 6936 | sum_raw(Parser *p) |
| 6937 | { |
| 6938 | if (p->error_indicator) { |
| 6939 | return NULL; |
| 6940 | } |
| 6941 | expr_ty res = NULL; |
| 6942 | int mark = p->mark; |
| 6943 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6944 | p->error_indicator = 1; |
| 6945 | return NULL; |
| 6946 | } |
| 6947 | int start_lineno = p->tokens[mark]->lineno; |
| 6948 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 6949 | int start_col_offset = p->tokens[mark]->col_offset; |
| 6950 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 6951 | { // sum '+' term |
| 6952 | expr_ty a; |
| 6953 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6954 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6955 | if ( |
| 6956 | (a = sum_rule(p)) |
| 6957 | && |
| 6958 | (literal = _PyPegen_expect_token(p, 14)) |
| 6959 | && |
| 6960 | (b = term_rule(p)) |
| 6961 | ) |
| 6962 | { |
| 6963 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6964 | if (token == NULL) { |
| 6965 | return NULL; |
| 6966 | } |
| 6967 | int end_lineno = token->end_lineno; |
| 6968 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6969 | int end_col_offset = token->end_col_offset; |
| 6970 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 6971 | res = _Py_BinOp ( a , Add , b , EXTRA ); |
| 6972 | if (res == NULL && PyErr_Occurred()) { |
| 6973 | p->error_indicator = 1; |
| 6974 | return NULL; |
| 6975 | } |
| 6976 | goto done; |
| 6977 | } |
| 6978 | p->mark = mark; |
| 6979 | } |
| 6980 | { // sum '-' term |
| 6981 | expr_ty a; |
| 6982 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 6983 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6984 | if ( |
| 6985 | (a = sum_rule(p)) |
| 6986 | && |
| 6987 | (literal = _PyPegen_expect_token(p, 15)) |
| 6988 | && |
| 6989 | (b = term_rule(p)) |
| 6990 | ) |
| 6991 | { |
| 6992 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6993 | if (token == NULL) { |
| 6994 | return NULL; |
| 6995 | } |
| 6996 | int end_lineno = token->end_lineno; |
| 6997 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 6998 | int end_col_offset = token->end_col_offset; |
| 6999 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7000 | res = _Py_BinOp ( a , Sub , b , EXTRA ); |
| 7001 | if (res == NULL && PyErr_Occurred()) { |
| 7002 | p->error_indicator = 1; |
| 7003 | return NULL; |
| 7004 | } |
| 7005 | goto done; |
| 7006 | } |
| 7007 | p->mark = mark; |
| 7008 | } |
| 7009 | { // term |
| 7010 | expr_ty term_var; |
| 7011 | if ( |
| 7012 | (term_var = term_rule(p)) |
| 7013 | ) |
| 7014 | { |
| 7015 | res = term_var; |
| 7016 | goto done; |
| 7017 | } |
| 7018 | p->mark = mark; |
| 7019 | } |
| 7020 | res = NULL; |
| 7021 | done: |
| 7022 | return res; |
| 7023 | } |
| 7024 | |
| 7025 | // Left-recursive |
| 7026 | // term: |
| 7027 | // | term '*' factor |
| 7028 | // | term '/' factor |
| 7029 | // | term '//' factor |
| 7030 | // | term '%' factor |
| 7031 | // | term '@' factor |
| 7032 | // | factor |
| 7033 | static expr_ty term_raw(Parser *); |
| 7034 | static expr_ty |
| 7035 | term_rule(Parser *p) |
| 7036 | { |
| 7037 | expr_ty res = NULL; |
| 7038 | if (_PyPegen_is_memoized(p, term_type, &res)) |
| 7039 | return res; |
| 7040 | int mark = p->mark; |
| 7041 | int resmark = p->mark; |
| 7042 | while (1) { |
| 7043 | int tmpvar_6 = _PyPegen_update_memo(p, mark, term_type, res); |
| 7044 | if (tmpvar_6) { |
| 7045 | return res; |
| 7046 | } |
| 7047 | p->mark = mark; |
| 7048 | void *raw = term_raw(p); |
| 7049 | if (raw == NULL || p->mark <= resmark) |
| 7050 | break; |
| 7051 | resmark = p->mark; |
| 7052 | res = raw; |
| 7053 | } |
| 7054 | p->mark = resmark; |
| 7055 | return res; |
| 7056 | } |
| 7057 | static expr_ty |
| 7058 | term_raw(Parser *p) |
| 7059 | { |
| 7060 | if (p->error_indicator) { |
| 7061 | return NULL; |
| 7062 | } |
| 7063 | expr_ty res = NULL; |
| 7064 | int mark = p->mark; |
| 7065 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7066 | p->error_indicator = 1; |
| 7067 | return NULL; |
| 7068 | } |
| 7069 | int start_lineno = p->tokens[mark]->lineno; |
| 7070 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7071 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7072 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7073 | { // term '*' factor |
| 7074 | expr_ty a; |
| 7075 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7076 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7077 | if ( |
| 7078 | (a = term_rule(p)) |
| 7079 | && |
| 7080 | (literal = _PyPegen_expect_token(p, 16)) |
| 7081 | && |
| 7082 | (b = factor_rule(p)) |
| 7083 | ) |
| 7084 | { |
| 7085 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7086 | if (token == NULL) { |
| 7087 | return NULL; |
| 7088 | } |
| 7089 | int end_lineno = token->end_lineno; |
| 7090 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7091 | int end_col_offset = token->end_col_offset; |
| 7092 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7093 | res = _Py_BinOp ( a , Mult , b , EXTRA ); |
| 7094 | if (res == NULL && PyErr_Occurred()) { |
| 7095 | p->error_indicator = 1; |
| 7096 | return NULL; |
| 7097 | } |
| 7098 | goto done; |
| 7099 | } |
| 7100 | p->mark = mark; |
| 7101 | } |
| 7102 | { // term '/' factor |
| 7103 | expr_ty a; |
| 7104 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7105 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7106 | if ( |
| 7107 | (a = term_rule(p)) |
| 7108 | && |
| 7109 | (literal = _PyPegen_expect_token(p, 17)) |
| 7110 | && |
| 7111 | (b = factor_rule(p)) |
| 7112 | ) |
| 7113 | { |
| 7114 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7115 | if (token == NULL) { |
| 7116 | return NULL; |
| 7117 | } |
| 7118 | int end_lineno = token->end_lineno; |
| 7119 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7120 | int end_col_offset = token->end_col_offset; |
| 7121 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7122 | res = _Py_BinOp ( a , Div , b , EXTRA ); |
| 7123 | if (res == NULL && PyErr_Occurred()) { |
| 7124 | p->error_indicator = 1; |
| 7125 | return NULL; |
| 7126 | } |
| 7127 | goto done; |
| 7128 | } |
| 7129 | p->mark = mark; |
| 7130 | } |
| 7131 | { // term '//' factor |
| 7132 | expr_ty a; |
| 7133 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7134 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7135 | if ( |
| 7136 | (a = term_rule(p)) |
| 7137 | && |
| 7138 | (literal = _PyPegen_expect_token(p, 47)) |
| 7139 | && |
| 7140 | (b = factor_rule(p)) |
| 7141 | ) |
| 7142 | { |
| 7143 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7144 | if (token == NULL) { |
| 7145 | return NULL; |
| 7146 | } |
| 7147 | int end_lineno = token->end_lineno; |
| 7148 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7149 | int end_col_offset = token->end_col_offset; |
| 7150 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7151 | res = _Py_BinOp ( a , FloorDiv , b , EXTRA ); |
| 7152 | if (res == NULL && PyErr_Occurred()) { |
| 7153 | p->error_indicator = 1; |
| 7154 | return NULL; |
| 7155 | } |
| 7156 | goto done; |
| 7157 | } |
| 7158 | p->mark = mark; |
| 7159 | } |
| 7160 | { // term '%' factor |
| 7161 | expr_ty a; |
| 7162 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7163 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7164 | if ( |
| 7165 | (a = term_rule(p)) |
| 7166 | && |
| 7167 | (literal = _PyPegen_expect_token(p, 24)) |
| 7168 | && |
| 7169 | (b = factor_rule(p)) |
| 7170 | ) |
| 7171 | { |
| 7172 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7173 | if (token == NULL) { |
| 7174 | return NULL; |
| 7175 | } |
| 7176 | int end_lineno = token->end_lineno; |
| 7177 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7178 | int end_col_offset = token->end_col_offset; |
| 7179 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7180 | res = _Py_BinOp ( a , Mod , b , EXTRA ); |
| 7181 | if (res == NULL && PyErr_Occurred()) { |
| 7182 | p->error_indicator = 1; |
| 7183 | return NULL; |
| 7184 | } |
| 7185 | goto done; |
| 7186 | } |
| 7187 | p->mark = mark; |
| 7188 | } |
| 7189 | { // term '@' factor |
| 7190 | expr_ty a; |
| 7191 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7192 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7193 | if ( |
| 7194 | (a = term_rule(p)) |
| 7195 | && |
| 7196 | (literal = _PyPegen_expect_token(p, 49)) |
| 7197 | && |
| 7198 | (b = factor_rule(p)) |
| 7199 | ) |
| 7200 | { |
| 7201 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7202 | if (token == NULL) { |
| 7203 | return NULL; |
| 7204 | } |
| 7205 | int end_lineno = token->end_lineno; |
| 7206 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7207 | int end_col_offset = token->end_col_offset; |
| 7208 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 7209 | res = CHECK_VERSION ( 5 , "The '@' operator is" , _Py_BinOp ( a , MatMult , b , EXTRA ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7210 | if (res == NULL && PyErr_Occurred()) { |
| 7211 | p->error_indicator = 1; |
| 7212 | return NULL; |
| 7213 | } |
| 7214 | goto done; |
| 7215 | } |
| 7216 | p->mark = mark; |
| 7217 | } |
| 7218 | { // factor |
| 7219 | expr_ty factor_var; |
| 7220 | if ( |
| 7221 | (factor_var = factor_rule(p)) |
| 7222 | ) |
| 7223 | { |
| 7224 | res = factor_var; |
| 7225 | goto done; |
| 7226 | } |
| 7227 | p->mark = mark; |
| 7228 | } |
| 7229 | res = NULL; |
| 7230 | done: |
| 7231 | return res; |
| 7232 | } |
| 7233 | |
| 7234 | // factor: '+' factor | '-' factor | '~' factor | power |
| 7235 | static expr_ty |
| 7236 | factor_rule(Parser *p) |
| 7237 | { |
| 7238 | if (p->error_indicator) { |
| 7239 | return NULL; |
| 7240 | } |
| 7241 | expr_ty res = NULL; |
| 7242 | if (_PyPegen_is_memoized(p, factor_type, &res)) |
| 7243 | return res; |
| 7244 | int mark = p->mark; |
| 7245 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7246 | p->error_indicator = 1; |
| 7247 | return NULL; |
| 7248 | } |
| 7249 | int start_lineno = p->tokens[mark]->lineno; |
| 7250 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7251 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7252 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7253 | { // '+' factor |
| 7254 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7255 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7256 | if ( |
| 7257 | (literal = _PyPegen_expect_token(p, 14)) |
| 7258 | && |
| 7259 | (a = factor_rule(p)) |
| 7260 | ) |
| 7261 | { |
| 7262 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7263 | if (token == NULL) { |
| 7264 | return NULL; |
| 7265 | } |
| 7266 | int end_lineno = token->end_lineno; |
| 7267 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7268 | int end_col_offset = token->end_col_offset; |
| 7269 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7270 | res = _Py_UnaryOp ( UAdd , a , EXTRA ); |
| 7271 | if (res == NULL && PyErr_Occurred()) { |
| 7272 | p->error_indicator = 1; |
| 7273 | return NULL; |
| 7274 | } |
| 7275 | goto done; |
| 7276 | } |
| 7277 | p->mark = mark; |
| 7278 | } |
| 7279 | { // '-' factor |
| 7280 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7281 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7282 | if ( |
| 7283 | (literal = _PyPegen_expect_token(p, 15)) |
| 7284 | && |
| 7285 | (a = factor_rule(p)) |
| 7286 | ) |
| 7287 | { |
| 7288 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7289 | if (token == NULL) { |
| 7290 | return NULL; |
| 7291 | } |
| 7292 | int end_lineno = token->end_lineno; |
| 7293 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7294 | int end_col_offset = token->end_col_offset; |
| 7295 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7296 | res = _Py_UnaryOp ( USub , a , EXTRA ); |
| 7297 | if (res == NULL && PyErr_Occurred()) { |
| 7298 | p->error_indicator = 1; |
| 7299 | return NULL; |
| 7300 | } |
| 7301 | goto done; |
| 7302 | } |
| 7303 | p->mark = mark; |
| 7304 | } |
| 7305 | { // '~' factor |
| 7306 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7307 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7308 | if ( |
| 7309 | (literal = _PyPegen_expect_token(p, 31)) |
| 7310 | && |
| 7311 | (a = factor_rule(p)) |
| 7312 | ) |
| 7313 | { |
| 7314 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7315 | if (token == NULL) { |
| 7316 | return NULL; |
| 7317 | } |
| 7318 | int end_lineno = token->end_lineno; |
| 7319 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7320 | int end_col_offset = token->end_col_offset; |
| 7321 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7322 | res = _Py_UnaryOp ( Invert , a , EXTRA ); |
| 7323 | if (res == NULL && PyErr_Occurred()) { |
| 7324 | p->error_indicator = 1; |
| 7325 | return NULL; |
| 7326 | } |
| 7327 | goto done; |
| 7328 | } |
| 7329 | p->mark = mark; |
| 7330 | } |
| 7331 | { // power |
| 7332 | expr_ty power_var; |
| 7333 | if ( |
| 7334 | (power_var = power_rule(p)) |
| 7335 | ) |
| 7336 | { |
| 7337 | res = power_var; |
| 7338 | goto done; |
| 7339 | } |
| 7340 | p->mark = mark; |
| 7341 | } |
| 7342 | res = NULL; |
| 7343 | done: |
| 7344 | _PyPegen_insert_memo(p, mark, factor_type, res); |
| 7345 | return res; |
| 7346 | } |
| 7347 | |
| 7348 | // power: await_primary '**' factor | await_primary |
| 7349 | static expr_ty |
| 7350 | power_rule(Parser *p) |
| 7351 | { |
| 7352 | if (p->error_indicator) { |
| 7353 | return NULL; |
| 7354 | } |
| 7355 | expr_ty res = NULL; |
| 7356 | int mark = p->mark; |
| 7357 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7358 | p->error_indicator = 1; |
| 7359 | return NULL; |
| 7360 | } |
| 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 |
| 7365 | { // await_primary '**' factor |
| 7366 | expr_ty a; |
| 7367 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7368 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7369 | if ( |
| 7370 | (a = await_primary_rule(p)) |
| 7371 | && |
| 7372 | (literal = _PyPegen_expect_token(p, 35)) |
| 7373 | && |
| 7374 | (b = factor_rule(p)) |
| 7375 | ) |
| 7376 | { |
| 7377 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7378 | if (token == NULL) { |
| 7379 | return NULL; |
| 7380 | } |
| 7381 | int end_lineno = token->end_lineno; |
| 7382 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7383 | int end_col_offset = token->end_col_offset; |
| 7384 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7385 | res = _Py_BinOp ( a , Pow , b , EXTRA ); |
| 7386 | if (res == NULL && PyErr_Occurred()) { |
| 7387 | p->error_indicator = 1; |
| 7388 | return NULL; |
| 7389 | } |
| 7390 | goto done; |
| 7391 | } |
| 7392 | p->mark = mark; |
| 7393 | } |
| 7394 | { // await_primary |
| 7395 | expr_ty await_primary_var; |
| 7396 | if ( |
| 7397 | (await_primary_var = await_primary_rule(p)) |
| 7398 | ) |
| 7399 | { |
| 7400 | res = await_primary_var; |
| 7401 | goto done; |
| 7402 | } |
| 7403 | p->mark = mark; |
| 7404 | } |
| 7405 | res = NULL; |
| 7406 | done: |
| 7407 | return res; |
| 7408 | } |
| 7409 | |
| 7410 | // await_primary: AWAIT primary | primary |
| 7411 | static expr_ty |
| 7412 | await_primary_rule(Parser *p) |
| 7413 | { |
| 7414 | if (p->error_indicator) { |
| 7415 | return NULL; |
| 7416 | } |
| 7417 | expr_ty res = NULL; |
| 7418 | if (_PyPegen_is_memoized(p, await_primary_type, &res)) |
| 7419 | return res; |
| 7420 | int mark = p->mark; |
| 7421 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7422 | p->error_indicator = 1; |
| 7423 | return NULL; |
| 7424 | } |
| 7425 | int start_lineno = p->tokens[mark]->lineno; |
| 7426 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7427 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7428 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7429 | { // AWAIT primary |
| 7430 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7431 | Token * await_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7432 | if ( |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 7433 | (await_var = _PyPegen_expect_token(p, AWAIT)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7434 | && |
| 7435 | (a = primary_rule(p)) |
| 7436 | ) |
| 7437 | { |
| 7438 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7439 | if (token == NULL) { |
| 7440 | return NULL; |
| 7441 | } |
| 7442 | int end_lineno = token->end_lineno; |
| 7443 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7444 | int end_col_offset = token->end_col_offset; |
| 7445 | UNUSED(end_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 7446 | res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7447 | if (res == NULL && PyErr_Occurred()) { |
| 7448 | p->error_indicator = 1; |
| 7449 | return NULL; |
| 7450 | } |
| 7451 | goto done; |
| 7452 | } |
| 7453 | p->mark = mark; |
| 7454 | } |
| 7455 | { // primary |
| 7456 | expr_ty primary_var; |
| 7457 | if ( |
| 7458 | (primary_var = primary_rule(p)) |
| 7459 | ) |
| 7460 | { |
| 7461 | res = primary_var; |
| 7462 | goto done; |
| 7463 | } |
| 7464 | p->mark = mark; |
| 7465 | } |
| 7466 | res = NULL; |
| 7467 | done: |
| 7468 | _PyPegen_insert_memo(p, mark, await_primary_type, res); |
| 7469 | return res; |
| 7470 | } |
| 7471 | |
| 7472 | // Left-recursive |
| 7473 | // primary: |
| 7474 | // | primary '.' NAME |
| 7475 | // | primary genexp |
| 7476 | // | primary '(' arguments? ')' |
| 7477 | // | primary '[' slices ']' |
| 7478 | // | atom |
| 7479 | static expr_ty primary_raw(Parser *); |
| 7480 | static expr_ty |
| 7481 | primary_rule(Parser *p) |
| 7482 | { |
| 7483 | expr_ty res = NULL; |
| 7484 | if (_PyPegen_is_memoized(p, primary_type, &res)) |
| 7485 | return res; |
| 7486 | int mark = p->mark; |
| 7487 | int resmark = p->mark; |
| 7488 | while (1) { |
| 7489 | int tmpvar_7 = _PyPegen_update_memo(p, mark, primary_type, res); |
| 7490 | if (tmpvar_7) { |
| 7491 | return res; |
| 7492 | } |
| 7493 | p->mark = mark; |
| 7494 | void *raw = primary_raw(p); |
| 7495 | if (raw == NULL || p->mark <= resmark) |
| 7496 | break; |
| 7497 | resmark = p->mark; |
| 7498 | res = raw; |
| 7499 | } |
| 7500 | p->mark = resmark; |
| 7501 | return res; |
| 7502 | } |
| 7503 | static expr_ty |
| 7504 | primary_raw(Parser *p) |
| 7505 | { |
| 7506 | if (p->error_indicator) { |
| 7507 | return NULL; |
| 7508 | } |
| 7509 | expr_ty res = NULL; |
| 7510 | int mark = p->mark; |
| 7511 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7512 | p->error_indicator = 1; |
| 7513 | return NULL; |
| 7514 | } |
| 7515 | int start_lineno = p->tokens[mark]->lineno; |
| 7516 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7517 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7518 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7519 | { // primary '.' NAME |
| 7520 | expr_ty a; |
| 7521 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7522 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7523 | if ( |
| 7524 | (a = primary_rule(p)) |
| 7525 | && |
| 7526 | (literal = _PyPegen_expect_token(p, 23)) |
| 7527 | && |
| 7528 | (b = _PyPegen_name_token(p)) |
| 7529 | ) |
| 7530 | { |
| 7531 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7532 | if (token == NULL) { |
| 7533 | return NULL; |
| 7534 | } |
| 7535 | int end_lineno = token->end_lineno; |
| 7536 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7537 | int end_col_offset = token->end_col_offset; |
| 7538 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7539 | res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
| 7540 | if (res == NULL && PyErr_Occurred()) { |
| 7541 | p->error_indicator = 1; |
| 7542 | return NULL; |
| 7543 | } |
| 7544 | goto done; |
| 7545 | } |
| 7546 | p->mark = mark; |
| 7547 | } |
| 7548 | { // primary genexp |
| 7549 | expr_ty a; |
| 7550 | expr_ty b; |
| 7551 | if ( |
| 7552 | (a = primary_rule(p)) |
| 7553 | && |
| 7554 | (b = genexp_rule(p)) |
| 7555 | ) |
| 7556 | { |
| 7557 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7558 | if (token == NULL) { |
| 7559 | return NULL; |
| 7560 | } |
| 7561 | int end_lineno = token->end_lineno; |
| 7562 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7563 | int end_col_offset = token->end_col_offset; |
| 7564 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7565 | res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
| 7566 | if (res == NULL && PyErr_Occurred()) { |
| 7567 | p->error_indicator = 1; |
| 7568 | return NULL; |
| 7569 | } |
| 7570 | goto done; |
| 7571 | } |
| 7572 | p->mark = mark; |
| 7573 | } |
| 7574 | { // primary '(' arguments? ')' |
| 7575 | expr_ty a; |
| 7576 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7577 | Token * literal; |
| 7578 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7579 | if ( |
| 7580 | (a = primary_rule(p)) |
| 7581 | && |
| 7582 | (literal = _PyPegen_expect_token(p, 7)) |
| 7583 | && |
| 7584 | (b = arguments_rule(p), 1) |
| 7585 | && |
| 7586 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 7587 | ) |
| 7588 | { |
| 7589 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7590 | if (token == NULL) { |
| 7591 | return NULL; |
| 7592 | } |
| 7593 | int end_lineno = token->end_lineno; |
| 7594 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7595 | int end_col_offset = token->end_col_offset; |
| 7596 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7597 | res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 7598 | if (res == NULL && PyErr_Occurred()) { |
| 7599 | p->error_indicator = 1; |
| 7600 | return NULL; |
| 7601 | } |
| 7602 | goto done; |
| 7603 | } |
| 7604 | p->mark = mark; |
| 7605 | } |
| 7606 | { // primary '[' slices ']' |
| 7607 | expr_ty a; |
| 7608 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7609 | Token * literal; |
| 7610 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7611 | if ( |
| 7612 | (a = primary_rule(p)) |
| 7613 | && |
| 7614 | (literal = _PyPegen_expect_token(p, 9)) |
| 7615 | && |
| 7616 | (b = slices_rule(p)) |
| 7617 | && |
| 7618 | (literal_1 = _PyPegen_expect_token(p, 10)) |
| 7619 | ) |
| 7620 | { |
| 7621 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7622 | if (token == NULL) { |
| 7623 | return NULL; |
| 7624 | } |
| 7625 | int end_lineno = token->end_lineno; |
| 7626 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7627 | int end_col_offset = token->end_col_offset; |
| 7628 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7629 | res = _Py_Subscript ( a , b , Load , EXTRA ); |
| 7630 | if (res == NULL && PyErr_Occurred()) { |
| 7631 | p->error_indicator = 1; |
| 7632 | return NULL; |
| 7633 | } |
| 7634 | goto done; |
| 7635 | } |
| 7636 | p->mark = mark; |
| 7637 | } |
| 7638 | { // atom |
| 7639 | expr_ty atom_var; |
| 7640 | if ( |
| 7641 | (atom_var = atom_rule(p)) |
| 7642 | ) |
| 7643 | { |
| 7644 | res = atom_var; |
| 7645 | goto done; |
| 7646 | } |
| 7647 | p->mark = mark; |
| 7648 | } |
| 7649 | res = NULL; |
| 7650 | done: |
| 7651 | return res; |
| 7652 | } |
| 7653 | |
| 7654 | // slices: slice !',' | ','.slice+ ','? |
| 7655 | static expr_ty |
| 7656 | slices_rule(Parser *p) |
| 7657 | { |
| 7658 | if (p->error_indicator) { |
| 7659 | return NULL; |
| 7660 | } |
| 7661 | expr_ty res = NULL; |
| 7662 | int mark = p->mark; |
| 7663 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7664 | p->error_indicator = 1; |
| 7665 | return NULL; |
| 7666 | } |
| 7667 | int start_lineno = p->tokens[mark]->lineno; |
| 7668 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7669 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7670 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7671 | { // slice !',' |
| 7672 | expr_ty a; |
| 7673 | if ( |
| 7674 | (a = slice_rule(p)) |
| 7675 | && |
| 7676 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) |
| 7677 | ) |
| 7678 | { |
| 7679 | res = a; |
| 7680 | if (res == NULL && PyErr_Occurred()) { |
| 7681 | p->error_indicator = 1; |
| 7682 | return NULL; |
| 7683 | } |
| 7684 | goto done; |
| 7685 | } |
| 7686 | p->mark = mark; |
| 7687 | } |
| 7688 | { // ','.slice+ ','? |
| 7689 | asdl_seq * a; |
| 7690 | void *opt_var; |
| 7691 | UNUSED(opt_var); // Silence compiler warnings |
| 7692 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7693 | (a = _gather_93_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7694 | && |
| 7695 | (opt_var = _PyPegen_expect_token(p, 12), 1) |
| 7696 | ) |
| 7697 | { |
| 7698 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7699 | if (token == NULL) { |
| 7700 | return NULL; |
| 7701 | } |
| 7702 | int end_lineno = token->end_lineno; |
| 7703 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7704 | int end_col_offset = token->end_col_offset; |
| 7705 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7706 | res = _Py_Tuple ( a , Load , EXTRA ); |
| 7707 | if (res == NULL && PyErr_Occurred()) { |
| 7708 | p->error_indicator = 1; |
| 7709 | return NULL; |
| 7710 | } |
| 7711 | goto done; |
| 7712 | } |
| 7713 | p->mark = mark; |
| 7714 | } |
| 7715 | res = NULL; |
| 7716 | done: |
| 7717 | return res; |
| 7718 | } |
| 7719 | |
| 7720 | // slice: expression? ':' expression? [':' expression?] | expression |
| 7721 | static expr_ty |
| 7722 | slice_rule(Parser *p) |
| 7723 | { |
| 7724 | if (p->error_indicator) { |
| 7725 | return NULL; |
| 7726 | } |
| 7727 | expr_ty res = NULL; |
| 7728 | int mark = p->mark; |
| 7729 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7730 | p->error_indicator = 1; |
| 7731 | return NULL; |
| 7732 | } |
| 7733 | int start_lineno = p->tokens[mark]->lineno; |
| 7734 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7735 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7736 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7737 | { // expression? ':' expression? [':' expression?] |
| 7738 | void *a; |
| 7739 | void *b; |
| 7740 | void *c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7741 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7742 | if ( |
| 7743 | (a = expression_rule(p), 1) |
| 7744 | && |
| 7745 | (literal = _PyPegen_expect_token(p, 11)) |
| 7746 | && |
| 7747 | (b = expression_rule(p), 1) |
| 7748 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7749 | (c = _tmp_95_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7750 | ) |
| 7751 | { |
| 7752 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7753 | if (token == NULL) { |
| 7754 | return NULL; |
| 7755 | } |
| 7756 | int end_lineno = token->end_lineno; |
| 7757 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7758 | int end_col_offset = token->end_col_offset; |
| 7759 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7760 | res = _Py_Slice ( a , b , c , EXTRA ); |
| 7761 | if (res == NULL && PyErr_Occurred()) { |
| 7762 | p->error_indicator = 1; |
| 7763 | return NULL; |
| 7764 | } |
| 7765 | goto done; |
| 7766 | } |
| 7767 | p->mark = mark; |
| 7768 | } |
| 7769 | { // expression |
| 7770 | expr_ty a; |
| 7771 | if ( |
| 7772 | (a = expression_rule(p)) |
| 7773 | ) |
| 7774 | { |
| 7775 | res = a; |
| 7776 | if (res == NULL && PyErr_Occurred()) { |
| 7777 | p->error_indicator = 1; |
| 7778 | return NULL; |
| 7779 | } |
| 7780 | goto done; |
| 7781 | } |
| 7782 | p->mark = mark; |
| 7783 | } |
| 7784 | res = NULL; |
| 7785 | done: |
| 7786 | return res; |
| 7787 | } |
| 7788 | |
| 7789 | // atom: |
| 7790 | // | NAME |
| 7791 | // | 'True' |
| 7792 | // | 'False' |
| 7793 | // | 'None' |
| 7794 | // | '__new_parser__' |
| 7795 | // | &STRING strings |
| 7796 | // | NUMBER |
| 7797 | // | &'(' (tuple | group | genexp) |
| 7798 | // | &'[' (list | listcomp) |
| 7799 | // | &'{' (dict | set | dictcomp | setcomp) |
| 7800 | // | '...' |
| 7801 | static expr_ty |
| 7802 | atom_rule(Parser *p) |
| 7803 | { |
| 7804 | if (p->error_indicator) { |
| 7805 | return NULL; |
| 7806 | } |
| 7807 | expr_ty res = NULL; |
| 7808 | int mark = p->mark; |
| 7809 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7810 | p->error_indicator = 1; |
| 7811 | return NULL; |
| 7812 | } |
| 7813 | int start_lineno = p->tokens[mark]->lineno; |
| 7814 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 7815 | int start_col_offset = p->tokens[mark]->col_offset; |
| 7816 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 7817 | { // NAME |
| 7818 | expr_ty name_var; |
| 7819 | if ( |
| 7820 | (name_var = _PyPegen_name_token(p)) |
| 7821 | ) |
| 7822 | { |
| 7823 | res = name_var; |
| 7824 | goto done; |
| 7825 | } |
| 7826 | p->mark = mark; |
| 7827 | } |
| 7828 | { // 'True' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7829 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7830 | if ( |
| 7831 | (keyword = _PyPegen_expect_token(p, 527)) |
| 7832 | ) |
| 7833 | { |
| 7834 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7835 | if (token == NULL) { |
| 7836 | return NULL; |
| 7837 | } |
| 7838 | int end_lineno = token->end_lineno; |
| 7839 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7840 | int end_col_offset = token->end_col_offset; |
| 7841 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7842 | res = _Py_Constant ( Py_True , NULL , EXTRA ); |
| 7843 | if (res == NULL && PyErr_Occurred()) { |
| 7844 | p->error_indicator = 1; |
| 7845 | return NULL; |
| 7846 | } |
| 7847 | goto done; |
| 7848 | } |
| 7849 | p->mark = mark; |
| 7850 | } |
| 7851 | { // 'False' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7852 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7853 | if ( |
| 7854 | (keyword = _PyPegen_expect_token(p, 528)) |
| 7855 | ) |
| 7856 | { |
| 7857 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7858 | if (token == NULL) { |
| 7859 | return NULL; |
| 7860 | } |
| 7861 | int end_lineno = token->end_lineno; |
| 7862 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7863 | int end_col_offset = token->end_col_offset; |
| 7864 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7865 | res = _Py_Constant ( Py_False , NULL , EXTRA ); |
| 7866 | if (res == NULL && PyErr_Occurred()) { |
| 7867 | p->error_indicator = 1; |
| 7868 | return NULL; |
| 7869 | } |
| 7870 | goto done; |
| 7871 | } |
| 7872 | p->mark = mark; |
| 7873 | } |
| 7874 | { // 'None' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7875 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7876 | if ( |
| 7877 | (keyword = _PyPegen_expect_token(p, 529)) |
| 7878 | ) |
| 7879 | { |
| 7880 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7881 | if (token == NULL) { |
| 7882 | return NULL; |
| 7883 | } |
| 7884 | int end_lineno = token->end_lineno; |
| 7885 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7886 | int end_col_offset = token->end_col_offset; |
| 7887 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7888 | res = _Py_Constant ( Py_None , NULL , EXTRA ); |
| 7889 | if (res == NULL && PyErr_Occurred()) { |
| 7890 | p->error_indicator = 1; |
| 7891 | return NULL; |
| 7892 | } |
| 7893 | goto done; |
| 7894 | } |
| 7895 | p->mark = mark; |
| 7896 | } |
| 7897 | { // '__new_parser__' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7898 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7899 | if ( |
| 7900 | (keyword = _PyPegen_expect_token(p, 530)) |
| 7901 | ) |
| 7902 | { |
| 7903 | res = RAISE_SYNTAX_ERROR ( "You found it!" ); |
| 7904 | if (res == NULL && PyErr_Occurred()) { |
| 7905 | p->error_indicator = 1; |
| 7906 | return NULL; |
| 7907 | } |
| 7908 | goto done; |
| 7909 | } |
| 7910 | p->mark = mark; |
| 7911 | } |
| 7912 | { // &STRING strings |
| 7913 | expr_ty strings_var; |
| 7914 | if ( |
| 7915 | _PyPegen_lookahead(1, _PyPegen_string_token, p) |
| 7916 | && |
| 7917 | (strings_var = strings_rule(p)) |
| 7918 | ) |
| 7919 | { |
| 7920 | res = strings_var; |
| 7921 | goto done; |
| 7922 | } |
| 7923 | p->mark = mark; |
| 7924 | } |
| 7925 | { // NUMBER |
| 7926 | expr_ty number_var; |
| 7927 | if ( |
| 7928 | (number_var = _PyPegen_number_token(p)) |
| 7929 | ) |
| 7930 | { |
| 7931 | res = number_var; |
| 7932 | goto done; |
| 7933 | } |
| 7934 | p->mark = mark; |
| 7935 | } |
| 7936 | { // &'(' (tuple | group | genexp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7937 | void *_tmp_96_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7938 | if ( |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 7939 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7940 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7941 | (_tmp_96_var = _tmp_96_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7942 | ) |
| 7943 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7944 | res = _tmp_96_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7945 | goto done; |
| 7946 | } |
| 7947 | p->mark = mark; |
| 7948 | } |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 7949 | { // &'[' (list | listcomp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7950 | void *_tmp_97_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7951 | if ( |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 7952 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7953 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7954 | (_tmp_97_var = _tmp_97_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7955 | ) |
| 7956 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7957 | res = _tmp_97_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7958 | goto done; |
| 7959 | } |
| 7960 | p->mark = mark; |
| 7961 | } |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 7962 | { // &'{' (dict | set | dictcomp | setcomp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7963 | void *_tmp_98_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 7964 | if ( |
| 7965 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) |
| 7966 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7967 | (_tmp_98_var = _tmp_98_rule(p)) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 7968 | ) |
| 7969 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7970 | res = _tmp_98_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 7971 | goto done; |
| 7972 | } |
| 7973 | p->mark = mark; |
| 7974 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7975 | { // '...' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7976 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7977 | if ( |
| 7978 | (literal = _PyPegen_expect_token(p, 52)) |
| 7979 | ) |
| 7980 | { |
| 7981 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7982 | if (token == NULL) { |
| 7983 | return NULL; |
| 7984 | } |
| 7985 | int end_lineno = token->end_lineno; |
| 7986 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 7987 | int end_col_offset = token->end_col_offset; |
| 7988 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 7989 | res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA ); |
| 7990 | if (res == NULL && PyErr_Occurred()) { |
| 7991 | p->error_indicator = 1; |
| 7992 | return NULL; |
| 7993 | } |
| 7994 | goto done; |
| 7995 | } |
| 7996 | p->mark = mark; |
| 7997 | } |
| 7998 | res = NULL; |
| 7999 | done: |
| 8000 | return res; |
| 8001 | } |
| 8002 | |
| 8003 | // strings: STRING+ |
| 8004 | static expr_ty |
| 8005 | strings_rule(Parser *p) |
| 8006 | { |
| 8007 | if (p->error_indicator) { |
| 8008 | return NULL; |
| 8009 | } |
| 8010 | expr_ty res = NULL; |
| 8011 | if (_PyPegen_is_memoized(p, strings_type, &res)) |
| 8012 | return res; |
| 8013 | int mark = p->mark; |
| 8014 | { // STRING+ |
| 8015 | asdl_seq * a; |
| 8016 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8017 | (a = _loop1_99_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8018 | ) |
| 8019 | { |
| 8020 | res = _PyPegen_concatenate_strings ( p , a ); |
| 8021 | if (res == NULL && PyErr_Occurred()) { |
| 8022 | p->error_indicator = 1; |
| 8023 | return NULL; |
| 8024 | } |
| 8025 | goto done; |
| 8026 | } |
| 8027 | p->mark = mark; |
| 8028 | } |
| 8029 | res = NULL; |
| 8030 | done: |
| 8031 | _PyPegen_insert_memo(p, mark, strings_type, res); |
| 8032 | return res; |
| 8033 | } |
| 8034 | |
| 8035 | // list: '[' star_named_expressions? ']' |
| 8036 | static expr_ty |
| 8037 | list_rule(Parser *p) |
| 8038 | { |
| 8039 | if (p->error_indicator) { |
| 8040 | return NULL; |
| 8041 | } |
| 8042 | expr_ty res = NULL; |
| 8043 | int mark = p->mark; |
| 8044 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8045 | p->error_indicator = 1; |
| 8046 | return NULL; |
| 8047 | } |
| 8048 | int start_lineno = p->tokens[mark]->lineno; |
| 8049 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8050 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8051 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8052 | { // '[' star_named_expressions? ']' |
| 8053 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8054 | Token * literal; |
| 8055 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8056 | if ( |
| 8057 | (literal = _PyPegen_expect_token(p, 9)) |
| 8058 | && |
| 8059 | (a = star_named_expressions_rule(p), 1) |
| 8060 | && |
| 8061 | (literal_1 = _PyPegen_expect_token(p, 10)) |
| 8062 | ) |
| 8063 | { |
| 8064 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8065 | if (token == NULL) { |
| 8066 | return NULL; |
| 8067 | } |
| 8068 | int end_lineno = token->end_lineno; |
| 8069 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8070 | int end_col_offset = token->end_col_offset; |
| 8071 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8072 | res = _Py_List ( a , Load , EXTRA ); |
| 8073 | if (res == NULL && PyErr_Occurred()) { |
| 8074 | p->error_indicator = 1; |
| 8075 | return NULL; |
| 8076 | } |
| 8077 | goto done; |
| 8078 | } |
| 8079 | p->mark = mark; |
| 8080 | } |
| 8081 | res = NULL; |
| 8082 | done: |
| 8083 | return res; |
| 8084 | } |
| 8085 | |
| 8086 | // listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension |
| 8087 | static expr_ty |
| 8088 | listcomp_rule(Parser *p) |
| 8089 | { |
| 8090 | if (p->error_indicator) { |
| 8091 | return NULL; |
| 8092 | } |
| 8093 | expr_ty res = NULL; |
| 8094 | int mark = p->mark; |
| 8095 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8096 | p->error_indicator = 1; |
| 8097 | return NULL; |
| 8098 | } |
| 8099 | int start_lineno = p->tokens[mark]->lineno; |
| 8100 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8101 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8102 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8103 | { // '[' named_expression for_if_clauses ']' |
| 8104 | expr_ty a; |
| 8105 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8106 | Token * literal; |
| 8107 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8108 | if ( |
| 8109 | (literal = _PyPegen_expect_token(p, 9)) |
| 8110 | && |
| 8111 | (a = named_expression_rule(p)) |
| 8112 | && |
| 8113 | (b = for_if_clauses_rule(p)) |
| 8114 | && |
| 8115 | (literal_1 = _PyPegen_expect_token(p, 10)) |
| 8116 | ) |
| 8117 | { |
| 8118 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8119 | if (token == NULL) { |
| 8120 | return NULL; |
| 8121 | } |
| 8122 | int end_lineno = token->end_lineno; |
| 8123 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8124 | int end_col_offset = token->end_col_offset; |
| 8125 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8126 | res = _Py_ListComp ( a , b , EXTRA ); |
| 8127 | if (res == NULL && PyErr_Occurred()) { |
| 8128 | p->error_indicator = 1; |
| 8129 | return NULL; |
| 8130 | } |
| 8131 | goto done; |
| 8132 | } |
| 8133 | p->mark = mark; |
| 8134 | } |
| 8135 | { // invalid_comprehension |
| 8136 | void *invalid_comprehension_var; |
| 8137 | if ( |
| 8138 | (invalid_comprehension_var = invalid_comprehension_rule(p)) |
| 8139 | ) |
| 8140 | { |
| 8141 | res = invalid_comprehension_var; |
| 8142 | goto done; |
| 8143 | } |
| 8144 | p->mark = mark; |
| 8145 | } |
| 8146 | res = NULL; |
| 8147 | done: |
| 8148 | return res; |
| 8149 | } |
| 8150 | |
| 8151 | // tuple: '(' [star_named_expression ',' star_named_expressions?] ')' |
| 8152 | static expr_ty |
| 8153 | tuple_rule(Parser *p) |
| 8154 | { |
| 8155 | if (p->error_indicator) { |
| 8156 | return NULL; |
| 8157 | } |
| 8158 | expr_ty res = NULL; |
| 8159 | int mark = p->mark; |
| 8160 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8161 | p->error_indicator = 1; |
| 8162 | return NULL; |
| 8163 | } |
| 8164 | int start_lineno = p->tokens[mark]->lineno; |
| 8165 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8166 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8167 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8168 | { // '(' [star_named_expression ',' star_named_expressions?] ')' |
| 8169 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8170 | Token * literal; |
| 8171 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8172 | if ( |
| 8173 | (literal = _PyPegen_expect_token(p, 7)) |
| 8174 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8175 | (a = _tmp_100_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8176 | && |
| 8177 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 8178 | ) |
| 8179 | { |
| 8180 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8181 | if (token == NULL) { |
| 8182 | return NULL; |
| 8183 | } |
| 8184 | int end_lineno = token->end_lineno; |
| 8185 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8186 | int end_col_offset = token->end_col_offset; |
| 8187 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8188 | res = _Py_Tuple ( a , Load , EXTRA ); |
| 8189 | if (res == NULL && PyErr_Occurred()) { |
| 8190 | p->error_indicator = 1; |
| 8191 | return NULL; |
| 8192 | } |
| 8193 | goto done; |
| 8194 | } |
| 8195 | p->mark = mark; |
| 8196 | } |
| 8197 | res = NULL; |
| 8198 | done: |
| 8199 | return res; |
| 8200 | } |
| 8201 | |
| 8202 | // group: '(' (yield_expr | named_expression) ')' |
| 8203 | static expr_ty |
| 8204 | group_rule(Parser *p) |
| 8205 | { |
| 8206 | if (p->error_indicator) { |
| 8207 | return NULL; |
| 8208 | } |
| 8209 | expr_ty res = NULL; |
| 8210 | int mark = p->mark; |
| 8211 | { // '(' (yield_expr | named_expression) ')' |
| 8212 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8213 | Token * literal; |
| 8214 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8215 | if ( |
| 8216 | (literal = _PyPegen_expect_token(p, 7)) |
| 8217 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8218 | (a = _tmp_101_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8219 | && |
| 8220 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 8221 | ) |
| 8222 | { |
| 8223 | res = a; |
| 8224 | if (res == NULL && PyErr_Occurred()) { |
| 8225 | p->error_indicator = 1; |
| 8226 | return NULL; |
| 8227 | } |
| 8228 | goto done; |
| 8229 | } |
| 8230 | p->mark = mark; |
| 8231 | } |
| 8232 | res = NULL; |
| 8233 | done: |
| 8234 | return res; |
| 8235 | } |
| 8236 | |
| 8237 | // genexp: '(' expression for_if_clauses ')' | invalid_comprehension |
| 8238 | static expr_ty |
| 8239 | genexp_rule(Parser *p) |
| 8240 | { |
| 8241 | if (p->error_indicator) { |
| 8242 | return NULL; |
| 8243 | } |
| 8244 | expr_ty res = NULL; |
| 8245 | int mark = p->mark; |
| 8246 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8247 | p->error_indicator = 1; |
| 8248 | return NULL; |
| 8249 | } |
| 8250 | int start_lineno = p->tokens[mark]->lineno; |
| 8251 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8252 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8253 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8254 | { // '(' expression for_if_clauses ')' |
| 8255 | expr_ty a; |
| 8256 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8257 | Token * literal; |
| 8258 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8259 | if ( |
| 8260 | (literal = _PyPegen_expect_token(p, 7)) |
| 8261 | && |
| 8262 | (a = expression_rule(p)) |
| 8263 | && |
| 8264 | (b = for_if_clauses_rule(p)) |
| 8265 | && |
| 8266 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 8267 | ) |
| 8268 | { |
| 8269 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8270 | if (token == NULL) { |
| 8271 | return NULL; |
| 8272 | } |
| 8273 | int end_lineno = token->end_lineno; |
| 8274 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8275 | int end_col_offset = token->end_col_offset; |
| 8276 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8277 | res = _Py_GeneratorExp ( a , b , EXTRA ); |
| 8278 | if (res == NULL && PyErr_Occurred()) { |
| 8279 | p->error_indicator = 1; |
| 8280 | return NULL; |
| 8281 | } |
| 8282 | goto done; |
| 8283 | } |
| 8284 | p->mark = mark; |
| 8285 | } |
| 8286 | { // invalid_comprehension |
| 8287 | void *invalid_comprehension_var; |
| 8288 | if ( |
| 8289 | (invalid_comprehension_var = invalid_comprehension_rule(p)) |
| 8290 | ) |
| 8291 | { |
| 8292 | res = invalid_comprehension_var; |
| 8293 | goto done; |
| 8294 | } |
| 8295 | p->mark = mark; |
| 8296 | } |
| 8297 | res = NULL; |
| 8298 | done: |
| 8299 | return res; |
| 8300 | } |
| 8301 | |
| 8302 | // set: '{' expressions_list '}' |
| 8303 | static expr_ty |
| 8304 | set_rule(Parser *p) |
| 8305 | { |
| 8306 | if (p->error_indicator) { |
| 8307 | return NULL; |
| 8308 | } |
| 8309 | expr_ty res = NULL; |
| 8310 | int mark = p->mark; |
| 8311 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8312 | p->error_indicator = 1; |
| 8313 | return NULL; |
| 8314 | } |
| 8315 | int start_lineno = p->tokens[mark]->lineno; |
| 8316 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8317 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8318 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8319 | { // '{' expressions_list '}' |
| 8320 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8321 | Token * literal; |
| 8322 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8323 | if ( |
| 8324 | (literal = _PyPegen_expect_token(p, 25)) |
| 8325 | && |
| 8326 | (a = expressions_list_rule(p)) |
| 8327 | && |
| 8328 | (literal_1 = _PyPegen_expect_token(p, 26)) |
| 8329 | ) |
| 8330 | { |
| 8331 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8332 | if (token == NULL) { |
| 8333 | return NULL; |
| 8334 | } |
| 8335 | int end_lineno = token->end_lineno; |
| 8336 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8337 | int end_col_offset = token->end_col_offset; |
| 8338 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8339 | res = _Py_Set ( a , EXTRA ); |
| 8340 | if (res == NULL && PyErr_Occurred()) { |
| 8341 | p->error_indicator = 1; |
| 8342 | return NULL; |
| 8343 | } |
| 8344 | goto done; |
| 8345 | } |
| 8346 | p->mark = mark; |
| 8347 | } |
| 8348 | res = NULL; |
| 8349 | done: |
| 8350 | return res; |
| 8351 | } |
| 8352 | |
| 8353 | // setcomp: '{' expression for_if_clauses '}' | invalid_comprehension |
| 8354 | static expr_ty |
| 8355 | setcomp_rule(Parser *p) |
| 8356 | { |
| 8357 | if (p->error_indicator) { |
| 8358 | return NULL; |
| 8359 | } |
| 8360 | expr_ty res = NULL; |
| 8361 | int mark = p->mark; |
| 8362 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8363 | p->error_indicator = 1; |
| 8364 | return NULL; |
| 8365 | } |
| 8366 | int start_lineno = p->tokens[mark]->lineno; |
| 8367 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8368 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8369 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8370 | { // '{' expression for_if_clauses '}' |
| 8371 | expr_ty a; |
| 8372 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8373 | Token * literal; |
| 8374 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8375 | if ( |
| 8376 | (literal = _PyPegen_expect_token(p, 25)) |
| 8377 | && |
| 8378 | (a = expression_rule(p)) |
| 8379 | && |
| 8380 | (b = for_if_clauses_rule(p)) |
| 8381 | && |
| 8382 | (literal_1 = _PyPegen_expect_token(p, 26)) |
| 8383 | ) |
| 8384 | { |
| 8385 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8386 | if (token == NULL) { |
| 8387 | return NULL; |
| 8388 | } |
| 8389 | int end_lineno = token->end_lineno; |
| 8390 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8391 | int end_col_offset = token->end_col_offset; |
| 8392 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8393 | res = _Py_SetComp ( a , b , EXTRA ); |
| 8394 | if (res == NULL && PyErr_Occurred()) { |
| 8395 | p->error_indicator = 1; |
| 8396 | return NULL; |
| 8397 | } |
| 8398 | goto done; |
| 8399 | } |
| 8400 | p->mark = mark; |
| 8401 | } |
| 8402 | { // invalid_comprehension |
| 8403 | void *invalid_comprehension_var; |
| 8404 | if ( |
| 8405 | (invalid_comprehension_var = invalid_comprehension_rule(p)) |
| 8406 | ) |
| 8407 | { |
| 8408 | res = invalid_comprehension_var; |
| 8409 | goto done; |
| 8410 | } |
| 8411 | p->mark = mark; |
| 8412 | } |
| 8413 | res = NULL; |
| 8414 | done: |
| 8415 | return res; |
| 8416 | } |
| 8417 | |
| 8418 | // dict: '{' kvpairs? '}' |
| 8419 | static expr_ty |
| 8420 | dict_rule(Parser *p) |
| 8421 | { |
| 8422 | if (p->error_indicator) { |
| 8423 | return NULL; |
| 8424 | } |
| 8425 | expr_ty res = NULL; |
| 8426 | int mark = p->mark; |
| 8427 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8428 | p->error_indicator = 1; |
| 8429 | return NULL; |
| 8430 | } |
| 8431 | int start_lineno = p->tokens[mark]->lineno; |
| 8432 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8433 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8434 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8435 | { // '{' kvpairs? '}' |
| 8436 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8437 | Token * literal; |
| 8438 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8439 | if ( |
| 8440 | (literal = _PyPegen_expect_token(p, 25)) |
| 8441 | && |
| 8442 | (a = kvpairs_rule(p), 1) |
| 8443 | && |
| 8444 | (literal_1 = _PyPegen_expect_token(p, 26)) |
| 8445 | ) |
| 8446 | { |
| 8447 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8448 | if (token == NULL) { |
| 8449 | return NULL; |
| 8450 | } |
| 8451 | int end_lineno = token->end_lineno; |
| 8452 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8453 | int end_col_offset = token->end_col_offset; |
| 8454 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8455 | res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA ); |
| 8456 | if (res == NULL && PyErr_Occurred()) { |
| 8457 | p->error_indicator = 1; |
| 8458 | return NULL; |
| 8459 | } |
| 8460 | goto done; |
| 8461 | } |
| 8462 | p->mark = mark; |
| 8463 | } |
| 8464 | res = NULL; |
| 8465 | done: |
| 8466 | return res; |
| 8467 | } |
| 8468 | |
| 8469 | // dictcomp: '{' kvpair for_if_clauses '}' |
| 8470 | static expr_ty |
| 8471 | dictcomp_rule(Parser *p) |
| 8472 | { |
| 8473 | if (p->error_indicator) { |
| 8474 | return NULL; |
| 8475 | } |
| 8476 | expr_ty res = NULL; |
| 8477 | int mark = p->mark; |
| 8478 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8479 | p->error_indicator = 1; |
| 8480 | return NULL; |
| 8481 | } |
| 8482 | int start_lineno = p->tokens[mark]->lineno; |
| 8483 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8484 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8485 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8486 | { // '{' kvpair for_if_clauses '}' |
| 8487 | KeyValuePair* a; |
| 8488 | asdl_seq* b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8489 | Token * literal; |
| 8490 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8491 | if ( |
| 8492 | (literal = _PyPegen_expect_token(p, 25)) |
| 8493 | && |
| 8494 | (a = kvpair_rule(p)) |
| 8495 | && |
| 8496 | (b = for_if_clauses_rule(p)) |
| 8497 | && |
| 8498 | (literal_1 = _PyPegen_expect_token(p, 26)) |
| 8499 | ) |
| 8500 | { |
| 8501 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8502 | if (token == NULL) { |
| 8503 | return NULL; |
| 8504 | } |
| 8505 | int end_lineno = token->end_lineno; |
| 8506 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8507 | int end_col_offset = token->end_col_offset; |
| 8508 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8509 | res = _Py_DictComp ( a -> key , a -> value , b , EXTRA ); |
| 8510 | if (res == NULL && PyErr_Occurred()) { |
| 8511 | p->error_indicator = 1; |
| 8512 | return NULL; |
| 8513 | } |
| 8514 | goto done; |
| 8515 | } |
| 8516 | p->mark = mark; |
| 8517 | } |
| 8518 | res = NULL; |
| 8519 | done: |
| 8520 | return res; |
| 8521 | } |
| 8522 | |
| 8523 | // kvpairs: ','.kvpair+ ','? |
| 8524 | static asdl_seq* |
| 8525 | kvpairs_rule(Parser *p) |
| 8526 | { |
| 8527 | if (p->error_indicator) { |
| 8528 | return NULL; |
| 8529 | } |
| 8530 | asdl_seq* res = NULL; |
| 8531 | int mark = p->mark; |
| 8532 | { // ','.kvpair+ ','? |
| 8533 | asdl_seq * a; |
| 8534 | void *opt_var; |
| 8535 | UNUSED(opt_var); // Silence compiler warnings |
| 8536 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8537 | (a = _gather_102_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8538 | && |
| 8539 | (opt_var = _PyPegen_expect_token(p, 12), 1) |
| 8540 | ) |
| 8541 | { |
| 8542 | res = a; |
| 8543 | if (res == NULL && PyErr_Occurred()) { |
| 8544 | p->error_indicator = 1; |
| 8545 | return NULL; |
| 8546 | } |
| 8547 | goto done; |
| 8548 | } |
| 8549 | p->mark = mark; |
| 8550 | } |
| 8551 | res = NULL; |
| 8552 | done: |
| 8553 | return res; |
| 8554 | } |
| 8555 | |
| 8556 | // kvpair: '**' bitwise_or | expression ':' expression |
| 8557 | static KeyValuePair* |
| 8558 | kvpair_rule(Parser *p) |
| 8559 | { |
| 8560 | if (p->error_indicator) { |
| 8561 | return NULL; |
| 8562 | } |
| 8563 | KeyValuePair* res = NULL; |
| 8564 | int mark = p->mark; |
| 8565 | { // '**' bitwise_or |
| 8566 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8567 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8568 | if ( |
| 8569 | (literal = _PyPegen_expect_token(p, 35)) |
| 8570 | && |
| 8571 | (a = bitwise_or_rule(p)) |
| 8572 | ) |
| 8573 | { |
| 8574 | res = _PyPegen_key_value_pair ( p , NULL , a ); |
| 8575 | if (res == NULL && PyErr_Occurred()) { |
| 8576 | p->error_indicator = 1; |
| 8577 | return NULL; |
| 8578 | } |
| 8579 | goto done; |
| 8580 | } |
| 8581 | p->mark = mark; |
| 8582 | } |
| 8583 | { // expression ':' expression |
| 8584 | expr_ty a; |
| 8585 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8586 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8587 | if ( |
| 8588 | (a = expression_rule(p)) |
| 8589 | && |
| 8590 | (literal = _PyPegen_expect_token(p, 11)) |
| 8591 | && |
| 8592 | (b = expression_rule(p)) |
| 8593 | ) |
| 8594 | { |
| 8595 | res = _PyPegen_key_value_pair ( p , a , b ); |
| 8596 | if (res == NULL && PyErr_Occurred()) { |
| 8597 | p->error_indicator = 1; |
| 8598 | return NULL; |
| 8599 | } |
| 8600 | goto done; |
| 8601 | } |
| 8602 | p->mark = mark; |
| 8603 | } |
| 8604 | res = NULL; |
| 8605 | done: |
| 8606 | return res; |
| 8607 | } |
| 8608 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8609 | // for_if_clauses: for_if_clause+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8610 | static asdl_seq* |
| 8611 | for_if_clauses_rule(Parser *p) |
| 8612 | { |
| 8613 | if (p->error_indicator) { |
| 8614 | return NULL; |
| 8615 | } |
| 8616 | asdl_seq* res = NULL; |
| 8617 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8618 | { // for_if_clause+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8619 | asdl_seq * _loop1_104_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8620 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8621 | (_loop1_104_var = _loop1_104_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8622 | ) |
| 8623 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8624 | res = _loop1_104_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8625 | goto done; |
| 8626 | } |
| 8627 | p->mark = mark; |
| 8628 | } |
| 8629 | res = NULL; |
| 8630 | done: |
| 8631 | return res; |
| 8632 | } |
| 8633 | |
| 8634 | // for_if_clause: |
| 8635 | // | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8636 | // | 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8637 | static comprehension_ty |
| 8638 | for_if_clause_rule(Parser *p) |
| 8639 | { |
| 8640 | if (p->error_indicator) { |
| 8641 | return NULL; |
| 8642 | } |
| 8643 | comprehension_ty res = NULL; |
| 8644 | int mark = p->mark; |
| 8645 | { // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8646 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8647 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8648 | expr_ty b; |
| 8649 | asdl_seq * c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8650 | Token * keyword; |
| 8651 | Token * keyword_1; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8652 | if ( |
| 8653 | (async_var = _PyPegen_expect_token(p, ASYNC)) |
| 8654 | && |
| 8655 | (keyword = _PyPegen_expect_token(p, 517)) |
| 8656 | && |
| 8657 | (a = star_targets_rule(p)) |
| 8658 | && |
| 8659 | (keyword_1 = _PyPegen_expect_token(p, 518)) |
| 8660 | && |
| 8661 | (b = disjunction_rule(p)) |
| 8662 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8663 | (c = _loop0_105_rule(p)) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8664 | ) |
| 8665 | { |
| 8666 | res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) ); |
| 8667 | if (res == NULL && PyErr_Occurred()) { |
| 8668 | p->error_indicator = 1; |
| 8669 | return NULL; |
| 8670 | } |
| 8671 | goto done; |
| 8672 | } |
| 8673 | p->mark = mark; |
| 8674 | } |
| 8675 | { // 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8676 | expr_ty a; |
| 8677 | expr_ty b; |
| 8678 | asdl_seq * c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8679 | Token * keyword; |
| 8680 | Token * keyword_1; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8681 | if ( |
| 8682 | (keyword = _PyPegen_expect_token(p, 517)) |
| 8683 | && |
| 8684 | (a = star_targets_rule(p)) |
| 8685 | && |
| 8686 | (keyword_1 = _PyPegen_expect_token(p, 518)) |
| 8687 | && |
| 8688 | (b = disjunction_rule(p)) |
| 8689 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8690 | (c = _loop0_106_rule(p)) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8691 | ) |
| 8692 | { |
| 8693 | res = _Py_comprehension ( a , b , c , 0 , p -> arena ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8694 | if (res == NULL && PyErr_Occurred()) { |
| 8695 | p->error_indicator = 1; |
| 8696 | return NULL; |
| 8697 | } |
| 8698 | goto done; |
| 8699 | } |
| 8700 | p->mark = mark; |
| 8701 | } |
| 8702 | res = NULL; |
| 8703 | done: |
| 8704 | return res; |
| 8705 | } |
| 8706 | |
| 8707 | // yield_expr: 'yield' 'from' expression | 'yield' star_expressions? |
| 8708 | static expr_ty |
| 8709 | yield_expr_rule(Parser *p) |
| 8710 | { |
| 8711 | if (p->error_indicator) { |
| 8712 | return NULL; |
| 8713 | } |
| 8714 | expr_ty res = NULL; |
| 8715 | int mark = p->mark; |
| 8716 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8717 | p->error_indicator = 1; |
| 8718 | return NULL; |
| 8719 | } |
| 8720 | int start_lineno = p->tokens[mark]->lineno; |
| 8721 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8722 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8723 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8724 | { // 'yield' 'from' expression |
| 8725 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8726 | Token * keyword; |
| 8727 | Token * keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8728 | if ( |
| 8729 | (keyword = _PyPegen_expect_token(p, 504)) |
| 8730 | && |
| 8731 | (keyword_1 = _PyPegen_expect_token(p, 514)) |
| 8732 | && |
| 8733 | (a = expression_rule(p)) |
| 8734 | ) |
| 8735 | { |
| 8736 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8737 | if (token == NULL) { |
| 8738 | return NULL; |
| 8739 | } |
| 8740 | int end_lineno = token->end_lineno; |
| 8741 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8742 | int end_col_offset = token->end_col_offset; |
| 8743 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8744 | res = _Py_YieldFrom ( a , EXTRA ); |
| 8745 | if (res == NULL && PyErr_Occurred()) { |
| 8746 | p->error_indicator = 1; |
| 8747 | return NULL; |
| 8748 | } |
| 8749 | goto done; |
| 8750 | } |
| 8751 | p->mark = mark; |
| 8752 | } |
| 8753 | { // 'yield' star_expressions? |
| 8754 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8755 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8756 | if ( |
| 8757 | (keyword = _PyPegen_expect_token(p, 504)) |
| 8758 | && |
| 8759 | (a = star_expressions_rule(p), 1) |
| 8760 | ) |
| 8761 | { |
| 8762 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8763 | if (token == NULL) { |
| 8764 | return NULL; |
| 8765 | } |
| 8766 | int end_lineno = token->end_lineno; |
| 8767 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8768 | int end_col_offset = token->end_col_offset; |
| 8769 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8770 | res = _Py_Yield ( a , EXTRA ); |
| 8771 | if (res == NULL && PyErr_Occurred()) { |
| 8772 | p->error_indicator = 1; |
| 8773 | return NULL; |
| 8774 | } |
| 8775 | goto done; |
| 8776 | } |
| 8777 | p->mark = mark; |
| 8778 | } |
| 8779 | res = NULL; |
| 8780 | done: |
| 8781 | return res; |
| 8782 | } |
| 8783 | |
| 8784 | // arguments: args ','? &')' | incorrect_arguments |
| 8785 | static expr_ty |
| 8786 | arguments_rule(Parser *p) |
| 8787 | { |
| 8788 | if (p->error_indicator) { |
| 8789 | return NULL; |
| 8790 | } |
| 8791 | expr_ty res = NULL; |
| 8792 | if (_PyPegen_is_memoized(p, arguments_type, &res)) |
| 8793 | return res; |
| 8794 | int mark = p->mark; |
| 8795 | { // args ','? &')' |
| 8796 | expr_ty a; |
| 8797 | void *opt_var; |
| 8798 | UNUSED(opt_var); // Silence compiler warnings |
| 8799 | if ( |
| 8800 | (a = args_rule(p)) |
| 8801 | && |
| 8802 | (opt_var = _PyPegen_expect_token(p, 12), 1) |
| 8803 | && |
| 8804 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) |
| 8805 | ) |
| 8806 | { |
| 8807 | res = a; |
| 8808 | if (res == NULL && PyErr_Occurred()) { |
| 8809 | p->error_indicator = 1; |
| 8810 | return NULL; |
| 8811 | } |
| 8812 | goto done; |
| 8813 | } |
| 8814 | p->mark = mark; |
| 8815 | } |
| 8816 | { // incorrect_arguments |
| 8817 | void *incorrect_arguments_var; |
| 8818 | if ( |
| 8819 | (incorrect_arguments_var = incorrect_arguments_rule(p)) |
| 8820 | ) |
| 8821 | { |
| 8822 | res = incorrect_arguments_var; |
| 8823 | goto done; |
| 8824 | } |
| 8825 | p->mark = mark; |
| 8826 | } |
| 8827 | res = NULL; |
| 8828 | done: |
| 8829 | _PyPegen_insert_memo(p, mark, arguments_type, res); |
| 8830 | return res; |
| 8831 | } |
| 8832 | |
| 8833 | // args: starred_expression [',' args] | kwargs | named_expression [',' args] |
| 8834 | static expr_ty |
| 8835 | args_rule(Parser *p) |
| 8836 | { |
| 8837 | if (p->error_indicator) { |
| 8838 | return NULL; |
| 8839 | } |
| 8840 | expr_ty res = NULL; |
| 8841 | int mark = p->mark; |
| 8842 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8843 | p->error_indicator = 1; |
| 8844 | return NULL; |
| 8845 | } |
| 8846 | int start_lineno = p->tokens[mark]->lineno; |
| 8847 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 8848 | int start_col_offset = p->tokens[mark]->col_offset; |
| 8849 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 8850 | { // starred_expression [',' args] |
| 8851 | expr_ty a; |
| 8852 | void *b; |
| 8853 | if ( |
| 8854 | (a = starred_expression_rule(p)) |
| 8855 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8856 | (b = _tmp_107_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8857 | ) |
| 8858 | { |
| 8859 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8860 | if (token == NULL) { |
| 8861 | return NULL; |
| 8862 | } |
| 8863 | int end_lineno = token->end_lineno; |
| 8864 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8865 | int end_col_offset = token->end_col_offset; |
| 8866 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8867 | 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 ); |
| 8868 | if (res == NULL && PyErr_Occurred()) { |
| 8869 | p->error_indicator = 1; |
| 8870 | return NULL; |
| 8871 | } |
| 8872 | goto done; |
| 8873 | } |
| 8874 | p->mark = mark; |
| 8875 | } |
| 8876 | { // kwargs |
| 8877 | asdl_seq* a; |
| 8878 | if ( |
| 8879 | (a = kwargs_rule(p)) |
| 8880 | ) |
| 8881 | { |
| 8882 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8883 | if (token == NULL) { |
| 8884 | return NULL; |
| 8885 | } |
| 8886 | int end_lineno = token->end_lineno; |
| 8887 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8888 | int end_col_offset = token->end_col_offset; |
| 8889 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8890 | 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 ); |
| 8891 | if (res == NULL && PyErr_Occurred()) { |
| 8892 | p->error_indicator = 1; |
| 8893 | return NULL; |
| 8894 | } |
| 8895 | goto done; |
| 8896 | } |
| 8897 | p->mark = mark; |
| 8898 | } |
| 8899 | { // named_expression [',' args] |
| 8900 | expr_ty a; |
| 8901 | void *b; |
| 8902 | if ( |
| 8903 | (a = named_expression_rule(p)) |
| 8904 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8905 | (b = _tmp_108_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8906 | ) |
| 8907 | { |
| 8908 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8909 | if (token == NULL) { |
| 8910 | return NULL; |
| 8911 | } |
| 8912 | int end_lineno = token->end_lineno; |
| 8913 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 8914 | int end_col_offset = token->end_col_offset; |
| 8915 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 8916 | 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 ); |
| 8917 | if (res == NULL && PyErr_Occurred()) { |
| 8918 | p->error_indicator = 1; |
| 8919 | return NULL; |
| 8920 | } |
| 8921 | goto done; |
| 8922 | } |
| 8923 | p->mark = mark; |
| 8924 | } |
| 8925 | res = NULL; |
| 8926 | done: |
| 8927 | return res; |
| 8928 | } |
| 8929 | |
| 8930 | // kwargs: |
| 8931 | // | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
| 8932 | // | ','.kwarg_or_starred+ |
| 8933 | // | ','.kwarg_or_double_starred+ |
| 8934 | static asdl_seq* |
| 8935 | kwargs_rule(Parser *p) |
| 8936 | { |
| 8937 | if (p->error_indicator) { |
| 8938 | return NULL; |
| 8939 | } |
| 8940 | asdl_seq* res = NULL; |
| 8941 | int mark = p->mark; |
| 8942 | { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
| 8943 | asdl_seq * a; |
| 8944 | asdl_seq * b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8945 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8946 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8947 | (a = _gather_109_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8948 | && |
| 8949 | (literal = _PyPegen_expect_token(p, 12)) |
| 8950 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8951 | (b = _gather_111_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8952 | ) |
| 8953 | { |
| 8954 | res = _PyPegen_join_sequences ( p , a , b ); |
| 8955 | if (res == NULL && PyErr_Occurred()) { |
| 8956 | p->error_indicator = 1; |
| 8957 | return NULL; |
| 8958 | } |
| 8959 | goto done; |
| 8960 | } |
| 8961 | p->mark = mark; |
| 8962 | } |
| 8963 | { // ','.kwarg_or_starred+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8964 | asdl_seq * _gather_113_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8965 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8966 | (_gather_113_var = _gather_113_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8967 | ) |
| 8968 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8969 | res = _gather_113_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8970 | goto done; |
| 8971 | } |
| 8972 | p->mark = mark; |
| 8973 | } |
| 8974 | { // ','.kwarg_or_double_starred+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8975 | asdl_seq * _gather_115_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8976 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8977 | (_gather_115_var = _gather_115_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8978 | ) |
| 8979 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8980 | res = _gather_115_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8981 | goto done; |
| 8982 | } |
| 8983 | p->mark = mark; |
| 8984 | } |
| 8985 | res = NULL; |
| 8986 | done: |
| 8987 | return res; |
| 8988 | } |
| 8989 | |
| 8990 | // starred_expression: '*' expression |
| 8991 | static expr_ty |
| 8992 | starred_expression_rule(Parser *p) |
| 8993 | { |
| 8994 | if (p->error_indicator) { |
| 8995 | return NULL; |
| 8996 | } |
| 8997 | expr_ty res = NULL; |
| 8998 | int mark = p->mark; |
| 8999 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9000 | p->error_indicator = 1; |
| 9001 | return NULL; |
| 9002 | } |
| 9003 | int start_lineno = p->tokens[mark]->lineno; |
| 9004 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9005 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9006 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9007 | { // '*' expression |
| 9008 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9009 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9010 | if ( |
| 9011 | (literal = _PyPegen_expect_token(p, 16)) |
| 9012 | && |
| 9013 | (a = expression_rule(p)) |
| 9014 | ) |
| 9015 | { |
| 9016 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9017 | if (token == NULL) { |
| 9018 | return NULL; |
| 9019 | } |
| 9020 | int end_lineno = token->end_lineno; |
| 9021 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9022 | int end_col_offset = token->end_col_offset; |
| 9023 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9024 | res = _Py_Starred ( a , Load , EXTRA ); |
| 9025 | if (res == NULL && PyErr_Occurred()) { |
| 9026 | p->error_indicator = 1; |
| 9027 | return NULL; |
| 9028 | } |
| 9029 | goto done; |
| 9030 | } |
| 9031 | p->mark = mark; |
| 9032 | } |
| 9033 | res = NULL; |
| 9034 | done: |
| 9035 | return res; |
| 9036 | } |
| 9037 | |
| 9038 | // kwarg_or_starred: NAME '=' expression | starred_expression |
| 9039 | static KeywordOrStarred* |
| 9040 | kwarg_or_starred_rule(Parser *p) |
| 9041 | { |
| 9042 | if (p->error_indicator) { |
| 9043 | return NULL; |
| 9044 | } |
| 9045 | KeywordOrStarred* res = NULL; |
| 9046 | int mark = p->mark; |
| 9047 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9048 | p->error_indicator = 1; |
| 9049 | return NULL; |
| 9050 | } |
| 9051 | int start_lineno = p->tokens[mark]->lineno; |
| 9052 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9053 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9054 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9055 | { // NAME '=' expression |
| 9056 | expr_ty a; |
| 9057 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9058 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9059 | if ( |
| 9060 | (a = _PyPegen_name_token(p)) |
| 9061 | && |
| 9062 | (literal = _PyPegen_expect_token(p, 22)) |
| 9063 | && |
| 9064 | (b = expression_rule(p)) |
| 9065 | ) |
| 9066 | { |
| 9067 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9068 | if (token == NULL) { |
| 9069 | return NULL; |
| 9070 | } |
| 9071 | int end_lineno = token->end_lineno; |
| 9072 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9073 | int end_col_offset = token->end_col_offset; |
| 9074 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9075 | res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
| 9076 | if (res == NULL && PyErr_Occurred()) { |
| 9077 | p->error_indicator = 1; |
| 9078 | return NULL; |
| 9079 | } |
| 9080 | goto done; |
| 9081 | } |
| 9082 | p->mark = mark; |
| 9083 | } |
| 9084 | { // starred_expression |
| 9085 | expr_ty a; |
| 9086 | if ( |
| 9087 | (a = starred_expression_rule(p)) |
| 9088 | ) |
| 9089 | { |
| 9090 | res = _PyPegen_keyword_or_starred ( p , a , 0 ); |
| 9091 | if (res == NULL && PyErr_Occurred()) { |
| 9092 | p->error_indicator = 1; |
| 9093 | return NULL; |
| 9094 | } |
| 9095 | goto done; |
| 9096 | } |
| 9097 | p->mark = mark; |
| 9098 | } |
| 9099 | res = NULL; |
| 9100 | done: |
| 9101 | return res; |
| 9102 | } |
| 9103 | |
| 9104 | // kwarg_or_double_starred: NAME '=' expression | '**' expression |
| 9105 | static KeywordOrStarred* |
| 9106 | kwarg_or_double_starred_rule(Parser *p) |
| 9107 | { |
| 9108 | if (p->error_indicator) { |
| 9109 | return NULL; |
| 9110 | } |
| 9111 | KeywordOrStarred* res = NULL; |
| 9112 | int mark = p->mark; |
| 9113 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9114 | p->error_indicator = 1; |
| 9115 | return NULL; |
| 9116 | } |
| 9117 | int start_lineno = p->tokens[mark]->lineno; |
| 9118 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9119 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9120 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9121 | { // NAME '=' expression |
| 9122 | expr_ty a; |
| 9123 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9124 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9125 | if ( |
| 9126 | (a = _PyPegen_name_token(p)) |
| 9127 | && |
| 9128 | (literal = _PyPegen_expect_token(p, 22)) |
| 9129 | && |
| 9130 | (b = expression_rule(p)) |
| 9131 | ) |
| 9132 | { |
| 9133 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9134 | if (token == NULL) { |
| 9135 | return NULL; |
| 9136 | } |
| 9137 | int end_lineno = token->end_lineno; |
| 9138 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9139 | int end_col_offset = token->end_col_offset; |
| 9140 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9141 | res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
| 9142 | if (res == NULL && PyErr_Occurred()) { |
| 9143 | p->error_indicator = 1; |
| 9144 | return NULL; |
| 9145 | } |
| 9146 | goto done; |
| 9147 | } |
| 9148 | p->mark = mark; |
| 9149 | } |
| 9150 | { // '**' expression |
| 9151 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9152 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9153 | if ( |
| 9154 | (literal = _PyPegen_expect_token(p, 35)) |
| 9155 | && |
| 9156 | (a = expression_rule(p)) |
| 9157 | ) |
| 9158 | { |
| 9159 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9160 | if (token == NULL) { |
| 9161 | return NULL; |
| 9162 | } |
| 9163 | int end_lineno = token->end_lineno; |
| 9164 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9165 | int end_col_offset = token->end_col_offset; |
| 9166 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9167 | res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 ); |
| 9168 | if (res == NULL && PyErr_Occurred()) { |
| 9169 | p->error_indicator = 1; |
| 9170 | return NULL; |
| 9171 | } |
| 9172 | goto done; |
| 9173 | } |
| 9174 | p->mark = mark; |
| 9175 | } |
| 9176 | res = NULL; |
| 9177 | done: |
| 9178 | return res; |
| 9179 | } |
| 9180 | |
| 9181 | // star_targets: star_target !',' | star_target ((',' star_target))* ','? |
| 9182 | static expr_ty |
| 9183 | star_targets_rule(Parser *p) |
| 9184 | { |
| 9185 | if (p->error_indicator) { |
| 9186 | return NULL; |
| 9187 | } |
| 9188 | expr_ty res = NULL; |
| 9189 | int mark = p->mark; |
| 9190 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9191 | p->error_indicator = 1; |
| 9192 | return NULL; |
| 9193 | } |
| 9194 | int start_lineno = p->tokens[mark]->lineno; |
| 9195 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9196 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9197 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9198 | { // star_target !',' |
| 9199 | expr_ty a; |
| 9200 | if ( |
| 9201 | (a = star_target_rule(p)) |
| 9202 | && |
| 9203 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) |
| 9204 | ) |
| 9205 | { |
| 9206 | res = a; |
| 9207 | if (res == NULL && PyErr_Occurred()) { |
| 9208 | p->error_indicator = 1; |
| 9209 | return NULL; |
| 9210 | } |
| 9211 | goto done; |
| 9212 | } |
| 9213 | p->mark = mark; |
| 9214 | } |
| 9215 | { // star_target ((',' star_target))* ','? |
| 9216 | expr_ty a; |
| 9217 | asdl_seq * b; |
| 9218 | void *opt_var; |
| 9219 | UNUSED(opt_var); // Silence compiler warnings |
| 9220 | if ( |
| 9221 | (a = star_target_rule(p)) |
| 9222 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9223 | (b = _loop0_117_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9224 | && |
| 9225 | (opt_var = _PyPegen_expect_token(p, 12), 1) |
| 9226 | ) |
| 9227 | { |
| 9228 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9229 | if (token == NULL) { |
| 9230 | return NULL; |
| 9231 | } |
| 9232 | int end_lineno = token->end_lineno; |
| 9233 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9234 | int end_col_offset = token->end_col_offset; |
| 9235 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9236 | res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA ); |
| 9237 | if (res == NULL && PyErr_Occurred()) { |
| 9238 | p->error_indicator = 1; |
| 9239 | return NULL; |
| 9240 | } |
| 9241 | goto done; |
| 9242 | } |
| 9243 | p->mark = mark; |
| 9244 | } |
| 9245 | res = NULL; |
| 9246 | done: |
| 9247 | return res; |
| 9248 | } |
| 9249 | |
| 9250 | // star_targets_seq: ','.star_target+ ','? |
| 9251 | static asdl_seq* |
| 9252 | star_targets_seq_rule(Parser *p) |
| 9253 | { |
| 9254 | if (p->error_indicator) { |
| 9255 | return NULL; |
| 9256 | } |
| 9257 | asdl_seq* res = NULL; |
| 9258 | int mark = p->mark; |
| 9259 | { // ','.star_target+ ','? |
| 9260 | asdl_seq * a; |
| 9261 | void *opt_var; |
| 9262 | UNUSED(opt_var); // Silence compiler warnings |
| 9263 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9264 | (a = _gather_118_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9265 | && |
| 9266 | (opt_var = _PyPegen_expect_token(p, 12), 1) |
| 9267 | ) |
| 9268 | { |
| 9269 | res = a; |
| 9270 | if (res == NULL && PyErr_Occurred()) { |
| 9271 | p->error_indicator = 1; |
| 9272 | return NULL; |
| 9273 | } |
| 9274 | goto done; |
| 9275 | } |
| 9276 | p->mark = mark; |
| 9277 | } |
| 9278 | res = NULL; |
| 9279 | done: |
| 9280 | return res; |
| 9281 | } |
| 9282 | |
| 9283 | // star_target: |
| 9284 | // | '*' (!'*' star_target) |
| 9285 | // | t_primary '.' NAME !t_lookahead |
| 9286 | // | t_primary '[' slices ']' !t_lookahead |
| 9287 | // | star_atom |
| 9288 | static expr_ty |
| 9289 | star_target_rule(Parser *p) |
| 9290 | { |
| 9291 | if (p->error_indicator) { |
| 9292 | return NULL; |
| 9293 | } |
| 9294 | expr_ty res = NULL; |
| 9295 | if (_PyPegen_is_memoized(p, star_target_type, &res)) |
| 9296 | return res; |
| 9297 | int mark = p->mark; |
| 9298 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9299 | p->error_indicator = 1; |
| 9300 | return NULL; |
| 9301 | } |
| 9302 | int start_lineno = p->tokens[mark]->lineno; |
| 9303 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9304 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9305 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9306 | { // '*' (!'*' star_target) |
| 9307 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9308 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9309 | if ( |
| 9310 | (literal = _PyPegen_expect_token(p, 16)) |
| 9311 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9312 | (a = _tmp_120_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9313 | ) |
| 9314 | { |
| 9315 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9316 | if (token == NULL) { |
| 9317 | return NULL; |
| 9318 | } |
| 9319 | int end_lineno = token->end_lineno; |
| 9320 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9321 | int end_col_offset = token->end_col_offset; |
| 9322 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9323 | res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA ); |
| 9324 | if (res == NULL && PyErr_Occurred()) { |
| 9325 | p->error_indicator = 1; |
| 9326 | return NULL; |
| 9327 | } |
| 9328 | goto done; |
| 9329 | } |
| 9330 | p->mark = mark; |
| 9331 | } |
| 9332 | { // t_primary '.' NAME !t_lookahead |
| 9333 | expr_ty a; |
| 9334 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9335 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9336 | if ( |
| 9337 | (a = t_primary_rule(p)) |
| 9338 | && |
| 9339 | (literal = _PyPegen_expect_token(p, 23)) |
| 9340 | && |
| 9341 | (b = _PyPegen_name_token(p)) |
| 9342 | && |
| 9343 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9344 | ) |
| 9345 | { |
| 9346 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9347 | if (token == NULL) { |
| 9348 | return NULL; |
| 9349 | } |
| 9350 | int end_lineno = token->end_lineno; |
| 9351 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9352 | int end_col_offset = token->end_col_offset; |
| 9353 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9354 | res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 9355 | if (res == NULL && PyErr_Occurred()) { |
| 9356 | p->error_indicator = 1; |
| 9357 | return NULL; |
| 9358 | } |
| 9359 | goto done; |
| 9360 | } |
| 9361 | p->mark = mark; |
| 9362 | } |
| 9363 | { // t_primary '[' slices ']' !t_lookahead |
| 9364 | expr_ty a; |
| 9365 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9366 | Token * literal; |
| 9367 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9368 | if ( |
| 9369 | (a = t_primary_rule(p)) |
| 9370 | && |
| 9371 | (literal = _PyPegen_expect_token(p, 9)) |
| 9372 | && |
| 9373 | (b = slices_rule(p)) |
| 9374 | && |
| 9375 | (literal_1 = _PyPegen_expect_token(p, 10)) |
| 9376 | && |
| 9377 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9378 | ) |
| 9379 | { |
| 9380 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9381 | if (token == NULL) { |
| 9382 | return NULL; |
| 9383 | } |
| 9384 | int end_lineno = token->end_lineno; |
| 9385 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9386 | int end_col_offset = token->end_col_offset; |
| 9387 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9388 | res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 9389 | if (res == NULL && PyErr_Occurred()) { |
| 9390 | p->error_indicator = 1; |
| 9391 | return NULL; |
| 9392 | } |
| 9393 | goto done; |
| 9394 | } |
| 9395 | p->mark = mark; |
| 9396 | } |
| 9397 | { // star_atom |
| 9398 | expr_ty star_atom_var; |
| 9399 | if ( |
| 9400 | (star_atom_var = star_atom_rule(p)) |
| 9401 | ) |
| 9402 | { |
| 9403 | res = star_atom_var; |
| 9404 | goto done; |
| 9405 | } |
| 9406 | p->mark = mark; |
| 9407 | } |
| 9408 | res = NULL; |
| 9409 | done: |
| 9410 | _PyPegen_insert_memo(p, mark, star_target_type, res); |
| 9411 | return res; |
| 9412 | } |
| 9413 | |
| 9414 | // star_atom: |
| 9415 | // | NAME |
| 9416 | // | '(' star_target ')' |
| 9417 | // | '(' star_targets_seq? ')' |
| 9418 | // | '[' star_targets_seq? ']' |
| 9419 | static expr_ty |
| 9420 | star_atom_rule(Parser *p) |
| 9421 | { |
| 9422 | if (p->error_indicator) { |
| 9423 | return NULL; |
| 9424 | } |
| 9425 | expr_ty res = NULL; |
| 9426 | int mark = p->mark; |
| 9427 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9428 | p->error_indicator = 1; |
| 9429 | return NULL; |
| 9430 | } |
| 9431 | int start_lineno = p->tokens[mark]->lineno; |
| 9432 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9433 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9434 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9435 | { // NAME |
| 9436 | expr_ty a; |
| 9437 | if ( |
| 9438 | (a = _PyPegen_name_token(p)) |
| 9439 | ) |
| 9440 | { |
| 9441 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9442 | if (res == NULL && PyErr_Occurred()) { |
| 9443 | p->error_indicator = 1; |
| 9444 | return NULL; |
| 9445 | } |
| 9446 | goto done; |
| 9447 | } |
| 9448 | p->mark = mark; |
| 9449 | } |
| 9450 | { // '(' star_target ')' |
| 9451 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9452 | Token * literal; |
| 9453 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9454 | if ( |
| 9455 | (literal = _PyPegen_expect_token(p, 7)) |
| 9456 | && |
| 9457 | (a = star_target_rule(p)) |
| 9458 | && |
| 9459 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 9460 | ) |
| 9461 | { |
| 9462 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9463 | if (res == NULL && PyErr_Occurred()) { |
| 9464 | p->error_indicator = 1; |
| 9465 | return NULL; |
| 9466 | } |
| 9467 | goto done; |
| 9468 | } |
| 9469 | p->mark = mark; |
| 9470 | } |
| 9471 | { // '(' star_targets_seq? ')' |
| 9472 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9473 | Token * literal; |
| 9474 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9475 | if ( |
| 9476 | (literal = _PyPegen_expect_token(p, 7)) |
| 9477 | && |
| 9478 | (a = star_targets_seq_rule(p), 1) |
| 9479 | && |
| 9480 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 9481 | ) |
| 9482 | { |
| 9483 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9484 | if (token == NULL) { |
| 9485 | return NULL; |
| 9486 | } |
| 9487 | int end_lineno = token->end_lineno; |
| 9488 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9489 | int end_col_offset = token->end_col_offset; |
| 9490 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9491 | res = _Py_Tuple ( a , Store , EXTRA ); |
| 9492 | if (res == NULL && PyErr_Occurred()) { |
| 9493 | p->error_indicator = 1; |
| 9494 | return NULL; |
| 9495 | } |
| 9496 | goto done; |
| 9497 | } |
| 9498 | p->mark = mark; |
| 9499 | } |
| 9500 | { // '[' star_targets_seq? ']' |
| 9501 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9502 | Token * literal; |
| 9503 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9504 | if ( |
| 9505 | (literal = _PyPegen_expect_token(p, 9)) |
| 9506 | && |
| 9507 | (a = star_targets_seq_rule(p), 1) |
| 9508 | && |
| 9509 | (literal_1 = _PyPegen_expect_token(p, 10)) |
| 9510 | ) |
| 9511 | { |
| 9512 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9513 | if (token == NULL) { |
| 9514 | return NULL; |
| 9515 | } |
| 9516 | int end_lineno = token->end_lineno; |
| 9517 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9518 | int end_col_offset = token->end_col_offset; |
| 9519 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9520 | res = _Py_List ( a , Store , EXTRA ); |
| 9521 | if (res == NULL && PyErr_Occurred()) { |
| 9522 | p->error_indicator = 1; |
| 9523 | return NULL; |
| 9524 | } |
| 9525 | goto done; |
| 9526 | } |
| 9527 | p->mark = mark; |
| 9528 | } |
| 9529 | res = NULL; |
| 9530 | done: |
| 9531 | return res; |
| 9532 | } |
| 9533 | |
| 9534 | // inside_paren_ann_assign_target: |
| 9535 | // | ann_assign_subscript_attribute_target |
| 9536 | // | NAME |
| 9537 | // | '(' inside_paren_ann_assign_target ')' |
| 9538 | static expr_ty |
| 9539 | inside_paren_ann_assign_target_rule(Parser *p) |
| 9540 | { |
| 9541 | if (p->error_indicator) { |
| 9542 | return NULL; |
| 9543 | } |
| 9544 | expr_ty res = NULL; |
| 9545 | int mark = p->mark; |
| 9546 | { // ann_assign_subscript_attribute_target |
| 9547 | expr_ty ann_assign_subscript_attribute_target_var; |
| 9548 | if ( |
| 9549 | (ann_assign_subscript_attribute_target_var = ann_assign_subscript_attribute_target_rule(p)) |
| 9550 | ) |
| 9551 | { |
| 9552 | res = ann_assign_subscript_attribute_target_var; |
| 9553 | goto done; |
| 9554 | } |
| 9555 | p->mark = mark; |
| 9556 | } |
| 9557 | { // NAME |
| 9558 | expr_ty a; |
| 9559 | if ( |
| 9560 | (a = _PyPegen_name_token(p)) |
| 9561 | ) |
| 9562 | { |
| 9563 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9564 | if (res == NULL && PyErr_Occurred()) { |
| 9565 | p->error_indicator = 1; |
| 9566 | return NULL; |
| 9567 | } |
| 9568 | goto done; |
| 9569 | } |
| 9570 | p->mark = mark; |
| 9571 | } |
| 9572 | { // '(' inside_paren_ann_assign_target ')' |
| 9573 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9574 | Token * literal; |
| 9575 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9576 | if ( |
| 9577 | (literal = _PyPegen_expect_token(p, 7)) |
| 9578 | && |
| 9579 | (a = inside_paren_ann_assign_target_rule(p)) |
| 9580 | && |
| 9581 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 9582 | ) |
| 9583 | { |
| 9584 | res = a; |
| 9585 | if (res == NULL && PyErr_Occurred()) { |
| 9586 | p->error_indicator = 1; |
| 9587 | return NULL; |
| 9588 | } |
| 9589 | goto done; |
| 9590 | } |
| 9591 | p->mark = mark; |
| 9592 | } |
| 9593 | res = NULL; |
| 9594 | done: |
| 9595 | return res; |
| 9596 | } |
| 9597 | |
| 9598 | // ann_assign_subscript_attribute_target: |
| 9599 | // | t_primary '.' NAME !t_lookahead |
| 9600 | // | t_primary '[' slices ']' !t_lookahead |
| 9601 | static expr_ty |
| 9602 | ann_assign_subscript_attribute_target_rule(Parser *p) |
| 9603 | { |
| 9604 | if (p->error_indicator) { |
| 9605 | return NULL; |
| 9606 | } |
| 9607 | expr_ty res = NULL; |
| 9608 | int mark = p->mark; |
| 9609 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9610 | p->error_indicator = 1; |
| 9611 | return NULL; |
| 9612 | } |
| 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 |
| 9617 | { // t_primary '.' NAME !t_lookahead |
| 9618 | expr_ty a; |
| 9619 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9620 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9621 | if ( |
| 9622 | (a = t_primary_rule(p)) |
| 9623 | && |
| 9624 | (literal = _PyPegen_expect_token(p, 23)) |
| 9625 | && |
| 9626 | (b = _PyPegen_name_token(p)) |
| 9627 | && |
| 9628 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9629 | ) |
| 9630 | { |
| 9631 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9632 | if (token == NULL) { |
| 9633 | return NULL; |
| 9634 | } |
| 9635 | int end_lineno = token->end_lineno; |
| 9636 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9637 | int end_col_offset = token->end_col_offset; |
| 9638 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9639 | res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 9640 | if (res == NULL && PyErr_Occurred()) { |
| 9641 | p->error_indicator = 1; |
| 9642 | return NULL; |
| 9643 | } |
| 9644 | goto done; |
| 9645 | } |
| 9646 | p->mark = mark; |
| 9647 | } |
| 9648 | { // t_primary '[' slices ']' !t_lookahead |
| 9649 | expr_ty a; |
| 9650 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9651 | Token * literal; |
| 9652 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9653 | if ( |
| 9654 | (a = t_primary_rule(p)) |
| 9655 | && |
| 9656 | (literal = _PyPegen_expect_token(p, 9)) |
| 9657 | && |
| 9658 | (b = slices_rule(p)) |
| 9659 | && |
| 9660 | (literal_1 = _PyPegen_expect_token(p, 10)) |
| 9661 | && |
| 9662 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9663 | ) |
| 9664 | { |
| 9665 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9666 | if (token == NULL) { |
| 9667 | return NULL; |
| 9668 | } |
| 9669 | int end_lineno = token->end_lineno; |
| 9670 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9671 | int end_col_offset = token->end_col_offset; |
| 9672 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9673 | res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 9674 | if (res == NULL && PyErr_Occurred()) { |
| 9675 | p->error_indicator = 1; |
| 9676 | return NULL; |
| 9677 | } |
| 9678 | goto done; |
| 9679 | } |
| 9680 | p->mark = mark; |
| 9681 | } |
| 9682 | res = NULL; |
| 9683 | done: |
| 9684 | return res; |
| 9685 | } |
| 9686 | |
| 9687 | // del_targets: ','.del_target+ ','? |
| 9688 | static asdl_seq* |
| 9689 | del_targets_rule(Parser *p) |
| 9690 | { |
| 9691 | if (p->error_indicator) { |
| 9692 | return NULL; |
| 9693 | } |
| 9694 | asdl_seq* res = NULL; |
| 9695 | int mark = p->mark; |
| 9696 | { // ','.del_target+ ','? |
| 9697 | asdl_seq * a; |
| 9698 | void *opt_var; |
| 9699 | UNUSED(opt_var); // Silence compiler warnings |
| 9700 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9701 | (a = _gather_121_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9702 | && |
| 9703 | (opt_var = _PyPegen_expect_token(p, 12), 1) |
| 9704 | ) |
| 9705 | { |
| 9706 | res = a; |
| 9707 | if (res == NULL && PyErr_Occurred()) { |
| 9708 | p->error_indicator = 1; |
| 9709 | return NULL; |
| 9710 | } |
| 9711 | goto done; |
| 9712 | } |
| 9713 | p->mark = mark; |
| 9714 | } |
| 9715 | res = NULL; |
| 9716 | done: |
| 9717 | return res; |
| 9718 | } |
| 9719 | |
| 9720 | // del_target: |
| 9721 | // | t_primary '.' NAME !t_lookahead |
| 9722 | // | t_primary '[' slices ']' !t_lookahead |
| 9723 | // | del_t_atom |
| 9724 | static expr_ty |
| 9725 | del_target_rule(Parser *p) |
| 9726 | { |
| 9727 | if (p->error_indicator) { |
| 9728 | return NULL; |
| 9729 | } |
| 9730 | expr_ty res = NULL; |
| 9731 | if (_PyPegen_is_memoized(p, del_target_type, &res)) |
| 9732 | return res; |
| 9733 | int mark = p->mark; |
| 9734 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9735 | p->error_indicator = 1; |
| 9736 | return NULL; |
| 9737 | } |
| 9738 | int start_lineno = p->tokens[mark]->lineno; |
| 9739 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9740 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9741 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9742 | { // t_primary '.' NAME !t_lookahead |
| 9743 | expr_ty a; |
| 9744 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9745 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9746 | if ( |
| 9747 | (a = t_primary_rule(p)) |
| 9748 | && |
| 9749 | (literal = _PyPegen_expect_token(p, 23)) |
| 9750 | && |
| 9751 | (b = _PyPegen_name_token(p)) |
| 9752 | && |
| 9753 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9754 | ) |
| 9755 | { |
| 9756 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9757 | if (token == NULL) { |
| 9758 | return NULL; |
| 9759 | } |
| 9760 | int end_lineno = token->end_lineno; |
| 9761 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9762 | int end_col_offset = token->end_col_offset; |
| 9763 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9764 | res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA ); |
| 9765 | if (res == NULL && PyErr_Occurred()) { |
| 9766 | p->error_indicator = 1; |
| 9767 | return NULL; |
| 9768 | } |
| 9769 | goto done; |
| 9770 | } |
| 9771 | p->mark = mark; |
| 9772 | } |
| 9773 | { // t_primary '[' slices ']' !t_lookahead |
| 9774 | expr_ty a; |
| 9775 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9776 | Token * literal; |
| 9777 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9778 | if ( |
| 9779 | (a = t_primary_rule(p)) |
| 9780 | && |
| 9781 | (literal = _PyPegen_expect_token(p, 9)) |
| 9782 | && |
| 9783 | (b = slices_rule(p)) |
| 9784 | && |
| 9785 | (literal_1 = _PyPegen_expect_token(p, 10)) |
| 9786 | && |
| 9787 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9788 | ) |
| 9789 | { |
| 9790 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9791 | if (token == NULL) { |
| 9792 | return NULL; |
| 9793 | } |
| 9794 | int end_lineno = token->end_lineno; |
| 9795 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9796 | int end_col_offset = token->end_col_offset; |
| 9797 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9798 | res = _Py_Subscript ( a , b , Del , EXTRA ); |
| 9799 | if (res == NULL && PyErr_Occurred()) { |
| 9800 | p->error_indicator = 1; |
| 9801 | return NULL; |
| 9802 | } |
| 9803 | goto done; |
| 9804 | } |
| 9805 | p->mark = mark; |
| 9806 | } |
| 9807 | { // del_t_atom |
| 9808 | expr_ty del_t_atom_var; |
| 9809 | if ( |
| 9810 | (del_t_atom_var = del_t_atom_rule(p)) |
| 9811 | ) |
| 9812 | { |
| 9813 | res = del_t_atom_var; |
| 9814 | goto done; |
| 9815 | } |
| 9816 | p->mark = mark; |
| 9817 | } |
| 9818 | res = NULL; |
| 9819 | done: |
| 9820 | _PyPegen_insert_memo(p, mark, del_target_type, res); |
| 9821 | return res; |
| 9822 | } |
| 9823 | |
| 9824 | // del_t_atom: NAME | '(' del_target ')' | '(' del_targets? ')' | '[' del_targets? ']' |
| 9825 | static expr_ty |
| 9826 | del_t_atom_rule(Parser *p) |
| 9827 | { |
| 9828 | if (p->error_indicator) { |
| 9829 | return NULL; |
| 9830 | } |
| 9831 | expr_ty res = NULL; |
| 9832 | int mark = p->mark; |
| 9833 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9834 | p->error_indicator = 1; |
| 9835 | return NULL; |
| 9836 | } |
| 9837 | int start_lineno = p->tokens[mark]->lineno; |
| 9838 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9839 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9840 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9841 | { // NAME |
| 9842 | expr_ty a; |
| 9843 | if ( |
| 9844 | (a = _PyPegen_name_token(p)) |
| 9845 | ) |
| 9846 | { |
| 9847 | res = _PyPegen_set_expr_context ( p , a , Del ); |
| 9848 | if (res == NULL && PyErr_Occurred()) { |
| 9849 | p->error_indicator = 1; |
| 9850 | return NULL; |
| 9851 | } |
| 9852 | goto done; |
| 9853 | } |
| 9854 | p->mark = mark; |
| 9855 | } |
| 9856 | { // '(' del_target ')' |
| 9857 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9858 | Token * literal; |
| 9859 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9860 | if ( |
| 9861 | (literal = _PyPegen_expect_token(p, 7)) |
| 9862 | && |
| 9863 | (a = del_target_rule(p)) |
| 9864 | && |
| 9865 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 9866 | ) |
| 9867 | { |
| 9868 | res = _PyPegen_set_expr_context ( p , a , Del ); |
| 9869 | if (res == NULL && PyErr_Occurred()) { |
| 9870 | p->error_indicator = 1; |
| 9871 | return NULL; |
| 9872 | } |
| 9873 | goto done; |
| 9874 | } |
| 9875 | p->mark = mark; |
| 9876 | } |
| 9877 | { // '(' del_targets? ')' |
| 9878 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9879 | Token * literal; |
| 9880 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9881 | if ( |
| 9882 | (literal = _PyPegen_expect_token(p, 7)) |
| 9883 | && |
| 9884 | (a = del_targets_rule(p), 1) |
| 9885 | && |
| 9886 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 9887 | ) |
| 9888 | { |
| 9889 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9890 | if (token == NULL) { |
| 9891 | return NULL; |
| 9892 | } |
| 9893 | int end_lineno = token->end_lineno; |
| 9894 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9895 | int end_col_offset = token->end_col_offset; |
| 9896 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9897 | res = _Py_Tuple ( a , Del , EXTRA ); |
| 9898 | if (res == NULL && PyErr_Occurred()) { |
| 9899 | p->error_indicator = 1; |
| 9900 | return NULL; |
| 9901 | } |
| 9902 | goto done; |
| 9903 | } |
| 9904 | p->mark = mark; |
| 9905 | } |
| 9906 | { // '[' del_targets? ']' |
| 9907 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9908 | Token * literal; |
| 9909 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9910 | if ( |
| 9911 | (literal = _PyPegen_expect_token(p, 9)) |
| 9912 | && |
| 9913 | (a = del_targets_rule(p), 1) |
| 9914 | && |
| 9915 | (literal_1 = _PyPegen_expect_token(p, 10)) |
| 9916 | ) |
| 9917 | { |
| 9918 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9919 | if (token == NULL) { |
| 9920 | return NULL; |
| 9921 | } |
| 9922 | int end_lineno = token->end_lineno; |
| 9923 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 9924 | int end_col_offset = token->end_col_offset; |
| 9925 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 9926 | res = _Py_List ( a , Del , EXTRA ); |
| 9927 | if (res == NULL && PyErr_Occurred()) { |
| 9928 | p->error_indicator = 1; |
| 9929 | return NULL; |
| 9930 | } |
| 9931 | goto done; |
| 9932 | } |
| 9933 | p->mark = mark; |
| 9934 | } |
| 9935 | res = NULL; |
| 9936 | done: |
| 9937 | return res; |
| 9938 | } |
| 9939 | |
| 9940 | // targets: ','.target+ ','? |
| 9941 | static asdl_seq* |
| 9942 | targets_rule(Parser *p) |
| 9943 | { |
| 9944 | if (p->error_indicator) { |
| 9945 | return NULL; |
| 9946 | } |
| 9947 | asdl_seq* res = NULL; |
| 9948 | int mark = p->mark; |
| 9949 | { // ','.target+ ','? |
| 9950 | asdl_seq * a; |
| 9951 | void *opt_var; |
| 9952 | UNUSED(opt_var); // Silence compiler warnings |
| 9953 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9954 | (a = _gather_123_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9955 | && |
| 9956 | (opt_var = _PyPegen_expect_token(p, 12), 1) |
| 9957 | ) |
| 9958 | { |
| 9959 | res = a; |
| 9960 | if (res == NULL && PyErr_Occurred()) { |
| 9961 | p->error_indicator = 1; |
| 9962 | return NULL; |
| 9963 | } |
| 9964 | goto done; |
| 9965 | } |
| 9966 | p->mark = mark; |
| 9967 | } |
| 9968 | res = NULL; |
| 9969 | done: |
| 9970 | return res; |
| 9971 | } |
| 9972 | |
| 9973 | // target: |
| 9974 | // | t_primary '.' NAME !t_lookahead |
| 9975 | // | t_primary '[' slices ']' !t_lookahead |
| 9976 | // | t_atom |
| 9977 | static expr_ty |
| 9978 | target_rule(Parser *p) |
| 9979 | { |
| 9980 | if (p->error_indicator) { |
| 9981 | return NULL; |
| 9982 | } |
| 9983 | expr_ty res = NULL; |
| 9984 | if (_PyPegen_is_memoized(p, target_type, &res)) |
| 9985 | return res; |
| 9986 | int mark = p->mark; |
| 9987 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9988 | p->error_indicator = 1; |
| 9989 | return NULL; |
| 9990 | } |
| 9991 | int start_lineno = p->tokens[mark]->lineno; |
| 9992 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 9993 | int start_col_offset = p->tokens[mark]->col_offset; |
| 9994 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 9995 | { // t_primary '.' NAME !t_lookahead |
| 9996 | expr_ty a; |
| 9997 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 9998 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9999 | if ( |
| 10000 | (a = t_primary_rule(p)) |
| 10001 | && |
| 10002 | (literal = _PyPegen_expect_token(p, 23)) |
| 10003 | && |
| 10004 | (b = _PyPegen_name_token(p)) |
| 10005 | && |
| 10006 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 10007 | ) |
| 10008 | { |
| 10009 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10010 | if (token == NULL) { |
| 10011 | return NULL; |
| 10012 | } |
| 10013 | int end_lineno = token->end_lineno; |
| 10014 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10015 | int end_col_offset = token->end_col_offset; |
| 10016 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10017 | res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 10018 | if (res == NULL && PyErr_Occurred()) { |
| 10019 | p->error_indicator = 1; |
| 10020 | return NULL; |
| 10021 | } |
| 10022 | goto done; |
| 10023 | } |
| 10024 | p->mark = mark; |
| 10025 | } |
| 10026 | { // t_primary '[' slices ']' !t_lookahead |
| 10027 | expr_ty a; |
| 10028 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10029 | Token * literal; |
| 10030 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10031 | if ( |
| 10032 | (a = t_primary_rule(p)) |
| 10033 | && |
| 10034 | (literal = _PyPegen_expect_token(p, 9)) |
| 10035 | && |
| 10036 | (b = slices_rule(p)) |
| 10037 | && |
| 10038 | (literal_1 = _PyPegen_expect_token(p, 10)) |
| 10039 | && |
| 10040 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 10041 | ) |
| 10042 | { |
| 10043 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10044 | if (token == NULL) { |
| 10045 | return NULL; |
| 10046 | } |
| 10047 | int end_lineno = token->end_lineno; |
| 10048 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10049 | int end_col_offset = token->end_col_offset; |
| 10050 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10051 | res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 10052 | if (res == NULL && PyErr_Occurred()) { |
| 10053 | p->error_indicator = 1; |
| 10054 | return NULL; |
| 10055 | } |
| 10056 | goto done; |
| 10057 | } |
| 10058 | p->mark = mark; |
| 10059 | } |
| 10060 | { // t_atom |
| 10061 | expr_ty t_atom_var; |
| 10062 | if ( |
| 10063 | (t_atom_var = t_atom_rule(p)) |
| 10064 | ) |
| 10065 | { |
| 10066 | res = t_atom_var; |
| 10067 | goto done; |
| 10068 | } |
| 10069 | p->mark = mark; |
| 10070 | } |
| 10071 | res = NULL; |
| 10072 | done: |
| 10073 | _PyPegen_insert_memo(p, mark, target_type, res); |
| 10074 | return res; |
| 10075 | } |
| 10076 | |
| 10077 | // Left-recursive |
| 10078 | // t_primary: |
| 10079 | // | t_primary '.' NAME &t_lookahead |
| 10080 | // | t_primary '[' slices ']' &t_lookahead |
| 10081 | // | t_primary genexp &t_lookahead |
| 10082 | // | t_primary '(' arguments? ')' &t_lookahead |
| 10083 | // | atom &t_lookahead |
| 10084 | static expr_ty t_primary_raw(Parser *); |
| 10085 | static expr_ty |
| 10086 | t_primary_rule(Parser *p) |
| 10087 | { |
| 10088 | expr_ty res = NULL; |
| 10089 | if (_PyPegen_is_memoized(p, t_primary_type, &res)) |
| 10090 | return res; |
| 10091 | int mark = p->mark; |
| 10092 | int resmark = p->mark; |
| 10093 | while (1) { |
| 10094 | int tmpvar_8 = _PyPegen_update_memo(p, mark, t_primary_type, res); |
| 10095 | if (tmpvar_8) { |
| 10096 | return res; |
| 10097 | } |
| 10098 | p->mark = mark; |
| 10099 | void *raw = t_primary_raw(p); |
| 10100 | if (raw == NULL || p->mark <= resmark) |
| 10101 | break; |
| 10102 | resmark = p->mark; |
| 10103 | res = raw; |
| 10104 | } |
| 10105 | p->mark = resmark; |
| 10106 | return res; |
| 10107 | } |
| 10108 | static expr_ty |
| 10109 | t_primary_raw(Parser *p) |
| 10110 | { |
| 10111 | if (p->error_indicator) { |
| 10112 | return NULL; |
| 10113 | } |
| 10114 | expr_ty res = NULL; |
| 10115 | int mark = p->mark; |
| 10116 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10117 | p->error_indicator = 1; |
| 10118 | return NULL; |
| 10119 | } |
| 10120 | int start_lineno = p->tokens[mark]->lineno; |
| 10121 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 10122 | int start_col_offset = p->tokens[mark]->col_offset; |
| 10123 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 10124 | { // t_primary '.' NAME &t_lookahead |
| 10125 | expr_ty a; |
| 10126 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10127 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10128 | if ( |
| 10129 | (a = t_primary_rule(p)) |
| 10130 | && |
| 10131 | (literal = _PyPegen_expect_token(p, 23)) |
| 10132 | && |
| 10133 | (b = _PyPegen_name_token(p)) |
| 10134 | && |
| 10135 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10136 | ) |
| 10137 | { |
| 10138 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10139 | if (token == NULL) { |
| 10140 | return NULL; |
| 10141 | } |
| 10142 | int end_lineno = token->end_lineno; |
| 10143 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10144 | int end_col_offset = token->end_col_offset; |
| 10145 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10146 | res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
| 10147 | if (res == NULL && PyErr_Occurred()) { |
| 10148 | p->error_indicator = 1; |
| 10149 | return NULL; |
| 10150 | } |
| 10151 | goto done; |
| 10152 | } |
| 10153 | p->mark = mark; |
| 10154 | } |
| 10155 | { // t_primary '[' slices ']' &t_lookahead |
| 10156 | expr_ty a; |
| 10157 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10158 | Token * literal; |
| 10159 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10160 | if ( |
| 10161 | (a = t_primary_rule(p)) |
| 10162 | && |
| 10163 | (literal = _PyPegen_expect_token(p, 9)) |
| 10164 | && |
| 10165 | (b = slices_rule(p)) |
| 10166 | && |
| 10167 | (literal_1 = _PyPegen_expect_token(p, 10)) |
| 10168 | && |
| 10169 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10170 | ) |
| 10171 | { |
| 10172 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10173 | if (token == NULL) { |
| 10174 | return NULL; |
| 10175 | } |
| 10176 | int end_lineno = token->end_lineno; |
| 10177 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10178 | int end_col_offset = token->end_col_offset; |
| 10179 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10180 | res = _Py_Subscript ( a , b , Load , EXTRA ); |
| 10181 | if (res == NULL && PyErr_Occurred()) { |
| 10182 | p->error_indicator = 1; |
| 10183 | return NULL; |
| 10184 | } |
| 10185 | goto done; |
| 10186 | } |
| 10187 | p->mark = mark; |
| 10188 | } |
| 10189 | { // t_primary genexp &t_lookahead |
| 10190 | expr_ty a; |
| 10191 | expr_ty b; |
| 10192 | if ( |
| 10193 | (a = t_primary_rule(p)) |
| 10194 | && |
| 10195 | (b = genexp_rule(p)) |
| 10196 | && |
| 10197 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10198 | ) |
| 10199 | { |
| 10200 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10201 | if (token == NULL) { |
| 10202 | return NULL; |
| 10203 | } |
| 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_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
| 10209 | if (res == NULL && PyErr_Occurred()) { |
| 10210 | p->error_indicator = 1; |
| 10211 | return NULL; |
| 10212 | } |
| 10213 | goto done; |
| 10214 | } |
| 10215 | p->mark = mark; |
| 10216 | } |
| 10217 | { // t_primary '(' arguments? ')' &t_lookahead |
| 10218 | expr_ty a; |
| 10219 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10220 | Token * literal; |
| 10221 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10222 | if ( |
| 10223 | (a = t_primary_rule(p)) |
| 10224 | && |
| 10225 | (literal = _PyPegen_expect_token(p, 7)) |
| 10226 | && |
| 10227 | (b = arguments_rule(p), 1) |
| 10228 | && |
| 10229 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 10230 | && |
| 10231 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10232 | ) |
| 10233 | { |
| 10234 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10235 | if (token == NULL) { |
| 10236 | return NULL; |
| 10237 | } |
| 10238 | int end_lineno = token->end_lineno; |
| 10239 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10240 | int end_col_offset = token->end_col_offset; |
| 10241 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10242 | res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 10243 | if (res == NULL && PyErr_Occurred()) { |
| 10244 | p->error_indicator = 1; |
| 10245 | return NULL; |
| 10246 | } |
| 10247 | goto done; |
| 10248 | } |
| 10249 | p->mark = mark; |
| 10250 | } |
| 10251 | { // atom &t_lookahead |
| 10252 | expr_ty a; |
| 10253 | if ( |
| 10254 | (a = atom_rule(p)) |
| 10255 | && |
| 10256 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10257 | ) |
| 10258 | { |
| 10259 | res = a; |
| 10260 | if (res == NULL && PyErr_Occurred()) { |
| 10261 | p->error_indicator = 1; |
| 10262 | return NULL; |
| 10263 | } |
| 10264 | goto done; |
| 10265 | } |
| 10266 | p->mark = mark; |
| 10267 | } |
| 10268 | res = NULL; |
| 10269 | done: |
| 10270 | return res; |
| 10271 | } |
| 10272 | |
| 10273 | // t_lookahead: '(' | '[' | '.' |
| 10274 | static void * |
| 10275 | t_lookahead_rule(Parser *p) |
| 10276 | { |
| 10277 | if (p->error_indicator) { |
| 10278 | return NULL; |
| 10279 | } |
| 10280 | void * res = NULL; |
| 10281 | int mark = p->mark; |
| 10282 | { // '(' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10283 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10284 | if ( |
| 10285 | (literal = _PyPegen_expect_token(p, 7)) |
| 10286 | ) |
| 10287 | { |
| 10288 | res = literal; |
| 10289 | goto done; |
| 10290 | } |
| 10291 | p->mark = mark; |
| 10292 | } |
| 10293 | { // '[' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10294 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10295 | if ( |
| 10296 | (literal = _PyPegen_expect_token(p, 9)) |
| 10297 | ) |
| 10298 | { |
| 10299 | res = literal; |
| 10300 | goto done; |
| 10301 | } |
| 10302 | p->mark = mark; |
| 10303 | } |
| 10304 | { // '.' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10305 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10306 | if ( |
| 10307 | (literal = _PyPegen_expect_token(p, 23)) |
| 10308 | ) |
| 10309 | { |
| 10310 | res = literal; |
| 10311 | goto done; |
| 10312 | } |
| 10313 | p->mark = mark; |
| 10314 | } |
| 10315 | res = NULL; |
| 10316 | done: |
| 10317 | return res; |
| 10318 | } |
| 10319 | |
| 10320 | // t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']' |
| 10321 | static expr_ty |
| 10322 | t_atom_rule(Parser *p) |
| 10323 | { |
| 10324 | if (p->error_indicator) { |
| 10325 | return NULL; |
| 10326 | } |
| 10327 | expr_ty res = NULL; |
| 10328 | int mark = p->mark; |
| 10329 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10330 | p->error_indicator = 1; |
| 10331 | return NULL; |
| 10332 | } |
| 10333 | int start_lineno = p->tokens[mark]->lineno; |
| 10334 | UNUSED(start_lineno); // Only used by EXTRA macro |
| 10335 | int start_col_offset = p->tokens[mark]->col_offset; |
| 10336 | UNUSED(start_col_offset); // Only used by EXTRA macro |
| 10337 | { // NAME |
| 10338 | expr_ty a; |
| 10339 | if ( |
| 10340 | (a = _PyPegen_name_token(p)) |
| 10341 | ) |
| 10342 | { |
| 10343 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 10344 | if (res == NULL && PyErr_Occurred()) { |
| 10345 | p->error_indicator = 1; |
| 10346 | return NULL; |
| 10347 | } |
| 10348 | goto done; |
| 10349 | } |
| 10350 | p->mark = mark; |
| 10351 | } |
| 10352 | { // '(' target ')' |
| 10353 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10354 | Token * literal; |
| 10355 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10356 | if ( |
| 10357 | (literal = _PyPegen_expect_token(p, 7)) |
| 10358 | && |
| 10359 | (a = target_rule(p)) |
| 10360 | && |
| 10361 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 10362 | ) |
| 10363 | { |
| 10364 | res = _PyPegen_set_expr_context ( p , a , Store ); |
| 10365 | if (res == NULL && PyErr_Occurred()) { |
| 10366 | p->error_indicator = 1; |
| 10367 | return NULL; |
| 10368 | } |
| 10369 | goto done; |
| 10370 | } |
| 10371 | p->mark = mark; |
| 10372 | } |
| 10373 | { // '(' targets? ')' |
| 10374 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10375 | Token * literal; |
| 10376 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10377 | if ( |
| 10378 | (literal = _PyPegen_expect_token(p, 7)) |
| 10379 | && |
| 10380 | (b = targets_rule(p), 1) |
| 10381 | && |
| 10382 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 10383 | ) |
| 10384 | { |
| 10385 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10386 | if (token == NULL) { |
| 10387 | return NULL; |
| 10388 | } |
| 10389 | int end_lineno = token->end_lineno; |
| 10390 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10391 | int end_col_offset = token->end_col_offset; |
| 10392 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10393 | res = _Py_Tuple ( b , Store , EXTRA ); |
| 10394 | if (res == NULL && PyErr_Occurred()) { |
| 10395 | p->error_indicator = 1; |
| 10396 | return NULL; |
| 10397 | } |
| 10398 | goto done; |
| 10399 | } |
| 10400 | p->mark = mark; |
| 10401 | } |
| 10402 | { // '[' targets? ']' |
| 10403 | void *b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10404 | Token * literal; |
| 10405 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10406 | if ( |
| 10407 | (literal = _PyPegen_expect_token(p, 9)) |
| 10408 | && |
| 10409 | (b = targets_rule(p), 1) |
| 10410 | && |
| 10411 | (literal_1 = _PyPegen_expect_token(p, 10)) |
| 10412 | ) |
| 10413 | { |
| 10414 | Token *token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10415 | if (token == NULL) { |
| 10416 | return NULL; |
| 10417 | } |
| 10418 | int end_lineno = token->end_lineno; |
| 10419 | UNUSED(end_lineno); // Only used by EXTRA macro |
| 10420 | int end_col_offset = token->end_col_offset; |
| 10421 | UNUSED(end_col_offset); // Only used by EXTRA macro |
| 10422 | res = _Py_List ( b , Store , EXTRA ); |
| 10423 | if (res == NULL && PyErr_Occurred()) { |
| 10424 | p->error_indicator = 1; |
| 10425 | return NULL; |
| 10426 | } |
| 10427 | goto done; |
| 10428 | } |
| 10429 | p->mark = mark; |
| 10430 | } |
| 10431 | res = NULL; |
| 10432 | done: |
| 10433 | return res; |
| 10434 | } |
| 10435 | |
| 10436 | // incorrect_arguments: |
| 10437 | // | args ',' '*' |
| 10438 | // | expression for_if_clauses ',' [args | expression for_if_clauses] |
| 10439 | // | args ',' args |
| 10440 | static void * |
| 10441 | incorrect_arguments_rule(Parser *p) |
| 10442 | { |
| 10443 | if (p->error_indicator) { |
| 10444 | return NULL; |
| 10445 | } |
| 10446 | void * res = NULL; |
| 10447 | int mark = p->mark; |
| 10448 | { // args ',' '*' |
| 10449 | expr_ty args_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10450 | Token * literal; |
| 10451 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10452 | if ( |
| 10453 | (args_var = args_rule(p)) |
| 10454 | && |
| 10455 | (literal = _PyPegen_expect_token(p, 12)) |
| 10456 | && |
| 10457 | (literal_1 = _PyPegen_expect_token(p, 16)) |
| 10458 | ) |
| 10459 | { |
| 10460 | res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" ); |
| 10461 | if (res == NULL && PyErr_Occurred()) { |
| 10462 | p->error_indicator = 1; |
| 10463 | return NULL; |
| 10464 | } |
| 10465 | goto done; |
| 10466 | } |
| 10467 | p->mark = mark; |
| 10468 | } |
| 10469 | { // expression for_if_clauses ',' [args | expression for_if_clauses] |
| 10470 | expr_ty expression_var; |
| 10471 | asdl_seq* for_if_clauses_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10472 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10473 | void *opt_var; |
| 10474 | UNUSED(opt_var); // Silence compiler warnings |
| 10475 | if ( |
| 10476 | (expression_var = expression_rule(p)) |
| 10477 | && |
| 10478 | (for_if_clauses_var = for_if_clauses_rule(p)) |
| 10479 | && |
| 10480 | (literal = _PyPegen_expect_token(p, 12)) |
| 10481 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10482 | (opt_var = _tmp_125_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10483 | ) |
| 10484 | { |
| 10485 | res = RAISE_SYNTAX_ERROR ( "Generator expression must be parenthesized" ); |
| 10486 | if (res == NULL && PyErr_Occurred()) { |
| 10487 | p->error_indicator = 1; |
| 10488 | return NULL; |
| 10489 | } |
| 10490 | goto done; |
| 10491 | } |
| 10492 | p->mark = mark; |
| 10493 | } |
| 10494 | { // args ',' args |
| 10495 | expr_ty a; |
| 10496 | expr_ty args_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10497 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10498 | if ( |
| 10499 | (a = args_rule(p)) |
| 10500 | && |
| 10501 | (literal = _PyPegen_expect_token(p, 12)) |
| 10502 | && |
| 10503 | (args_var = args_rule(p)) |
| 10504 | ) |
| 10505 | { |
| 10506 | res = _PyPegen_arguments_parsing_error ( p , a ); |
| 10507 | if (res == NULL && PyErr_Occurred()) { |
| 10508 | p->error_indicator = 1; |
| 10509 | return NULL; |
| 10510 | } |
| 10511 | goto done; |
| 10512 | } |
| 10513 | p->mark = mark; |
| 10514 | } |
| 10515 | res = NULL; |
| 10516 | done: |
| 10517 | return res; |
| 10518 | } |
| 10519 | |
| 10520 | // invalid_named_expression: expression ':=' expression |
| 10521 | static void * |
| 10522 | invalid_named_expression_rule(Parser *p) |
| 10523 | { |
| 10524 | if (p->error_indicator) { |
| 10525 | return NULL; |
| 10526 | } |
| 10527 | void * res = NULL; |
| 10528 | int mark = p->mark; |
| 10529 | { // expression ':=' expression |
| 10530 | expr_ty a; |
| 10531 | expr_ty expression_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10532 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10533 | if ( |
| 10534 | (a = expression_rule(p)) |
| 10535 | && |
| 10536 | (literal = _PyPegen_expect_token(p, 53)) |
| 10537 | && |
| 10538 | (expression_var = expression_rule(p)) |
| 10539 | ) |
| 10540 | { |
| 10541 | res = RAISE_SYNTAX_ERROR ( "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) ); |
| 10542 | if (res == NULL && PyErr_Occurred()) { |
| 10543 | p->error_indicator = 1; |
| 10544 | return NULL; |
| 10545 | } |
| 10546 | goto done; |
| 10547 | } |
| 10548 | p->mark = mark; |
| 10549 | } |
| 10550 | res = NULL; |
| 10551 | done: |
| 10552 | return res; |
| 10553 | } |
| 10554 | |
| 10555 | // invalid_assignment: |
| 10556 | // | list ':' |
| 10557 | // | tuple ':' |
| 10558 | // | expression ':' expression ['=' annotated_rhs] |
| 10559 | // | expression ('=' | augassign) (yield_expr | star_expressions) |
| 10560 | static void * |
| 10561 | invalid_assignment_rule(Parser *p) |
| 10562 | { |
| 10563 | if (p->error_indicator) { |
| 10564 | return NULL; |
| 10565 | } |
| 10566 | void * res = NULL; |
| 10567 | int mark = p->mark; |
| 10568 | { // list ':' |
| 10569 | expr_ty list_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10570 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10571 | if ( |
| 10572 | (list_var = list_rule(p)) |
| 10573 | && |
| 10574 | (literal = _PyPegen_expect_token(p, 11)) |
| 10575 | ) |
| 10576 | { |
| 10577 | res = RAISE_SYNTAX_ERROR ( "only single target (not list) can be annotated" ); |
| 10578 | if (res == NULL && PyErr_Occurred()) { |
| 10579 | p->error_indicator = 1; |
| 10580 | return NULL; |
| 10581 | } |
| 10582 | goto done; |
| 10583 | } |
| 10584 | p->mark = mark; |
| 10585 | } |
| 10586 | { // tuple ':' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10587 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10588 | expr_ty tuple_var; |
| 10589 | if ( |
| 10590 | (tuple_var = tuple_rule(p)) |
| 10591 | && |
| 10592 | (literal = _PyPegen_expect_token(p, 11)) |
| 10593 | ) |
| 10594 | { |
| 10595 | res = RAISE_SYNTAX_ERROR ( "only single target (not tuple) can be annotated" ); |
| 10596 | if (res == NULL && PyErr_Occurred()) { |
| 10597 | p->error_indicator = 1; |
| 10598 | return NULL; |
| 10599 | } |
| 10600 | goto done; |
| 10601 | } |
| 10602 | p->mark = mark; |
| 10603 | } |
| 10604 | { // expression ':' expression ['=' annotated_rhs] |
| 10605 | expr_ty expression_var; |
| 10606 | expr_ty expression_var_1; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10607 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10608 | void *opt_var; |
| 10609 | UNUSED(opt_var); // Silence compiler warnings |
| 10610 | if ( |
| 10611 | (expression_var = expression_rule(p)) |
| 10612 | && |
| 10613 | (literal = _PyPegen_expect_token(p, 11)) |
| 10614 | && |
| 10615 | (expression_var_1 = expression_rule(p)) |
| 10616 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10617 | (opt_var = _tmp_126_rule(p), 1) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10618 | ) |
| 10619 | { |
| 10620 | res = RAISE_SYNTAX_ERROR ( "illegal target for annotation" ); |
| 10621 | if (res == NULL && PyErr_Occurred()) { |
| 10622 | p->error_indicator = 1; |
| 10623 | return NULL; |
| 10624 | } |
| 10625 | goto done; |
| 10626 | } |
| 10627 | p->mark = mark; |
| 10628 | } |
| 10629 | { // expression ('=' | augassign) (yield_expr | star_expressions) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10630 | void *_tmp_127_var; |
| 10631 | void *_tmp_128_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10632 | expr_ty a; |
| 10633 | if ( |
| 10634 | (a = expression_rule(p)) |
| 10635 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10636 | (_tmp_127_var = _tmp_127_rule(p)) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 10637 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10638 | (_tmp_128_var = _tmp_128_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10639 | ) |
| 10640 | { |
Batuhan Taskaya | 76c1b4d | 2020-05-01 16:13:43 +0300 | [diff] [blame] | 10641 | res = RAISE_SYNTAX_ERROR_NO_COL_OFFSET ( "cannot assign to %s" , _PyPegen_get_expr_name ( a ) ); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10642 | if (res == NULL && PyErr_Occurred()) { |
| 10643 | p->error_indicator = 1; |
| 10644 | return NULL; |
| 10645 | } |
| 10646 | goto done; |
| 10647 | } |
| 10648 | p->mark = mark; |
| 10649 | } |
| 10650 | res = NULL; |
| 10651 | done: |
| 10652 | return res; |
| 10653 | } |
| 10654 | |
| 10655 | // invalid_block: NEWLINE !INDENT |
| 10656 | static void * |
| 10657 | invalid_block_rule(Parser *p) |
| 10658 | { |
| 10659 | if (p->error_indicator) { |
| 10660 | return NULL; |
| 10661 | } |
| 10662 | void * res = NULL; |
| 10663 | int mark = p->mark; |
| 10664 | { // NEWLINE !INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10665 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10666 | if ( |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 10667 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10668 | && |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 10669 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10670 | ) |
| 10671 | { |
| 10672 | res = RAISE_INDENTATION_ERROR ( "expected an indented block" ); |
| 10673 | if (res == NULL && PyErr_Occurred()) { |
| 10674 | p->error_indicator = 1; |
| 10675 | return NULL; |
| 10676 | } |
| 10677 | goto done; |
| 10678 | } |
| 10679 | p->mark = mark; |
| 10680 | } |
| 10681 | res = NULL; |
| 10682 | done: |
| 10683 | return res; |
| 10684 | } |
| 10685 | |
| 10686 | // invalid_comprehension: ('[' | '(' | '{') '*' expression for_if_clauses |
| 10687 | static void * |
| 10688 | invalid_comprehension_rule(Parser *p) |
| 10689 | { |
| 10690 | if (p->error_indicator) { |
| 10691 | return NULL; |
| 10692 | } |
| 10693 | void * res = NULL; |
| 10694 | int mark = p->mark; |
| 10695 | { // ('[' | '(' | '{') '*' expression for_if_clauses |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10696 | void *_tmp_129_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10697 | expr_ty expression_var; |
| 10698 | asdl_seq* for_if_clauses_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10699 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10700 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10701 | (_tmp_129_var = _tmp_129_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10702 | && |
| 10703 | (literal = _PyPegen_expect_token(p, 16)) |
| 10704 | && |
| 10705 | (expression_var = expression_rule(p)) |
| 10706 | && |
| 10707 | (for_if_clauses_var = for_if_clauses_rule(p)) |
| 10708 | ) |
| 10709 | { |
| 10710 | res = RAISE_SYNTAX_ERROR ( "iterable unpacking cannot be used in comprehension" ); |
| 10711 | if (res == NULL && PyErr_Occurred()) { |
| 10712 | p->error_indicator = 1; |
| 10713 | return NULL; |
| 10714 | } |
| 10715 | goto done; |
| 10716 | } |
| 10717 | p->mark = mark; |
| 10718 | } |
| 10719 | res = NULL; |
| 10720 | done: |
| 10721 | return res; |
| 10722 | } |
| 10723 | |
| 10724 | // invalid_parameters: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10725 | // | param_no_default* (slash_with_default | param_with_default+) param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10726 | static void * |
| 10727 | invalid_parameters_rule(Parser *p) |
| 10728 | { |
| 10729 | if (p->error_indicator) { |
| 10730 | return NULL; |
| 10731 | } |
| 10732 | void * res = NULL; |
| 10733 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10734 | { // param_no_default* (slash_with_default | param_with_default+) param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10735 | asdl_seq * _loop0_130_var; |
| 10736 | void *_tmp_131_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10737 | arg_ty param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10738 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10739 | (_loop0_130_var = _loop0_130_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10740 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10741 | (_tmp_131_var = _tmp_131_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10742 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10743 | (param_no_default_var = param_no_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10744 | ) |
| 10745 | { |
| 10746 | res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" ); |
| 10747 | if (res == NULL && PyErr_Occurred()) { |
| 10748 | p->error_indicator = 1; |
| 10749 | return NULL; |
| 10750 | } |
| 10751 | goto done; |
| 10752 | } |
| 10753 | p->mark = mark; |
| 10754 | } |
| 10755 | res = NULL; |
| 10756 | done: |
| 10757 | return res; |
| 10758 | } |
| 10759 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10760 | // invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
| 10761 | static void * |
| 10762 | invalid_double_type_comments_rule(Parser *p) |
| 10763 | { |
| 10764 | if (p->error_indicator) { |
| 10765 | return NULL; |
| 10766 | } |
| 10767 | void * res = NULL; |
| 10768 | int mark = p->mark; |
| 10769 | { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10770 | Token * indent_var; |
| 10771 | Token * newline_var; |
| 10772 | Token * newline_var_1; |
| 10773 | Token * type_comment_var; |
| 10774 | Token * type_comment_var_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10775 | if ( |
| 10776 | (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) |
| 10777 | && |
| 10778 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) |
| 10779 | && |
| 10780 | (type_comment_var_1 = _PyPegen_expect_token(p, TYPE_COMMENT)) |
| 10781 | && |
| 10782 | (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) |
| 10783 | && |
| 10784 | (indent_var = _PyPegen_expect_token(p, INDENT)) |
| 10785 | ) |
| 10786 | { |
| 10787 | res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" ); |
| 10788 | if (res == NULL && PyErr_Occurred()) { |
| 10789 | p->error_indicator = 1; |
| 10790 | return NULL; |
| 10791 | } |
| 10792 | goto done; |
| 10793 | } |
| 10794 | p->mark = mark; |
| 10795 | } |
| 10796 | res = NULL; |
| 10797 | done: |
| 10798 | return res; |
| 10799 | } |
| 10800 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10801 | // _loop0_1: NEWLINE |
| 10802 | static asdl_seq * |
| 10803 | _loop0_1_rule(Parser *p) |
| 10804 | { |
| 10805 | if (p->error_indicator) { |
| 10806 | return NULL; |
| 10807 | } |
| 10808 | void *res = NULL; |
| 10809 | int mark = p->mark; |
| 10810 | int start_mark = p->mark; |
| 10811 | void **children = PyMem_Malloc(sizeof(void *)); |
| 10812 | if (!children) { |
| 10813 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 10814 | return NULL; |
| 10815 | } |
| 10816 | ssize_t children_capacity = 1; |
| 10817 | ssize_t n = 0; |
| 10818 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10819 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10820 | while ( |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 10821 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10822 | ) |
| 10823 | { |
| 10824 | res = newline_var; |
| 10825 | if (n == children_capacity) { |
| 10826 | children_capacity *= 2; |
| 10827 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 10828 | if (!children) { |
| 10829 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 10830 | return NULL; |
| 10831 | } |
| 10832 | } |
| 10833 | children[n++] = res; |
| 10834 | mark = p->mark; |
| 10835 | } |
| 10836 | p->mark = mark; |
| 10837 | } |
| 10838 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 10839 | if (!seq) { |
| 10840 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_1"); |
| 10841 | PyMem_Free(children); |
| 10842 | return NULL; |
| 10843 | } |
| 10844 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 10845 | PyMem_Free(children); |
| 10846 | _PyPegen_insert_memo(p, start_mark, _loop0_1_type, seq); |
| 10847 | return seq; |
| 10848 | } |
| 10849 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10850 | // _loop0_2: NEWLINE |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10851 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10852 | _loop0_2_rule(Parser *p) |
| 10853 | { |
| 10854 | if (p->error_indicator) { |
| 10855 | return NULL; |
| 10856 | } |
| 10857 | void *res = NULL; |
| 10858 | int mark = p->mark; |
| 10859 | int start_mark = p->mark; |
| 10860 | void **children = PyMem_Malloc(sizeof(void *)); |
| 10861 | if (!children) { |
| 10862 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 10863 | return NULL; |
| 10864 | } |
| 10865 | ssize_t children_capacity = 1; |
| 10866 | ssize_t n = 0; |
| 10867 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10868 | Token * newline_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10869 | while ( |
| 10870 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) |
| 10871 | ) |
| 10872 | { |
| 10873 | res = newline_var; |
| 10874 | if (n == children_capacity) { |
| 10875 | children_capacity *= 2; |
| 10876 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 10877 | if (!children) { |
| 10878 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 10879 | return NULL; |
| 10880 | } |
| 10881 | } |
| 10882 | children[n++] = res; |
| 10883 | mark = p->mark; |
| 10884 | } |
| 10885 | p->mark = mark; |
| 10886 | } |
| 10887 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 10888 | if (!seq) { |
| 10889 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_2"); |
| 10890 | PyMem_Free(children); |
| 10891 | return NULL; |
| 10892 | } |
| 10893 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 10894 | PyMem_Free(children); |
| 10895 | _PyPegen_insert_memo(p, start_mark, _loop0_2_type, seq); |
| 10896 | return seq; |
| 10897 | } |
| 10898 | |
| 10899 | // _loop0_4: ',' expression |
| 10900 | static asdl_seq * |
| 10901 | _loop0_4_rule(Parser *p) |
| 10902 | { |
| 10903 | if (p->error_indicator) { |
| 10904 | return NULL; |
| 10905 | } |
| 10906 | void *res = NULL; |
| 10907 | int mark = p->mark; |
| 10908 | int start_mark = p->mark; |
| 10909 | void **children = PyMem_Malloc(sizeof(void *)); |
| 10910 | if (!children) { |
| 10911 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 10912 | return NULL; |
| 10913 | } |
| 10914 | ssize_t children_capacity = 1; |
| 10915 | ssize_t n = 0; |
| 10916 | { // ',' expression |
| 10917 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10918 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10919 | while ( |
| 10920 | (literal = _PyPegen_expect_token(p, 12)) |
| 10921 | && |
| 10922 | (elem = expression_rule(p)) |
| 10923 | ) |
| 10924 | { |
| 10925 | res = elem; |
| 10926 | if (res == NULL && PyErr_Occurred()) { |
| 10927 | p->error_indicator = 1; |
| 10928 | PyMem_Free(children); |
| 10929 | return NULL; |
| 10930 | } |
| 10931 | if (n == children_capacity) { |
| 10932 | children_capacity *= 2; |
| 10933 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 10934 | if (!children) { |
| 10935 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 10936 | return NULL; |
| 10937 | } |
| 10938 | } |
| 10939 | children[n++] = res; |
| 10940 | mark = p->mark; |
| 10941 | } |
| 10942 | p->mark = mark; |
| 10943 | } |
| 10944 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 10945 | if (!seq) { |
| 10946 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_4"); |
| 10947 | PyMem_Free(children); |
| 10948 | return NULL; |
| 10949 | } |
| 10950 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 10951 | PyMem_Free(children); |
| 10952 | _PyPegen_insert_memo(p, start_mark, _loop0_4_type, seq); |
| 10953 | return seq; |
| 10954 | } |
| 10955 | |
| 10956 | // _gather_3: expression _loop0_4 |
| 10957 | static asdl_seq * |
| 10958 | _gather_3_rule(Parser *p) |
| 10959 | { |
| 10960 | if (p->error_indicator) { |
| 10961 | return NULL; |
| 10962 | } |
| 10963 | asdl_seq * res = NULL; |
| 10964 | int mark = p->mark; |
| 10965 | { // expression _loop0_4 |
| 10966 | expr_ty elem; |
| 10967 | asdl_seq * seq; |
| 10968 | if ( |
| 10969 | (elem = expression_rule(p)) |
| 10970 | && |
| 10971 | (seq = _loop0_4_rule(p)) |
| 10972 | ) |
| 10973 | { |
| 10974 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 10975 | goto done; |
| 10976 | } |
| 10977 | p->mark = mark; |
| 10978 | } |
| 10979 | res = NULL; |
| 10980 | done: |
| 10981 | return res; |
| 10982 | } |
| 10983 | |
| 10984 | // _loop0_6: ',' expression |
| 10985 | static asdl_seq * |
| 10986 | _loop0_6_rule(Parser *p) |
| 10987 | { |
| 10988 | if (p->error_indicator) { |
| 10989 | return NULL; |
| 10990 | } |
| 10991 | void *res = NULL; |
| 10992 | int mark = p->mark; |
| 10993 | int start_mark = p->mark; |
| 10994 | void **children = PyMem_Malloc(sizeof(void *)); |
| 10995 | if (!children) { |
| 10996 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 10997 | return NULL; |
| 10998 | } |
| 10999 | ssize_t children_capacity = 1; |
| 11000 | ssize_t n = 0; |
| 11001 | { // ',' expression |
| 11002 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11003 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11004 | while ( |
| 11005 | (literal = _PyPegen_expect_token(p, 12)) |
| 11006 | && |
| 11007 | (elem = expression_rule(p)) |
| 11008 | ) |
| 11009 | { |
| 11010 | res = elem; |
| 11011 | if (res == NULL && PyErr_Occurred()) { |
| 11012 | p->error_indicator = 1; |
| 11013 | PyMem_Free(children); |
| 11014 | return NULL; |
| 11015 | } |
| 11016 | if (n == children_capacity) { |
| 11017 | children_capacity *= 2; |
| 11018 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11019 | if (!children) { |
| 11020 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11021 | return NULL; |
| 11022 | } |
| 11023 | } |
| 11024 | children[n++] = res; |
| 11025 | mark = p->mark; |
| 11026 | } |
| 11027 | p->mark = mark; |
| 11028 | } |
| 11029 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11030 | if (!seq) { |
| 11031 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_6"); |
| 11032 | PyMem_Free(children); |
| 11033 | return NULL; |
| 11034 | } |
| 11035 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11036 | PyMem_Free(children); |
| 11037 | _PyPegen_insert_memo(p, start_mark, _loop0_6_type, seq); |
| 11038 | return seq; |
| 11039 | } |
| 11040 | |
| 11041 | // _gather_5: expression _loop0_6 |
| 11042 | static asdl_seq * |
| 11043 | _gather_5_rule(Parser *p) |
| 11044 | { |
| 11045 | if (p->error_indicator) { |
| 11046 | return NULL; |
| 11047 | } |
| 11048 | asdl_seq * res = NULL; |
| 11049 | int mark = p->mark; |
| 11050 | { // expression _loop0_6 |
| 11051 | expr_ty elem; |
| 11052 | asdl_seq * seq; |
| 11053 | if ( |
| 11054 | (elem = expression_rule(p)) |
| 11055 | && |
| 11056 | (seq = _loop0_6_rule(p)) |
| 11057 | ) |
| 11058 | { |
| 11059 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11060 | goto done; |
| 11061 | } |
| 11062 | p->mark = mark; |
| 11063 | } |
| 11064 | res = NULL; |
| 11065 | done: |
| 11066 | return res; |
| 11067 | } |
| 11068 | |
| 11069 | // _loop0_8: ',' expression |
| 11070 | static asdl_seq * |
| 11071 | _loop0_8_rule(Parser *p) |
| 11072 | { |
| 11073 | if (p->error_indicator) { |
| 11074 | return NULL; |
| 11075 | } |
| 11076 | void *res = NULL; |
| 11077 | int mark = p->mark; |
| 11078 | int start_mark = p->mark; |
| 11079 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11080 | if (!children) { |
| 11081 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11082 | return NULL; |
| 11083 | } |
| 11084 | ssize_t children_capacity = 1; |
| 11085 | ssize_t n = 0; |
| 11086 | { // ',' expression |
| 11087 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11088 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11089 | while ( |
| 11090 | (literal = _PyPegen_expect_token(p, 12)) |
| 11091 | && |
| 11092 | (elem = expression_rule(p)) |
| 11093 | ) |
| 11094 | { |
| 11095 | res = elem; |
| 11096 | if (res == NULL && PyErr_Occurred()) { |
| 11097 | p->error_indicator = 1; |
| 11098 | PyMem_Free(children); |
| 11099 | return NULL; |
| 11100 | } |
| 11101 | if (n == children_capacity) { |
| 11102 | children_capacity *= 2; |
| 11103 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11104 | if (!children) { |
| 11105 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11106 | return NULL; |
| 11107 | } |
| 11108 | } |
| 11109 | children[n++] = res; |
| 11110 | mark = p->mark; |
| 11111 | } |
| 11112 | p->mark = mark; |
| 11113 | } |
| 11114 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11115 | if (!seq) { |
| 11116 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_8"); |
| 11117 | PyMem_Free(children); |
| 11118 | return NULL; |
| 11119 | } |
| 11120 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11121 | PyMem_Free(children); |
| 11122 | _PyPegen_insert_memo(p, start_mark, _loop0_8_type, seq); |
| 11123 | return seq; |
| 11124 | } |
| 11125 | |
| 11126 | // _gather_7: expression _loop0_8 |
| 11127 | static asdl_seq * |
| 11128 | _gather_7_rule(Parser *p) |
| 11129 | { |
| 11130 | if (p->error_indicator) { |
| 11131 | return NULL; |
| 11132 | } |
| 11133 | asdl_seq * res = NULL; |
| 11134 | int mark = p->mark; |
| 11135 | { // expression _loop0_8 |
| 11136 | expr_ty elem; |
| 11137 | asdl_seq * seq; |
| 11138 | if ( |
| 11139 | (elem = expression_rule(p)) |
| 11140 | && |
| 11141 | (seq = _loop0_8_rule(p)) |
| 11142 | ) |
| 11143 | { |
| 11144 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11145 | goto done; |
| 11146 | } |
| 11147 | p->mark = mark; |
| 11148 | } |
| 11149 | res = NULL; |
| 11150 | done: |
| 11151 | return res; |
| 11152 | } |
| 11153 | |
| 11154 | // _loop0_10: ',' expression |
| 11155 | static asdl_seq * |
| 11156 | _loop0_10_rule(Parser *p) |
| 11157 | { |
| 11158 | if (p->error_indicator) { |
| 11159 | return NULL; |
| 11160 | } |
| 11161 | void *res = NULL; |
| 11162 | int mark = p->mark; |
| 11163 | int start_mark = p->mark; |
| 11164 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11165 | if (!children) { |
| 11166 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11167 | return NULL; |
| 11168 | } |
| 11169 | ssize_t children_capacity = 1; |
| 11170 | ssize_t n = 0; |
| 11171 | { // ',' expression |
| 11172 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11173 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11174 | while ( |
| 11175 | (literal = _PyPegen_expect_token(p, 12)) |
| 11176 | && |
| 11177 | (elem = expression_rule(p)) |
| 11178 | ) |
| 11179 | { |
| 11180 | res = elem; |
| 11181 | if (res == NULL && PyErr_Occurred()) { |
| 11182 | p->error_indicator = 1; |
| 11183 | PyMem_Free(children); |
| 11184 | return NULL; |
| 11185 | } |
| 11186 | if (n == children_capacity) { |
| 11187 | children_capacity *= 2; |
| 11188 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11189 | if (!children) { |
| 11190 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11191 | return NULL; |
| 11192 | } |
| 11193 | } |
| 11194 | children[n++] = res; |
| 11195 | mark = p->mark; |
| 11196 | } |
| 11197 | p->mark = mark; |
| 11198 | } |
| 11199 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11200 | if (!seq) { |
| 11201 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_10"); |
| 11202 | PyMem_Free(children); |
| 11203 | return NULL; |
| 11204 | } |
| 11205 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11206 | PyMem_Free(children); |
| 11207 | _PyPegen_insert_memo(p, start_mark, _loop0_10_type, seq); |
| 11208 | return seq; |
| 11209 | } |
| 11210 | |
| 11211 | // _gather_9: expression _loop0_10 |
| 11212 | static asdl_seq * |
| 11213 | _gather_9_rule(Parser *p) |
| 11214 | { |
| 11215 | if (p->error_indicator) { |
| 11216 | return NULL; |
| 11217 | } |
| 11218 | asdl_seq * res = NULL; |
| 11219 | int mark = p->mark; |
| 11220 | { // expression _loop0_10 |
| 11221 | expr_ty elem; |
| 11222 | asdl_seq * seq; |
| 11223 | if ( |
| 11224 | (elem = expression_rule(p)) |
| 11225 | && |
| 11226 | (seq = _loop0_10_rule(p)) |
| 11227 | ) |
| 11228 | { |
| 11229 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11230 | goto done; |
| 11231 | } |
| 11232 | p->mark = mark; |
| 11233 | } |
| 11234 | res = NULL; |
| 11235 | done: |
| 11236 | return res; |
| 11237 | } |
| 11238 | |
| 11239 | // _loop1_11: statement |
| 11240 | static asdl_seq * |
| 11241 | _loop1_11_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11242 | { |
| 11243 | if (p->error_indicator) { |
| 11244 | return NULL; |
| 11245 | } |
| 11246 | void *res = NULL; |
| 11247 | int mark = p->mark; |
| 11248 | int start_mark = p->mark; |
| 11249 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11250 | if (!children) { |
| 11251 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11252 | return NULL; |
| 11253 | } |
| 11254 | ssize_t children_capacity = 1; |
| 11255 | ssize_t n = 0; |
| 11256 | { // statement |
| 11257 | asdl_seq* statement_var; |
| 11258 | while ( |
| 11259 | (statement_var = statement_rule(p)) |
| 11260 | ) |
| 11261 | { |
| 11262 | res = statement_var; |
| 11263 | if (n == children_capacity) { |
| 11264 | children_capacity *= 2; |
| 11265 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11266 | if (!children) { |
| 11267 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11268 | return NULL; |
| 11269 | } |
| 11270 | } |
| 11271 | children[n++] = res; |
| 11272 | mark = p->mark; |
| 11273 | } |
| 11274 | p->mark = mark; |
| 11275 | } |
| 11276 | if (n == 0) { |
| 11277 | PyMem_Free(children); |
| 11278 | return NULL; |
| 11279 | } |
| 11280 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11281 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11282 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_11"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11283 | PyMem_Free(children); |
| 11284 | return NULL; |
| 11285 | } |
| 11286 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11287 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11288 | _PyPegen_insert_memo(p, start_mark, _loop1_11_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11289 | return seq; |
| 11290 | } |
| 11291 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11292 | // _loop0_13: ';' small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11293 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11294 | _loop0_13_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11295 | { |
| 11296 | if (p->error_indicator) { |
| 11297 | return NULL; |
| 11298 | } |
| 11299 | void *res = NULL; |
| 11300 | int mark = p->mark; |
| 11301 | int start_mark = p->mark; |
| 11302 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11303 | if (!children) { |
| 11304 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11305 | return NULL; |
| 11306 | } |
| 11307 | ssize_t children_capacity = 1; |
| 11308 | ssize_t n = 0; |
| 11309 | { // ';' small_stmt |
| 11310 | stmt_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11311 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11312 | while ( |
| 11313 | (literal = _PyPegen_expect_token(p, 13)) |
| 11314 | && |
| 11315 | (elem = small_stmt_rule(p)) |
| 11316 | ) |
| 11317 | { |
| 11318 | res = elem; |
| 11319 | if (res == NULL && PyErr_Occurred()) { |
| 11320 | p->error_indicator = 1; |
| 11321 | PyMem_Free(children); |
| 11322 | return NULL; |
| 11323 | } |
| 11324 | if (n == children_capacity) { |
| 11325 | children_capacity *= 2; |
| 11326 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11327 | if (!children) { |
| 11328 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11329 | return NULL; |
| 11330 | } |
| 11331 | } |
| 11332 | children[n++] = res; |
| 11333 | mark = p->mark; |
| 11334 | } |
| 11335 | p->mark = mark; |
| 11336 | } |
| 11337 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11338 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11339 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_13"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11340 | PyMem_Free(children); |
| 11341 | return NULL; |
| 11342 | } |
| 11343 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11344 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11345 | _PyPegen_insert_memo(p, start_mark, _loop0_13_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11346 | return seq; |
| 11347 | } |
| 11348 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11349 | // _gather_12: small_stmt _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11350 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11351 | _gather_12_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11352 | { |
| 11353 | if (p->error_indicator) { |
| 11354 | return NULL; |
| 11355 | } |
| 11356 | asdl_seq * res = NULL; |
| 11357 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11358 | { // small_stmt _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11359 | stmt_ty elem; |
| 11360 | asdl_seq * seq; |
| 11361 | if ( |
| 11362 | (elem = small_stmt_rule(p)) |
| 11363 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11364 | (seq = _loop0_13_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11365 | ) |
| 11366 | { |
| 11367 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11368 | goto done; |
| 11369 | } |
| 11370 | p->mark = mark; |
| 11371 | } |
| 11372 | res = NULL; |
| 11373 | done: |
| 11374 | return res; |
| 11375 | } |
| 11376 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11377 | // _tmp_14: 'import' | 'from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11378 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11379 | _tmp_14_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11380 | { |
| 11381 | if (p->error_indicator) { |
| 11382 | return NULL; |
| 11383 | } |
| 11384 | void * res = NULL; |
| 11385 | int mark = p->mark; |
| 11386 | { // 'import' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11387 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11388 | if ( |
| 11389 | (keyword = _PyPegen_expect_token(p, 513)) |
| 11390 | ) |
| 11391 | { |
| 11392 | res = keyword; |
| 11393 | goto done; |
| 11394 | } |
| 11395 | p->mark = mark; |
| 11396 | } |
| 11397 | { // 'from' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11398 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11399 | if ( |
| 11400 | (keyword = _PyPegen_expect_token(p, 514)) |
| 11401 | ) |
| 11402 | { |
| 11403 | res = keyword; |
| 11404 | goto done; |
| 11405 | } |
| 11406 | p->mark = mark; |
| 11407 | } |
| 11408 | res = NULL; |
| 11409 | done: |
| 11410 | return res; |
| 11411 | } |
| 11412 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11413 | // _tmp_15: 'def' | '@' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11414 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11415 | _tmp_15_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11416 | { |
| 11417 | if (p->error_indicator) { |
| 11418 | return NULL; |
| 11419 | } |
| 11420 | void * res = NULL; |
| 11421 | int mark = p->mark; |
| 11422 | { // 'def' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11423 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11424 | if ( |
| 11425 | (keyword = _PyPegen_expect_token(p, 522)) |
| 11426 | ) |
| 11427 | { |
| 11428 | res = keyword; |
| 11429 | goto done; |
| 11430 | } |
| 11431 | p->mark = mark; |
| 11432 | } |
| 11433 | { // '@' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11434 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11435 | if ( |
| 11436 | (literal = _PyPegen_expect_token(p, 49)) |
| 11437 | ) |
| 11438 | { |
| 11439 | res = literal; |
| 11440 | goto done; |
| 11441 | } |
| 11442 | p->mark = mark; |
| 11443 | } |
| 11444 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11445 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11446 | if ( |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 11447 | (async_var = _PyPegen_expect_token(p, ASYNC)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11448 | ) |
| 11449 | { |
| 11450 | res = async_var; |
| 11451 | goto done; |
| 11452 | } |
| 11453 | p->mark = mark; |
| 11454 | } |
| 11455 | res = NULL; |
| 11456 | done: |
| 11457 | return res; |
| 11458 | } |
| 11459 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11460 | // _tmp_16: 'class' | '@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11461 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11462 | _tmp_16_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11463 | { |
| 11464 | if (p->error_indicator) { |
| 11465 | return NULL; |
| 11466 | } |
| 11467 | void * res = NULL; |
| 11468 | int mark = p->mark; |
| 11469 | { // 'class' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11470 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11471 | if ( |
| 11472 | (keyword = _PyPegen_expect_token(p, 523)) |
| 11473 | ) |
| 11474 | { |
| 11475 | res = keyword; |
| 11476 | goto done; |
| 11477 | } |
| 11478 | p->mark = mark; |
| 11479 | } |
| 11480 | { // '@' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11481 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11482 | if ( |
| 11483 | (literal = _PyPegen_expect_token(p, 49)) |
| 11484 | ) |
| 11485 | { |
| 11486 | res = literal; |
| 11487 | goto done; |
| 11488 | } |
| 11489 | p->mark = mark; |
| 11490 | } |
| 11491 | res = NULL; |
| 11492 | done: |
| 11493 | return res; |
| 11494 | } |
| 11495 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11496 | // _tmp_17: 'with' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11497 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11498 | _tmp_17_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11499 | { |
| 11500 | if (p->error_indicator) { |
| 11501 | return NULL; |
| 11502 | } |
| 11503 | void * res = NULL; |
| 11504 | int mark = p->mark; |
| 11505 | { // 'with' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11506 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11507 | if ( |
| 11508 | (keyword = _PyPegen_expect_token(p, 519)) |
| 11509 | ) |
| 11510 | { |
| 11511 | res = keyword; |
| 11512 | goto done; |
| 11513 | } |
| 11514 | p->mark = mark; |
| 11515 | } |
| 11516 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11517 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11518 | if ( |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 11519 | (async_var = _PyPegen_expect_token(p, ASYNC)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11520 | ) |
| 11521 | { |
| 11522 | res = async_var; |
| 11523 | goto done; |
| 11524 | } |
| 11525 | p->mark = mark; |
| 11526 | } |
| 11527 | res = NULL; |
| 11528 | done: |
| 11529 | return res; |
| 11530 | } |
| 11531 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11532 | // _tmp_18: 'for' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11533 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11534 | _tmp_18_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11535 | { |
| 11536 | if (p->error_indicator) { |
| 11537 | return NULL; |
| 11538 | } |
| 11539 | void * res = NULL; |
| 11540 | int mark = p->mark; |
| 11541 | { // 'for' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11542 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11543 | if ( |
| 11544 | (keyword = _PyPegen_expect_token(p, 517)) |
| 11545 | ) |
| 11546 | { |
| 11547 | res = keyword; |
| 11548 | goto done; |
| 11549 | } |
| 11550 | p->mark = mark; |
| 11551 | } |
| 11552 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11553 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11554 | if ( |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 11555 | (async_var = _PyPegen_expect_token(p, ASYNC)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11556 | ) |
| 11557 | { |
| 11558 | res = async_var; |
| 11559 | goto done; |
| 11560 | } |
| 11561 | p->mark = mark; |
| 11562 | } |
| 11563 | res = NULL; |
| 11564 | done: |
| 11565 | return res; |
| 11566 | } |
| 11567 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11568 | // _tmp_19: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11569 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11570 | _tmp_19_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11571 | { |
| 11572 | if (p->error_indicator) { |
| 11573 | return NULL; |
| 11574 | } |
| 11575 | void * res = NULL; |
| 11576 | int mark = p->mark; |
| 11577 | { // '=' annotated_rhs |
| 11578 | expr_ty d; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11579 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11580 | if ( |
| 11581 | (literal = _PyPegen_expect_token(p, 22)) |
| 11582 | && |
| 11583 | (d = annotated_rhs_rule(p)) |
| 11584 | ) |
| 11585 | { |
| 11586 | res = d; |
| 11587 | if (res == NULL && PyErr_Occurred()) { |
| 11588 | p->error_indicator = 1; |
| 11589 | return NULL; |
| 11590 | } |
| 11591 | goto done; |
| 11592 | } |
| 11593 | p->mark = mark; |
| 11594 | } |
| 11595 | res = NULL; |
| 11596 | done: |
| 11597 | return res; |
| 11598 | } |
| 11599 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11600 | // _tmp_20: '(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11601 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11602 | _tmp_20_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11603 | { |
| 11604 | if (p->error_indicator) { |
| 11605 | return NULL; |
| 11606 | } |
| 11607 | void * res = NULL; |
| 11608 | int mark = p->mark; |
| 11609 | { // '(' inside_paren_ann_assign_target ')' |
| 11610 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11611 | Token * literal; |
| 11612 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11613 | if ( |
| 11614 | (literal = _PyPegen_expect_token(p, 7)) |
| 11615 | && |
| 11616 | (b = inside_paren_ann_assign_target_rule(p)) |
| 11617 | && |
| 11618 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 11619 | ) |
| 11620 | { |
| 11621 | res = b; |
| 11622 | if (res == NULL && PyErr_Occurred()) { |
| 11623 | p->error_indicator = 1; |
| 11624 | return NULL; |
| 11625 | } |
| 11626 | goto done; |
| 11627 | } |
| 11628 | p->mark = mark; |
| 11629 | } |
| 11630 | { // ann_assign_subscript_attribute_target |
| 11631 | expr_ty ann_assign_subscript_attribute_target_var; |
| 11632 | if ( |
| 11633 | (ann_assign_subscript_attribute_target_var = ann_assign_subscript_attribute_target_rule(p)) |
| 11634 | ) |
| 11635 | { |
| 11636 | res = ann_assign_subscript_attribute_target_var; |
| 11637 | goto done; |
| 11638 | } |
| 11639 | p->mark = mark; |
| 11640 | } |
| 11641 | res = NULL; |
| 11642 | done: |
| 11643 | return res; |
| 11644 | } |
| 11645 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11646 | // _tmp_21: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11647 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11648 | _tmp_21_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11649 | { |
| 11650 | if (p->error_indicator) { |
| 11651 | return NULL; |
| 11652 | } |
| 11653 | void * res = NULL; |
| 11654 | int mark = p->mark; |
| 11655 | { // '=' annotated_rhs |
| 11656 | expr_ty d; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11657 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11658 | if ( |
| 11659 | (literal = _PyPegen_expect_token(p, 22)) |
| 11660 | && |
| 11661 | (d = annotated_rhs_rule(p)) |
| 11662 | ) |
| 11663 | { |
| 11664 | res = d; |
| 11665 | if (res == NULL && PyErr_Occurred()) { |
| 11666 | p->error_indicator = 1; |
| 11667 | return NULL; |
| 11668 | } |
| 11669 | goto done; |
| 11670 | } |
| 11671 | p->mark = mark; |
| 11672 | } |
| 11673 | res = NULL; |
| 11674 | done: |
| 11675 | return res; |
| 11676 | } |
| 11677 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11678 | // _loop1_22: (star_targets '=') |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11679 | static asdl_seq * |
| 11680 | _loop1_22_rule(Parser *p) |
| 11681 | { |
| 11682 | if (p->error_indicator) { |
| 11683 | return NULL; |
| 11684 | } |
| 11685 | void *res = NULL; |
| 11686 | int mark = p->mark; |
| 11687 | int start_mark = p->mark; |
| 11688 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11689 | if (!children) { |
| 11690 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11691 | return NULL; |
| 11692 | } |
| 11693 | ssize_t children_capacity = 1; |
| 11694 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11695 | { // (star_targets '=') |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 11696 | void *_tmp_132_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11697 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 11698 | (_tmp_132_var = _tmp_132_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11699 | ) |
| 11700 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 11701 | res = _tmp_132_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11702 | if (n == children_capacity) { |
| 11703 | children_capacity *= 2; |
| 11704 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11705 | if (!children) { |
| 11706 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11707 | return NULL; |
| 11708 | } |
| 11709 | } |
| 11710 | children[n++] = res; |
| 11711 | mark = p->mark; |
| 11712 | } |
| 11713 | p->mark = mark; |
| 11714 | } |
| 11715 | if (n == 0) { |
| 11716 | PyMem_Free(children); |
| 11717 | return NULL; |
| 11718 | } |
| 11719 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11720 | if (!seq) { |
| 11721 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_22"); |
| 11722 | PyMem_Free(children); |
| 11723 | return NULL; |
| 11724 | } |
| 11725 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11726 | PyMem_Free(children); |
| 11727 | _PyPegen_insert_memo(p, start_mark, _loop1_22_type, seq); |
| 11728 | return seq; |
| 11729 | } |
| 11730 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11731 | // _tmp_23: yield_expr | star_expressions |
| 11732 | static void * |
| 11733 | _tmp_23_rule(Parser *p) |
| 11734 | { |
| 11735 | if (p->error_indicator) { |
| 11736 | return NULL; |
| 11737 | } |
| 11738 | void * res = NULL; |
| 11739 | int mark = p->mark; |
| 11740 | { // yield_expr |
| 11741 | expr_ty yield_expr_var; |
| 11742 | if ( |
| 11743 | (yield_expr_var = yield_expr_rule(p)) |
| 11744 | ) |
| 11745 | { |
| 11746 | res = yield_expr_var; |
| 11747 | goto done; |
| 11748 | } |
| 11749 | p->mark = mark; |
| 11750 | } |
| 11751 | { // star_expressions |
| 11752 | expr_ty star_expressions_var; |
| 11753 | if ( |
| 11754 | (star_expressions_var = star_expressions_rule(p)) |
| 11755 | ) |
| 11756 | { |
| 11757 | res = star_expressions_var; |
| 11758 | goto done; |
| 11759 | } |
| 11760 | p->mark = mark; |
| 11761 | } |
| 11762 | res = NULL; |
| 11763 | done: |
| 11764 | return res; |
| 11765 | } |
| 11766 | |
| 11767 | // _tmp_24: yield_expr | star_expressions |
| 11768 | static void * |
| 11769 | _tmp_24_rule(Parser *p) |
| 11770 | { |
| 11771 | if (p->error_indicator) { |
| 11772 | return NULL; |
| 11773 | } |
| 11774 | void * res = NULL; |
| 11775 | int mark = p->mark; |
| 11776 | { // yield_expr |
| 11777 | expr_ty yield_expr_var; |
| 11778 | if ( |
| 11779 | (yield_expr_var = yield_expr_rule(p)) |
| 11780 | ) |
| 11781 | { |
| 11782 | res = yield_expr_var; |
| 11783 | goto done; |
| 11784 | } |
| 11785 | p->mark = mark; |
| 11786 | } |
| 11787 | { // star_expressions |
| 11788 | expr_ty star_expressions_var; |
| 11789 | if ( |
| 11790 | (star_expressions_var = star_expressions_rule(p)) |
| 11791 | ) |
| 11792 | { |
| 11793 | res = star_expressions_var; |
| 11794 | goto done; |
| 11795 | } |
| 11796 | p->mark = mark; |
| 11797 | } |
| 11798 | res = NULL; |
| 11799 | done: |
| 11800 | return res; |
| 11801 | } |
| 11802 | |
| 11803 | // _loop0_26: ',' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11804 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11805 | _loop0_26_rule(Parser *p) |
| 11806 | { |
| 11807 | if (p->error_indicator) { |
| 11808 | return NULL; |
| 11809 | } |
| 11810 | void *res = NULL; |
| 11811 | int mark = p->mark; |
| 11812 | int start_mark = p->mark; |
| 11813 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11814 | if (!children) { |
| 11815 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11816 | return NULL; |
| 11817 | } |
| 11818 | ssize_t children_capacity = 1; |
| 11819 | ssize_t n = 0; |
| 11820 | { // ',' NAME |
| 11821 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11822 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11823 | while ( |
| 11824 | (literal = _PyPegen_expect_token(p, 12)) |
| 11825 | && |
| 11826 | (elem = _PyPegen_name_token(p)) |
| 11827 | ) |
| 11828 | { |
| 11829 | res = elem; |
| 11830 | if (res == NULL && PyErr_Occurred()) { |
| 11831 | p->error_indicator = 1; |
| 11832 | PyMem_Free(children); |
| 11833 | return NULL; |
| 11834 | } |
| 11835 | if (n == children_capacity) { |
| 11836 | children_capacity *= 2; |
| 11837 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11838 | if (!children) { |
| 11839 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11840 | return NULL; |
| 11841 | } |
| 11842 | } |
| 11843 | children[n++] = res; |
| 11844 | mark = p->mark; |
| 11845 | } |
| 11846 | p->mark = mark; |
| 11847 | } |
| 11848 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11849 | if (!seq) { |
| 11850 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_26"); |
| 11851 | PyMem_Free(children); |
| 11852 | return NULL; |
| 11853 | } |
| 11854 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11855 | PyMem_Free(children); |
| 11856 | _PyPegen_insert_memo(p, start_mark, _loop0_26_type, seq); |
| 11857 | return seq; |
| 11858 | } |
| 11859 | |
| 11860 | // _gather_25: NAME _loop0_26 |
| 11861 | static asdl_seq * |
| 11862 | _gather_25_rule(Parser *p) |
| 11863 | { |
| 11864 | if (p->error_indicator) { |
| 11865 | return NULL; |
| 11866 | } |
| 11867 | asdl_seq * res = NULL; |
| 11868 | int mark = p->mark; |
| 11869 | { // NAME _loop0_26 |
| 11870 | expr_ty elem; |
| 11871 | asdl_seq * seq; |
| 11872 | if ( |
| 11873 | (elem = _PyPegen_name_token(p)) |
| 11874 | && |
| 11875 | (seq = _loop0_26_rule(p)) |
| 11876 | ) |
| 11877 | { |
| 11878 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11879 | goto done; |
| 11880 | } |
| 11881 | p->mark = mark; |
| 11882 | } |
| 11883 | res = NULL; |
| 11884 | done: |
| 11885 | return res; |
| 11886 | } |
| 11887 | |
| 11888 | // _loop0_28: ',' NAME |
| 11889 | static asdl_seq * |
| 11890 | _loop0_28_rule(Parser *p) |
| 11891 | { |
| 11892 | if (p->error_indicator) { |
| 11893 | return NULL; |
| 11894 | } |
| 11895 | void *res = NULL; |
| 11896 | int mark = p->mark; |
| 11897 | int start_mark = p->mark; |
| 11898 | void **children = PyMem_Malloc(sizeof(void *)); |
| 11899 | if (!children) { |
| 11900 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11901 | return NULL; |
| 11902 | } |
| 11903 | ssize_t children_capacity = 1; |
| 11904 | ssize_t n = 0; |
| 11905 | { // ',' NAME |
| 11906 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11907 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11908 | while ( |
| 11909 | (literal = _PyPegen_expect_token(p, 12)) |
| 11910 | && |
| 11911 | (elem = _PyPegen_name_token(p)) |
| 11912 | ) |
| 11913 | { |
| 11914 | res = elem; |
| 11915 | if (res == NULL && PyErr_Occurred()) { |
| 11916 | p->error_indicator = 1; |
| 11917 | PyMem_Free(children); |
| 11918 | return NULL; |
| 11919 | } |
| 11920 | if (n == children_capacity) { |
| 11921 | children_capacity *= 2; |
| 11922 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 11923 | if (!children) { |
| 11924 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11925 | return NULL; |
| 11926 | } |
| 11927 | } |
| 11928 | children[n++] = res; |
| 11929 | mark = p->mark; |
| 11930 | } |
| 11931 | p->mark = mark; |
| 11932 | } |
| 11933 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 11934 | if (!seq) { |
| 11935 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_28"); |
| 11936 | PyMem_Free(children); |
| 11937 | return NULL; |
| 11938 | } |
| 11939 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 11940 | PyMem_Free(children); |
| 11941 | _PyPegen_insert_memo(p, start_mark, _loop0_28_type, seq); |
| 11942 | return seq; |
| 11943 | } |
| 11944 | |
| 11945 | // _gather_27: NAME _loop0_28 |
| 11946 | static asdl_seq * |
| 11947 | _gather_27_rule(Parser *p) |
| 11948 | { |
| 11949 | if (p->error_indicator) { |
| 11950 | return NULL; |
| 11951 | } |
| 11952 | asdl_seq * res = NULL; |
| 11953 | int mark = p->mark; |
| 11954 | { // NAME _loop0_28 |
| 11955 | expr_ty elem; |
| 11956 | asdl_seq * seq; |
| 11957 | if ( |
| 11958 | (elem = _PyPegen_name_token(p)) |
| 11959 | && |
| 11960 | (seq = _loop0_28_rule(p)) |
| 11961 | ) |
| 11962 | { |
| 11963 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 11964 | goto done; |
| 11965 | } |
| 11966 | p->mark = mark; |
| 11967 | } |
| 11968 | res = NULL; |
| 11969 | done: |
| 11970 | return res; |
| 11971 | } |
| 11972 | |
| 11973 | // _tmp_29: ',' expression |
| 11974 | static void * |
| 11975 | _tmp_29_rule(Parser *p) |
| 11976 | { |
| 11977 | if (p->error_indicator) { |
| 11978 | return NULL; |
| 11979 | } |
| 11980 | void * res = NULL; |
| 11981 | int mark = p->mark; |
| 11982 | { // ',' expression |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11983 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11984 | expr_ty z; |
| 11985 | if ( |
| 11986 | (literal = _PyPegen_expect_token(p, 12)) |
| 11987 | && |
| 11988 | (z = expression_rule(p)) |
| 11989 | ) |
| 11990 | { |
| 11991 | res = z; |
| 11992 | if (res == NULL && PyErr_Occurred()) { |
| 11993 | p->error_indicator = 1; |
| 11994 | return NULL; |
| 11995 | } |
| 11996 | goto done; |
| 11997 | } |
| 11998 | p->mark = mark; |
| 11999 | } |
| 12000 | res = NULL; |
| 12001 | done: |
| 12002 | return res; |
| 12003 | } |
| 12004 | |
| 12005 | // _loop0_30: ('.' | '...') |
| 12006 | static asdl_seq * |
| 12007 | _loop0_30_rule(Parser *p) |
| 12008 | { |
| 12009 | if (p->error_indicator) { |
| 12010 | return NULL; |
| 12011 | } |
| 12012 | void *res = NULL; |
| 12013 | int mark = p->mark; |
| 12014 | int start_mark = p->mark; |
| 12015 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12016 | if (!children) { |
| 12017 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12018 | return NULL; |
| 12019 | } |
| 12020 | ssize_t children_capacity = 1; |
| 12021 | ssize_t n = 0; |
| 12022 | { // ('.' | '...') |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 12023 | void *_tmp_133_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12024 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 12025 | (_tmp_133_var = _tmp_133_rule(p)) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12026 | ) |
| 12027 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 12028 | res = _tmp_133_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12029 | if (n == children_capacity) { |
| 12030 | children_capacity *= 2; |
| 12031 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12032 | if (!children) { |
| 12033 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12034 | return NULL; |
| 12035 | } |
| 12036 | } |
| 12037 | children[n++] = res; |
| 12038 | mark = p->mark; |
| 12039 | } |
| 12040 | p->mark = mark; |
| 12041 | } |
| 12042 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12043 | if (!seq) { |
| 12044 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_30"); |
| 12045 | PyMem_Free(children); |
| 12046 | return NULL; |
| 12047 | } |
| 12048 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12049 | PyMem_Free(children); |
| 12050 | _PyPegen_insert_memo(p, start_mark, _loop0_30_type, seq); |
| 12051 | return seq; |
| 12052 | } |
| 12053 | |
| 12054 | // _loop1_31: ('.' | '...') |
| 12055 | static asdl_seq * |
| 12056 | _loop1_31_rule(Parser *p) |
| 12057 | { |
| 12058 | if (p->error_indicator) { |
| 12059 | return NULL; |
| 12060 | } |
| 12061 | void *res = NULL; |
| 12062 | int mark = p->mark; |
| 12063 | int start_mark = p->mark; |
| 12064 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12065 | if (!children) { |
| 12066 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12067 | return NULL; |
| 12068 | } |
| 12069 | ssize_t children_capacity = 1; |
| 12070 | ssize_t n = 0; |
| 12071 | { // ('.' | '...') |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 12072 | void *_tmp_134_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12073 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 12074 | (_tmp_134_var = _tmp_134_rule(p)) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12075 | ) |
| 12076 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 12077 | res = _tmp_134_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12078 | if (n == children_capacity) { |
| 12079 | children_capacity *= 2; |
| 12080 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12081 | if (!children) { |
| 12082 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12083 | return NULL; |
| 12084 | } |
| 12085 | } |
| 12086 | children[n++] = res; |
| 12087 | mark = p->mark; |
| 12088 | } |
| 12089 | p->mark = mark; |
| 12090 | } |
| 12091 | if (n == 0) { |
| 12092 | PyMem_Free(children); |
| 12093 | return NULL; |
| 12094 | } |
| 12095 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12096 | if (!seq) { |
| 12097 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_31"); |
| 12098 | PyMem_Free(children); |
| 12099 | return NULL; |
| 12100 | } |
| 12101 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12102 | PyMem_Free(children); |
| 12103 | _PyPegen_insert_memo(p, start_mark, _loop1_31_type, seq); |
| 12104 | return seq; |
| 12105 | } |
| 12106 | |
| 12107 | // _loop0_33: ',' import_from_as_name |
| 12108 | static asdl_seq * |
| 12109 | _loop0_33_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12110 | { |
| 12111 | if (p->error_indicator) { |
| 12112 | return NULL; |
| 12113 | } |
| 12114 | void *res = NULL; |
| 12115 | int mark = p->mark; |
| 12116 | int start_mark = p->mark; |
| 12117 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12118 | if (!children) { |
| 12119 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12120 | return NULL; |
| 12121 | } |
| 12122 | ssize_t children_capacity = 1; |
| 12123 | ssize_t n = 0; |
| 12124 | { // ',' import_from_as_name |
| 12125 | alias_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12126 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12127 | while ( |
| 12128 | (literal = _PyPegen_expect_token(p, 12)) |
| 12129 | && |
| 12130 | (elem = import_from_as_name_rule(p)) |
| 12131 | ) |
| 12132 | { |
| 12133 | res = elem; |
| 12134 | if (res == NULL && PyErr_Occurred()) { |
| 12135 | p->error_indicator = 1; |
| 12136 | PyMem_Free(children); |
| 12137 | return NULL; |
| 12138 | } |
| 12139 | if (n == children_capacity) { |
| 12140 | children_capacity *= 2; |
| 12141 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12142 | if (!children) { |
| 12143 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12144 | return NULL; |
| 12145 | } |
| 12146 | } |
| 12147 | children[n++] = res; |
| 12148 | mark = p->mark; |
| 12149 | } |
| 12150 | p->mark = mark; |
| 12151 | } |
| 12152 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12153 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12154 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_33"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12155 | PyMem_Free(children); |
| 12156 | return NULL; |
| 12157 | } |
| 12158 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12159 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12160 | _PyPegen_insert_memo(p, start_mark, _loop0_33_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12161 | return seq; |
| 12162 | } |
| 12163 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12164 | // _gather_32: import_from_as_name _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12165 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12166 | _gather_32_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12167 | { |
| 12168 | if (p->error_indicator) { |
| 12169 | return NULL; |
| 12170 | } |
| 12171 | asdl_seq * res = NULL; |
| 12172 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12173 | { // import_from_as_name _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12174 | alias_ty elem; |
| 12175 | asdl_seq * seq; |
| 12176 | if ( |
| 12177 | (elem = import_from_as_name_rule(p)) |
| 12178 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12179 | (seq = _loop0_33_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12180 | ) |
| 12181 | { |
| 12182 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12183 | goto done; |
| 12184 | } |
| 12185 | p->mark = mark; |
| 12186 | } |
| 12187 | res = NULL; |
| 12188 | done: |
| 12189 | return res; |
| 12190 | } |
| 12191 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12192 | // _tmp_34: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12193 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12194 | _tmp_34_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12195 | { |
| 12196 | if (p->error_indicator) { |
| 12197 | return NULL; |
| 12198 | } |
| 12199 | void * res = NULL; |
| 12200 | int mark = p->mark; |
| 12201 | { // 'as' NAME |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12202 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12203 | expr_ty z; |
| 12204 | if ( |
| 12205 | (keyword = _PyPegen_expect_token(p, 531)) |
| 12206 | && |
| 12207 | (z = _PyPegen_name_token(p)) |
| 12208 | ) |
| 12209 | { |
| 12210 | res = z; |
| 12211 | if (res == NULL && PyErr_Occurred()) { |
| 12212 | p->error_indicator = 1; |
| 12213 | return NULL; |
| 12214 | } |
| 12215 | goto done; |
| 12216 | } |
| 12217 | p->mark = mark; |
| 12218 | } |
| 12219 | res = NULL; |
| 12220 | done: |
| 12221 | return res; |
| 12222 | } |
| 12223 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12224 | // _loop0_36: ',' dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12225 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12226 | _loop0_36_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12227 | { |
| 12228 | if (p->error_indicator) { |
| 12229 | return NULL; |
| 12230 | } |
| 12231 | void *res = NULL; |
| 12232 | int mark = p->mark; |
| 12233 | int start_mark = p->mark; |
| 12234 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12235 | if (!children) { |
| 12236 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12237 | return NULL; |
| 12238 | } |
| 12239 | ssize_t children_capacity = 1; |
| 12240 | ssize_t n = 0; |
| 12241 | { // ',' dotted_as_name |
| 12242 | alias_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12243 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12244 | while ( |
| 12245 | (literal = _PyPegen_expect_token(p, 12)) |
| 12246 | && |
| 12247 | (elem = dotted_as_name_rule(p)) |
| 12248 | ) |
| 12249 | { |
| 12250 | res = elem; |
| 12251 | if (res == NULL && PyErr_Occurred()) { |
| 12252 | p->error_indicator = 1; |
| 12253 | PyMem_Free(children); |
| 12254 | return NULL; |
| 12255 | } |
| 12256 | if (n == children_capacity) { |
| 12257 | children_capacity *= 2; |
| 12258 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12259 | if (!children) { |
| 12260 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12261 | return NULL; |
| 12262 | } |
| 12263 | } |
| 12264 | children[n++] = res; |
| 12265 | mark = p->mark; |
| 12266 | } |
| 12267 | p->mark = mark; |
| 12268 | } |
| 12269 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12270 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12271 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_36"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12272 | PyMem_Free(children); |
| 12273 | return NULL; |
| 12274 | } |
| 12275 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12276 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12277 | _PyPegen_insert_memo(p, start_mark, _loop0_36_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12278 | return seq; |
| 12279 | } |
| 12280 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12281 | // _gather_35: dotted_as_name _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12282 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12283 | _gather_35_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12284 | { |
| 12285 | if (p->error_indicator) { |
| 12286 | return NULL; |
| 12287 | } |
| 12288 | asdl_seq * res = NULL; |
| 12289 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12290 | { // dotted_as_name _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12291 | alias_ty elem; |
| 12292 | asdl_seq * seq; |
| 12293 | if ( |
| 12294 | (elem = dotted_as_name_rule(p)) |
| 12295 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12296 | (seq = _loop0_36_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12297 | ) |
| 12298 | { |
| 12299 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12300 | goto done; |
| 12301 | } |
| 12302 | p->mark = mark; |
| 12303 | } |
| 12304 | res = NULL; |
| 12305 | done: |
| 12306 | return res; |
| 12307 | } |
| 12308 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12309 | // _tmp_37: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12310 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12311 | _tmp_37_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12312 | { |
| 12313 | if (p->error_indicator) { |
| 12314 | return NULL; |
| 12315 | } |
| 12316 | void * res = NULL; |
| 12317 | int mark = p->mark; |
| 12318 | { // 'as' NAME |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12319 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12320 | expr_ty z; |
| 12321 | if ( |
| 12322 | (keyword = _PyPegen_expect_token(p, 531)) |
| 12323 | && |
| 12324 | (z = _PyPegen_name_token(p)) |
| 12325 | ) |
| 12326 | { |
| 12327 | res = z; |
| 12328 | if (res == NULL && PyErr_Occurred()) { |
| 12329 | p->error_indicator = 1; |
| 12330 | return NULL; |
| 12331 | } |
| 12332 | goto done; |
| 12333 | } |
| 12334 | p->mark = mark; |
| 12335 | } |
| 12336 | res = NULL; |
| 12337 | done: |
| 12338 | return res; |
| 12339 | } |
| 12340 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12341 | // _loop0_39: ',' with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12342 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12343 | _loop0_39_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12344 | { |
| 12345 | if (p->error_indicator) { |
| 12346 | return NULL; |
| 12347 | } |
| 12348 | void *res = NULL; |
| 12349 | int mark = p->mark; |
| 12350 | int start_mark = p->mark; |
| 12351 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12352 | if (!children) { |
| 12353 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12354 | return NULL; |
| 12355 | } |
| 12356 | ssize_t children_capacity = 1; |
| 12357 | ssize_t n = 0; |
| 12358 | { // ',' with_item |
| 12359 | withitem_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12360 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12361 | while ( |
| 12362 | (literal = _PyPegen_expect_token(p, 12)) |
| 12363 | && |
| 12364 | (elem = with_item_rule(p)) |
| 12365 | ) |
| 12366 | { |
| 12367 | res = elem; |
| 12368 | if (res == NULL && PyErr_Occurred()) { |
| 12369 | p->error_indicator = 1; |
| 12370 | PyMem_Free(children); |
| 12371 | return NULL; |
| 12372 | } |
| 12373 | if (n == children_capacity) { |
| 12374 | children_capacity *= 2; |
| 12375 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12376 | if (!children) { |
| 12377 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12378 | return NULL; |
| 12379 | } |
| 12380 | } |
| 12381 | children[n++] = res; |
| 12382 | mark = p->mark; |
| 12383 | } |
| 12384 | p->mark = mark; |
| 12385 | } |
| 12386 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12387 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12388 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_39"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12389 | PyMem_Free(children); |
| 12390 | return NULL; |
| 12391 | } |
| 12392 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12393 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12394 | _PyPegen_insert_memo(p, start_mark, _loop0_39_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12395 | return seq; |
| 12396 | } |
| 12397 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12398 | // _gather_38: with_item _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12399 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12400 | _gather_38_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12401 | { |
| 12402 | if (p->error_indicator) { |
| 12403 | return NULL; |
| 12404 | } |
| 12405 | asdl_seq * res = NULL; |
| 12406 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12407 | { // with_item _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12408 | withitem_ty elem; |
| 12409 | asdl_seq * seq; |
| 12410 | if ( |
| 12411 | (elem = with_item_rule(p)) |
| 12412 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12413 | (seq = _loop0_39_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12414 | ) |
| 12415 | { |
| 12416 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12417 | goto done; |
| 12418 | } |
| 12419 | p->mark = mark; |
| 12420 | } |
| 12421 | res = NULL; |
| 12422 | done: |
| 12423 | return res; |
| 12424 | } |
| 12425 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12426 | // _loop0_41: ',' with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12427 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12428 | _loop0_41_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12429 | { |
| 12430 | if (p->error_indicator) { |
| 12431 | return NULL; |
| 12432 | } |
| 12433 | void *res = NULL; |
| 12434 | int mark = p->mark; |
| 12435 | int start_mark = p->mark; |
| 12436 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12437 | if (!children) { |
| 12438 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12439 | return NULL; |
| 12440 | } |
| 12441 | ssize_t children_capacity = 1; |
| 12442 | ssize_t n = 0; |
| 12443 | { // ',' with_item |
| 12444 | withitem_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12445 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12446 | while ( |
| 12447 | (literal = _PyPegen_expect_token(p, 12)) |
| 12448 | && |
| 12449 | (elem = with_item_rule(p)) |
| 12450 | ) |
| 12451 | { |
| 12452 | res = elem; |
| 12453 | if (res == NULL && PyErr_Occurred()) { |
| 12454 | p->error_indicator = 1; |
| 12455 | PyMem_Free(children); |
| 12456 | return NULL; |
| 12457 | } |
| 12458 | if (n == children_capacity) { |
| 12459 | children_capacity *= 2; |
| 12460 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12461 | if (!children) { |
| 12462 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12463 | return NULL; |
| 12464 | } |
| 12465 | } |
| 12466 | children[n++] = res; |
| 12467 | mark = p->mark; |
| 12468 | } |
| 12469 | p->mark = mark; |
| 12470 | } |
| 12471 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12472 | if (!seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12473 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_41"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12474 | PyMem_Free(children); |
| 12475 | return NULL; |
| 12476 | } |
| 12477 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12478 | PyMem_Free(children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12479 | _PyPegen_insert_memo(p, start_mark, _loop0_41_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12480 | return seq; |
| 12481 | } |
| 12482 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12483 | // _gather_40: with_item _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12484 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12485 | _gather_40_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12486 | { |
| 12487 | if (p->error_indicator) { |
| 12488 | return NULL; |
| 12489 | } |
| 12490 | asdl_seq * res = NULL; |
| 12491 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12492 | { // with_item _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12493 | withitem_ty elem; |
| 12494 | asdl_seq * seq; |
| 12495 | if ( |
| 12496 | (elem = with_item_rule(p)) |
| 12497 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12498 | (seq = _loop0_41_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12499 | ) |
| 12500 | { |
| 12501 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12502 | goto done; |
| 12503 | } |
| 12504 | p->mark = mark; |
| 12505 | } |
| 12506 | res = NULL; |
| 12507 | done: |
| 12508 | return res; |
| 12509 | } |
| 12510 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12511 | // _loop0_43: ',' with_item |
| 12512 | static asdl_seq * |
| 12513 | _loop0_43_rule(Parser *p) |
| 12514 | { |
| 12515 | if (p->error_indicator) { |
| 12516 | return NULL; |
| 12517 | } |
| 12518 | void *res = NULL; |
| 12519 | int mark = p->mark; |
| 12520 | int start_mark = p->mark; |
| 12521 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12522 | if (!children) { |
| 12523 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12524 | return NULL; |
| 12525 | } |
| 12526 | ssize_t children_capacity = 1; |
| 12527 | ssize_t n = 0; |
| 12528 | { // ',' with_item |
| 12529 | withitem_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12530 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12531 | while ( |
| 12532 | (literal = _PyPegen_expect_token(p, 12)) |
| 12533 | && |
| 12534 | (elem = with_item_rule(p)) |
| 12535 | ) |
| 12536 | { |
| 12537 | res = elem; |
| 12538 | if (res == NULL && PyErr_Occurred()) { |
| 12539 | p->error_indicator = 1; |
| 12540 | PyMem_Free(children); |
| 12541 | return NULL; |
| 12542 | } |
| 12543 | if (n == children_capacity) { |
| 12544 | children_capacity *= 2; |
| 12545 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12546 | if (!children) { |
| 12547 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12548 | return NULL; |
| 12549 | } |
| 12550 | } |
| 12551 | children[n++] = res; |
| 12552 | mark = p->mark; |
| 12553 | } |
| 12554 | p->mark = mark; |
| 12555 | } |
| 12556 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12557 | if (!seq) { |
| 12558 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_43"); |
| 12559 | PyMem_Free(children); |
| 12560 | return NULL; |
| 12561 | } |
| 12562 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12563 | PyMem_Free(children); |
| 12564 | _PyPegen_insert_memo(p, start_mark, _loop0_43_type, seq); |
| 12565 | return seq; |
| 12566 | } |
| 12567 | |
| 12568 | // _gather_42: with_item _loop0_43 |
| 12569 | static asdl_seq * |
| 12570 | _gather_42_rule(Parser *p) |
| 12571 | { |
| 12572 | if (p->error_indicator) { |
| 12573 | return NULL; |
| 12574 | } |
| 12575 | asdl_seq * res = NULL; |
| 12576 | int mark = p->mark; |
| 12577 | { // with_item _loop0_43 |
| 12578 | withitem_ty elem; |
| 12579 | asdl_seq * seq; |
| 12580 | if ( |
| 12581 | (elem = with_item_rule(p)) |
| 12582 | && |
| 12583 | (seq = _loop0_43_rule(p)) |
| 12584 | ) |
| 12585 | { |
| 12586 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12587 | goto done; |
| 12588 | } |
| 12589 | p->mark = mark; |
| 12590 | } |
| 12591 | res = NULL; |
| 12592 | done: |
| 12593 | return res; |
| 12594 | } |
| 12595 | |
| 12596 | // _loop0_45: ',' with_item |
| 12597 | static asdl_seq * |
| 12598 | _loop0_45_rule(Parser *p) |
| 12599 | { |
| 12600 | if (p->error_indicator) { |
| 12601 | return NULL; |
| 12602 | } |
| 12603 | void *res = NULL; |
| 12604 | int mark = p->mark; |
| 12605 | int start_mark = p->mark; |
| 12606 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12607 | if (!children) { |
| 12608 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12609 | return NULL; |
| 12610 | } |
| 12611 | ssize_t children_capacity = 1; |
| 12612 | ssize_t n = 0; |
| 12613 | { // ',' with_item |
| 12614 | withitem_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12615 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12616 | while ( |
| 12617 | (literal = _PyPegen_expect_token(p, 12)) |
| 12618 | && |
| 12619 | (elem = with_item_rule(p)) |
| 12620 | ) |
| 12621 | { |
| 12622 | res = elem; |
| 12623 | if (res == NULL && PyErr_Occurred()) { |
| 12624 | p->error_indicator = 1; |
| 12625 | PyMem_Free(children); |
| 12626 | return NULL; |
| 12627 | } |
| 12628 | if (n == children_capacity) { |
| 12629 | children_capacity *= 2; |
| 12630 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12631 | if (!children) { |
| 12632 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12633 | return NULL; |
| 12634 | } |
| 12635 | } |
| 12636 | children[n++] = res; |
| 12637 | mark = p->mark; |
| 12638 | } |
| 12639 | p->mark = mark; |
| 12640 | } |
| 12641 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12642 | if (!seq) { |
| 12643 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_45"); |
| 12644 | PyMem_Free(children); |
| 12645 | return NULL; |
| 12646 | } |
| 12647 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12648 | PyMem_Free(children); |
| 12649 | _PyPegen_insert_memo(p, start_mark, _loop0_45_type, seq); |
| 12650 | return seq; |
| 12651 | } |
| 12652 | |
| 12653 | // _gather_44: with_item _loop0_45 |
| 12654 | static asdl_seq * |
| 12655 | _gather_44_rule(Parser *p) |
| 12656 | { |
| 12657 | if (p->error_indicator) { |
| 12658 | return NULL; |
| 12659 | } |
| 12660 | asdl_seq * res = NULL; |
| 12661 | int mark = p->mark; |
| 12662 | { // with_item _loop0_45 |
| 12663 | withitem_ty elem; |
| 12664 | asdl_seq * seq; |
| 12665 | if ( |
| 12666 | (elem = with_item_rule(p)) |
| 12667 | && |
| 12668 | (seq = _loop0_45_rule(p)) |
| 12669 | ) |
| 12670 | { |
| 12671 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 12672 | goto done; |
| 12673 | } |
| 12674 | p->mark = mark; |
| 12675 | } |
| 12676 | res = NULL; |
| 12677 | done: |
| 12678 | return res; |
| 12679 | } |
| 12680 | |
| 12681 | // _tmp_46: 'as' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12682 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12683 | _tmp_46_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12684 | { |
| 12685 | if (p->error_indicator) { |
| 12686 | return NULL; |
| 12687 | } |
| 12688 | void * res = NULL; |
| 12689 | int mark = p->mark; |
| 12690 | { // 'as' target |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12691 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12692 | expr_ty t; |
| 12693 | if ( |
| 12694 | (keyword = _PyPegen_expect_token(p, 531)) |
| 12695 | && |
| 12696 | (t = target_rule(p)) |
| 12697 | ) |
| 12698 | { |
| 12699 | res = t; |
| 12700 | if (res == NULL && PyErr_Occurred()) { |
| 12701 | p->error_indicator = 1; |
| 12702 | return NULL; |
| 12703 | } |
| 12704 | goto done; |
| 12705 | } |
| 12706 | p->mark = mark; |
| 12707 | } |
| 12708 | res = NULL; |
| 12709 | done: |
| 12710 | return res; |
| 12711 | } |
| 12712 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12713 | // _loop1_47: except_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12714 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12715 | _loop1_47_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12716 | { |
| 12717 | if (p->error_indicator) { |
| 12718 | return NULL; |
| 12719 | } |
| 12720 | void *res = NULL; |
| 12721 | int mark = p->mark; |
| 12722 | int start_mark = p->mark; |
| 12723 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12724 | if (!children) { |
| 12725 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12726 | return NULL; |
| 12727 | } |
| 12728 | ssize_t children_capacity = 1; |
| 12729 | ssize_t n = 0; |
| 12730 | { // except_block |
| 12731 | excepthandler_ty except_block_var; |
| 12732 | while ( |
| 12733 | (except_block_var = except_block_rule(p)) |
| 12734 | ) |
| 12735 | { |
| 12736 | res = except_block_var; |
| 12737 | if (n == children_capacity) { |
| 12738 | children_capacity *= 2; |
| 12739 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12740 | if (!children) { |
| 12741 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12742 | return NULL; |
| 12743 | } |
| 12744 | } |
| 12745 | children[n++] = res; |
| 12746 | mark = p->mark; |
| 12747 | } |
| 12748 | p->mark = mark; |
| 12749 | } |
| 12750 | if (n == 0) { |
| 12751 | PyMem_Free(children); |
| 12752 | return NULL; |
| 12753 | } |
| 12754 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12755 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12756 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_47"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12757 | PyMem_Free(children); |
| 12758 | return NULL; |
| 12759 | } |
| 12760 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12761 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12762 | _PyPegen_insert_memo(p, start_mark, _loop1_47_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12763 | return seq; |
| 12764 | } |
| 12765 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12766 | // _tmp_48: 'as' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12767 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12768 | _tmp_48_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12769 | { |
| 12770 | if (p->error_indicator) { |
| 12771 | return NULL; |
| 12772 | } |
| 12773 | void * res = NULL; |
| 12774 | int mark = p->mark; |
| 12775 | { // 'as' target |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12776 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12777 | expr_ty z; |
| 12778 | if ( |
| 12779 | (keyword = _PyPegen_expect_token(p, 531)) |
| 12780 | && |
| 12781 | (z = target_rule(p)) |
| 12782 | ) |
| 12783 | { |
| 12784 | res = z; |
| 12785 | if (res == NULL && PyErr_Occurred()) { |
| 12786 | p->error_indicator = 1; |
| 12787 | return NULL; |
| 12788 | } |
| 12789 | goto done; |
| 12790 | } |
| 12791 | p->mark = mark; |
| 12792 | } |
| 12793 | res = NULL; |
| 12794 | done: |
| 12795 | return res; |
| 12796 | } |
| 12797 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12798 | // _tmp_49: 'from' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12799 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12800 | _tmp_49_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12801 | { |
| 12802 | if (p->error_indicator) { |
| 12803 | return NULL; |
| 12804 | } |
| 12805 | void * res = NULL; |
| 12806 | int mark = p->mark; |
| 12807 | { // 'from' expression |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12808 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12809 | expr_ty z; |
| 12810 | if ( |
| 12811 | (keyword = _PyPegen_expect_token(p, 514)) |
| 12812 | && |
| 12813 | (z = expression_rule(p)) |
| 12814 | ) |
| 12815 | { |
| 12816 | res = z; |
| 12817 | if (res == NULL && PyErr_Occurred()) { |
| 12818 | p->error_indicator = 1; |
| 12819 | return NULL; |
| 12820 | } |
| 12821 | goto done; |
| 12822 | } |
| 12823 | p->mark = mark; |
| 12824 | } |
| 12825 | res = NULL; |
| 12826 | done: |
| 12827 | return res; |
| 12828 | } |
| 12829 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12830 | // _tmp_50: '->' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12831 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12832 | _tmp_50_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12833 | { |
| 12834 | if (p->error_indicator) { |
| 12835 | return NULL; |
| 12836 | } |
| 12837 | void * res = NULL; |
| 12838 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12839 | { // '->' expression |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12840 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12841 | expr_ty z; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12842 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12843 | (literal = _PyPegen_expect_token(p, 51)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12844 | && |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12845 | (z = expression_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12846 | ) |
| 12847 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12848 | res = z; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12849 | if (res == NULL && PyErr_Occurred()) { |
| 12850 | p->error_indicator = 1; |
| 12851 | return NULL; |
| 12852 | } |
| 12853 | goto done; |
| 12854 | } |
| 12855 | p->mark = mark; |
| 12856 | } |
| 12857 | res = NULL; |
| 12858 | done: |
| 12859 | return res; |
| 12860 | } |
| 12861 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12862 | // _tmp_51: '->' expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12863 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12864 | _tmp_51_rule(Parser *p) |
| 12865 | { |
| 12866 | if (p->error_indicator) { |
| 12867 | return NULL; |
| 12868 | } |
| 12869 | void * res = NULL; |
| 12870 | int mark = p->mark; |
| 12871 | { // '->' expression |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12872 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12873 | expr_ty z; |
| 12874 | if ( |
| 12875 | (literal = _PyPegen_expect_token(p, 51)) |
| 12876 | && |
| 12877 | (z = expression_rule(p)) |
| 12878 | ) |
| 12879 | { |
| 12880 | res = z; |
| 12881 | if (res == NULL && PyErr_Occurred()) { |
| 12882 | p->error_indicator = 1; |
| 12883 | return NULL; |
| 12884 | } |
| 12885 | goto done; |
| 12886 | } |
| 12887 | p->mark = mark; |
| 12888 | } |
| 12889 | res = NULL; |
| 12890 | done: |
| 12891 | return res; |
| 12892 | } |
| 12893 | |
| 12894 | // _tmp_52: NEWLINE INDENT |
| 12895 | static void * |
| 12896 | _tmp_52_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12897 | { |
| 12898 | if (p->error_indicator) { |
| 12899 | return NULL; |
| 12900 | } |
| 12901 | void * res = NULL; |
| 12902 | int mark = p->mark; |
| 12903 | { // NEWLINE INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 12904 | Token * indent_var; |
| 12905 | Token * newline_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12906 | if ( |
| 12907 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) |
| 12908 | && |
| 12909 | (indent_var = _PyPegen_expect_token(p, INDENT)) |
| 12910 | ) |
| 12911 | { |
| 12912 | res = _PyPegen_dummy_name(p, newline_var, indent_var); |
| 12913 | goto done; |
| 12914 | } |
| 12915 | p->mark = mark; |
| 12916 | } |
| 12917 | res = NULL; |
| 12918 | done: |
| 12919 | return res; |
| 12920 | } |
| 12921 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12922 | // _loop0_53: param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12923 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12924 | _loop0_53_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12925 | { |
| 12926 | if (p->error_indicator) { |
| 12927 | return NULL; |
| 12928 | } |
| 12929 | void *res = NULL; |
| 12930 | int mark = p->mark; |
| 12931 | int start_mark = p->mark; |
| 12932 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12933 | if (!children) { |
| 12934 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12935 | return NULL; |
| 12936 | } |
| 12937 | ssize_t children_capacity = 1; |
| 12938 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12939 | { // param_no_default |
| 12940 | arg_ty param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12941 | while ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12942 | (param_no_default_var = param_no_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12943 | ) |
| 12944 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12945 | res = param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12946 | if (n == children_capacity) { |
| 12947 | children_capacity *= 2; |
| 12948 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12949 | if (!children) { |
| 12950 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12951 | return NULL; |
| 12952 | } |
| 12953 | } |
| 12954 | children[n++] = res; |
| 12955 | mark = p->mark; |
| 12956 | } |
| 12957 | p->mark = mark; |
| 12958 | } |
| 12959 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 12960 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12961 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_53"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12962 | PyMem_Free(children); |
| 12963 | return NULL; |
| 12964 | } |
| 12965 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 12966 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12967 | _PyPegen_insert_memo(p, start_mark, _loop0_53_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12968 | return seq; |
| 12969 | } |
| 12970 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12971 | // _loop0_54: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12972 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12973 | _loop0_54_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12974 | { |
| 12975 | if (p->error_indicator) { |
| 12976 | return NULL; |
| 12977 | } |
| 12978 | void *res = NULL; |
| 12979 | int mark = p->mark; |
| 12980 | int start_mark = p->mark; |
| 12981 | void **children = PyMem_Malloc(sizeof(void *)); |
| 12982 | if (!children) { |
| 12983 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12984 | return NULL; |
| 12985 | } |
| 12986 | ssize_t children_capacity = 1; |
| 12987 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12988 | { // param_with_default |
| 12989 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12990 | while ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12991 | (param_with_default_var = param_with_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12992 | ) |
| 12993 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12994 | res = param_with_default_var; |
| 12995 | if (n == children_capacity) { |
| 12996 | children_capacity *= 2; |
| 12997 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 12998 | if (!children) { |
| 12999 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13000 | return NULL; |
| 13001 | } |
| 13002 | } |
| 13003 | children[n++] = res; |
| 13004 | mark = p->mark; |
| 13005 | } |
| 13006 | p->mark = mark; |
| 13007 | } |
| 13008 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13009 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13010 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_54"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13011 | PyMem_Free(children); |
| 13012 | return NULL; |
| 13013 | } |
| 13014 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13015 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13016 | _PyPegen_insert_memo(p, start_mark, _loop0_54_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13017 | return seq; |
| 13018 | } |
| 13019 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13020 | // _loop0_55: param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13021 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13022 | _loop0_55_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13023 | { |
| 13024 | if (p->error_indicator) { |
| 13025 | return NULL; |
| 13026 | } |
| 13027 | void *res = NULL; |
| 13028 | int mark = p->mark; |
| 13029 | int start_mark = p->mark; |
| 13030 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13031 | if (!children) { |
| 13032 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13033 | return NULL; |
| 13034 | } |
| 13035 | ssize_t children_capacity = 1; |
| 13036 | ssize_t n = 0; |
| 13037 | { // param_with_default |
| 13038 | NameDefaultPair* param_with_default_var; |
| 13039 | while ( |
| 13040 | (param_with_default_var = param_with_default_rule(p)) |
| 13041 | ) |
| 13042 | { |
| 13043 | res = param_with_default_var; |
| 13044 | if (n == children_capacity) { |
| 13045 | children_capacity *= 2; |
| 13046 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13047 | if (!children) { |
| 13048 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13049 | return NULL; |
| 13050 | } |
| 13051 | } |
| 13052 | children[n++] = res; |
| 13053 | mark = p->mark; |
| 13054 | } |
| 13055 | p->mark = mark; |
| 13056 | } |
| 13057 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13058 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13059 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_55"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13060 | PyMem_Free(children); |
| 13061 | return NULL; |
| 13062 | } |
| 13063 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13064 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13065 | _PyPegen_insert_memo(p, start_mark, _loop0_55_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13066 | return seq; |
| 13067 | } |
| 13068 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13069 | // _loop1_56: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13070 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13071 | _loop1_56_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13072 | { |
| 13073 | if (p->error_indicator) { |
| 13074 | return NULL; |
| 13075 | } |
| 13076 | void *res = NULL; |
| 13077 | int mark = p->mark; |
| 13078 | int start_mark = p->mark; |
| 13079 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13080 | if (!children) { |
| 13081 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13082 | return NULL; |
| 13083 | } |
| 13084 | ssize_t children_capacity = 1; |
| 13085 | ssize_t n = 0; |
| 13086 | { // param_no_default |
| 13087 | arg_ty param_no_default_var; |
| 13088 | while ( |
| 13089 | (param_no_default_var = param_no_default_rule(p)) |
| 13090 | ) |
| 13091 | { |
| 13092 | res = param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13093 | if (n == children_capacity) { |
| 13094 | children_capacity *= 2; |
| 13095 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13096 | if (!children) { |
| 13097 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13098 | return NULL; |
| 13099 | } |
| 13100 | } |
| 13101 | children[n++] = res; |
| 13102 | mark = p->mark; |
| 13103 | } |
| 13104 | p->mark = mark; |
| 13105 | } |
| 13106 | if (n == 0) { |
| 13107 | PyMem_Free(children); |
| 13108 | return NULL; |
| 13109 | } |
| 13110 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13111 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13112 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_56"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13113 | PyMem_Free(children); |
| 13114 | return NULL; |
| 13115 | } |
| 13116 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13117 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13118 | _PyPegen_insert_memo(p, start_mark, _loop1_56_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13119 | return seq; |
| 13120 | } |
| 13121 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13122 | // _loop0_57: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13123 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13124 | _loop0_57_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13125 | { |
| 13126 | if (p->error_indicator) { |
| 13127 | return NULL; |
| 13128 | } |
| 13129 | void *res = NULL; |
| 13130 | int mark = p->mark; |
| 13131 | int start_mark = p->mark; |
| 13132 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13133 | if (!children) { |
| 13134 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13135 | return NULL; |
| 13136 | } |
| 13137 | ssize_t children_capacity = 1; |
| 13138 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13139 | { // param_with_default |
| 13140 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13141 | while ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13142 | (param_with_default_var = param_with_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13143 | ) |
| 13144 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13145 | res = param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13146 | if (n == children_capacity) { |
| 13147 | children_capacity *= 2; |
| 13148 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13149 | if (!children) { |
| 13150 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13151 | return NULL; |
| 13152 | } |
| 13153 | } |
| 13154 | children[n++] = res; |
| 13155 | mark = p->mark; |
| 13156 | } |
| 13157 | p->mark = mark; |
| 13158 | } |
| 13159 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13160 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13161 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_57"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13162 | PyMem_Free(children); |
| 13163 | return NULL; |
| 13164 | } |
| 13165 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13166 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13167 | _PyPegen_insert_memo(p, start_mark, _loop0_57_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13168 | return seq; |
| 13169 | } |
| 13170 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13171 | // _loop1_58: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13172 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13173 | _loop1_58_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13174 | { |
| 13175 | if (p->error_indicator) { |
| 13176 | return NULL; |
| 13177 | } |
| 13178 | void *res = NULL; |
| 13179 | int mark = p->mark; |
| 13180 | int start_mark = p->mark; |
| 13181 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13182 | if (!children) { |
| 13183 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13184 | return NULL; |
| 13185 | } |
| 13186 | ssize_t children_capacity = 1; |
| 13187 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13188 | { // param_with_default |
| 13189 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13190 | while ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13191 | (param_with_default_var = param_with_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13192 | ) |
| 13193 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13194 | res = param_with_default_var; |
| 13195 | if (n == children_capacity) { |
| 13196 | children_capacity *= 2; |
| 13197 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13198 | if (!children) { |
| 13199 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13200 | return NULL; |
| 13201 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13202 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13203 | children[n++] = res; |
| 13204 | mark = p->mark; |
| 13205 | } |
| 13206 | p->mark = mark; |
| 13207 | } |
| 13208 | if (n == 0) { |
| 13209 | PyMem_Free(children); |
| 13210 | return NULL; |
| 13211 | } |
| 13212 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13213 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13214 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_58"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13215 | PyMem_Free(children); |
| 13216 | return NULL; |
| 13217 | } |
| 13218 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13219 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13220 | _PyPegen_insert_memo(p, start_mark, _loop1_58_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13221 | return seq; |
| 13222 | } |
| 13223 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13224 | // _loop1_59: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13225 | static asdl_seq * |
| 13226 | _loop1_59_rule(Parser *p) |
| 13227 | { |
| 13228 | if (p->error_indicator) { |
| 13229 | return NULL; |
| 13230 | } |
| 13231 | void *res = NULL; |
| 13232 | int mark = p->mark; |
| 13233 | int start_mark = p->mark; |
| 13234 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13235 | if (!children) { |
| 13236 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13237 | return NULL; |
| 13238 | } |
| 13239 | ssize_t children_capacity = 1; |
| 13240 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13241 | { // param_no_default |
| 13242 | arg_ty param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13243 | while ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13244 | (param_no_default_var = param_no_default_rule(p)) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13245 | ) |
| 13246 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13247 | res = param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13248 | if (n == children_capacity) { |
| 13249 | children_capacity *= 2; |
| 13250 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13251 | if (!children) { |
| 13252 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13253 | return NULL; |
| 13254 | } |
| 13255 | } |
| 13256 | children[n++] = res; |
| 13257 | mark = p->mark; |
| 13258 | } |
| 13259 | p->mark = mark; |
| 13260 | } |
| 13261 | if (n == 0) { |
| 13262 | PyMem_Free(children); |
| 13263 | return NULL; |
| 13264 | } |
| 13265 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13266 | if (!seq) { |
| 13267 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_59"); |
| 13268 | PyMem_Free(children); |
| 13269 | return NULL; |
| 13270 | } |
| 13271 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13272 | PyMem_Free(children); |
| 13273 | _PyPegen_insert_memo(p, start_mark, _loop1_59_type, seq); |
| 13274 | return seq; |
| 13275 | } |
| 13276 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13277 | // _loop1_60: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13278 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13279 | _loop1_60_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13280 | { |
| 13281 | if (p->error_indicator) { |
| 13282 | return NULL; |
| 13283 | } |
| 13284 | void *res = NULL; |
| 13285 | int mark = p->mark; |
| 13286 | int start_mark = p->mark; |
| 13287 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13288 | if (!children) { |
| 13289 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13290 | return NULL; |
| 13291 | } |
| 13292 | ssize_t children_capacity = 1; |
| 13293 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13294 | { // param_no_default |
| 13295 | arg_ty param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13296 | while ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13297 | (param_no_default_var = param_no_default_rule(p)) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13298 | ) |
| 13299 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13300 | res = param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13301 | if (n == children_capacity) { |
| 13302 | children_capacity *= 2; |
| 13303 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13304 | if (!children) { |
| 13305 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13306 | return NULL; |
| 13307 | } |
| 13308 | } |
| 13309 | children[n++] = res; |
| 13310 | mark = p->mark; |
| 13311 | } |
| 13312 | p->mark = mark; |
| 13313 | } |
| 13314 | if (n == 0) { |
| 13315 | PyMem_Free(children); |
| 13316 | return NULL; |
| 13317 | } |
| 13318 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13319 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13320 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_60"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13321 | PyMem_Free(children); |
| 13322 | return NULL; |
| 13323 | } |
| 13324 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13325 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13326 | _PyPegen_insert_memo(p, start_mark, _loop1_60_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13327 | return seq; |
| 13328 | } |
| 13329 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13330 | // _loop0_61: param_no_default |
| 13331 | static asdl_seq * |
| 13332 | _loop0_61_rule(Parser *p) |
| 13333 | { |
| 13334 | if (p->error_indicator) { |
| 13335 | return NULL; |
| 13336 | } |
| 13337 | void *res = NULL; |
| 13338 | int mark = p->mark; |
| 13339 | int start_mark = p->mark; |
| 13340 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13341 | if (!children) { |
| 13342 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13343 | return NULL; |
| 13344 | } |
| 13345 | ssize_t children_capacity = 1; |
| 13346 | ssize_t n = 0; |
| 13347 | { // param_no_default |
| 13348 | arg_ty param_no_default_var; |
| 13349 | while ( |
| 13350 | (param_no_default_var = param_no_default_rule(p)) |
| 13351 | ) |
| 13352 | { |
| 13353 | res = param_no_default_var; |
| 13354 | if (n == children_capacity) { |
| 13355 | children_capacity *= 2; |
| 13356 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13357 | if (!children) { |
| 13358 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13359 | return NULL; |
| 13360 | } |
| 13361 | } |
| 13362 | children[n++] = res; |
| 13363 | mark = p->mark; |
| 13364 | } |
| 13365 | p->mark = mark; |
| 13366 | } |
| 13367 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13368 | if (!seq) { |
| 13369 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_61"); |
| 13370 | PyMem_Free(children); |
| 13371 | return NULL; |
| 13372 | } |
| 13373 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13374 | PyMem_Free(children); |
| 13375 | _PyPegen_insert_memo(p, start_mark, _loop0_61_type, seq); |
| 13376 | return seq; |
| 13377 | } |
| 13378 | |
| 13379 | // _loop1_62: param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13380 | static asdl_seq * |
| 13381 | _loop1_62_rule(Parser *p) |
| 13382 | { |
| 13383 | if (p->error_indicator) { |
| 13384 | return NULL; |
| 13385 | } |
| 13386 | void *res = NULL; |
| 13387 | int mark = p->mark; |
| 13388 | int start_mark = p->mark; |
| 13389 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13390 | if (!children) { |
| 13391 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13392 | return NULL; |
| 13393 | } |
| 13394 | ssize_t children_capacity = 1; |
| 13395 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13396 | { // param_with_default |
| 13397 | NameDefaultPair* param_with_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13398 | while ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13399 | (param_with_default_var = param_with_default_rule(p)) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13400 | ) |
| 13401 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13402 | res = param_with_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13403 | if (n == children_capacity) { |
| 13404 | children_capacity *= 2; |
| 13405 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13406 | if (!children) { |
| 13407 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13408 | return NULL; |
| 13409 | } |
| 13410 | } |
| 13411 | children[n++] = res; |
| 13412 | mark = p->mark; |
| 13413 | } |
| 13414 | p->mark = mark; |
| 13415 | } |
| 13416 | if (n == 0) { |
| 13417 | PyMem_Free(children); |
| 13418 | return NULL; |
| 13419 | } |
| 13420 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13421 | if (!seq) { |
| 13422 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_62"); |
| 13423 | PyMem_Free(children); |
| 13424 | return NULL; |
| 13425 | } |
| 13426 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13427 | PyMem_Free(children); |
| 13428 | _PyPegen_insert_memo(p, start_mark, _loop1_62_type, seq); |
| 13429 | return seq; |
| 13430 | } |
| 13431 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13432 | // _loop0_63: param_no_default |
| 13433 | static asdl_seq * |
| 13434 | _loop0_63_rule(Parser *p) |
| 13435 | { |
| 13436 | if (p->error_indicator) { |
| 13437 | return NULL; |
| 13438 | } |
| 13439 | void *res = NULL; |
| 13440 | int mark = p->mark; |
| 13441 | int start_mark = p->mark; |
| 13442 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13443 | if (!children) { |
| 13444 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13445 | return NULL; |
| 13446 | } |
| 13447 | ssize_t children_capacity = 1; |
| 13448 | ssize_t n = 0; |
| 13449 | { // param_no_default |
| 13450 | arg_ty param_no_default_var; |
| 13451 | while ( |
| 13452 | (param_no_default_var = param_no_default_rule(p)) |
| 13453 | ) |
| 13454 | { |
| 13455 | res = param_no_default_var; |
| 13456 | if (n == children_capacity) { |
| 13457 | children_capacity *= 2; |
| 13458 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13459 | if (!children) { |
| 13460 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13461 | return NULL; |
| 13462 | } |
| 13463 | } |
| 13464 | children[n++] = res; |
| 13465 | mark = p->mark; |
| 13466 | } |
| 13467 | p->mark = mark; |
| 13468 | } |
| 13469 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13470 | if (!seq) { |
| 13471 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_63"); |
| 13472 | PyMem_Free(children); |
| 13473 | return NULL; |
| 13474 | } |
| 13475 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13476 | PyMem_Free(children); |
| 13477 | _PyPegen_insert_memo(p, start_mark, _loop0_63_type, seq); |
| 13478 | return seq; |
| 13479 | } |
| 13480 | |
| 13481 | // _loop1_64: param_with_default |
| 13482 | static asdl_seq * |
| 13483 | _loop1_64_rule(Parser *p) |
| 13484 | { |
| 13485 | if (p->error_indicator) { |
| 13486 | return NULL; |
| 13487 | } |
| 13488 | void *res = NULL; |
| 13489 | int mark = p->mark; |
| 13490 | int start_mark = p->mark; |
| 13491 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13492 | if (!children) { |
| 13493 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13494 | return NULL; |
| 13495 | } |
| 13496 | ssize_t children_capacity = 1; |
| 13497 | ssize_t n = 0; |
| 13498 | { // param_with_default |
| 13499 | NameDefaultPair* param_with_default_var; |
| 13500 | while ( |
| 13501 | (param_with_default_var = param_with_default_rule(p)) |
| 13502 | ) |
| 13503 | { |
| 13504 | res = param_with_default_var; |
| 13505 | if (n == children_capacity) { |
| 13506 | children_capacity *= 2; |
| 13507 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13508 | if (!children) { |
| 13509 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13510 | return NULL; |
| 13511 | } |
| 13512 | } |
| 13513 | children[n++] = res; |
| 13514 | mark = p->mark; |
| 13515 | } |
| 13516 | p->mark = mark; |
| 13517 | } |
| 13518 | if (n == 0) { |
| 13519 | PyMem_Free(children); |
| 13520 | return NULL; |
| 13521 | } |
| 13522 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13523 | if (!seq) { |
| 13524 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_64"); |
| 13525 | PyMem_Free(children); |
| 13526 | return NULL; |
| 13527 | } |
| 13528 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13529 | PyMem_Free(children); |
| 13530 | _PyPegen_insert_memo(p, start_mark, _loop1_64_type, seq); |
| 13531 | return seq; |
| 13532 | } |
| 13533 | |
| 13534 | // _loop0_65: param_maybe_default |
| 13535 | static asdl_seq * |
| 13536 | _loop0_65_rule(Parser *p) |
| 13537 | { |
| 13538 | if (p->error_indicator) { |
| 13539 | return NULL; |
| 13540 | } |
| 13541 | void *res = NULL; |
| 13542 | int mark = p->mark; |
| 13543 | int start_mark = p->mark; |
| 13544 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13545 | if (!children) { |
| 13546 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13547 | return NULL; |
| 13548 | } |
| 13549 | ssize_t children_capacity = 1; |
| 13550 | ssize_t n = 0; |
| 13551 | { // param_maybe_default |
| 13552 | NameDefaultPair* param_maybe_default_var; |
| 13553 | while ( |
| 13554 | (param_maybe_default_var = param_maybe_default_rule(p)) |
| 13555 | ) |
| 13556 | { |
| 13557 | res = param_maybe_default_var; |
| 13558 | if (n == children_capacity) { |
| 13559 | children_capacity *= 2; |
| 13560 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13561 | if (!children) { |
| 13562 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13563 | return NULL; |
| 13564 | } |
| 13565 | } |
| 13566 | children[n++] = res; |
| 13567 | mark = p->mark; |
| 13568 | } |
| 13569 | p->mark = mark; |
| 13570 | } |
| 13571 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13572 | if (!seq) { |
| 13573 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_65"); |
| 13574 | PyMem_Free(children); |
| 13575 | return NULL; |
| 13576 | } |
| 13577 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13578 | PyMem_Free(children); |
| 13579 | _PyPegen_insert_memo(p, start_mark, _loop0_65_type, seq); |
| 13580 | return seq; |
| 13581 | } |
| 13582 | |
| 13583 | // _loop1_66: param_maybe_default |
| 13584 | static asdl_seq * |
| 13585 | _loop1_66_rule(Parser *p) |
| 13586 | { |
| 13587 | if (p->error_indicator) { |
| 13588 | return NULL; |
| 13589 | } |
| 13590 | void *res = NULL; |
| 13591 | int mark = p->mark; |
| 13592 | int start_mark = p->mark; |
| 13593 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13594 | if (!children) { |
| 13595 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13596 | return NULL; |
| 13597 | } |
| 13598 | ssize_t children_capacity = 1; |
| 13599 | ssize_t n = 0; |
| 13600 | { // param_maybe_default |
| 13601 | NameDefaultPair* param_maybe_default_var; |
| 13602 | while ( |
| 13603 | (param_maybe_default_var = param_maybe_default_rule(p)) |
| 13604 | ) |
| 13605 | { |
| 13606 | res = param_maybe_default_var; |
| 13607 | if (n == children_capacity) { |
| 13608 | children_capacity *= 2; |
| 13609 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13610 | if (!children) { |
| 13611 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13612 | return NULL; |
| 13613 | } |
| 13614 | } |
| 13615 | children[n++] = res; |
| 13616 | mark = p->mark; |
| 13617 | } |
| 13618 | p->mark = mark; |
| 13619 | } |
| 13620 | if (n == 0) { |
| 13621 | PyMem_Free(children); |
| 13622 | return NULL; |
| 13623 | } |
| 13624 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13625 | if (!seq) { |
| 13626 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_66"); |
| 13627 | PyMem_Free(children); |
| 13628 | return NULL; |
| 13629 | } |
| 13630 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13631 | PyMem_Free(children); |
| 13632 | _PyPegen_insert_memo(p, start_mark, _loop1_66_type, seq); |
| 13633 | return seq; |
| 13634 | } |
| 13635 | |
| 13636 | // _loop1_67: ('@' named_expression NEWLINE) |
| 13637 | static asdl_seq * |
| 13638 | _loop1_67_rule(Parser *p) |
| 13639 | { |
| 13640 | if (p->error_indicator) { |
| 13641 | return NULL; |
| 13642 | } |
| 13643 | void *res = NULL; |
| 13644 | int mark = p->mark; |
| 13645 | int start_mark = p->mark; |
| 13646 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13647 | if (!children) { |
| 13648 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13649 | return NULL; |
| 13650 | } |
| 13651 | ssize_t children_capacity = 1; |
| 13652 | ssize_t n = 0; |
| 13653 | { // ('@' named_expression NEWLINE) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 13654 | void *_tmp_135_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13655 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 13656 | (_tmp_135_var = _tmp_135_rule(p)) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13657 | ) |
| 13658 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 13659 | res = _tmp_135_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13660 | if (n == children_capacity) { |
| 13661 | children_capacity *= 2; |
| 13662 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13663 | if (!children) { |
| 13664 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13665 | return NULL; |
| 13666 | } |
| 13667 | } |
| 13668 | children[n++] = res; |
| 13669 | mark = p->mark; |
| 13670 | } |
| 13671 | p->mark = mark; |
| 13672 | } |
| 13673 | if (n == 0) { |
| 13674 | PyMem_Free(children); |
| 13675 | return NULL; |
| 13676 | } |
| 13677 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13678 | if (!seq) { |
| 13679 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_67"); |
| 13680 | PyMem_Free(children); |
| 13681 | return NULL; |
| 13682 | } |
| 13683 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13684 | PyMem_Free(children); |
| 13685 | _PyPegen_insert_memo(p, start_mark, _loop1_67_type, seq); |
| 13686 | return seq; |
| 13687 | } |
| 13688 | |
| 13689 | // _tmp_68: '(' arguments? ')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13690 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13691 | _tmp_68_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13692 | { |
| 13693 | if (p->error_indicator) { |
| 13694 | return NULL; |
| 13695 | } |
| 13696 | void * res = NULL; |
| 13697 | int mark = p->mark; |
| 13698 | { // '(' arguments? ')' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13699 | Token * literal; |
| 13700 | Token * literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13701 | void *z; |
| 13702 | if ( |
| 13703 | (literal = _PyPegen_expect_token(p, 7)) |
| 13704 | && |
| 13705 | (z = arguments_rule(p), 1) |
| 13706 | && |
| 13707 | (literal_1 = _PyPegen_expect_token(p, 8)) |
| 13708 | ) |
| 13709 | { |
| 13710 | res = z; |
| 13711 | if (res == NULL && PyErr_Occurred()) { |
| 13712 | p->error_indicator = 1; |
| 13713 | return NULL; |
| 13714 | } |
| 13715 | goto done; |
| 13716 | } |
| 13717 | p->mark = mark; |
| 13718 | } |
| 13719 | res = NULL; |
| 13720 | done: |
| 13721 | return res; |
| 13722 | } |
| 13723 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13724 | // _loop0_70: ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13725 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13726 | _loop0_70_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13727 | { |
| 13728 | if (p->error_indicator) { |
| 13729 | return NULL; |
| 13730 | } |
| 13731 | void *res = NULL; |
| 13732 | int mark = p->mark; |
| 13733 | int start_mark = p->mark; |
| 13734 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13735 | if (!children) { |
| 13736 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13737 | return NULL; |
| 13738 | } |
| 13739 | ssize_t children_capacity = 1; |
| 13740 | ssize_t n = 0; |
| 13741 | { // ',' star_expression |
| 13742 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13743 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13744 | while ( |
| 13745 | (literal = _PyPegen_expect_token(p, 12)) |
| 13746 | && |
| 13747 | (elem = star_expression_rule(p)) |
| 13748 | ) |
| 13749 | { |
| 13750 | res = elem; |
| 13751 | if (res == NULL && PyErr_Occurred()) { |
| 13752 | p->error_indicator = 1; |
| 13753 | PyMem_Free(children); |
| 13754 | return NULL; |
| 13755 | } |
| 13756 | if (n == children_capacity) { |
| 13757 | children_capacity *= 2; |
| 13758 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13759 | if (!children) { |
| 13760 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13761 | return NULL; |
| 13762 | } |
| 13763 | } |
| 13764 | children[n++] = res; |
| 13765 | mark = p->mark; |
| 13766 | } |
| 13767 | p->mark = mark; |
| 13768 | } |
| 13769 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13770 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13771 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_70"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13772 | PyMem_Free(children); |
| 13773 | return NULL; |
| 13774 | } |
| 13775 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13776 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13777 | _PyPegen_insert_memo(p, start_mark, _loop0_70_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13778 | return seq; |
| 13779 | } |
| 13780 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13781 | // _gather_69: star_expression _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13782 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13783 | _gather_69_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13784 | { |
| 13785 | if (p->error_indicator) { |
| 13786 | return NULL; |
| 13787 | } |
| 13788 | asdl_seq * res = NULL; |
| 13789 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13790 | { // star_expression _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13791 | expr_ty elem; |
| 13792 | asdl_seq * seq; |
| 13793 | if ( |
| 13794 | (elem = star_expression_rule(p)) |
| 13795 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13796 | (seq = _loop0_70_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13797 | ) |
| 13798 | { |
| 13799 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 13800 | goto done; |
| 13801 | } |
| 13802 | p->mark = mark; |
| 13803 | } |
| 13804 | res = NULL; |
| 13805 | done: |
| 13806 | return res; |
| 13807 | } |
| 13808 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13809 | // _loop1_71: (',' star_expression) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13810 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13811 | _loop1_71_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13812 | { |
| 13813 | if (p->error_indicator) { |
| 13814 | return NULL; |
| 13815 | } |
| 13816 | void *res = NULL; |
| 13817 | int mark = p->mark; |
| 13818 | int start_mark = p->mark; |
| 13819 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13820 | if (!children) { |
| 13821 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13822 | return NULL; |
| 13823 | } |
| 13824 | ssize_t children_capacity = 1; |
| 13825 | ssize_t n = 0; |
| 13826 | { // (',' star_expression) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 13827 | void *_tmp_136_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13828 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 13829 | (_tmp_136_var = _tmp_136_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13830 | ) |
| 13831 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 13832 | res = _tmp_136_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13833 | if (n == children_capacity) { |
| 13834 | children_capacity *= 2; |
| 13835 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13836 | if (!children) { |
| 13837 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13838 | return NULL; |
| 13839 | } |
| 13840 | } |
| 13841 | children[n++] = res; |
| 13842 | mark = p->mark; |
| 13843 | } |
| 13844 | p->mark = mark; |
| 13845 | } |
| 13846 | if (n == 0) { |
| 13847 | PyMem_Free(children); |
| 13848 | return NULL; |
| 13849 | } |
| 13850 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13851 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13852 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_71"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13853 | PyMem_Free(children); |
| 13854 | return NULL; |
| 13855 | } |
| 13856 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13857 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13858 | _PyPegen_insert_memo(p, start_mark, _loop1_71_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13859 | return seq; |
| 13860 | } |
| 13861 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13862 | // _loop0_73: ',' star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13863 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13864 | _loop0_73_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13865 | { |
| 13866 | if (p->error_indicator) { |
| 13867 | return NULL; |
| 13868 | } |
| 13869 | void *res = NULL; |
| 13870 | int mark = p->mark; |
| 13871 | int start_mark = p->mark; |
| 13872 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13873 | if (!children) { |
| 13874 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13875 | return NULL; |
| 13876 | } |
| 13877 | ssize_t children_capacity = 1; |
| 13878 | ssize_t n = 0; |
| 13879 | { // ',' star_named_expression |
| 13880 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13881 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13882 | while ( |
| 13883 | (literal = _PyPegen_expect_token(p, 12)) |
| 13884 | && |
| 13885 | (elem = star_named_expression_rule(p)) |
| 13886 | ) |
| 13887 | { |
| 13888 | res = elem; |
| 13889 | if (res == NULL && PyErr_Occurred()) { |
| 13890 | p->error_indicator = 1; |
| 13891 | PyMem_Free(children); |
| 13892 | return NULL; |
| 13893 | } |
| 13894 | if (n == children_capacity) { |
| 13895 | children_capacity *= 2; |
| 13896 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13897 | if (!children) { |
| 13898 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13899 | return NULL; |
| 13900 | } |
| 13901 | } |
| 13902 | children[n++] = res; |
| 13903 | mark = p->mark; |
| 13904 | } |
| 13905 | p->mark = mark; |
| 13906 | } |
| 13907 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13908 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13909 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_73"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13910 | PyMem_Free(children); |
| 13911 | return NULL; |
| 13912 | } |
| 13913 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13914 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13915 | _PyPegen_insert_memo(p, start_mark, _loop0_73_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13916 | return seq; |
| 13917 | } |
| 13918 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13919 | // _gather_72: star_named_expression _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13920 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13921 | _gather_72_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13922 | { |
| 13923 | if (p->error_indicator) { |
| 13924 | return NULL; |
| 13925 | } |
| 13926 | asdl_seq * res = NULL; |
| 13927 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13928 | { // star_named_expression _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13929 | expr_ty elem; |
| 13930 | asdl_seq * seq; |
| 13931 | if ( |
| 13932 | (elem = star_named_expression_rule(p)) |
| 13933 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13934 | (seq = _loop0_73_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13935 | ) |
| 13936 | { |
| 13937 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 13938 | goto done; |
| 13939 | } |
| 13940 | p->mark = mark; |
| 13941 | } |
| 13942 | res = NULL; |
| 13943 | done: |
| 13944 | return res; |
| 13945 | } |
| 13946 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13947 | // _loop1_74: (',' expression) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13948 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13949 | _loop1_74_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13950 | { |
| 13951 | if (p->error_indicator) { |
| 13952 | return NULL; |
| 13953 | } |
| 13954 | void *res = NULL; |
| 13955 | int mark = p->mark; |
| 13956 | int start_mark = p->mark; |
| 13957 | void **children = PyMem_Malloc(sizeof(void *)); |
| 13958 | if (!children) { |
| 13959 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13960 | return NULL; |
| 13961 | } |
| 13962 | ssize_t children_capacity = 1; |
| 13963 | ssize_t n = 0; |
| 13964 | { // (',' expression) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 13965 | void *_tmp_137_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13966 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 13967 | (_tmp_137_var = _tmp_137_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13968 | ) |
| 13969 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 13970 | res = _tmp_137_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13971 | if (n == children_capacity) { |
| 13972 | children_capacity *= 2; |
| 13973 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 13974 | if (!children) { |
| 13975 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13976 | return NULL; |
| 13977 | } |
| 13978 | } |
| 13979 | children[n++] = res; |
| 13980 | mark = p->mark; |
| 13981 | } |
| 13982 | p->mark = mark; |
| 13983 | } |
| 13984 | if (n == 0) { |
| 13985 | PyMem_Free(children); |
| 13986 | return NULL; |
| 13987 | } |
| 13988 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 13989 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13990 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_74"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13991 | PyMem_Free(children); |
| 13992 | return NULL; |
| 13993 | } |
| 13994 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 13995 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13996 | _PyPegen_insert_memo(p, start_mark, _loop1_74_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13997 | return seq; |
| 13998 | } |
| 13999 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14000 | // _loop0_75: lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14001 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14002 | _loop0_75_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14003 | { |
| 14004 | if (p->error_indicator) { |
| 14005 | return NULL; |
| 14006 | } |
| 14007 | void *res = NULL; |
| 14008 | int mark = p->mark; |
| 14009 | int start_mark = p->mark; |
| 14010 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14011 | if (!children) { |
| 14012 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14013 | return NULL; |
| 14014 | } |
| 14015 | ssize_t children_capacity = 1; |
| 14016 | ssize_t n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14017 | { // lambda_param_no_default |
| 14018 | arg_ty lambda_param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14019 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14020 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14021 | ) |
| 14022 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14023 | res = lambda_param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14024 | if (n == children_capacity) { |
| 14025 | children_capacity *= 2; |
| 14026 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14027 | if (!children) { |
| 14028 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14029 | return NULL; |
| 14030 | } |
| 14031 | } |
| 14032 | children[n++] = res; |
| 14033 | mark = p->mark; |
| 14034 | } |
| 14035 | p->mark = mark; |
| 14036 | } |
| 14037 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14038 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14039 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_75"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14040 | PyMem_Free(children); |
| 14041 | return NULL; |
| 14042 | } |
| 14043 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14044 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14045 | _PyPegen_insert_memo(p, start_mark, _loop0_75_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14046 | return seq; |
| 14047 | } |
| 14048 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14049 | // _loop0_76: lambda_param_with_default |
| 14050 | static asdl_seq * |
| 14051 | _loop0_76_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14052 | { |
| 14053 | if (p->error_indicator) { |
| 14054 | return NULL; |
| 14055 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14056 | void *res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14057 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14058 | int start_mark = p->mark; |
| 14059 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14060 | if (!children) { |
| 14061 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14062 | return NULL; |
| 14063 | } |
| 14064 | ssize_t children_capacity = 1; |
| 14065 | ssize_t n = 0; |
| 14066 | { // lambda_param_with_default |
| 14067 | NameDefaultPair* lambda_param_with_default_var; |
| 14068 | while ( |
| 14069 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14070 | ) |
| 14071 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14072 | res = lambda_param_with_default_var; |
| 14073 | if (n == children_capacity) { |
| 14074 | children_capacity *= 2; |
| 14075 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14076 | if (!children) { |
| 14077 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14078 | return NULL; |
| 14079 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14080 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14081 | children[n++] = res; |
| 14082 | mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14083 | } |
| 14084 | p->mark = mark; |
| 14085 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14086 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14087 | if (!seq) { |
| 14088 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_76"); |
| 14089 | PyMem_Free(children); |
| 14090 | return NULL; |
| 14091 | } |
| 14092 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14093 | PyMem_Free(children); |
| 14094 | _PyPegen_insert_memo(p, start_mark, _loop0_76_type, seq); |
| 14095 | return seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14096 | } |
| 14097 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14098 | // _loop0_77: lambda_param_with_default |
| 14099 | static asdl_seq * |
| 14100 | _loop0_77_rule(Parser *p) |
| 14101 | { |
| 14102 | if (p->error_indicator) { |
| 14103 | return NULL; |
| 14104 | } |
| 14105 | void *res = NULL; |
| 14106 | int mark = p->mark; |
| 14107 | int start_mark = p->mark; |
| 14108 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14109 | if (!children) { |
| 14110 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14111 | return NULL; |
| 14112 | } |
| 14113 | ssize_t children_capacity = 1; |
| 14114 | ssize_t n = 0; |
| 14115 | { // lambda_param_with_default |
| 14116 | NameDefaultPair* lambda_param_with_default_var; |
| 14117 | while ( |
| 14118 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) |
| 14119 | ) |
| 14120 | { |
| 14121 | res = lambda_param_with_default_var; |
| 14122 | if (n == children_capacity) { |
| 14123 | children_capacity *= 2; |
| 14124 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14125 | if (!children) { |
| 14126 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14127 | return NULL; |
| 14128 | } |
| 14129 | } |
| 14130 | children[n++] = res; |
| 14131 | mark = p->mark; |
| 14132 | } |
| 14133 | p->mark = mark; |
| 14134 | } |
| 14135 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14136 | if (!seq) { |
| 14137 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_77"); |
| 14138 | PyMem_Free(children); |
| 14139 | return NULL; |
| 14140 | } |
| 14141 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14142 | PyMem_Free(children); |
| 14143 | _PyPegen_insert_memo(p, start_mark, _loop0_77_type, seq); |
| 14144 | return seq; |
| 14145 | } |
| 14146 | |
| 14147 | // _loop1_78: lambda_param_no_default |
| 14148 | static asdl_seq * |
| 14149 | _loop1_78_rule(Parser *p) |
| 14150 | { |
| 14151 | if (p->error_indicator) { |
| 14152 | return NULL; |
| 14153 | } |
| 14154 | void *res = NULL; |
| 14155 | int mark = p->mark; |
| 14156 | int start_mark = p->mark; |
| 14157 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14158 | if (!children) { |
| 14159 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14160 | return NULL; |
| 14161 | } |
| 14162 | ssize_t children_capacity = 1; |
| 14163 | ssize_t n = 0; |
| 14164 | { // lambda_param_no_default |
| 14165 | arg_ty lambda_param_no_default_var; |
| 14166 | while ( |
| 14167 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) |
| 14168 | ) |
| 14169 | { |
| 14170 | res = lambda_param_no_default_var; |
| 14171 | if (n == children_capacity) { |
| 14172 | children_capacity *= 2; |
| 14173 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14174 | if (!children) { |
| 14175 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14176 | return NULL; |
| 14177 | } |
| 14178 | } |
| 14179 | children[n++] = res; |
| 14180 | mark = p->mark; |
| 14181 | } |
| 14182 | p->mark = mark; |
| 14183 | } |
| 14184 | if (n == 0) { |
| 14185 | PyMem_Free(children); |
| 14186 | return NULL; |
| 14187 | } |
| 14188 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14189 | if (!seq) { |
| 14190 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_78"); |
| 14191 | PyMem_Free(children); |
| 14192 | return NULL; |
| 14193 | } |
| 14194 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14195 | PyMem_Free(children); |
| 14196 | _PyPegen_insert_memo(p, start_mark, _loop1_78_type, seq); |
| 14197 | return seq; |
| 14198 | } |
| 14199 | |
| 14200 | // _loop0_79: lambda_param_with_default |
| 14201 | static asdl_seq * |
| 14202 | _loop0_79_rule(Parser *p) |
| 14203 | { |
| 14204 | if (p->error_indicator) { |
| 14205 | return NULL; |
| 14206 | } |
| 14207 | void *res = NULL; |
| 14208 | int mark = p->mark; |
| 14209 | int start_mark = p->mark; |
| 14210 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14211 | if (!children) { |
| 14212 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14213 | return NULL; |
| 14214 | } |
| 14215 | ssize_t children_capacity = 1; |
| 14216 | ssize_t n = 0; |
| 14217 | { // lambda_param_with_default |
| 14218 | NameDefaultPair* lambda_param_with_default_var; |
| 14219 | while ( |
| 14220 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) |
| 14221 | ) |
| 14222 | { |
| 14223 | res = lambda_param_with_default_var; |
| 14224 | if (n == children_capacity) { |
| 14225 | children_capacity *= 2; |
| 14226 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14227 | if (!children) { |
| 14228 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14229 | return NULL; |
| 14230 | } |
| 14231 | } |
| 14232 | children[n++] = res; |
| 14233 | mark = p->mark; |
| 14234 | } |
| 14235 | p->mark = mark; |
| 14236 | } |
| 14237 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14238 | if (!seq) { |
| 14239 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_79"); |
| 14240 | PyMem_Free(children); |
| 14241 | return NULL; |
| 14242 | } |
| 14243 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14244 | PyMem_Free(children); |
| 14245 | _PyPegen_insert_memo(p, start_mark, _loop0_79_type, seq); |
| 14246 | return seq; |
| 14247 | } |
| 14248 | |
| 14249 | // _loop1_80: lambda_param_with_default |
| 14250 | static asdl_seq * |
| 14251 | _loop1_80_rule(Parser *p) |
| 14252 | { |
| 14253 | if (p->error_indicator) { |
| 14254 | return NULL; |
| 14255 | } |
| 14256 | void *res = NULL; |
| 14257 | int mark = p->mark; |
| 14258 | int start_mark = p->mark; |
| 14259 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14260 | if (!children) { |
| 14261 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14262 | return NULL; |
| 14263 | } |
| 14264 | ssize_t children_capacity = 1; |
| 14265 | ssize_t n = 0; |
| 14266 | { // lambda_param_with_default |
| 14267 | NameDefaultPair* lambda_param_with_default_var; |
| 14268 | while ( |
| 14269 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) |
| 14270 | ) |
| 14271 | { |
| 14272 | res = lambda_param_with_default_var; |
| 14273 | if (n == children_capacity) { |
| 14274 | children_capacity *= 2; |
| 14275 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14276 | if (!children) { |
| 14277 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14278 | return NULL; |
| 14279 | } |
| 14280 | } |
| 14281 | children[n++] = res; |
| 14282 | mark = p->mark; |
| 14283 | } |
| 14284 | p->mark = mark; |
| 14285 | } |
| 14286 | if (n == 0) { |
| 14287 | PyMem_Free(children); |
| 14288 | return NULL; |
| 14289 | } |
| 14290 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14291 | if (!seq) { |
| 14292 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_80"); |
| 14293 | PyMem_Free(children); |
| 14294 | return NULL; |
| 14295 | } |
| 14296 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14297 | PyMem_Free(children); |
| 14298 | _PyPegen_insert_memo(p, start_mark, _loop1_80_type, seq); |
| 14299 | return seq; |
| 14300 | } |
| 14301 | |
| 14302 | // _loop1_81: lambda_param_no_default |
| 14303 | static asdl_seq * |
| 14304 | _loop1_81_rule(Parser *p) |
| 14305 | { |
| 14306 | if (p->error_indicator) { |
| 14307 | return NULL; |
| 14308 | } |
| 14309 | void *res = NULL; |
| 14310 | int mark = p->mark; |
| 14311 | int start_mark = p->mark; |
| 14312 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14313 | if (!children) { |
| 14314 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14315 | return NULL; |
| 14316 | } |
| 14317 | ssize_t children_capacity = 1; |
| 14318 | ssize_t n = 0; |
| 14319 | { // lambda_param_no_default |
| 14320 | arg_ty lambda_param_no_default_var; |
| 14321 | while ( |
| 14322 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) |
| 14323 | ) |
| 14324 | { |
| 14325 | res = lambda_param_no_default_var; |
| 14326 | if (n == children_capacity) { |
| 14327 | children_capacity *= 2; |
| 14328 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14329 | if (!children) { |
| 14330 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14331 | return NULL; |
| 14332 | } |
| 14333 | } |
| 14334 | children[n++] = res; |
| 14335 | mark = p->mark; |
| 14336 | } |
| 14337 | p->mark = mark; |
| 14338 | } |
| 14339 | if (n == 0) { |
| 14340 | PyMem_Free(children); |
| 14341 | return NULL; |
| 14342 | } |
| 14343 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14344 | if (!seq) { |
| 14345 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_81"); |
| 14346 | PyMem_Free(children); |
| 14347 | return NULL; |
| 14348 | } |
| 14349 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14350 | PyMem_Free(children); |
| 14351 | _PyPegen_insert_memo(p, start_mark, _loop1_81_type, seq); |
| 14352 | return seq; |
| 14353 | } |
| 14354 | |
| 14355 | // _loop1_82: lambda_param_no_default |
| 14356 | static asdl_seq * |
| 14357 | _loop1_82_rule(Parser *p) |
| 14358 | { |
| 14359 | if (p->error_indicator) { |
| 14360 | return NULL; |
| 14361 | } |
| 14362 | void *res = NULL; |
| 14363 | int mark = p->mark; |
| 14364 | int start_mark = p->mark; |
| 14365 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14366 | if (!children) { |
| 14367 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14368 | return NULL; |
| 14369 | } |
| 14370 | ssize_t children_capacity = 1; |
| 14371 | ssize_t n = 0; |
| 14372 | { // lambda_param_no_default |
| 14373 | arg_ty lambda_param_no_default_var; |
| 14374 | while ( |
| 14375 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) |
| 14376 | ) |
| 14377 | { |
| 14378 | res = lambda_param_no_default_var; |
| 14379 | if (n == children_capacity) { |
| 14380 | children_capacity *= 2; |
| 14381 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14382 | if (!children) { |
| 14383 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14384 | return NULL; |
| 14385 | } |
| 14386 | } |
| 14387 | children[n++] = res; |
| 14388 | mark = p->mark; |
| 14389 | } |
| 14390 | p->mark = mark; |
| 14391 | } |
| 14392 | if (n == 0) { |
| 14393 | PyMem_Free(children); |
| 14394 | return NULL; |
| 14395 | } |
| 14396 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14397 | if (!seq) { |
| 14398 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_82"); |
| 14399 | PyMem_Free(children); |
| 14400 | return NULL; |
| 14401 | } |
| 14402 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14403 | PyMem_Free(children); |
| 14404 | _PyPegen_insert_memo(p, start_mark, _loop1_82_type, seq); |
| 14405 | return seq; |
| 14406 | } |
| 14407 | |
| 14408 | // _loop0_83: lambda_param_no_default |
| 14409 | static asdl_seq * |
| 14410 | _loop0_83_rule(Parser *p) |
| 14411 | { |
| 14412 | if (p->error_indicator) { |
| 14413 | return NULL; |
| 14414 | } |
| 14415 | void *res = NULL; |
| 14416 | int mark = p->mark; |
| 14417 | int start_mark = p->mark; |
| 14418 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14419 | if (!children) { |
| 14420 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14421 | return NULL; |
| 14422 | } |
| 14423 | ssize_t children_capacity = 1; |
| 14424 | ssize_t n = 0; |
| 14425 | { // lambda_param_no_default |
| 14426 | arg_ty lambda_param_no_default_var; |
| 14427 | while ( |
| 14428 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) |
| 14429 | ) |
| 14430 | { |
| 14431 | res = lambda_param_no_default_var; |
| 14432 | if (n == children_capacity) { |
| 14433 | children_capacity *= 2; |
| 14434 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14435 | if (!children) { |
| 14436 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14437 | return NULL; |
| 14438 | } |
| 14439 | } |
| 14440 | children[n++] = res; |
| 14441 | mark = p->mark; |
| 14442 | } |
| 14443 | p->mark = mark; |
| 14444 | } |
| 14445 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14446 | if (!seq) { |
| 14447 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_83"); |
| 14448 | PyMem_Free(children); |
| 14449 | return NULL; |
| 14450 | } |
| 14451 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14452 | PyMem_Free(children); |
| 14453 | _PyPegen_insert_memo(p, start_mark, _loop0_83_type, seq); |
| 14454 | return seq; |
| 14455 | } |
| 14456 | |
| 14457 | // _loop1_84: lambda_param_with_default |
| 14458 | static asdl_seq * |
| 14459 | _loop1_84_rule(Parser *p) |
| 14460 | { |
| 14461 | if (p->error_indicator) { |
| 14462 | return NULL; |
| 14463 | } |
| 14464 | void *res = NULL; |
| 14465 | int mark = p->mark; |
| 14466 | int start_mark = p->mark; |
| 14467 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14468 | if (!children) { |
| 14469 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14470 | return NULL; |
| 14471 | } |
| 14472 | ssize_t children_capacity = 1; |
| 14473 | ssize_t n = 0; |
| 14474 | { // lambda_param_with_default |
| 14475 | NameDefaultPair* lambda_param_with_default_var; |
| 14476 | while ( |
| 14477 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) |
| 14478 | ) |
| 14479 | { |
| 14480 | res = lambda_param_with_default_var; |
| 14481 | if (n == children_capacity) { |
| 14482 | children_capacity *= 2; |
| 14483 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14484 | if (!children) { |
| 14485 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14486 | return NULL; |
| 14487 | } |
| 14488 | } |
| 14489 | children[n++] = res; |
| 14490 | mark = p->mark; |
| 14491 | } |
| 14492 | p->mark = mark; |
| 14493 | } |
| 14494 | if (n == 0) { |
| 14495 | PyMem_Free(children); |
| 14496 | return NULL; |
| 14497 | } |
| 14498 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14499 | if (!seq) { |
| 14500 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_84"); |
| 14501 | PyMem_Free(children); |
| 14502 | return NULL; |
| 14503 | } |
| 14504 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14505 | PyMem_Free(children); |
| 14506 | _PyPegen_insert_memo(p, start_mark, _loop1_84_type, seq); |
| 14507 | return seq; |
| 14508 | } |
| 14509 | |
| 14510 | // _loop0_85: lambda_param_no_default |
| 14511 | static asdl_seq * |
| 14512 | _loop0_85_rule(Parser *p) |
| 14513 | { |
| 14514 | if (p->error_indicator) { |
| 14515 | return NULL; |
| 14516 | } |
| 14517 | void *res = NULL; |
| 14518 | int mark = p->mark; |
| 14519 | int start_mark = p->mark; |
| 14520 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14521 | if (!children) { |
| 14522 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14523 | return NULL; |
| 14524 | } |
| 14525 | ssize_t children_capacity = 1; |
| 14526 | ssize_t n = 0; |
| 14527 | { // lambda_param_no_default |
| 14528 | arg_ty lambda_param_no_default_var; |
| 14529 | while ( |
| 14530 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) |
| 14531 | ) |
| 14532 | { |
| 14533 | res = lambda_param_no_default_var; |
| 14534 | if (n == children_capacity) { |
| 14535 | children_capacity *= 2; |
| 14536 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14537 | if (!children) { |
| 14538 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14539 | return NULL; |
| 14540 | } |
| 14541 | } |
| 14542 | children[n++] = res; |
| 14543 | mark = p->mark; |
| 14544 | } |
| 14545 | p->mark = mark; |
| 14546 | } |
| 14547 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14548 | if (!seq) { |
| 14549 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_85"); |
| 14550 | PyMem_Free(children); |
| 14551 | return NULL; |
| 14552 | } |
| 14553 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14554 | PyMem_Free(children); |
| 14555 | _PyPegen_insert_memo(p, start_mark, _loop0_85_type, seq); |
| 14556 | return seq; |
| 14557 | } |
| 14558 | |
| 14559 | // _loop1_86: lambda_param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14560 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14561 | _loop1_86_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14562 | { |
| 14563 | if (p->error_indicator) { |
| 14564 | return NULL; |
| 14565 | } |
| 14566 | void *res = NULL; |
| 14567 | int mark = p->mark; |
| 14568 | int start_mark = p->mark; |
| 14569 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14570 | if (!children) { |
| 14571 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14572 | return NULL; |
| 14573 | } |
| 14574 | ssize_t children_capacity = 1; |
| 14575 | ssize_t n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14576 | { // lambda_param_with_default |
| 14577 | NameDefaultPair* lambda_param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14578 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14579 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14580 | ) |
| 14581 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14582 | res = lambda_param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14583 | if (n == children_capacity) { |
| 14584 | children_capacity *= 2; |
| 14585 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14586 | if (!children) { |
| 14587 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14588 | return NULL; |
| 14589 | } |
| 14590 | } |
| 14591 | children[n++] = res; |
| 14592 | mark = p->mark; |
| 14593 | } |
| 14594 | p->mark = mark; |
| 14595 | } |
| 14596 | if (n == 0) { |
| 14597 | PyMem_Free(children); |
| 14598 | return NULL; |
| 14599 | } |
| 14600 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14601 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14602 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_86"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14603 | PyMem_Free(children); |
| 14604 | return NULL; |
| 14605 | } |
| 14606 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14607 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14608 | _PyPegen_insert_memo(p, start_mark, _loop1_86_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14609 | return seq; |
| 14610 | } |
| 14611 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14612 | // _loop0_87: lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14613 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14614 | _loop0_87_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14615 | { |
| 14616 | if (p->error_indicator) { |
| 14617 | return NULL; |
| 14618 | } |
| 14619 | void *res = NULL; |
| 14620 | int mark = p->mark; |
| 14621 | int start_mark = p->mark; |
| 14622 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14623 | if (!children) { |
| 14624 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14625 | return NULL; |
| 14626 | } |
| 14627 | ssize_t children_capacity = 1; |
| 14628 | ssize_t n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14629 | { // lambda_param_maybe_default |
| 14630 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14631 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14632 | (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14633 | ) |
| 14634 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14635 | res = lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14636 | if (n == children_capacity) { |
| 14637 | children_capacity *= 2; |
| 14638 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14639 | if (!children) { |
| 14640 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14641 | return NULL; |
| 14642 | } |
| 14643 | } |
| 14644 | children[n++] = res; |
| 14645 | mark = p->mark; |
| 14646 | } |
| 14647 | p->mark = mark; |
| 14648 | } |
| 14649 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14650 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14651 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_87"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14652 | PyMem_Free(children); |
| 14653 | return NULL; |
| 14654 | } |
| 14655 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14656 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14657 | _PyPegen_insert_memo(p, start_mark, _loop0_87_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14658 | return seq; |
| 14659 | } |
| 14660 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14661 | // _loop1_88: lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14662 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14663 | _loop1_88_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14664 | { |
| 14665 | if (p->error_indicator) { |
| 14666 | return NULL; |
| 14667 | } |
| 14668 | void *res = NULL; |
| 14669 | int mark = p->mark; |
| 14670 | int start_mark = p->mark; |
| 14671 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14672 | if (!children) { |
| 14673 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14674 | return NULL; |
| 14675 | } |
| 14676 | ssize_t children_capacity = 1; |
| 14677 | ssize_t n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14678 | { // lambda_param_maybe_default |
| 14679 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14680 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14681 | (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14682 | ) |
| 14683 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14684 | res = lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14685 | if (n == children_capacity) { |
| 14686 | children_capacity *= 2; |
| 14687 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14688 | if (!children) { |
| 14689 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14690 | return NULL; |
| 14691 | } |
| 14692 | } |
| 14693 | children[n++] = res; |
| 14694 | mark = p->mark; |
| 14695 | } |
| 14696 | p->mark = mark; |
| 14697 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14698 | if (n == 0) { |
| 14699 | PyMem_Free(children); |
| 14700 | return NULL; |
| 14701 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14702 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14703 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14704 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_88"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14705 | PyMem_Free(children); |
| 14706 | return NULL; |
| 14707 | } |
| 14708 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14709 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14710 | _PyPegen_insert_memo(p, start_mark, _loop1_88_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14711 | return seq; |
| 14712 | } |
| 14713 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14714 | // _loop1_89: ('or' conjunction) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14715 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14716 | _loop1_89_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14717 | { |
| 14718 | if (p->error_indicator) { |
| 14719 | return NULL; |
| 14720 | } |
| 14721 | void *res = NULL; |
| 14722 | int mark = p->mark; |
| 14723 | int start_mark = p->mark; |
| 14724 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14725 | if (!children) { |
| 14726 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14727 | return NULL; |
| 14728 | } |
| 14729 | ssize_t children_capacity = 1; |
| 14730 | ssize_t n = 0; |
| 14731 | { // ('or' conjunction) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14732 | void *_tmp_138_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14733 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14734 | (_tmp_138_var = _tmp_138_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14735 | ) |
| 14736 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14737 | res = _tmp_138_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14738 | if (n == children_capacity) { |
| 14739 | children_capacity *= 2; |
| 14740 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14741 | if (!children) { |
| 14742 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14743 | return NULL; |
| 14744 | } |
| 14745 | } |
| 14746 | children[n++] = res; |
| 14747 | mark = p->mark; |
| 14748 | } |
| 14749 | p->mark = mark; |
| 14750 | } |
| 14751 | if (n == 0) { |
| 14752 | PyMem_Free(children); |
| 14753 | return NULL; |
| 14754 | } |
| 14755 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14756 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14757 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_89"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14758 | PyMem_Free(children); |
| 14759 | return NULL; |
| 14760 | } |
| 14761 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14762 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14763 | _PyPegen_insert_memo(p, start_mark, _loop1_89_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14764 | return seq; |
| 14765 | } |
| 14766 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14767 | // _loop1_90: ('and' inversion) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14768 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14769 | _loop1_90_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14770 | { |
| 14771 | if (p->error_indicator) { |
| 14772 | return NULL; |
| 14773 | } |
| 14774 | void *res = NULL; |
| 14775 | int mark = p->mark; |
| 14776 | int start_mark = p->mark; |
| 14777 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14778 | if (!children) { |
| 14779 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14780 | return NULL; |
| 14781 | } |
| 14782 | ssize_t children_capacity = 1; |
| 14783 | ssize_t n = 0; |
| 14784 | { // ('and' inversion) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14785 | void *_tmp_139_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14786 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14787 | (_tmp_139_var = _tmp_139_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14788 | ) |
| 14789 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14790 | res = _tmp_139_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14791 | if (n == children_capacity) { |
| 14792 | children_capacity *= 2; |
| 14793 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14794 | if (!children) { |
| 14795 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14796 | return NULL; |
| 14797 | } |
| 14798 | } |
| 14799 | children[n++] = res; |
| 14800 | mark = p->mark; |
| 14801 | } |
| 14802 | p->mark = mark; |
| 14803 | } |
| 14804 | if (n == 0) { |
| 14805 | PyMem_Free(children); |
| 14806 | return NULL; |
| 14807 | } |
| 14808 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14809 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14810 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_90"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14811 | PyMem_Free(children); |
| 14812 | return NULL; |
| 14813 | } |
| 14814 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14815 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14816 | _PyPegen_insert_memo(p, start_mark, _loop1_90_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14817 | return seq; |
| 14818 | } |
| 14819 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14820 | // _loop1_91: compare_op_bitwise_or_pair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14821 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14822 | _loop1_91_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14823 | { |
| 14824 | if (p->error_indicator) { |
| 14825 | return NULL; |
| 14826 | } |
| 14827 | void *res = NULL; |
| 14828 | int mark = p->mark; |
| 14829 | int start_mark = p->mark; |
| 14830 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14831 | if (!children) { |
| 14832 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14833 | return NULL; |
| 14834 | } |
| 14835 | ssize_t children_capacity = 1; |
| 14836 | ssize_t n = 0; |
| 14837 | { // compare_op_bitwise_or_pair |
| 14838 | CmpopExprPair* compare_op_bitwise_or_pair_var; |
| 14839 | while ( |
| 14840 | (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) |
| 14841 | ) |
| 14842 | { |
| 14843 | res = compare_op_bitwise_or_pair_var; |
| 14844 | if (n == children_capacity) { |
| 14845 | children_capacity *= 2; |
| 14846 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14847 | if (!children) { |
| 14848 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14849 | return NULL; |
| 14850 | } |
| 14851 | } |
| 14852 | children[n++] = res; |
| 14853 | mark = p->mark; |
| 14854 | } |
| 14855 | p->mark = mark; |
| 14856 | } |
| 14857 | if (n == 0) { |
| 14858 | PyMem_Free(children); |
| 14859 | return NULL; |
| 14860 | } |
| 14861 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14862 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14863 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_91"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14864 | PyMem_Free(children); |
| 14865 | return NULL; |
| 14866 | } |
| 14867 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14868 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14869 | _PyPegen_insert_memo(p, start_mark, _loop1_91_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14870 | return seq; |
| 14871 | } |
| 14872 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14873 | // _tmp_92: '!=' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 14874 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14875 | _tmp_92_rule(Parser *p) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 14876 | { |
| 14877 | if (p->error_indicator) { |
| 14878 | return NULL; |
| 14879 | } |
| 14880 | void * res = NULL; |
| 14881 | int mark = p->mark; |
| 14882 | { // '!=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 14883 | Token * tok; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 14884 | if ( |
| 14885 | (tok = _PyPegen_expect_token(p, 28)) |
| 14886 | ) |
| 14887 | { |
| 14888 | res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; |
| 14889 | if (res == NULL && PyErr_Occurred()) { |
| 14890 | p->error_indicator = 1; |
| 14891 | return NULL; |
| 14892 | } |
| 14893 | goto done; |
| 14894 | } |
| 14895 | p->mark = mark; |
| 14896 | } |
| 14897 | res = NULL; |
| 14898 | done: |
| 14899 | return res; |
| 14900 | } |
| 14901 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14902 | // _loop0_94: ',' slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14903 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14904 | _loop0_94_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14905 | { |
| 14906 | if (p->error_indicator) { |
| 14907 | return NULL; |
| 14908 | } |
| 14909 | void *res = NULL; |
| 14910 | int mark = p->mark; |
| 14911 | int start_mark = p->mark; |
| 14912 | void **children = PyMem_Malloc(sizeof(void *)); |
| 14913 | if (!children) { |
| 14914 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14915 | return NULL; |
| 14916 | } |
| 14917 | ssize_t children_capacity = 1; |
| 14918 | ssize_t n = 0; |
| 14919 | { // ',' slice |
| 14920 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 14921 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14922 | while ( |
| 14923 | (literal = _PyPegen_expect_token(p, 12)) |
| 14924 | && |
| 14925 | (elem = slice_rule(p)) |
| 14926 | ) |
| 14927 | { |
| 14928 | res = elem; |
| 14929 | if (res == NULL && PyErr_Occurred()) { |
| 14930 | p->error_indicator = 1; |
| 14931 | PyMem_Free(children); |
| 14932 | return NULL; |
| 14933 | } |
| 14934 | if (n == children_capacity) { |
| 14935 | children_capacity *= 2; |
| 14936 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 14937 | if (!children) { |
| 14938 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14939 | return NULL; |
| 14940 | } |
| 14941 | } |
| 14942 | children[n++] = res; |
| 14943 | mark = p->mark; |
| 14944 | } |
| 14945 | p->mark = mark; |
| 14946 | } |
| 14947 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 14948 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14949 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_94"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14950 | PyMem_Free(children); |
| 14951 | return NULL; |
| 14952 | } |
| 14953 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 14954 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14955 | _PyPegen_insert_memo(p, start_mark, _loop0_94_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14956 | return seq; |
| 14957 | } |
| 14958 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14959 | // _gather_93: slice _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14960 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14961 | _gather_93_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14962 | { |
| 14963 | if (p->error_indicator) { |
| 14964 | return NULL; |
| 14965 | } |
| 14966 | asdl_seq * res = NULL; |
| 14967 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14968 | { // slice _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14969 | expr_ty elem; |
| 14970 | asdl_seq * seq; |
| 14971 | if ( |
| 14972 | (elem = slice_rule(p)) |
| 14973 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14974 | (seq = _loop0_94_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14975 | ) |
| 14976 | { |
| 14977 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 14978 | goto done; |
| 14979 | } |
| 14980 | p->mark = mark; |
| 14981 | } |
| 14982 | res = NULL; |
| 14983 | done: |
| 14984 | return res; |
| 14985 | } |
| 14986 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14987 | // _tmp_95: ':' expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14988 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14989 | _tmp_95_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14990 | { |
| 14991 | if (p->error_indicator) { |
| 14992 | return NULL; |
| 14993 | } |
| 14994 | void * res = NULL; |
| 14995 | int mark = p->mark; |
| 14996 | { // ':' expression? |
| 14997 | void *d; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 14998 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14999 | if ( |
| 15000 | (literal = _PyPegen_expect_token(p, 11)) |
| 15001 | && |
| 15002 | (d = expression_rule(p), 1) |
| 15003 | ) |
| 15004 | { |
| 15005 | res = d; |
| 15006 | if (res == NULL && PyErr_Occurred()) { |
| 15007 | p->error_indicator = 1; |
| 15008 | return NULL; |
| 15009 | } |
| 15010 | goto done; |
| 15011 | } |
| 15012 | p->mark = mark; |
| 15013 | } |
| 15014 | res = NULL; |
| 15015 | done: |
| 15016 | return res; |
| 15017 | } |
| 15018 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15019 | // _tmp_96: tuple | group | genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15020 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15021 | _tmp_96_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15022 | { |
| 15023 | if (p->error_indicator) { |
| 15024 | return NULL; |
| 15025 | } |
| 15026 | void * res = NULL; |
| 15027 | int mark = p->mark; |
| 15028 | { // tuple |
| 15029 | expr_ty tuple_var; |
| 15030 | if ( |
| 15031 | (tuple_var = tuple_rule(p)) |
| 15032 | ) |
| 15033 | { |
| 15034 | res = tuple_var; |
| 15035 | goto done; |
| 15036 | } |
| 15037 | p->mark = mark; |
| 15038 | } |
| 15039 | { // group |
| 15040 | expr_ty group_var; |
| 15041 | if ( |
| 15042 | (group_var = group_rule(p)) |
| 15043 | ) |
| 15044 | { |
| 15045 | res = group_var; |
| 15046 | goto done; |
| 15047 | } |
| 15048 | p->mark = mark; |
| 15049 | } |
| 15050 | { // genexp |
| 15051 | expr_ty genexp_var; |
| 15052 | if ( |
| 15053 | (genexp_var = genexp_rule(p)) |
| 15054 | ) |
| 15055 | { |
| 15056 | res = genexp_var; |
| 15057 | goto done; |
| 15058 | } |
| 15059 | p->mark = mark; |
| 15060 | } |
| 15061 | res = NULL; |
| 15062 | done: |
| 15063 | return res; |
| 15064 | } |
| 15065 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15066 | // _tmp_97: list | listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15067 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15068 | _tmp_97_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15069 | { |
| 15070 | if (p->error_indicator) { |
| 15071 | return NULL; |
| 15072 | } |
| 15073 | void * res = NULL; |
| 15074 | int mark = p->mark; |
| 15075 | { // list |
| 15076 | expr_ty list_var; |
| 15077 | if ( |
| 15078 | (list_var = list_rule(p)) |
| 15079 | ) |
| 15080 | { |
| 15081 | res = list_var; |
| 15082 | goto done; |
| 15083 | } |
| 15084 | p->mark = mark; |
| 15085 | } |
| 15086 | { // listcomp |
| 15087 | expr_ty listcomp_var; |
| 15088 | if ( |
| 15089 | (listcomp_var = listcomp_rule(p)) |
| 15090 | ) |
| 15091 | { |
| 15092 | res = listcomp_var; |
| 15093 | goto done; |
| 15094 | } |
| 15095 | p->mark = mark; |
| 15096 | } |
| 15097 | res = NULL; |
| 15098 | done: |
| 15099 | return res; |
| 15100 | } |
| 15101 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15102 | // _tmp_98: dict | set | dictcomp | setcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15103 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15104 | _tmp_98_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15105 | { |
| 15106 | if (p->error_indicator) { |
| 15107 | return NULL; |
| 15108 | } |
| 15109 | void * res = NULL; |
| 15110 | int mark = p->mark; |
| 15111 | { // dict |
| 15112 | expr_ty dict_var; |
| 15113 | if ( |
| 15114 | (dict_var = dict_rule(p)) |
| 15115 | ) |
| 15116 | { |
| 15117 | res = dict_var; |
| 15118 | goto done; |
| 15119 | } |
| 15120 | p->mark = mark; |
| 15121 | } |
| 15122 | { // set |
| 15123 | expr_ty set_var; |
| 15124 | if ( |
| 15125 | (set_var = set_rule(p)) |
| 15126 | ) |
| 15127 | { |
| 15128 | res = set_var; |
| 15129 | goto done; |
| 15130 | } |
| 15131 | p->mark = mark; |
| 15132 | } |
| 15133 | { // dictcomp |
| 15134 | expr_ty dictcomp_var; |
| 15135 | if ( |
| 15136 | (dictcomp_var = dictcomp_rule(p)) |
| 15137 | ) |
| 15138 | { |
| 15139 | res = dictcomp_var; |
| 15140 | goto done; |
| 15141 | } |
| 15142 | p->mark = mark; |
| 15143 | } |
| 15144 | { // setcomp |
| 15145 | expr_ty setcomp_var; |
| 15146 | if ( |
| 15147 | (setcomp_var = setcomp_rule(p)) |
| 15148 | ) |
| 15149 | { |
| 15150 | res = setcomp_var; |
| 15151 | goto done; |
| 15152 | } |
| 15153 | p->mark = mark; |
| 15154 | } |
| 15155 | res = NULL; |
| 15156 | done: |
| 15157 | return res; |
| 15158 | } |
| 15159 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15160 | // _loop1_99: STRING |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15161 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15162 | _loop1_99_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15163 | { |
| 15164 | if (p->error_indicator) { |
| 15165 | return NULL; |
| 15166 | } |
| 15167 | void *res = NULL; |
| 15168 | int mark = p->mark; |
| 15169 | int start_mark = p->mark; |
| 15170 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15171 | if (!children) { |
| 15172 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15173 | return NULL; |
| 15174 | } |
| 15175 | ssize_t children_capacity = 1; |
| 15176 | ssize_t n = 0; |
| 15177 | { // STRING |
| 15178 | expr_ty string_var; |
| 15179 | while ( |
| 15180 | (string_var = _PyPegen_string_token(p)) |
| 15181 | ) |
| 15182 | { |
| 15183 | res = string_var; |
| 15184 | if (n == children_capacity) { |
| 15185 | children_capacity *= 2; |
| 15186 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15187 | if (!children) { |
| 15188 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15189 | return NULL; |
| 15190 | } |
| 15191 | } |
| 15192 | children[n++] = res; |
| 15193 | mark = p->mark; |
| 15194 | } |
| 15195 | p->mark = mark; |
| 15196 | } |
| 15197 | if (n == 0) { |
| 15198 | PyMem_Free(children); |
| 15199 | return NULL; |
| 15200 | } |
| 15201 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15202 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15203 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_99"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15204 | PyMem_Free(children); |
| 15205 | return NULL; |
| 15206 | } |
| 15207 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15208 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15209 | _PyPegen_insert_memo(p, start_mark, _loop1_99_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15210 | return seq; |
| 15211 | } |
| 15212 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15213 | // _tmp_100: star_named_expression ',' star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15214 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15215 | _tmp_100_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15216 | { |
| 15217 | if (p->error_indicator) { |
| 15218 | return NULL; |
| 15219 | } |
| 15220 | void * res = NULL; |
| 15221 | int mark = p->mark; |
| 15222 | { // star_named_expression ',' star_named_expressions? |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15223 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15224 | expr_ty y; |
| 15225 | void *z; |
| 15226 | if ( |
| 15227 | (y = star_named_expression_rule(p)) |
| 15228 | && |
| 15229 | (literal = _PyPegen_expect_token(p, 12)) |
| 15230 | && |
| 15231 | (z = star_named_expressions_rule(p), 1) |
| 15232 | ) |
| 15233 | { |
| 15234 | res = _PyPegen_seq_insert_in_front ( p , y , z ); |
| 15235 | if (res == NULL && PyErr_Occurred()) { |
| 15236 | p->error_indicator = 1; |
| 15237 | return NULL; |
| 15238 | } |
| 15239 | goto done; |
| 15240 | } |
| 15241 | p->mark = mark; |
| 15242 | } |
| 15243 | res = NULL; |
| 15244 | done: |
| 15245 | return res; |
| 15246 | } |
| 15247 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15248 | // _tmp_101: yield_expr | named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15249 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15250 | _tmp_101_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15251 | { |
| 15252 | if (p->error_indicator) { |
| 15253 | return NULL; |
| 15254 | } |
| 15255 | void * res = NULL; |
| 15256 | int mark = p->mark; |
| 15257 | { // yield_expr |
| 15258 | expr_ty yield_expr_var; |
| 15259 | if ( |
| 15260 | (yield_expr_var = yield_expr_rule(p)) |
| 15261 | ) |
| 15262 | { |
| 15263 | res = yield_expr_var; |
| 15264 | goto done; |
| 15265 | } |
| 15266 | p->mark = mark; |
| 15267 | } |
| 15268 | { // named_expression |
| 15269 | expr_ty named_expression_var; |
| 15270 | if ( |
| 15271 | (named_expression_var = named_expression_rule(p)) |
| 15272 | ) |
| 15273 | { |
| 15274 | res = named_expression_var; |
| 15275 | goto done; |
| 15276 | } |
| 15277 | p->mark = mark; |
| 15278 | } |
| 15279 | res = NULL; |
| 15280 | done: |
| 15281 | return res; |
| 15282 | } |
| 15283 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15284 | // _loop0_103: ',' kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15285 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15286 | _loop0_103_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15287 | { |
| 15288 | if (p->error_indicator) { |
| 15289 | return NULL; |
| 15290 | } |
| 15291 | void *res = NULL; |
| 15292 | int mark = p->mark; |
| 15293 | int start_mark = p->mark; |
| 15294 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15295 | if (!children) { |
| 15296 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15297 | return NULL; |
| 15298 | } |
| 15299 | ssize_t children_capacity = 1; |
| 15300 | ssize_t n = 0; |
| 15301 | { // ',' kvpair |
| 15302 | KeyValuePair* elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15303 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15304 | while ( |
| 15305 | (literal = _PyPegen_expect_token(p, 12)) |
| 15306 | && |
| 15307 | (elem = kvpair_rule(p)) |
| 15308 | ) |
| 15309 | { |
| 15310 | res = elem; |
| 15311 | if (res == NULL && PyErr_Occurred()) { |
| 15312 | p->error_indicator = 1; |
| 15313 | PyMem_Free(children); |
| 15314 | return NULL; |
| 15315 | } |
| 15316 | if (n == children_capacity) { |
| 15317 | children_capacity *= 2; |
| 15318 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15319 | if (!children) { |
| 15320 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15321 | return NULL; |
| 15322 | } |
| 15323 | } |
| 15324 | children[n++] = res; |
| 15325 | mark = p->mark; |
| 15326 | } |
| 15327 | p->mark = mark; |
| 15328 | } |
| 15329 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15330 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15331 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_103"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15332 | PyMem_Free(children); |
| 15333 | return NULL; |
| 15334 | } |
| 15335 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15336 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15337 | _PyPegen_insert_memo(p, start_mark, _loop0_103_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15338 | return seq; |
| 15339 | } |
| 15340 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15341 | // _gather_102: kvpair _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15342 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15343 | _gather_102_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15344 | { |
| 15345 | if (p->error_indicator) { |
| 15346 | return NULL; |
| 15347 | } |
| 15348 | asdl_seq * res = NULL; |
| 15349 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15350 | { // kvpair _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15351 | KeyValuePair* elem; |
| 15352 | asdl_seq * seq; |
| 15353 | if ( |
| 15354 | (elem = kvpair_rule(p)) |
| 15355 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15356 | (seq = _loop0_103_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15357 | ) |
| 15358 | { |
| 15359 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15360 | goto done; |
| 15361 | } |
| 15362 | p->mark = mark; |
| 15363 | } |
| 15364 | res = NULL; |
| 15365 | done: |
| 15366 | return res; |
| 15367 | } |
| 15368 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15369 | // _loop1_104: for_if_clause |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15370 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15371 | _loop1_104_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15372 | { |
| 15373 | if (p->error_indicator) { |
| 15374 | return NULL; |
| 15375 | } |
| 15376 | void *res = NULL; |
| 15377 | int mark = p->mark; |
| 15378 | int start_mark = p->mark; |
| 15379 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15380 | if (!children) { |
| 15381 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15382 | return NULL; |
| 15383 | } |
| 15384 | ssize_t children_capacity = 1; |
| 15385 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15386 | { // for_if_clause |
| 15387 | comprehension_ty for_if_clause_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15388 | while ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15389 | (for_if_clause_var = for_if_clause_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15390 | ) |
| 15391 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15392 | res = for_if_clause_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15393 | if (n == children_capacity) { |
| 15394 | children_capacity *= 2; |
| 15395 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15396 | if (!children) { |
| 15397 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15398 | return NULL; |
| 15399 | } |
| 15400 | } |
| 15401 | children[n++] = res; |
| 15402 | mark = p->mark; |
| 15403 | } |
| 15404 | p->mark = mark; |
| 15405 | } |
| 15406 | if (n == 0) { |
| 15407 | PyMem_Free(children); |
| 15408 | return NULL; |
| 15409 | } |
| 15410 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15411 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15412 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_104"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15413 | PyMem_Free(children); |
| 15414 | return NULL; |
| 15415 | } |
| 15416 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15417 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15418 | _PyPegen_insert_memo(p, start_mark, _loop1_104_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15419 | return seq; |
| 15420 | } |
| 15421 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15422 | // _loop0_105: ('if' disjunction) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15423 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15424 | _loop0_105_rule(Parser *p) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15425 | { |
| 15426 | if (p->error_indicator) { |
| 15427 | return NULL; |
| 15428 | } |
| 15429 | void *res = NULL; |
| 15430 | int mark = p->mark; |
| 15431 | int start_mark = p->mark; |
| 15432 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15433 | if (!children) { |
| 15434 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15435 | return NULL; |
| 15436 | } |
| 15437 | ssize_t children_capacity = 1; |
| 15438 | ssize_t n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15439 | { // ('if' disjunction) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15440 | void *_tmp_140_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15441 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15442 | (_tmp_140_var = _tmp_140_rule(p)) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15443 | ) |
| 15444 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15445 | res = _tmp_140_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15446 | if (n == children_capacity) { |
| 15447 | children_capacity *= 2; |
| 15448 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15449 | if (!children) { |
| 15450 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15451 | return NULL; |
| 15452 | } |
| 15453 | } |
| 15454 | children[n++] = res; |
| 15455 | mark = p->mark; |
| 15456 | } |
| 15457 | p->mark = mark; |
| 15458 | } |
| 15459 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15460 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15461 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_105"); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15462 | PyMem_Free(children); |
| 15463 | return NULL; |
| 15464 | } |
| 15465 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15466 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15467 | _PyPegen_insert_memo(p, start_mark, _loop0_105_type, seq); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15468 | return seq; |
| 15469 | } |
| 15470 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15471 | // _loop0_106: ('if' disjunction) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15472 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15473 | _loop0_106_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15474 | { |
| 15475 | if (p->error_indicator) { |
| 15476 | return NULL; |
| 15477 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15478 | void *res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15479 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15480 | int start_mark = p->mark; |
| 15481 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15482 | if (!children) { |
| 15483 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15484 | return NULL; |
| 15485 | } |
| 15486 | ssize_t children_capacity = 1; |
| 15487 | ssize_t n = 0; |
| 15488 | { // ('if' disjunction) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15489 | void *_tmp_141_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15490 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15491 | (_tmp_141_var = _tmp_141_rule(p)) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15492 | ) |
| 15493 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15494 | res = _tmp_141_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15495 | if (n == children_capacity) { |
| 15496 | children_capacity *= 2; |
| 15497 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15498 | if (!children) { |
| 15499 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15500 | return NULL; |
| 15501 | } |
| 15502 | } |
| 15503 | children[n++] = res; |
| 15504 | mark = p->mark; |
| 15505 | } |
| 15506 | p->mark = mark; |
| 15507 | } |
| 15508 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15509 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15510 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_106"); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15511 | PyMem_Free(children); |
| 15512 | return NULL; |
| 15513 | } |
| 15514 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15515 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15516 | _PyPegen_insert_memo(p, start_mark, _loop0_106_type, seq); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15517 | return seq; |
| 15518 | } |
| 15519 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15520 | // _tmp_107: ',' args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15521 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15522 | _tmp_107_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15523 | { |
| 15524 | if (p->error_indicator) { |
| 15525 | return NULL; |
| 15526 | } |
| 15527 | void * res = NULL; |
| 15528 | int mark = p->mark; |
| 15529 | { // ',' args |
| 15530 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15531 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15532 | if ( |
| 15533 | (literal = _PyPegen_expect_token(p, 12)) |
| 15534 | && |
| 15535 | (c = args_rule(p)) |
| 15536 | ) |
| 15537 | { |
| 15538 | res = c; |
| 15539 | if (res == NULL && PyErr_Occurred()) { |
| 15540 | p->error_indicator = 1; |
| 15541 | return NULL; |
| 15542 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15543 | goto done; |
| 15544 | } |
| 15545 | p->mark = mark; |
| 15546 | } |
| 15547 | res = NULL; |
| 15548 | done: |
| 15549 | return res; |
| 15550 | } |
| 15551 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15552 | // _tmp_108: ',' args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15553 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15554 | _tmp_108_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15555 | { |
| 15556 | if (p->error_indicator) { |
| 15557 | return NULL; |
| 15558 | } |
| 15559 | void * res = NULL; |
| 15560 | int mark = p->mark; |
| 15561 | { // ',' args |
| 15562 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15563 | Token * literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15564 | if ( |
| 15565 | (literal = _PyPegen_expect_token(p, 12)) |
| 15566 | && |
| 15567 | (c = args_rule(p)) |
| 15568 | ) |
| 15569 | { |
| 15570 | res = c; |
| 15571 | if (res == NULL && PyErr_Occurred()) { |
| 15572 | p->error_indicator = 1; |
| 15573 | return NULL; |
| 15574 | } |
| 15575 | goto done; |
| 15576 | } |
| 15577 | p->mark = mark; |
| 15578 | } |
| 15579 | res = NULL; |
| 15580 | done: |
| 15581 | return res; |
| 15582 | } |
| 15583 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15584 | // _loop0_110: ',' kwarg_or_starred |
| 15585 | static asdl_seq * |
| 15586 | _loop0_110_rule(Parser *p) |
| 15587 | { |
| 15588 | if (p->error_indicator) { |
| 15589 | return NULL; |
| 15590 | } |
| 15591 | void *res = NULL; |
| 15592 | int mark = p->mark; |
| 15593 | int start_mark = p->mark; |
| 15594 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15595 | if (!children) { |
| 15596 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15597 | return NULL; |
| 15598 | } |
| 15599 | ssize_t children_capacity = 1; |
| 15600 | ssize_t n = 0; |
| 15601 | { // ',' kwarg_or_starred |
| 15602 | KeywordOrStarred* elem; |
| 15603 | Token * literal; |
| 15604 | while ( |
| 15605 | (literal = _PyPegen_expect_token(p, 12)) |
| 15606 | && |
| 15607 | (elem = kwarg_or_starred_rule(p)) |
| 15608 | ) |
| 15609 | { |
| 15610 | res = elem; |
| 15611 | if (res == NULL && PyErr_Occurred()) { |
| 15612 | p->error_indicator = 1; |
| 15613 | PyMem_Free(children); |
| 15614 | return NULL; |
| 15615 | } |
| 15616 | if (n == children_capacity) { |
| 15617 | children_capacity *= 2; |
| 15618 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15619 | if (!children) { |
| 15620 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15621 | return NULL; |
| 15622 | } |
| 15623 | } |
| 15624 | children[n++] = res; |
| 15625 | mark = p->mark; |
| 15626 | } |
| 15627 | p->mark = mark; |
| 15628 | } |
| 15629 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15630 | if (!seq) { |
| 15631 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_110"); |
| 15632 | PyMem_Free(children); |
| 15633 | return NULL; |
| 15634 | } |
| 15635 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15636 | PyMem_Free(children); |
| 15637 | _PyPegen_insert_memo(p, start_mark, _loop0_110_type, seq); |
| 15638 | return seq; |
| 15639 | } |
| 15640 | |
| 15641 | // _gather_109: kwarg_or_starred _loop0_110 |
| 15642 | static asdl_seq * |
| 15643 | _gather_109_rule(Parser *p) |
| 15644 | { |
| 15645 | if (p->error_indicator) { |
| 15646 | return NULL; |
| 15647 | } |
| 15648 | asdl_seq * res = NULL; |
| 15649 | int mark = p->mark; |
| 15650 | { // kwarg_or_starred _loop0_110 |
| 15651 | KeywordOrStarred* elem; |
| 15652 | asdl_seq * seq; |
| 15653 | if ( |
| 15654 | (elem = kwarg_or_starred_rule(p)) |
| 15655 | && |
| 15656 | (seq = _loop0_110_rule(p)) |
| 15657 | ) |
| 15658 | { |
| 15659 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15660 | goto done; |
| 15661 | } |
| 15662 | p->mark = mark; |
| 15663 | } |
| 15664 | res = NULL; |
| 15665 | done: |
| 15666 | return res; |
| 15667 | } |
| 15668 | |
| 15669 | // _loop0_112: ',' kwarg_or_double_starred |
| 15670 | static asdl_seq * |
| 15671 | _loop0_112_rule(Parser *p) |
| 15672 | { |
| 15673 | if (p->error_indicator) { |
| 15674 | return NULL; |
| 15675 | } |
| 15676 | void *res = NULL; |
| 15677 | int mark = p->mark; |
| 15678 | int start_mark = p->mark; |
| 15679 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15680 | if (!children) { |
| 15681 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15682 | return NULL; |
| 15683 | } |
| 15684 | ssize_t children_capacity = 1; |
| 15685 | ssize_t n = 0; |
| 15686 | { // ',' kwarg_or_double_starred |
| 15687 | KeywordOrStarred* elem; |
| 15688 | Token * literal; |
| 15689 | while ( |
| 15690 | (literal = _PyPegen_expect_token(p, 12)) |
| 15691 | && |
| 15692 | (elem = kwarg_or_double_starred_rule(p)) |
| 15693 | ) |
| 15694 | { |
| 15695 | res = elem; |
| 15696 | if (res == NULL && PyErr_Occurred()) { |
| 15697 | p->error_indicator = 1; |
| 15698 | PyMem_Free(children); |
| 15699 | return NULL; |
| 15700 | } |
| 15701 | if (n == children_capacity) { |
| 15702 | children_capacity *= 2; |
| 15703 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15704 | if (!children) { |
| 15705 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15706 | return NULL; |
| 15707 | } |
| 15708 | } |
| 15709 | children[n++] = res; |
| 15710 | mark = p->mark; |
| 15711 | } |
| 15712 | p->mark = mark; |
| 15713 | } |
| 15714 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15715 | if (!seq) { |
| 15716 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_112"); |
| 15717 | PyMem_Free(children); |
| 15718 | return NULL; |
| 15719 | } |
| 15720 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15721 | PyMem_Free(children); |
| 15722 | _PyPegen_insert_memo(p, start_mark, _loop0_112_type, seq); |
| 15723 | return seq; |
| 15724 | } |
| 15725 | |
| 15726 | // _gather_111: kwarg_or_double_starred _loop0_112 |
| 15727 | static asdl_seq * |
| 15728 | _gather_111_rule(Parser *p) |
| 15729 | { |
| 15730 | if (p->error_indicator) { |
| 15731 | return NULL; |
| 15732 | } |
| 15733 | asdl_seq * res = NULL; |
| 15734 | int mark = p->mark; |
| 15735 | { // kwarg_or_double_starred _loop0_112 |
| 15736 | KeywordOrStarred* elem; |
| 15737 | asdl_seq * seq; |
| 15738 | if ( |
| 15739 | (elem = kwarg_or_double_starred_rule(p)) |
| 15740 | && |
| 15741 | (seq = _loop0_112_rule(p)) |
| 15742 | ) |
| 15743 | { |
| 15744 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15745 | goto done; |
| 15746 | } |
| 15747 | p->mark = mark; |
| 15748 | } |
| 15749 | res = NULL; |
| 15750 | done: |
| 15751 | return res; |
| 15752 | } |
| 15753 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15754 | // _loop0_114: ',' kwarg_or_starred |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15755 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15756 | _loop0_114_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15757 | { |
| 15758 | if (p->error_indicator) { |
| 15759 | return NULL; |
| 15760 | } |
| 15761 | void *res = NULL; |
| 15762 | int mark = p->mark; |
| 15763 | int start_mark = p->mark; |
| 15764 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15765 | if (!children) { |
| 15766 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15767 | return NULL; |
| 15768 | } |
| 15769 | ssize_t children_capacity = 1; |
| 15770 | ssize_t n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15771 | { // ',' kwarg_or_starred |
| 15772 | KeywordOrStarred* elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15773 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15774 | while ( |
| 15775 | (literal = _PyPegen_expect_token(p, 12)) |
| 15776 | && |
| 15777 | (elem = kwarg_or_starred_rule(p)) |
| 15778 | ) |
| 15779 | { |
| 15780 | res = elem; |
| 15781 | if (res == NULL && PyErr_Occurred()) { |
| 15782 | p->error_indicator = 1; |
| 15783 | PyMem_Free(children); |
| 15784 | return NULL; |
| 15785 | } |
| 15786 | if (n == children_capacity) { |
| 15787 | children_capacity *= 2; |
| 15788 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15789 | if (!children) { |
| 15790 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15791 | return NULL; |
| 15792 | } |
| 15793 | } |
| 15794 | children[n++] = res; |
| 15795 | mark = p->mark; |
| 15796 | } |
| 15797 | p->mark = mark; |
| 15798 | } |
| 15799 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15800 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15801 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_114"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15802 | PyMem_Free(children); |
| 15803 | return NULL; |
| 15804 | } |
| 15805 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15806 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15807 | _PyPegen_insert_memo(p, start_mark, _loop0_114_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15808 | return seq; |
| 15809 | } |
| 15810 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15811 | // _gather_113: kwarg_or_starred _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15812 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15813 | _gather_113_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15814 | { |
| 15815 | if (p->error_indicator) { |
| 15816 | return NULL; |
| 15817 | } |
| 15818 | asdl_seq * res = NULL; |
| 15819 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15820 | { // kwarg_or_starred _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15821 | KeywordOrStarred* elem; |
| 15822 | asdl_seq * seq; |
| 15823 | if ( |
| 15824 | (elem = kwarg_or_starred_rule(p)) |
| 15825 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15826 | (seq = _loop0_114_rule(p)) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15827 | ) |
| 15828 | { |
| 15829 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15830 | goto done; |
| 15831 | } |
| 15832 | p->mark = mark; |
| 15833 | } |
| 15834 | res = NULL; |
| 15835 | done: |
| 15836 | return res; |
| 15837 | } |
| 15838 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15839 | // _loop0_116: ',' kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15840 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15841 | _loop0_116_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15842 | { |
| 15843 | if (p->error_indicator) { |
| 15844 | return NULL; |
| 15845 | } |
| 15846 | void *res = NULL; |
| 15847 | int mark = p->mark; |
| 15848 | int start_mark = p->mark; |
| 15849 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15850 | if (!children) { |
| 15851 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15852 | return NULL; |
| 15853 | } |
| 15854 | ssize_t children_capacity = 1; |
| 15855 | ssize_t n = 0; |
| 15856 | { // ',' kwarg_or_double_starred |
| 15857 | KeywordOrStarred* elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15858 | Token * literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15859 | while ( |
| 15860 | (literal = _PyPegen_expect_token(p, 12)) |
| 15861 | && |
| 15862 | (elem = kwarg_or_double_starred_rule(p)) |
| 15863 | ) |
| 15864 | { |
| 15865 | res = elem; |
| 15866 | if (res == NULL && PyErr_Occurred()) { |
| 15867 | p->error_indicator = 1; |
| 15868 | PyMem_Free(children); |
| 15869 | return NULL; |
| 15870 | } |
| 15871 | if (n == children_capacity) { |
| 15872 | children_capacity *= 2; |
| 15873 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15874 | if (!children) { |
| 15875 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15876 | return NULL; |
| 15877 | } |
| 15878 | } |
| 15879 | children[n++] = res; |
| 15880 | mark = p->mark; |
| 15881 | } |
| 15882 | p->mark = mark; |
| 15883 | } |
| 15884 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15885 | if (!seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15886 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_116"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15887 | PyMem_Free(children); |
| 15888 | return NULL; |
| 15889 | } |
| 15890 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15891 | PyMem_Free(children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15892 | _PyPegen_insert_memo(p, start_mark, _loop0_116_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15893 | return seq; |
| 15894 | } |
| 15895 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15896 | // _gather_115: kwarg_or_double_starred _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15897 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15898 | _gather_115_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15899 | { |
| 15900 | if (p->error_indicator) { |
| 15901 | return NULL; |
| 15902 | } |
| 15903 | asdl_seq * res = NULL; |
| 15904 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15905 | { // kwarg_or_double_starred _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15906 | KeywordOrStarred* elem; |
| 15907 | asdl_seq * seq; |
| 15908 | if ( |
| 15909 | (elem = kwarg_or_double_starred_rule(p)) |
| 15910 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15911 | (seq = _loop0_116_rule(p)) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15912 | ) |
| 15913 | { |
| 15914 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 15915 | goto done; |
| 15916 | } |
| 15917 | p->mark = mark; |
| 15918 | } |
| 15919 | res = NULL; |
| 15920 | done: |
| 15921 | return res; |
| 15922 | } |
| 15923 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15924 | // _loop0_117: (',' star_target) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15925 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15926 | _loop0_117_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15927 | { |
| 15928 | if (p->error_indicator) { |
| 15929 | return NULL; |
| 15930 | } |
| 15931 | void *res = NULL; |
| 15932 | int mark = p->mark; |
| 15933 | int start_mark = p->mark; |
| 15934 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15935 | if (!children) { |
| 15936 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15937 | return NULL; |
| 15938 | } |
| 15939 | ssize_t children_capacity = 1; |
| 15940 | ssize_t n = 0; |
| 15941 | { // (',' star_target) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15942 | void *_tmp_142_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15943 | while ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15944 | (_tmp_142_var = _tmp_142_rule(p)) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15945 | ) |
| 15946 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15947 | res = _tmp_142_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15948 | if (n == children_capacity) { |
| 15949 | children_capacity *= 2; |
| 15950 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 15951 | if (!children) { |
| 15952 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15953 | return NULL; |
| 15954 | } |
| 15955 | } |
| 15956 | children[n++] = res; |
| 15957 | mark = p->mark; |
| 15958 | } |
| 15959 | p->mark = mark; |
| 15960 | } |
| 15961 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 15962 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15963 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_117"); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15964 | PyMem_Free(children); |
| 15965 | return NULL; |
| 15966 | } |
| 15967 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 15968 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15969 | _PyPegen_insert_memo(p, start_mark, _loop0_117_type, seq); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15970 | return seq; |
| 15971 | } |
| 15972 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15973 | // _loop0_119: ',' star_target |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15974 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15975 | _loop0_119_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15976 | { |
| 15977 | if (p->error_indicator) { |
| 15978 | return NULL; |
| 15979 | } |
| 15980 | void *res = NULL; |
| 15981 | int mark = p->mark; |
| 15982 | int start_mark = p->mark; |
| 15983 | void **children = PyMem_Malloc(sizeof(void *)); |
| 15984 | if (!children) { |
| 15985 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15986 | return NULL; |
| 15987 | } |
| 15988 | ssize_t children_capacity = 1; |
| 15989 | ssize_t n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15990 | { // ',' star_target |
| 15991 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15992 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15993 | while ( |
| 15994 | (literal = _PyPegen_expect_token(p, 12)) |
| 15995 | && |
| 15996 | (elem = star_target_rule(p)) |
| 15997 | ) |
| 15998 | { |
| 15999 | res = elem; |
| 16000 | if (res == NULL && PyErr_Occurred()) { |
| 16001 | p->error_indicator = 1; |
| 16002 | PyMem_Free(children); |
| 16003 | return NULL; |
| 16004 | } |
| 16005 | if (n == children_capacity) { |
| 16006 | children_capacity *= 2; |
| 16007 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16008 | if (!children) { |
| 16009 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16010 | return NULL; |
| 16011 | } |
| 16012 | } |
| 16013 | children[n++] = res; |
| 16014 | mark = p->mark; |
| 16015 | } |
| 16016 | p->mark = mark; |
| 16017 | } |
| 16018 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16019 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16020 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_119"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16021 | PyMem_Free(children); |
| 16022 | return NULL; |
| 16023 | } |
| 16024 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16025 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16026 | _PyPegen_insert_memo(p, start_mark, _loop0_119_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16027 | return seq; |
| 16028 | } |
| 16029 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16030 | // _gather_118: star_target _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16031 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16032 | _gather_118_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16033 | { |
| 16034 | if (p->error_indicator) { |
| 16035 | return NULL; |
| 16036 | } |
| 16037 | asdl_seq * res = NULL; |
| 16038 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16039 | { // star_target _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16040 | expr_ty elem; |
| 16041 | asdl_seq * seq; |
| 16042 | if ( |
| 16043 | (elem = star_target_rule(p)) |
| 16044 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16045 | (seq = _loop0_119_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16046 | ) |
| 16047 | { |
| 16048 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 16049 | goto done; |
| 16050 | } |
| 16051 | p->mark = mark; |
| 16052 | } |
| 16053 | res = NULL; |
| 16054 | done: |
| 16055 | return res; |
| 16056 | } |
| 16057 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16058 | // _tmp_120: !'*' star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16059 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16060 | _tmp_120_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16061 | { |
| 16062 | if (p->error_indicator) { |
| 16063 | return NULL; |
| 16064 | } |
| 16065 | void * res = NULL; |
| 16066 | int mark = p->mark; |
| 16067 | { // !'*' star_target |
| 16068 | expr_ty star_target_var; |
| 16069 | if ( |
| 16070 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) |
| 16071 | && |
| 16072 | (star_target_var = star_target_rule(p)) |
| 16073 | ) |
| 16074 | { |
| 16075 | res = star_target_var; |
| 16076 | goto done; |
| 16077 | } |
| 16078 | p->mark = mark; |
| 16079 | } |
| 16080 | res = NULL; |
| 16081 | done: |
| 16082 | return res; |
| 16083 | } |
| 16084 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16085 | // _loop0_122: ',' del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16086 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16087 | _loop0_122_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16088 | { |
| 16089 | if (p->error_indicator) { |
| 16090 | return NULL; |
| 16091 | } |
| 16092 | void *res = NULL; |
| 16093 | int mark = p->mark; |
| 16094 | int start_mark = p->mark; |
| 16095 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16096 | if (!children) { |
| 16097 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16098 | return NULL; |
| 16099 | } |
| 16100 | ssize_t children_capacity = 1; |
| 16101 | ssize_t n = 0; |
| 16102 | { // ',' del_target |
| 16103 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16104 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16105 | while ( |
| 16106 | (literal = _PyPegen_expect_token(p, 12)) |
| 16107 | && |
| 16108 | (elem = del_target_rule(p)) |
| 16109 | ) |
| 16110 | { |
| 16111 | res = elem; |
| 16112 | if (res == NULL && PyErr_Occurred()) { |
| 16113 | p->error_indicator = 1; |
| 16114 | PyMem_Free(children); |
| 16115 | return NULL; |
| 16116 | } |
| 16117 | if (n == children_capacity) { |
| 16118 | children_capacity *= 2; |
| 16119 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16120 | if (!children) { |
| 16121 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16122 | return NULL; |
| 16123 | } |
| 16124 | } |
| 16125 | children[n++] = res; |
| 16126 | mark = p->mark; |
| 16127 | } |
| 16128 | p->mark = mark; |
| 16129 | } |
| 16130 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16131 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16132 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_122"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16133 | PyMem_Free(children); |
| 16134 | return NULL; |
| 16135 | } |
| 16136 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16137 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16138 | _PyPegen_insert_memo(p, start_mark, _loop0_122_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16139 | return seq; |
| 16140 | } |
| 16141 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16142 | // _gather_121: del_target _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16143 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16144 | _gather_121_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16145 | { |
| 16146 | if (p->error_indicator) { |
| 16147 | return NULL; |
| 16148 | } |
| 16149 | asdl_seq * res = NULL; |
| 16150 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16151 | { // del_target _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16152 | expr_ty elem; |
| 16153 | asdl_seq * seq; |
| 16154 | if ( |
| 16155 | (elem = del_target_rule(p)) |
| 16156 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16157 | (seq = _loop0_122_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16158 | ) |
| 16159 | { |
| 16160 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 16161 | goto done; |
| 16162 | } |
| 16163 | p->mark = mark; |
| 16164 | } |
| 16165 | res = NULL; |
| 16166 | done: |
| 16167 | return res; |
| 16168 | } |
| 16169 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16170 | // _loop0_124: ',' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16171 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16172 | _loop0_124_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16173 | { |
| 16174 | if (p->error_indicator) { |
| 16175 | return NULL; |
| 16176 | } |
| 16177 | void *res = NULL; |
| 16178 | int mark = p->mark; |
| 16179 | int start_mark = p->mark; |
| 16180 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16181 | if (!children) { |
| 16182 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16183 | return NULL; |
| 16184 | } |
| 16185 | ssize_t children_capacity = 1; |
| 16186 | ssize_t n = 0; |
| 16187 | { // ',' target |
| 16188 | expr_ty elem; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16189 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16190 | while ( |
| 16191 | (literal = _PyPegen_expect_token(p, 12)) |
| 16192 | && |
| 16193 | (elem = target_rule(p)) |
| 16194 | ) |
| 16195 | { |
| 16196 | res = elem; |
| 16197 | if (res == NULL && PyErr_Occurred()) { |
| 16198 | p->error_indicator = 1; |
| 16199 | PyMem_Free(children); |
| 16200 | return NULL; |
| 16201 | } |
| 16202 | if (n == children_capacity) { |
| 16203 | children_capacity *= 2; |
| 16204 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16205 | if (!children) { |
| 16206 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16207 | return NULL; |
| 16208 | } |
| 16209 | } |
| 16210 | children[n++] = res; |
| 16211 | mark = p->mark; |
| 16212 | } |
| 16213 | p->mark = mark; |
| 16214 | } |
| 16215 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16216 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16217 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_124"); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16218 | PyMem_Free(children); |
| 16219 | return NULL; |
| 16220 | } |
| 16221 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16222 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16223 | _PyPegen_insert_memo(p, start_mark, _loop0_124_type, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16224 | return seq; |
| 16225 | } |
| 16226 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16227 | // _gather_123: target _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16228 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16229 | _gather_123_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16230 | { |
| 16231 | if (p->error_indicator) { |
| 16232 | return NULL; |
| 16233 | } |
| 16234 | asdl_seq * res = NULL; |
| 16235 | int mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16236 | { // target _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16237 | expr_ty elem; |
| 16238 | asdl_seq * seq; |
| 16239 | if ( |
| 16240 | (elem = target_rule(p)) |
| 16241 | && |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16242 | (seq = _loop0_124_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16243 | ) |
| 16244 | { |
| 16245 | res = _PyPegen_seq_insert_in_front(p, elem, seq); |
| 16246 | goto done; |
| 16247 | } |
| 16248 | p->mark = mark; |
| 16249 | } |
| 16250 | res = NULL; |
| 16251 | done: |
| 16252 | return res; |
| 16253 | } |
| 16254 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16255 | // _tmp_125: args | expression for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16256 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16257 | _tmp_125_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16258 | { |
| 16259 | if (p->error_indicator) { |
| 16260 | return NULL; |
| 16261 | } |
| 16262 | void * res = NULL; |
| 16263 | int mark = p->mark; |
| 16264 | { // args |
| 16265 | expr_ty args_var; |
| 16266 | if ( |
| 16267 | (args_var = args_rule(p)) |
| 16268 | ) |
| 16269 | { |
| 16270 | res = args_var; |
| 16271 | goto done; |
| 16272 | } |
| 16273 | p->mark = mark; |
| 16274 | } |
| 16275 | { // expression for_if_clauses |
| 16276 | expr_ty expression_var; |
| 16277 | asdl_seq* for_if_clauses_var; |
| 16278 | if ( |
| 16279 | (expression_var = expression_rule(p)) |
| 16280 | && |
| 16281 | (for_if_clauses_var = for_if_clauses_rule(p)) |
| 16282 | ) |
| 16283 | { |
| 16284 | res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); |
| 16285 | goto done; |
| 16286 | } |
| 16287 | p->mark = mark; |
| 16288 | } |
| 16289 | res = NULL; |
| 16290 | done: |
| 16291 | return res; |
| 16292 | } |
| 16293 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16294 | // _tmp_126: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16295 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16296 | _tmp_126_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16297 | { |
| 16298 | if (p->error_indicator) { |
| 16299 | return NULL; |
| 16300 | } |
| 16301 | void * res = NULL; |
| 16302 | int mark = p->mark; |
| 16303 | { // '=' annotated_rhs |
| 16304 | expr_ty annotated_rhs_var; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16305 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16306 | if ( |
| 16307 | (literal = _PyPegen_expect_token(p, 22)) |
| 16308 | && |
| 16309 | (annotated_rhs_var = annotated_rhs_rule(p)) |
| 16310 | ) |
| 16311 | { |
| 16312 | res = _PyPegen_dummy_name(p, literal, annotated_rhs_var); |
| 16313 | goto done; |
| 16314 | } |
| 16315 | p->mark = mark; |
| 16316 | } |
| 16317 | res = NULL; |
| 16318 | done: |
| 16319 | return res; |
| 16320 | } |
| 16321 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16322 | // _tmp_127: '=' | augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16323 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16324 | _tmp_127_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16325 | { |
| 16326 | if (p->error_indicator) { |
| 16327 | return NULL; |
| 16328 | } |
| 16329 | void * res = NULL; |
| 16330 | int mark = p->mark; |
| 16331 | { // '=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16332 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16333 | if ( |
| 16334 | (literal = _PyPegen_expect_token(p, 22)) |
| 16335 | ) |
| 16336 | { |
| 16337 | res = literal; |
| 16338 | goto done; |
| 16339 | } |
| 16340 | p->mark = mark; |
| 16341 | } |
| 16342 | { // augassign |
| 16343 | AugOperator* augassign_var; |
| 16344 | if ( |
| 16345 | (augassign_var = augassign_rule(p)) |
| 16346 | ) |
| 16347 | { |
| 16348 | res = augassign_var; |
| 16349 | goto done; |
| 16350 | } |
| 16351 | p->mark = mark; |
| 16352 | } |
| 16353 | res = NULL; |
| 16354 | done: |
| 16355 | return res; |
| 16356 | } |
| 16357 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16358 | // _tmp_128: yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16359 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16360 | _tmp_128_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16361 | { |
| 16362 | if (p->error_indicator) { |
| 16363 | return NULL; |
| 16364 | } |
| 16365 | void * res = NULL; |
| 16366 | int mark = p->mark; |
| 16367 | { // yield_expr |
| 16368 | expr_ty yield_expr_var; |
| 16369 | if ( |
| 16370 | (yield_expr_var = yield_expr_rule(p)) |
| 16371 | ) |
| 16372 | { |
| 16373 | res = yield_expr_var; |
| 16374 | goto done; |
| 16375 | } |
| 16376 | p->mark = mark; |
| 16377 | } |
| 16378 | { // star_expressions |
| 16379 | expr_ty star_expressions_var; |
| 16380 | if ( |
| 16381 | (star_expressions_var = star_expressions_rule(p)) |
| 16382 | ) |
| 16383 | { |
| 16384 | res = star_expressions_var; |
| 16385 | goto done; |
| 16386 | } |
| 16387 | p->mark = mark; |
| 16388 | } |
| 16389 | res = NULL; |
| 16390 | done: |
| 16391 | return res; |
| 16392 | } |
| 16393 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16394 | // _tmp_129: '[' | '(' | '{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16395 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16396 | _tmp_129_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16397 | { |
| 16398 | if (p->error_indicator) { |
| 16399 | return NULL; |
| 16400 | } |
| 16401 | void * res = NULL; |
| 16402 | int mark = p->mark; |
| 16403 | { // '[' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16404 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16405 | if ( |
| 16406 | (literal = _PyPegen_expect_token(p, 9)) |
| 16407 | ) |
| 16408 | { |
| 16409 | res = literal; |
| 16410 | goto done; |
| 16411 | } |
| 16412 | p->mark = mark; |
| 16413 | } |
| 16414 | { // '(' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16415 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16416 | if ( |
| 16417 | (literal = _PyPegen_expect_token(p, 7)) |
| 16418 | ) |
| 16419 | { |
| 16420 | res = literal; |
| 16421 | goto done; |
| 16422 | } |
| 16423 | p->mark = mark; |
| 16424 | } |
| 16425 | { // '{' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16426 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16427 | if ( |
| 16428 | (literal = _PyPegen_expect_token(p, 25)) |
| 16429 | ) |
| 16430 | { |
| 16431 | res = literal; |
| 16432 | goto done; |
| 16433 | } |
| 16434 | p->mark = mark; |
| 16435 | } |
| 16436 | res = NULL; |
| 16437 | done: |
| 16438 | return res; |
| 16439 | } |
| 16440 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16441 | // _loop0_130: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16442 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16443 | _loop0_130_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16444 | { |
| 16445 | if (p->error_indicator) { |
| 16446 | return NULL; |
| 16447 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16448 | void *res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16449 | int mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16450 | int start_mark = p->mark; |
| 16451 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16452 | if (!children) { |
| 16453 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16454 | return NULL; |
| 16455 | } |
| 16456 | ssize_t children_capacity = 1; |
| 16457 | ssize_t n = 0; |
| 16458 | { // param_no_default |
| 16459 | arg_ty param_no_default_var; |
| 16460 | while ( |
| 16461 | (param_no_default_var = param_no_default_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16462 | ) |
| 16463 | { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16464 | res = param_no_default_var; |
| 16465 | if (n == children_capacity) { |
| 16466 | children_capacity *= 2; |
| 16467 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16468 | if (!children) { |
| 16469 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16470 | return NULL; |
| 16471 | } |
| 16472 | } |
| 16473 | children[n++] = res; |
| 16474 | mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16475 | } |
| 16476 | p->mark = mark; |
| 16477 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16478 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16479 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16480 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_130"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16481 | PyMem_Free(children); |
| 16482 | return NULL; |
| 16483 | } |
| 16484 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16485 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16486 | _PyPegen_insert_memo(p, start_mark, _loop0_130_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16487 | return seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16488 | } |
| 16489 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16490 | // _tmp_131: slash_with_default | param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16491 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16492 | _tmp_131_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16493 | { |
| 16494 | if (p->error_indicator) { |
| 16495 | return NULL; |
| 16496 | } |
| 16497 | void * res = NULL; |
| 16498 | int mark = p->mark; |
| 16499 | { // slash_with_default |
| 16500 | SlashWithDefault* slash_with_default_var; |
| 16501 | if ( |
| 16502 | (slash_with_default_var = slash_with_default_rule(p)) |
| 16503 | ) |
| 16504 | { |
| 16505 | res = slash_with_default_var; |
| 16506 | goto done; |
| 16507 | } |
| 16508 | p->mark = mark; |
| 16509 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16510 | { // param_with_default+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16511 | asdl_seq * _loop1_143_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16512 | if ( |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16513 | (_loop1_143_var = _loop1_143_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16514 | ) |
| 16515 | { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16516 | res = _loop1_143_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16517 | goto done; |
| 16518 | } |
| 16519 | p->mark = mark; |
| 16520 | } |
| 16521 | res = NULL; |
| 16522 | done: |
| 16523 | return res; |
| 16524 | } |
| 16525 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16526 | // _tmp_132: star_targets '=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16527 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16528 | _tmp_132_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16529 | { |
| 16530 | if (p->error_indicator) { |
| 16531 | return NULL; |
| 16532 | } |
| 16533 | void * res = NULL; |
| 16534 | int mark = p->mark; |
| 16535 | { // star_targets '=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16536 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16537 | expr_ty z; |
| 16538 | if ( |
| 16539 | (z = star_targets_rule(p)) |
| 16540 | && |
| 16541 | (literal = _PyPegen_expect_token(p, 22)) |
| 16542 | ) |
| 16543 | { |
| 16544 | res = z; |
| 16545 | if (res == NULL && PyErr_Occurred()) { |
| 16546 | p->error_indicator = 1; |
| 16547 | return NULL; |
| 16548 | } |
| 16549 | goto done; |
| 16550 | } |
| 16551 | p->mark = mark; |
| 16552 | } |
| 16553 | res = NULL; |
| 16554 | done: |
| 16555 | return res; |
| 16556 | } |
| 16557 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16558 | // _tmp_133: '.' | '...' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16559 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16560 | _tmp_133_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16561 | { |
| 16562 | if (p->error_indicator) { |
| 16563 | return NULL; |
| 16564 | } |
| 16565 | void * res = NULL; |
| 16566 | int mark = p->mark; |
| 16567 | { // '.' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16568 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16569 | if ( |
| 16570 | (literal = _PyPegen_expect_token(p, 23)) |
| 16571 | ) |
| 16572 | { |
| 16573 | res = literal; |
| 16574 | goto done; |
| 16575 | } |
| 16576 | p->mark = mark; |
| 16577 | } |
| 16578 | { // '...' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16579 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16580 | if ( |
| 16581 | (literal = _PyPegen_expect_token(p, 52)) |
| 16582 | ) |
| 16583 | { |
| 16584 | res = literal; |
| 16585 | goto done; |
| 16586 | } |
| 16587 | p->mark = mark; |
| 16588 | } |
| 16589 | res = NULL; |
| 16590 | done: |
| 16591 | return res; |
| 16592 | } |
| 16593 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16594 | // _tmp_134: '.' | '...' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16595 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16596 | _tmp_134_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16597 | { |
| 16598 | if (p->error_indicator) { |
| 16599 | return NULL; |
| 16600 | } |
| 16601 | void * res = NULL; |
| 16602 | int mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16603 | { // '.' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16604 | Token * literal; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16605 | if ( |
| 16606 | (literal = _PyPegen_expect_token(p, 23)) |
| 16607 | ) |
| 16608 | { |
| 16609 | res = literal; |
| 16610 | goto done; |
| 16611 | } |
| 16612 | p->mark = mark; |
| 16613 | } |
| 16614 | { // '...' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16615 | Token * literal; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16616 | if ( |
| 16617 | (literal = _PyPegen_expect_token(p, 52)) |
| 16618 | ) |
| 16619 | { |
| 16620 | res = literal; |
| 16621 | goto done; |
| 16622 | } |
| 16623 | p->mark = mark; |
| 16624 | } |
| 16625 | res = NULL; |
| 16626 | done: |
| 16627 | return res; |
| 16628 | } |
| 16629 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16630 | // _tmp_135: '@' named_expression NEWLINE |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16631 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16632 | _tmp_135_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16633 | { |
| 16634 | if (p->error_indicator) { |
| 16635 | return NULL; |
| 16636 | } |
| 16637 | void * res = NULL; |
| 16638 | int mark = p->mark; |
| 16639 | { // '@' named_expression NEWLINE |
| 16640 | expr_ty f; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16641 | Token * literal; |
| 16642 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16643 | if ( |
| 16644 | (literal = _PyPegen_expect_token(p, 49)) |
| 16645 | && |
| 16646 | (f = named_expression_rule(p)) |
| 16647 | && |
Pablo Galindo | 4db245e | 2020-04-29 10:42:21 +0100 | [diff] [blame] | 16648 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16649 | ) |
| 16650 | { |
| 16651 | res = f; |
| 16652 | if (res == NULL && PyErr_Occurred()) { |
| 16653 | p->error_indicator = 1; |
| 16654 | return NULL; |
| 16655 | } |
| 16656 | goto done; |
| 16657 | } |
| 16658 | p->mark = mark; |
| 16659 | } |
| 16660 | res = NULL; |
| 16661 | done: |
| 16662 | return res; |
| 16663 | } |
| 16664 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16665 | // _tmp_136: ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16666 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16667 | _tmp_136_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16668 | { |
| 16669 | if (p->error_indicator) { |
| 16670 | return NULL; |
| 16671 | } |
| 16672 | void * res = NULL; |
| 16673 | int mark = p->mark; |
| 16674 | { // ',' star_expression |
| 16675 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16676 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16677 | if ( |
| 16678 | (literal = _PyPegen_expect_token(p, 12)) |
| 16679 | && |
| 16680 | (c = star_expression_rule(p)) |
| 16681 | ) |
| 16682 | { |
| 16683 | res = c; |
| 16684 | if (res == NULL && PyErr_Occurred()) { |
| 16685 | p->error_indicator = 1; |
| 16686 | return NULL; |
| 16687 | } |
| 16688 | goto done; |
| 16689 | } |
| 16690 | p->mark = mark; |
| 16691 | } |
| 16692 | res = NULL; |
| 16693 | done: |
| 16694 | return res; |
| 16695 | } |
| 16696 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16697 | // _tmp_137: ',' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16698 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16699 | _tmp_137_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16700 | { |
| 16701 | if (p->error_indicator) { |
| 16702 | return NULL; |
| 16703 | } |
| 16704 | void * res = NULL; |
| 16705 | int mark = p->mark; |
| 16706 | { // ',' expression |
| 16707 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16708 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16709 | if ( |
| 16710 | (literal = _PyPegen_expect_token(p, 12)) |
| 16711 | && |
| 16712 | (c = expression_rule(p)) |
| 16713 | ) |
| 16714 | { |
| 16715 | res = c; |
| 16716 | if (res == NULL && PyErr_Occurred()) { |
| 16717 | p->error_indicator = 1; |
| 16718 | return NULL; |
| 16719 | } |
| 16720 | goto done; |
| 16721 | } |
| 16722 | p->mark = mark; |
| 16723 | } |
| 16724 | res = NULL; |
| 16725 | done: |
| 16726 | return res; |
| 16727 | } |
| 16728 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16729 | // _tmp_138: 'or' conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16730 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16731 | _tmp_138_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16732 | { |
| 16733 | if (p->error_indicator) { |
| 16734 | return NULL; |
| 16735 | } |
| 16736 | void * res = NULL; |
| 16737 | int mark = p->mark; |
| 16738 | { // 'or' conjunction |
| 16739 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16740 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16741 | if ( |
| 16742 | (keyword = _PyPegen_expect_token(p, 532)) |
| 16743 | && |
| 16744 | (c = conjunction_rule(p)) |
| 16745 | ) |
| 16746 | { |
| 16747 | res = c; |
| 16748 | if (res == NULL && PyErr_Occurred()) { |
| 16749 | p->error_indicator = 1; |
| 16750 | return NULL; |
| 16751 | } |
| 16752 | goto done; |
| 16753 | } |
| 16754 | p->mark = mark; |
| 16755 | } |
| 16756 | res = NULL; |
| 16757 | done: |
| 16758 | return res; |
| 16759 | } |
| 16760 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16761 | // _tmp_139: 'and' inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16762 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16763 | _tmp_139_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16764 | { |
| 16765 | if (p->error_indicator) { |
| 16766 | return NULL; |
| 16767 | } |
| 16768 | void * res = NULL; |
| 16769 | int mark = p->mark; |
| 16770 | { // 'and' inversion |
| 16771 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16772 | Token * keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16773 | if ( |
| 16774 | (keyword = _PyPegen_expect_token(p, 533)) |
| 16775 | && |
| 16776 | (c = inversion_rule(p)) |
| 16777 | ) |
| 16778 | { |
| 16779 | res = c; |
| 16780 | if (res == NULL && PyErr_Occurred()) { |
| 16781 | p->error_indicator = 1; |
| 16782 | return NULL; |
| 16783 | } |
| 16784 | goto done; |
| 16785 | } |
| 16786 | p->mark = mark; |
| 16787 | } |
| 16788 | res = NULL; |
| 16789 | done: |
| 16790 | return res; |
| 16791 | } |
| 16792 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16793 | // _tmp_140: 'if' disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16794 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16795 | _tmp_140_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16796 | { |
| 16797 | if (p->error_indicator) { |
| 16798 | return NULL; |
| 16799 | } |
| 16800 | void * res = NULL; |
| 16801 | int mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16802 | { // 'if' disjunction |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16803 | Token * keyword; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16804 | expr_ty z; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16805 | if ( |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16806 | (keyword = _PyPegen_expect_token(p, 510)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16807 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16808 | (z = disjunction_rule(p)) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16809 | ) |
| 16810 | { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16811 | res = z; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16812 | if (res == NULL && PyErr_Occurred()) { |
| 16813 | p->error_indicator = 1; |
| 16814 | return NULL; |
| 16815 | } |
| 16816 | goto done; |
| 16817 | } |
| 16818 | p->mark = mark; |
| 16819 | } |
| 16820 | res = NULL; |
| 16821 | done: |
| 16822 | return res; |
| 16823 | } |
| 16824 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16825 | // _tmp_141: 'if' disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16826 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16827 | _tmp_141_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16828 | { |
| 16829 | if (p->error_indicator) { |
| 16830 | return NULL; |
| 16831 | } |
| 16832 | void * res = NULL; |
| 16833 | int mark = p->mark; |
| 16834 | { // 'if' disjunction |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16835 | Token * keyword; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16836 | expr_ty z; |
| 16837 | if ( |
| 16838 | (keyword = _PyPegen_expect_token(p, 510)) |
| 16839 | && |
| 16840 | (z = disjunction_rule(p)) |
| 16841 | ) |
| 16842 | { |
| 16843 | res = z; |
| 16844 | if (res == NULL && PyErr_Occurred()) { |
| 16845 | p->error_indicator = 1; |
| 16846 | return NULL; |
| 16847 | } |
| 16848 | goto done; |
| 16849 | } |
| 16850 | p->mark = mark; |
| 16851 | } |
| 16852 | res = NULL; |
| 16853 | done: |
| 16854 | return res; |
| 16855 | } |
| 16856 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16857 | // _tmp_142: ',' star_target |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16858 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16859 | _tmp_142_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16860 | { |
| 16861 | if (p->error_indicator) { |
| 16862 | return NULL; |
| 16863 | } |
| 16864 | void * res = NULL; |
| 16865 | int mark = p->mark; |
| 16866 | { // ',' star_target |
| 16867 | expr_ty c; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 16868 | Token * literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16869 | if ( |
| 16870 | (literal = _PyPegen_expect_token(p, 12)) |
| 16871 | && |
| 16872 | (c = star_target_rule(p)) |
| 16873 | ) |
| 16874 | { |
| 16875 | res = c; |
| 16876 | if (res == NULL && PyErr_Occurred()) { |
| 16877 | p->error_indicator = 1; |
| 16878 | return NULL; |
| 16879 | } |
| 16880 | goto done; |
| 16881 | } |
| 16882 | p->mark = mark; |
| 16883 | } |
| 16884 | res = NULL; |
| 16885 | done: |
| 16886 | return res; |
| 16887 | } |
| 16888 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16889 | // _loop1_143: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16890 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16891 | _loop1_143_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16892 | { |
| 16893 | if (p->error_indicator) { |
| 16894 | return NULL; |
| 16895 | } |
| 16896 | void *res = NULL; |
| 16897 | int mark = p->mark; |
| 16898 | int start_mark = p->mark; |
| 16899 | void **children = PyMem_Malloc(sizeof(void *)); |
| 16900 | if (!children) { |
| 16901 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16902 | return NULL; |
| 16903 | } |
| 16904 | ssize_t children_capacity = 1; |
| 16905 | ssize_t n = 0; |
| 16906 | { // param_with_default |
| 16907 | NameDefaultPair* param_with_default_var; |
| 16908 | while ( |
| 16909 | (param_with_default_var = param_with_default_rule(p)) |
| 16910 | ) |
| 16911 | { |
| 16912 | res = param_with_default_var; |
| 16913 | if (n == children_capacity) { |
| 16914 | children_capacity *= 2; |
| 16915 | children = PyMem_Realloc(children, children_capacity*sizeof(void *)); |
| 16916 | if (!children) { |
| 16917 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16918 | return NULL; |
| 16919 | } |
| 16920 | } |
| 16921 | children[n++] = res; |
| 16922 | mark = p->mark; |
| 16923 | } |
| 16924 | p->mark = mark; |
| 16925 | } |
| 16926 | if (n == 0) { |
| 16927 | PyMem_Free(children); |
| 16928 | return NULL; |
| 16929 | } |
| 16930 | asdl_seq *seq = _Py_asdl_seq_new(n, p->arena); |
| 16931 | if (!seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16932 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_143"); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16933 | PyMem_Free(children); |
| 16934 | return NULL; |
| 16935 | } |
| 16936 | for (int i = 0; i < n; i++) asdl_seq_SET(seq, i, children[i]); |
| 16937 | PyMem_Free(children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16938 | _PyPegen_insert_memo(p, start_mark, _loop1_143_type, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16939 | return seq; |
| 16940 | } |
| 16941 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16942 | void * |
| 16943 | _PyPegen_parse(Parser *p) |
| 16944 | { |
| 16945 | // Initialize keywords |
| 16946 | p->keywords = reserved_keywords; |
| 16947 | p->n_keyword_lists = n_keyword_lists; |
| 16948 | |
| 16949 | // Run parser |
| 16950 | void *result = NULL; |
| 16951 | if (p->start_rule == Py_file_input) { |
| 16952 | result = file_rule(p); |
| 16953 | } else if (p->start_rule == Py_single_input) { |
| 16954 | result = interactive_rule(p); |
| 16955 | } else if (p->start_rule == Py_eval_input) { |
| 16956 | result = eval_rule(p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16957 | } else if (p->start_rule == Py_func_type_input) { |
| 16958 | result = func_type_rule(p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16959 | } else if (p->start_rule == Py_fstring_input) { |
| 16960 | result = fstring_rule(p); |
| 16961 | } |
| 16962 | |
| 16963 | return result; |
| 16964 | } |
| 16965 | |
| 16966 | // The end |