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 |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 207 | #define del_target_end_type 1136 |
| 208 | #define targets_type 1137 |
| 209 | #define target_type 1138 |
| 210 | #define t_primary_type 1139 // Left-recursive |
| 211 | #define t_lookahead_type 1140 |
| 212 | #define t_atom_type 1141 |
| 213 | #define incorrect_arguments_type 1142 |
| 214 | #define invalid_kwarg_type 1143 |
| 215 | #define invalid_named_expression_type 1144 |
| 216 | #define invalid_assignment_type 1145 |
| 217 | #define invalid_block_type 1146 |
| 218 | #define invalid_comprehension_type 1147 |
| 219 | #define invalid_parameters_type 1148 |
| 220 | #define invalid_star_etc_type 1149 |
| 221 | #define invalid_lambda_star_etc_type 1150 |
| 222 | #define invalid_double_type_comments_type 1151 |
| 223 | #define invalid_del_target_type 1152 |
| 224 | #define _loop0_1_type 1153 |
| 225 | #define _loop0_2_type 1154 |
| 226 | #define _loop0_4_type 1155 |
| 227 | #define _gather_3_type 1156 |
| 228 | #define _loop0_6_type 1157 |
| 229 | #define _gather_5_type 1158 |
| 230 | #define _loop0_8_type 1159 |
| 231 | #define _gather_7_type 1160 |
| 232 | #define _loop0_10_type 1161 |
| 233 | #define _gather_9_type 1162 |
| 234 | #define _loop1_11_type 1163 |
| 235 | #define _loop0_13_type 1164 |
| 236 | #define _gather_12_type 1165 |
| 237 | #define _tmp_14_type 1166 |
| 238 | #define _tmp_15_type 1167 |
| 239 | #define _tmp_16_type 1168 |
| 240 | #define _tmp_17_type 1169 |
| 241 | #define _tmp_18_type 1170 |
| 242 | #define _tmp_19_type 1171 |
| 243 | #define _tmp_20_type 1172 |
| 244 | #define _tmp_21_type 1173 |
| 245 | #define _loop1_22_type 1174 |
| 246 | #define _tmp_23_type 1175 |
| 247 | #define _tmp_24_type 1176 |
| 248 | #define _loop0_26_type 1177 |
| 249 | #define _gather_25_type 1178 |
| 250 | #define _loop0_28_type 1179 |
| 251 | #define _gather_27_type 1180 |
| 252 | #define _tmp_29_type 1181 |
| 253 | #define _loop0_30_type 1182 |
| 254 | #define _loop1_31_type 1183 |
| 255 | #define _loop0_33_type 1184 |
| 256 | #define _gather_32_type 1185 |
| 257 | #define _tmp_34_type 1186 |
| 258 | #define _loop0_36_type 1187 |
| 259 | #define _gather_35_type 1188 |
| 260 | #define _tmp_37_type 1189 |
| 261 | #define _loop0_39_type 1190 |
| 262 | #define _gather_38_type 1191 |
| 263 | #define _loop0_41_type 1192 |
| 264 | #define _gather_40_type 1193 |
| 265 | #define _loop0_43_type 1194 |
| 266 | #define _gather_42_type 1195 |
| 267 | #define _loop0_45_type 1196 |
| 268 | #define _gather_44_type 1197 |
| 269 | #define _tmp_46_type 1198 |
| 270 | #define _loop1_47_type 1199 |
| 271 | #define _tmp_48_type 1200 |
| 272 | #define _tmp_49_type 1201 |
| 273 | #define _tmp_50_type 1202 |
| 274 | #define _tmp_51_type 1203 |
| 275 | #define _tmp_52_type 1204 |
| 276 | #define _loop0_53_type 1205 |
| 277 | #define _loop0_54_type 1206 |
| 278 | #define _loop0_55_type 1207 |
| 279 | #define _loop1_56_type 1208 |
| 280 | #define _loop0_57_type 1209 |
| 281 | #define _loop1_58_type 1210 |
| 282 | #define _loop1_59_type 1211 |
| 283 | #define _loop1_60_type 1212 |
| 284 | #define _loop0_61_type 1213 |
| 285 | #define _loop1_62_type 1214 |
| 286 | #define _loop0_63_type 1215 |
| 287 | #define _loop1_64_type 1216 |
| 288 | #define _loop0_65_type 1217 |
| 289 | #define _loop1_66_type 1218 |
| 290 | #define _loop1_67_type 1219 |
| 291 | #define _tmp_68_type 1220 |
| 292 | #define _loop0_70_type 1221 |
| 293 | #define _gather_69_type 1222 |
| 294 | #define _loop1_71_type 1223 |
| 295 | #define _loop0_73_type 1224 |
| 296 | #define _gather_72_type 1225 |
| 297 | #define _loop1_74_type 1226 |
| 298 | #define _loop0_75_type 1227 |
| 299 | #define _loop0_76_type 1228 |
| 300 | #define _loop0_77_type 1229 |
| 301 | #define _loop1_78_type 1230 |
| 302 | #define _loop0_79_type 1231 |
| 303 | #define _loop1_80_type 1232 |
| 304 | #define _loop1_81_type 1233 |
| 305 | #define _loop1_82_type 1234 |
| 306 | #define _loop0_83_type 1235 |
| 307 | #define _loop1_84_type 1236 |
| 308 | #define _loop0_85_type 1237 |
| 309 | #define _loop1_86_type 1238 |
| 310 | #define _loop0_87_type 1239 |
| 311 | #define _loop1_88_type 1240 |
| 312 | #define _loop1_89_type 1241 |
| 313 | #define _loop1_90_type 1242 |
| 314 | #define _loop1_91_type 1243 |
| 315 | #define _tmp_92_type 1244 |
| 316 | #define _loop0_94_type 1245 |
| 317 | #define _gather_93_type 1246 |
| 318 | #define _tmp_95_type 1247 |
| 319 | #define _tmp_96_type 1248 |
| 320 | #define _tmp_97_type 1249 |
| 321 | #define _tmp_98_type 1250 |
| 322 | #define _loop1_99_type 1251 |
| 323 | #define _tmp_100_type 1252 |
| 324 | #define _tmp_101_type 1253 |
| 325 | #define _loop0_103_type 1254 |
| 326 | #define _gather_102_type 1255 |
| 327 | #define _loop1_104_type 1256 |
| 328 | #define _loop0_105_type 1257 |
| 329 | #define _loop0_106_type 1258 |
| 330 | #define _tmp_107_type 1259 |
| 331 | #define _tmp_108_type 1260 |
| 332 | #define _loop0_110_type 1261 |
| 333 | #define _gather_109_type 1262 |
| 334 | #define _loop0_112_type 1263 |
| 335 | #define _gather_111_type 1264 |
| 336 | #define _loop0_114_type 1265 |
| 337 | #define _gather_113_type 1266 |
| 338 | #define _loop0_116_type 1267 |
| 339 | #define _gather_115_type 1268 |
| 340 | #define _loop0_117_type 1269 |
| 341 | #define _loop0_119_type 1270 |
| 342 | #define _gather_118_type 1271 |
| 343 | #define _tmp_120_type 1272 |
| 344 | #define _loop0_122_type 1273 |
| 345 | #define _gather_121_type 1274 |
| 346 | #define _loop0_124_type 1275 |
| 347 | #define _gather_123_type 1276 |
| 348 | #define _tmp_125_type 1277 |
| 349 | #define _tmp_126_type 1278 |
| 350 | #define _tmp_127_type 1279 |
| 351 | #define _tmp_128_type 1280 |
| 352 | #define _tmp_129_type 1281 |
| 353 | #define _loop0_130_type 1282 |
| 354 | #define _tmp_131_type 1283 |
| 355 | #define _tmp_132_type 1284 |
| 356 | #define _tmp_133_type 1285 |
| 357 | #define _tmp_134_type 1286 |
| 358 | #define _tmp_135_type 1287 |
| 359 | #define _tmp_136_type 1288 |
| 360 | #define _tmp_137_type 1289 |
| 361 | #define _tmp_138_type 1290 |
| 362 | #define _tmp_139_type 1291 |
| 363 | #define _tmp_140_type 1292 |
| 364 | #define _tmp_141_type 1293 |
| 365 | #define _tmp_142_type 1294 |
| 366 | #define _tmp_143_type 1295 |
| 367 | #define _tmp_144_type 1296 |
| 368 | #define _loop1_145_type 1297 |
| 369 | #define _tmp_146_type 1298 |
| 370 | #define _tmp_147_type 1299 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 371 | |
| 372 | static mod_ty file_rule(Parser *p); |
| 373 | static mod_ty interactive_rule(Parser *p); |
| 374 | static mod_ty eval_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 375 | static mod_ty func_type_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 376 | static expr_ty fstring_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 377 | static asdl_seq* type_expressions_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 378 | static asdl_seq* statements_rule(Parser *p); |
| 379 | static asdl_seq* statement_rule(Parser *p); |
| 380 | static asdl_seq* statement_newline_rule(Parser *p); |
| 381 | static asdl_seq* simple_stmt_rule(Parser *p); |
| 382 | static stmt_ty small_stmt_rule(Parser *p); |
| 383 | static stmt_ty compound_stmt_rule(Parser *p); |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 384 | static stmt_ty assignment_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 385 | static AugOperator* augassign_rule(Parser *p); |
| 386 | static stmt_ty global_stmt_rule(Parser *p); |
| 387 | static stmt_ty nonlocal_stmt_rule(Parser *p); |
| 388 | static stmt_ty yield_stmt_rule(Parser *p); |
| 389 | static stmt_ty assert_stmt_rule(Parser *p); |
| 390 | static stmt_ty del_stmt_rule(Parser *p); |
| 391 | static stmt_ty import_stmt_rule(Parser *p); |
| 392 | static stmt_ty import_name_rule(Parser *p); |
| 393 | static stmt_ty import_from_rule(Parser *p); |
| 394 | static asdl_seq* import_from_targets_rule(Parser *p); |
| 395 | static asdl_seq* import_from_as_names_rule(Parser *p); |
| 396 | static alias_ty import_from_as_name_rule(Parser *p); |
| 397 | static asdl_seq* dotted_as_names_rule(Parser *p); |
| 398 | static alias_ty dotted_as_name_rule(Parser *p); |
| 399 | static expr_ty dotted_name_rule(Parser *p); |
| 400 | static stmt_ty if_stmt_rule(Parser *p); |
| 401 | static stmt_ty elif_stmt_rule(Parser *p); |
| 402 | static asdl_seq* else_block_rule(Parser *p); |
| 403 | static stmt_ty while_stmt_rule(Parser *p); |
| 404 | static stmt_ty for_stmt_rule(Parser *p); |
| 405 | static stmt_ty with_stmt_rule(Parser *p); |
| 406 | static withitem_ty with_item_rule(Parser *p); |
| 407 | static stmt_ty try_stmt_rule(Parser *p); |
| 408 | static excepthandler_ty except_block_rule(Parser *p); |
| 409 | static asdl_seq* finally_block_rule(Parser *p); |
| 410 | static stmt_ty return_stmt_rule(Parser *p); |
| 411 | static stmt_ty raise_stmt_rule(Parser *p); |
| 412 | static stmt_ty function_def_rule(Parser *p); |
| 413 | static stmt_ty function_def_raw_rule(Parser *p); |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 414 | static Token* func_type_comment_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 415 | static arguments_ty params_rule(Parser *p); |
| 416 | static arguments_ty parameters_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 417 | static asdl_seq* slash_no_default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 418 | static SlashWithDefault* slash_with_default_rule(Parser *p); |
| 419 | static StarEtc* star_etc_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 420 | static arg_ty kwds_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 421 | static arg_ty param_no_default_rule(Parser *p); |
| 422 | static NameDefaultPair* param_with_default_rule(Parser *p); |
| 423 | static NameDefaultPair* param_maybe_default_rule(Parser *p); |
| 424 | static arg_ty param_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 425 | static expr_ty annotation_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 426 | static expr_ty default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 427 | static asdl_seq* decorators_rule(Parser *p); |
| 428 | static stmt_ty class_def_rule(Parser *p); |
| 429 | static stmt_ty class_def_raw_rule(Parser *p); |
| 430 | static asdl_seq* block_rule(Parser *p); |
| 431 | static asdl_seq* expressions_list_rule(Parser *p); |
| 432 | static expr_ty star_expressions_rule(Parser *p); |
| 433 | static expr_ty star_expression_rule(Parser *p); |
| 434 | static asdl_seq* star_named_expressions_rule(Parser *p); |
| 435 | static expr_ty star_named_expression_rule(Parser *p); |
| 436 | static expr_ty named_expression_rule(Parser *p); |
| 437 | static expr_ty annotated_rhs_rule(Parser *p); |
| 438 | static expr_ty expressions_rule(Parser *p); |
| 439 | static expr_ty expression_rule(Parser *p); |
| 440 | static expr_ty lambdef_rule(Parser *p); |
| 441 | static arguments_ty lambda_parameters_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 442 | static asdl_seq* lambda_slash_no_default_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 443 | static SlashWithDefault* lambda_slash_with_default_rule(Parser *p); |
| 444 | static StarEtc* lambda_star_etc_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 445 | static arg_ty lambda_kwds_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 446 | static arg_ty lambda_param_no_default_rule(Parser *p); |
| 447 | static NameDefaultPair* lambda_param_with_default_rule(Parser *p); |
| 448 | static NameDefaultPair* lambda_param_maybe_default_rule(Parser *p); |
| 449 | static arg_ty lambda_param_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 450 | static expr_ty disjunction_rule(Parser *p); |
| 451 | static expr_ty conjunction_rule(Parser *p); |
| 452 | static expr_ty inversion_rule(Parser *p); |
| 453 | static expr_ty comparison_rule(Parser *p); |
| 454 | static CmpopExprPair* compare_op_bitwise_or_pair_rule(Parser *p); |
| 455 | static CmpopExprPair* eq_bitwise_or_rule(Parser *p); |
| 456 | static CmpopExprPair* noteq_bitwise_or_rule(Parser *p); |
| 457 | static CmpopExprPair* lte_bitwise_or_rule(Parser *p); |
| 458 | static CmpopExprPair* lt_bitwise_or_rule(Parser *p); |
| 459 | static CmpopExprPair* gte_bitwise_or_rule(Parser *p); |
| 460 | static CmpopExprPair* gt_bitwise_or_rule(Parser *p); |
| 461 | static CmpopExprPair* notin_bitwise_or_rule(Parser *p); |
| 462 | static CmpopExprPair* in_bitwise_or_rule(Parser *p); |
| 463 | static CmpopExprPair* isnot_bitwise_or_rule(Parser *p); |
| 464 | static CmpopExprPair* is_bitwise_or_rule(Parser *p); |
| 465 | static expr_ty bitwise_or_rule(Parser *p); |
| 466 | static expr_ty bitwise_xor_rule(Parser *p); |
| 467 | static expr_ty bitwise_and_rule(Parser *p); |
| 468 | static expr_ty shift_expr_rule(Parser *p); |
| 469 | static expr_ty sum_rule(Parser *p); |
| 470 | static expr_ty term_rule(Parser *p); |
| 471 | static expr_ty factor_rule(Parser *p); |
| 472 | static expr_ty power_rule(Parser *p); |
| 473 | static expr_ty await_primary_rule(Parser *p); |
| 474 | static expr_ty primary_rule(Parser *p); |
| 475 | static expr_ty slices_rule(Parser *p); |
| 476 | static expr_ty slice_rule(Parser *p); |
| 477 | static expr_ty atom_rule(Parser *p); |
| 478 | static expr_ty strings_rule(Parser *p); |
| 479 | static expr_ty list_rule(Parser *p); |
| 480 | static expr_ty listcomp_rule(Parser *p); |
| 481 | static expr_ty tuple_rule(Parser *p); |
| 482 | static expr_ty group_rule(Parser *p); |
| 483 | static expr_ty genexp_rule(Parser *p); |
| 484 | static expr_ty set_rule(Parser *p); |
| 485 | static expr_ty setcomp_rule(Parser *p); |
| 486 | static expr_ty dict_rule(Parser *p); |
| 487 | static expr_ty dictcomp_rule(Parser *p); |
| 488 | static asdl_seq* kvpairs_rule(Parser *p); |
| 489 | static KeyValuePair* kvpair_rule(Parser *p); |
| 490 | static asdl_seq* for_if_clauses_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 491 | static comprehension_ty for_if_clause_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 492 | static expr_ty yield_expr_rule(Parser *p); |
| 493 | static expr_ty arguments_rule(Parser *p); |
| 494 | static expr_ty args_rule(Parser *p); |
| 495 | static asdl_seq* kwargs_rule(Parser *p); |
| 496 | static expr_ty starred_expression_rule(Parser *p); |
| 497 | static KeywordOrStarred* kwarg_or_starred_rule(Parser *p); |
| 498 | static KeywordOrStarred* kwarg_or_double_starred_rule(Parser *p); |
| 499 | static expr_ty star_targets_rule(Parser *p); |
| 500 | static asdl_seq* star_targets_seq_rule(Parser *p); |
| 501 | static expr_ty star_target_rule(Parser *p); |
| 502 | static expr_ty star_atom_rule(Parser *p); |
| 503 | static expr_ty inside_paren_ann_assign_target_rule(Parser *p); |
| 504 | static expr_ty ann_assign_subscript_attribute_target_rule(Parser *p); |
| 505 | static asdl_seq* del_targets_rule(Parser *p); |
| 506 | static expr_ty del_target_rule(Parser *p); |
| 507 | static expr_ty del_t_atom_rule(Parser *p); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 508 | static void *del_target_end_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 509 | static asdl_seq* targets_rule(Parser *p); |
| 510 | static expr_ty target_rule(Parser *p); |
| 511 | static expr_ty t_primary_rule(Parser *p); |
| 512 | static void *t_lookahead_rule(Parser *p); |
| 513 | static expr_ty t_atom_rule(Parser *p); |
| 514 | static void *incorrect_arguments_rule(Parser *p); |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 515 | static void *invalid_kwarg_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 516 | static void *invalid_named_expression_rule(Parser *p); |
| 517 | static void *invalid_assignment_rule(Parser *p); |
| 518 | static void *invalid_block_rule(Parser *p); |
| 519 | static void *invalid_comprehension_rule(Parser *p); |
| 520 | static void *invalid_parameters_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 521 | static void *invalid_star_etc_rule(Parser *p); |
| 522 | static void *invalid_lambda_star_etc_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 523 | static void *invalid_double_type_comments_rule(Parser *p); |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 524 | static void *invalid_del_target_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 525 | static asdl_seq *_loop0_1_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 526 | static asdl_seq *_loop0_2_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 527 | static asdl_seq *_loop0_4_rule(Parser *p); |
| 528 | static asdl_seq *_gather_3_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 529 | static asdl_seq *_loop0_6_rule(Parser *p); |
| 530 | static asdl_seq *_gather_5_rule(Parser *p); |
| 531 | static asdl_seq *_loop0_8_rule(Parser *p); |
| 532 | static asdl_seq *_gather_7_rule(Parser *p); |
| 533 | static asdl_seq *_loop0_10_rule(Parser *p); |
| 534 | static asdl_seq *_gather_9_rule(Parser *p); |
| 535 | static asdl_seq *_loop1_11_rule(Parser *p); |
| 536 | static asdl_seq *_loop0_13_rule(Parser *p); |
| 537 | static asdl_seq *_gather_12_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 538 | static void *_tmp_14_rule(Parser *p); |
| 539 | static void *_tmp_15_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 540 | static void *_tmp_16_rule(Parser *p); |
| 541 | static void *_tmp_17_rule(Parser *p); |
| 542 | static void *_tmp_18_rule(Parser *p); |
| 543 | static void *_tmp_19_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 544 | static void *_tmp_20_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 545 | static void *_tmp_21_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 546 | static asdl_seq *_loop1_22_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 547 | static void *_tmp_23_rule(Parser *p); |
| 548 | static void *_tmp_24_rule(Parser *p); |
| 549 | static asdl_seq *_loop0_26_rule(Parser *p); |
| 550 | static asdl_seq *_gather_25_rule(Parser *p); |
| 551 | static asdl_seq *_loop0_28_rule(Parser *p); |
| 552 | static asdl_seq *_gather_27_rule(Parser *p); |
| 553 | static void *_tmp_29_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 554 | static asdl_seq *_loop0_30_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 555 | static asdl_seq *_loop1_31_rule(Parser *p); |
| 556 | static asdl_seq *_loop0_33_rule(Parser *p); |
| 557 | static asdl_seq *_gather_32_rule(Parser *p); |
| 558 | static void *_tmp_34_rule(Parser *p); |
| 559 | static asdl_seq *_loop0_36_rule(Parser *p); |
| 560 | static asdl_seq *_gather_35_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 561 | static void *_tmp_37_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 562 | static asdl_seq *_loop0_39_rule(Parser *p); |
| 563 | static asdl_seq *_gather_38_rule(Parser *p); |
| 564 | static asdl_seq *_loop0_41_rule(Parser *p); |
| 565 | static asdl_seq *_gather_40_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 566 | static asdl_seq *_loop0_43_rule(Parser *p); |
| 567 | static asdl_seq *_gather_42_rule(Parser *p); |
| 568 | static asdl_seq *_loop0_45_rule(Parser *p); |
| 569 | static asdl_seq *_gather_44_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 570 | static void *_tmp_46_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 571 | static asdl_seq *_loop1_47_rule(Parser *p); |
| 572 | static void *_tmp_48_rule(Parser *p); |
| 573 | static void *_tmp_49_rule(Parser *p); |
| 574 | static void *_tmp_50_rule(Parser *p); |
| 575 | static void *_tmp_51_rule(Parser *p); |
| 576 | static void *_tmp_52_rule(Parser *p); |
| 577 | static asdl_seq *_loop0_53_rule(Parser *p); |
| 578 | static asdl_seq *_loop0_54_rule(Parser *p); |
| 579 | static asdl_seq *_loop0_55_rule(Parser *p); |
| 580 | static asdl_seq *_loop1_56_rule(Parser *p); |
| 581 | static asdl_seq *_loop0_57_rule(Parser *p); |
| 582 | static asdl_seq *_loop1_58_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 583 | static asdl_seq *_loop1_59_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 584 | static asdl_seq *_loop1_60_rule(Parser *p); |
| 585 | static asdl_seq *_loop0_61_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 586 | static asdl_seq *_loop1_62_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 587 | static asdl_seq *_loop0_63_rule(Parser *p); |
| 588 | static asdl_seq *_loop1_64_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 589 | static asdl_seq *_loop0_65_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 590 | static asdl_seq *_loop1_66_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 591 | static asdl_seq *_loop1_67_rule(Parser *p); |
| 592 | static void *_tmp_68_rule(Parser *p); |
| 593 | static asdl_seq *_loop0_70_rule(Parser *p); |
| 594 | static asdl_seq *_gather_69_rule(Parser *p); |
| 595 | static asdl_seq *_loop1_71_rule(Parser *p); |
| 596 | static asdl_seq *_loop0_73_rule(Parser *p); |
| 597 | static asdl_seq *_gather_72_rule(Parser *p); |
| 598 | static asdl_seq *_loop1_74_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 599 | static asdl_seq *_loop0_75_rule(Parser *p); |
| 600 | static asdl_seq *_loop0_76_rule(Parser *p); |
| 601 | static asdl_seq *_loop0_77_rule(Parser *p); |
| 602 | static asdl_seq *_loop1_78_rule(Parser *p); |
| 603 | static asdl_seq *_loop0_79_rule(Parser *p); |
| 604 | static asdl_seq *_loop1_80_rule(Parser *p); |
| 605 | static asdl_seq *_loop1_81_rule(Parser *p); |
| 606 | static asdl_seq *_loop1_82_rule(Parser *p); |
| 607 | static asdl_seq *_loop0_83_rule(Parser *p); |
| 608 | static asdl_seq *_loop1_84_rule(Parser *p); |
| 609 | static asdl_seq *_loop0_85_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 610 | static asdl_seq *_loop1_86_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 611 | static asdl_seq *_loop0_87_rule(Parser *p); |
| 612 | static asdl_seq *_loop1_88_rule(Parser *p); |
| 613 | static asdl_seq *_loop1_89_rule(Parser *p); |
| 614 | static asdl_seq *_loop1_90_rule(Parser *p); |
| 615 | static asdl_seq *_loop1_91_rule(Parser *p); |
| 616 | static void *_tmp_92_rule(Parser *p); |
| 617 | static asdl_seq *_loop0_94_rule(Parser *p); |
| 618 | static asdl_seq *_gather_93_rule(Parser *p); |
| 619 | static void *_tmp_95_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 620 | static void *_tmp_96_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 621 | static void *_tmp_97_rule(Parser *p); |
| 622 | static void *_tmp_98_rule(Parser *p); |
| 623 | static asdl_seq *_loop1_99_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 624 | static void *_tmp_100_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 625 | static void *_tmp_101_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 626 | static asdl_seq *_loop0_103_rule(Parser *p); |
| 627 | static asdl_seq *_gather_102_rule(Parser *p); |
| 628 | static asdl_seq *_loop1_104_rule(Parser *p); |
| 629 | static asdl_seq *_loop0_105_rule(Parser *p); |
| 630 | static asdl_seq *_loop0_106_rule(Parser *p); |
| 631 | static void *_tmp_107_rule(Parser *p); |
| 632 | static void *_tmp_108_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 633 | static asdl_seq *_loop0_110_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 634 | static asdl_seq *_gather_109_rule(Parser *p); |
| 635 | static asdl_seq *_loop0_112_rule(Parser *p); |
| 636 | static asdl_seq *_gather_111_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 637 | static asdl_seq *_loop0_114_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 638 | static asdl_seq *_gather_113_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 639 | static asdl_seq *_loop0_116_rule(Parser *p); |
| 640 | static asdl_seq *_gather_115_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 641 | static asdl_seq *_loop0_117_rule(Parser *p); |
| 642 | static asdl_seq *_loop0_119_rule(Parser *p); |
| 643 | static asdl_seq *_gather_118_rule(Parser *p); |
| 644 | static void *_tmp_120_rule(Parser *p); |
| 645 | static asdl_seq *_loop0_122_rule(Parser *p); |
| 646 | static asdl_seq *_gather_121_rule(Parser *p); |
| 647 | static asdl_seq *_loop0_124_rule(Parser *p); |
| 648 | static asdl_seq *_gather_123_rule(Parser *p); |
| 649 | static void *_tmp_125_rule(Parser *p); |
| 650 | static void *_tmp_126_rule(Parser *p); |
| 651 | static void *_tmp_127_rule(Parser *p); |
| 652 | static void *_tmp_128_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 653 | static void *_tmp_129_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 654 | static asdl_seq *_loop0_130_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 655 | static void *_tmp_131_rule(Parser *p); |
| 656 | static void *_tmp_132_rule(Parser *p); |
| 657 | static void *_tmp_133_rule(Parser *p); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 658 | static void *_tmp_134_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 659 | static void *_tmp_135_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 660 | static void *_tmp_136_rule(Parser *p); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 661 | static void *_tmp_137_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 662 | static void *_tmp_138_rule(Parser *p); |
| 663 | static void *_tmp_139_rule(Parser *p); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 664 | static void *_tmp_140_rule(Parser *p); |
| 665 | static void *_tmp_141_rule(Parser *p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 666 | static void *_tmp_142_rule(Parser *p); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 667 | static void *_tmp_143_rule(Parser *p); |
| 668 | static void *_tmp_144_rule(Parser *p); |
| 669 | static asdl_seq *_loop1_145_rule(Parser *p); |
| 670 | static void *_tmp_146_rule(Parser *p); |
| 671 | static void *_tmp_147_rule(Parser *p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 672 | |
| 673 | |
| 674 | // file: statements? $ |
| 675 | static mod_ty |
| 676 | file_rule(Parser *p) |
| 677 | { |
| 678 | if (p->error_indicator) { |
| 679 | return NULL; |
| 680 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 681 | mod_ty _res = NULL; |
| 682 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 683 | { // statements? $ |
| 684 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 685 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 686 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 687 | (a = statements_rule(p), 1) // statements? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 688 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 689 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 690 | ) |
| 691 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 692 | _res = _PyPegen_make_module ( p , a ); |
| 693 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 694 | p->error_indicator = 1; |
| 695 | return NULL; |
| 696 | } |
| 697 | goto done; |
| 698 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 699 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 700 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 701 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 702 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 703 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 704 | } |
| 705 | |
| 706 | // interactive: statement_newline |
| 707 | static mod_ty |
| 708 | interactive_rule(Parser *p) |
| 709 | { |
| 710 | if (p->error_indicator) { |
| 711 | return NULL; |
| 712 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 713 | mod_ty _res = NULL; |
| 714 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 715 | { // statement_newline |
| 716 | asdl_seq* a; |
| 717 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 718 | (a = statement_newline_rule(p)) // statement_newline |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 719 | ) |
| 720 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 721 | _res = Interactive ( a , p -> arena ); |
| 722 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 723 | p->error_indicator = 1; |
| 724 | return NULL; |
| 725 | } |
| 726 | goto done; |
| 727 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 728 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 729 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 730 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 731 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 732 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 733 | } |
| 734 | |
| 735 | // eval: expressions NEWLINE* $ |
| 736 | static mod_ty |
| 737 | eval_rule(Parser *p) |
| 738 | { |
| 739 | if (p->error_indicator) { |
| 740 | return NULL; |
| 741 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 742 | mod_ty _res = NULL; |
| 743 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 744 | { // expressions NEWLINE* $ |
| 745 | asdl_seq * _loop0_1_var; |
| 746 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 747 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 748 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 749 | (a = expressions_rule(p)) // expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 750 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 751 | (_loop0_1_var = _loop0_1_rule(p)) // NEWLINE* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 752 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 753 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 754 | ) |
| 755 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 756 | _res = Expression ( a , p -> arena ); |
| 757 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 758 | p->error_indicator = 1; |
| 759 | return NULL; |
| 760 | } |
| 761 | goto done; |
| 762 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 763 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 764 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 765 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 766 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 767 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 768 | } |
| 769 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 770 | // func_type: '(' type_expressions? ')' '->' expression NEWLINE* $ |
| 771 | static mod_ty |
| 772 | func_type_rule(Parser *p) |
| 773 | { |
| 774 | if (p->error_indicator) { |
| 775 | return NULL; |
| 776 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 777 | mod_ty _res = NULL; |
| 778 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 779 | { // '(' type_expressions? ')' '->' expression NEWLINE* $ |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 780 | Token * _literal; |
| 781 | Token * _literal_1; |
| 782 | Token * _literal_2; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 783 | asdl_seq * _loop0_2_var; |
| 784 | void *a; |
| 785 | expr_ty b; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 786 | Token * endmarker_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 787 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 788 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 789 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 790 | (a = type_expressions_rule(p), 1) // type_expressions? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 791 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 792 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 793 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 794 | (_literal_2 = _PyPegen_expect_token(p, 51)) // token='->' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 795 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 796 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 797 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 798 | (_loop0_2_var = _loop0_2_rule(p)) // NEWLINE* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 799 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 800 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 801 | ) |
| 802 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 803 | _res = FunctionType ( a , b , p -> arena ); |
| 804 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 805 | p->error_indicator = 1; |
| 806 | return NULL; |
| 807 | } |
| 808 | goto done; |
| 809 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 810 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 811 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 812 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 813 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 814 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 815 | } |
| 816 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 817 | // fstring: star_expressions |
| 818 | static expr_ty |
| 819 | fstring_rule(Parser *p) |
| 820 | { |
| 821 | if (p->error_indicator) { |
| 822 | return NULL; |
| 823 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 824 | expr_ty _res = NULL; |
| 825 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 826 | { // star_expressions |
| 827 | expr_ty star_expressions_var; |
| 828 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 829 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 830 | ) |
| 831 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 832 | _res = star_expressions_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 833 | goto done; |
| 834 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 835 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 836 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 837 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 838 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 839 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 840 | } |
| 841 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 842 | // type_expressions: |
| 843 | // | ','.expression+ ',' '*' expression ',' '**' expression |
| 844 | // | ','.expression+ ',' '*' expression |
| 845 | // | ','.expression+ ',' '**' expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 846 | // | '*' expression ',' '**' expression |
| 847 | // | '*' expression |
| 848 | // | '**' expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 849 | // | ','.expression+ |
| 850 | static asdl_seq* |
| 851 | type_expressions_rule(Parser *p) |
| 852 | { |
| 853 | if (p->error_indicator) { |
| 854 | return NULL; |
| 855 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 856 | asdl_seq* _res = NULL; |
| 857 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 858 | { // ','.expression+ ',' '*' expression ',' '**' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 859 | Token * _literal; |
| 860 | Token * _literal_1; |
| 861 | Token * _literal_2; |
| 862 | Token * _literal_3; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 863 | asdl_seq * a; |
| 864 | expr_ty b; |
| 865 | expr_ty c; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 866 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 867 | (a = _gather_3_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 868 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 869 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 870 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 871 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 872 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 873 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 874 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 875 | (_literal_2 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 876 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 877 | (_literal_3 = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 878 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 879 | (c = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 880 | ) |
| 881 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 882 | _res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_seq_append_to_end ( p , a , b ) ) , c ); |
| 883 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 884 | p->error_indicator = 1; |
| 885 | return NULL; |
| 886 | } |
| 887 | goto done; |
| 888 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 889 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 890 | } |
| 891 | { // ','.expression+ ',' '*' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 892 | Token * _literal; |
| 893 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 894 | asdl_seq * a; |
| 895 | expr_ty b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 896 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 897 | (a = _gather_5_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 898 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 899 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 900 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 901 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 902 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 903 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 904 | ) |
| 905 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 906 | _res = _PyPegen_seq_append_to_end ( p , a , b ); |
| 907 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 908 | p->error_indicator = 1; |
| 909 | return NULL; |
| 910 | } |
| 911 | goto done; |
| 912 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 913 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 914 | } |
| 915 | { // ','.expression+ ',' '**' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 916 | Token * _literal; |
| 917 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 918 | asdl_seq * a; |
| 919 | expr_ty b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 920 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 921 | (a = _gather_7_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 922 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 923 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 924 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 925 | (_literal_1 = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 926 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 927 | (b = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 928 | ) |
| 929 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 930 | _res = _PyPegen_seq_append_to_end ( p , a , b ); |
| 931 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 932 | p->error_indicator = 1; |
| 933 | return NULL; |
| 934 | } |
| 935 | goto done; |
| 936 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 937 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 938 | } |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 939 | { // '*' expression ',' '**' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 940 | Token * _literal; |
| 941 | Token * _literal_1; |
| 942 | Token * _literal_2; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 943 | expr_ty a; |
| 944 | expr_ty b; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 945 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 946 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 947 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 948 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 949 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 950 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 951 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 952 | (_literal_2 = _PyPegen_expect_token(p, 35)) // token='**' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 953 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 954 | (b = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 955 | ) |
| 956 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 957 | _res = _PyPegen_seq_append_to_end ( p , CHECK ( _PyPegen_singleton_seq ( p , a ) ) , b ); |
| 958 | if (_res == NULL && PyErr_Occurred()) { |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 959 | p->error_indicator = 1; |
| 960 | return NULL; |
| 961 | } |
| 962 | goto done; |
| 963 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 964 | p->mark = _mark; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 965 | } |
| 966 | { // '*' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 967 | Token * _literal; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 968 | expr_ty a; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 969 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 970 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 971 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 972 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 973 | ) |
| 974 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 975 | _res = _PyPegen_singleton_seq ( p , a ); |
| 976 | if (_res == NULL && PyErr_Occurred()) { |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 977 | p->error_indicator = 1; |
| 978 | return NULL; |
| 979 | } |
| 980 | goto done; |
| 981 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 982 | p->mark = _mark; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 983 | } |
| 984 | { // '**' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 985 | Token * _literal; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 986 | expr_ty a; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 987 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 988 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 989 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 990 | (a = expression_rule(p)) // expression |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 991 | ) |
| 992 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 993 | _res = _PyPegen_singleton_seq ( p , a ); |
| 994 | if (_res == NULL && PyErr_Occurred()) { |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 995 | p->error_indicator = 1; |
| 996 | return NULL; |
| 997 | } |
| 998 | goto done; |
| 999 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1000 | p->mark = _mark; |
Shantanu | 603d354 | 2020-05-03 22:08:14 -0700 | [diff] [blame] | 1001 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1002 | { // ','.expression+ |
| 1003 | asdl_seq * _gather_9_var; |
| 1004 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1005 | (_gather_9_var = _gather_9_rule(p)) // ','.expression+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1006 | ) |
| 1007 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1008 | _res = _gather_9_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1009 | goto done; |
| 1010 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1011 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1012 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1013 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1014 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1015 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1016 | } |
| 1017 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1018 | // statements: statement+ |
| 1019 | static asdl_seq* |
| 1020 | statements_rule(Parser *p) |
| 1021 | { |
| 1022 | if (p->error_indicator) { |
| 1023 | return NULL; |
| 1024 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1025 | asdl_seq* _res = NULL; |
| 1026 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1027 | { // statement+ |
| 1028 | asdl_seq * a; |
| 1029 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1030 | (a = _loop1_11_rule(p)) // statement+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1031 | ) |
| 1032 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1033 | _res = _PyPegen_seq_flatten ( p , a ); |
| 1034 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1035 | p->error_indicator = 1; |
| 1036 | return NULL; |
| 1037 | } |
| 1038 | goto done; |
| 1039 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1040 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1041 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1042 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1043 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1044 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1045 | } |
| 1046 | |
| 1047 | // statement: compound_stmt | simple_stmt |
| 1048 | static asdl_seq* |
| 1049 | statement_rule(Parser *p) |
| 1050 | { |
| 1051 | if (p->error_indicator) { |
| 1052 | return NULL; |
| 1053 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1054 | asdl_seq* _res = NULL; |
| 1055 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1056 | { // compound_stmt |
| 1057 | stmt_ty a; |
| 1058 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1059 | (a = compound_stmt_rule(p)) // compound_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1060 | ) |
| 1061 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1062 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1063 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1064 | p->error_indicator = 1; |
| 1065 | return NULL; |
| 1066 | } |
| 1067 | goto done; |
| 1068 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1069 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1070 | } |
| 1071 | { // simple_stmt |
| 1072 | asdl_seq* simple_stmt_var; |
| 1073 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1074 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1075 | ) |
| 1076 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1077 | _res = simple_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1078 | goto done; |
| 1079 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1080 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1081 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1082 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1083 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1084 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1085 | } |
| 1086 | |
| 1087 | // statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $ |
| 1088 | static asdl_seq* |
| 1089 | statement_newline_rule(Parser *p) |
| 1090 | { |
| 1091 | if (p->error_indicator) { |
| 1092 | return NULL; |
| 1093 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1094 | asdl_seq* _res = NULL; |
| 1095 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1096 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1097 | p->error_indicator = 1; |
| 1098 | return NULL; |
| 1099 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1100 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1101 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1102 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1103 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1104 | { // compound_stmt NEWLINE |
| 1105 | stmt_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1106 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1107 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1108 | (a = compound_stmt_rule(p)) // compound_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1109 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1110 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1111 | ) |
| 1112 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1113 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1114 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1115 | p->error_indicator = 1; |
| 1116 | return NULL; |
| 1117 | } |
| 1118 | goto done; |
| 1119 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1120 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1121 | } |
| 1122 | { // simple_stmt |
| 1123 | asdl_seq* simple_stmt_var; |
| 1124 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1125 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1126 | ) |
| 1127 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1128 | _res = simple_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1129 | goto done; |
| 1130 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1131 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1132 | } |
| 1133 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1134 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1135 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1136 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1137 | ) |
| 1138 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1139 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1140 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1141 | return NULL; |
| 1142 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1143 | int _end_lineno = _token->end_lineno; |
| 1144 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1145 | int _end_col_offset = _token->end_col_offset; |
| 1146 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1147 | _res = _PyPegen_singleton_seq ( p , CHECK ( _Py_Pass ( EXTRA ) ) ); |
| 1148 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1149 | p->error_indicator = 1; |
| 1150 | return NULL; |
| 1151 | } |
| 1152 | goto done; |
| 1153 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1154 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1155 | } |
| 1156 | { // $ |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1157 | Token * endmarker_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1158 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1159 | (endmarker_var = _PyPegen_expect_token(p, ENDMARKER)) // token='ENDMARKER' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1160 | ) |
| 1161 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1162 | _res = _PyPegen_interactive_exit ( p ); |
| 1163 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1164 | p->error_indicator = 1; |
| 1165 | return NULL; |
| 1166 | } |
| 1167 | goto done; |
| 1168 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1169 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1170 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1171 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1172 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1173 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1174 | } |
| 1175 | |
| 1176 | // simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE |
| 1177 | static asdl_seq* |
| 1178 | simple_stmt_rule(Parser *p) |
| 1179 | { |
| 1180 | if (p->error_indicator) { |
| 1181 | return NULL; |
| 1182 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1183 | asdl_seq* _res = NULL; |
| 1184 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1185 | { // small_stmt !';' NEWLINE |
| 1186 | stmt_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1187 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1188 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1189 | (a = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1190 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1191 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1192 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1193 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1194 | ) |
| 1195 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1196 | _res = _PyPegen_singleton_seq ( p , a ); |
| 1197 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1198 | p->error_indicator = 1; |
| 1199 | return NULL; |
| 1200 | } |
| 1201 | goto done; |
| 1202 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1203 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1204 | } |
| 1205 | { // ';'.small_stmt+ ';'? NEWLINE |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1206 | void *_opt_var; |
| 1207 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1208 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 1209 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1210 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1211 | (a = _gather_12_rule(p)) // ';'.small_stmt+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1212 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1213 | (_opt_var = _PyPegen_expect_token(p, 13), 1) // ';'? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1214 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1215 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1216 | ) |
| 1217 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1218 | _res = a; |
| 1219 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1220 | p->error_indicator = 1; |
| 1221 | return NULL; |
| 1222 | } |
| 1223 | goto done; |
| 1224 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1225 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1226 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1227 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1228 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1229 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1230 | } |
| 1231 | |
| 1232 | // small_stmt: |
| 1233 | // | assignment |
| 1234 | // | star_expressions |
| 1235 | // | &'return' return_stmt |
| 1236 | // | &('import' | 'from') import_stmt |
| 1237 | // | &'raise' raise_stmt |
| 1238 | // | 'pass' |
| 1239 | // | &'del' del_stmt |
| 1240 | // | &'yield' yield_stmt |
| 1241 | // | &'assert' assert_stmt |
| 1242 | // | 'break' |
| 1243 | // | 'continue' |
| 1244 | // | &'global' global_stmt |
| 1245 | // | &'nonlocal' nonlocal_stmt |
| 1246 | static stmt_ty |
| 1247 | small_stmt_rule(Parser *p) |
| 1248 | { |
| 1249 | if (p->error_indicator) { |
| 1250 | return NULL; |
| 1251 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1252 | stmt_ty _res = NULL; |
| 1253 | if (_PyPegen_is_memoized(p, small_stmt_type, &_res)) |
| 1254 | return _res; |
| 1255 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1256 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1257 | p->error_indicator = 1; |
| 1258 | return NULL; |
| 1259 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1260 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1261 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1262 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1263 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1264 | { // assignment |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 1265 | stmt_ty assignment_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1266 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1267 | (assignment_var = assignment_rule(p)) // assignment |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1268 | ) |
| 1269 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1270 | _res = assignment_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1271 | goto done; |
| 1272 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1273 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1274 | } |
| 1275 | { // star_expressions |
| 1276 | expr_ty e; |
| 1277 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1278 | (e = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1279 | ) |
| 1280 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1281 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1282 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1283 | return NULL; |
| 1284 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1285 | int _end_lineno = _token->end_lineno; |
| 1286 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1287 | int _end_col_offset = _token->end_col_offset; |
| 1288 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1289 | _res = _Py_Expr ( e , EXTRA ); |
| 1290 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1291 | p->error_indicator = 1; |
| 1292 | return NULL; |
| 1293 | } |
| 1294 | goto done; |
| 1295 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1296 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1297 | } |
| 1298 | { // &'return' return_stmt |
| 1299 | stmt_ty return_stmt_var; |
| 1300 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1301 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1302 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1303 | (return_stmt_var = return_stmt_rule(p)) // return_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1304 | ) |
| 1305 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1306 | _res = return_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1307 | goto done; |
| 1308 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1309 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1310 | } |
| 1311 | { // &('import' | 'from') import_stmt |
| 1312 | stmt_ty import_stmt_var; |
| 1313 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1314 | _PyPegen_lookahead(1, _tmp_14_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1315 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1316 | (import_stmt_var = import_stmt_rule(p)) // import_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1317 | ) |
| 1318 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1319 | _res = import_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1320 | goto done; |
| 1321 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1322 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1323 | } |
| 1324 | { // &'raise' raise_stmt |
| 1325 | stmt_ty raise_stmt_var; |
| 1326 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1327 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1328 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1329 | (raise_stmt_var = raise_stmt_rule(p)) // raise_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1330 | ) |
| 1331 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1332 | _res = raise_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1333 | goto done; |
| 1334 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1335 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1336 | } |
| 1337 | { // 'pass' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1338 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1339 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1340 | (_keyword = _PyPegen_expect_token(p, 502)) // token='pass' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1341 | ) |
| 1342 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1343 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1344 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1345 | return NULL; |
| 1346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1347 | int _end_lineno = _token->end_lineno; |
| 1348 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1349 | int _end_col_offset = _token->end_col_offset; |
| 1350 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1351 | _res = _Py_Pass ( EXTRA ); |
| 1352 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1353 | p->error_indicator = 1; |
| 1354 | return NULL; |
| 1355 | } |
| 1356 | goto done; |
| 1357 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1358 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1359 | } |
| 1360 | { // &'del' del_stmt |
| 1361 | stmt_ty del_stmt_var; |
| 1362 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1363 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) // token='del' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1364 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1365 | (del_stmt_var = del_stmt_rule(p)) // del_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1366 | ) |
| 1367 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1368 | _res = del_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1369 | goto done; |
| 1370 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1371 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1372 | } |
| 1373 | { // &'yield' yield_stmt |
| 1374 | stmt_ty yield_stmt_var; |
| 1375 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1376 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1377 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1378 | (yield_stmt_var = yield_stmt_rule(p)) // yield_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1379 | ) |
| 1380 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1381 | _res = yield_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1382 | goto done; |
| 1383 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1384 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1385 | } |
| 1386 | { // &'assert' assert_stmt |
| 1387 | stmt_ty assert_stmt_var; |
| 1388 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1389 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) // token='assert' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1390 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1391 | (assert_stmt_var = assert_stmt_rule(p)) // assert_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1392 | ) |
| 1393 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1394 | _res = assert_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1395 | goto done; |
| 1396 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1397 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1398 | } |
| 1399 | { // 'break' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1400 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1401 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1402 | (_keyword = _PyPegen_expect_token(p, 506)) // token='break' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1403 | ) |
| 1404 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1405 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1406 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1407 | return NULL; |
| 1408 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1409 | int _end_lineno = _token->end_lineno; |
| 1410 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1411 | int _end_col_offset = _token->end_col_offset; |
| 1412 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1413 | _res = _Py_Break ( EXTRA ); |
| 1414 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1415 | p->error_indicator = 1; |
| 1416 | return NULL; |
| 1417 | } |
| 1418 | goto done; |
| 1419 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1420 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1421 | } |
| 1422 | { // 'continue' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1423 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1424 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1425 | (_keyword = _PyPegen_expect_token(p, 507)) // token='continue' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1426 | ) |
| 1427 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1428 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1429 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1430 | return NULL; |
| 1431 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1432 | int _end_lineno = _token->end_lineno; |
| 1433 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1434 | int _end_col_offset = _token->end_col_offset; |
| 1435 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1436 | _res = _Py_Continue ( EXTRA ); |
| 1437 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1438 | p->error_indicator = 1; |
| 1439 | return NULL; |
| 1440 | } |
| 1441 | goto done; |
| 1442 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1443 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1444 | } |
| 1445 | { // &'global' global_stmt |
| 1446 | stmt_ty global_stmt_var; |
| 1447 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1448 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1449 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1450 | (global_stmt_var = global_stmt_rule(p)) // global_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1451 | ) |
| 1452 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1453 | _res = global_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1454 | goto done; |
| 1455 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1456 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1457 | } |
| 1458 | { // &'nonlocal' nonlocal_stmt |
| 1459 | stmt_ty nonlocal_stmt_var; |
| 1460 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1461 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1462 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1463 | (nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1464 | ) |
| 1465 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1466 | _res = nonlocal_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1467 | goto done; |
| 1468 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1469 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1470 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1471 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1472 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1473 | _PyPegen_insert_memo(p, _mark, small_stmt_type, _res); |
| 1474 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1475 | } |
| 1476 | |
| 1477 | // compound_stmt: |
| 1478 | // | &('def' | '@' | ASYNC) function_def |
| 1479 | // | &'if' if_stmt |
| 1480 | // | &('class' | '@') class_def |
| 1481 | // | &('with' | ASYNC) with_stmt |
| 1482 | // | &('for' | ASYNC) for_stmt |
| 1483 | // | &'try' try_stmt |
| 1484 | // | &'while' while_stmt |
| 1485 | static stmt_ty |
| 1486 | compound_stmt_rule(Parser *p) |
| 1487 | { |
| 1488 | if (p->error_indicator) { |
| 1489 | return NULL; |
| 1490 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1491 | stmt_ty _res = NULL; |
| 1492 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1493 | { // &('def' | '@' | ASYNC) function_def |
| 1494 | stmt_ty function_def_var; |
| 1495 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1496 | _PyPegen_lookahead(1, _tmp_15_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1497 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1498 | (function_def_var = function_def_rule(p)) // function_def |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1499 | ) |
| 1500 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1501 | _res = function_def_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1502 | goto done; |
| 1503 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1504 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1505 | } |
| 1506 | { // &'if' if_stmt |
| 1507 | stmt_ty if_stmt_var; |
| 1508 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1509 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 510) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1510 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1511 | (if_stmt_var = if_stmt_rule(p)) // if_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1512 | ) |
| 1513 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1514 | _res = if_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1515 | goto done; |
| 1516 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1517 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1518 | } |
| 1519 | { // &('class' | '@') class_def |
| 1520 | stmt_ty class_def_var; |
| 1521 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1522 | _PyPegen_lookahead(1, _tmp_16_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1523 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1524 | (class_def_var = class_def_rule(p)) // class_def |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1525 | ) |
| 1526 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1527 | _res = class_def_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1528 | goto done; |
| 1529 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1530 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1531 | } |
| 1532 | { // &('with' | ASYNC) with_stmt |
| 1533 | stmt_ty with_stmt_var; |
| 1534 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1535 | _PyPegen_lookahead(1, _tmp_17_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1536 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1537 | (with_stmt_var = with_stmt_rule(p)) // with_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1538 | ) |
| 1539 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1540 | _res = with_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1541 | goto done; |
| 1542 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1543 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1544 | } |
| 1545 | { // &('for' | ASYNC) for_stmt |
| 1546 | stmt_ty for_stmt_var; |
| 1547 | if ( |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1548 | _PyPegen_lookahead(1, _tmp_18_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1549 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1550 | (for_stmt_var = for_stmt_rule(p)) // for_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1551 | ) |
| 1552 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1553 | _res = for_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1554 | goto done; |
| 1555 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1556 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1557 | } |
| 1558 | { // &'try' try_stmt |
| 1559 | stmt_ty try_stmt_var; |
| 1560 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1561 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 511) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1562 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1563 | (try_stmt_var = try_stmt_rule(p)) // try_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1564 | ) |
| 1565 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1566 | _res = try_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1567 | goto done; |
| 1568 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1569 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1570 | } |
| 1571 | { // &'while' while_stmt |
| 1572 | stmt_ty while_stmt_var; |
| 1573 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1574 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 512) // token='while' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1575 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1576 | (while_stmt_var = while_stmt_rule(p)) // while_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1577 | ) |
| 1578 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1579 | _res = while_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1580 | goto done; |
| 1581 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1582 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1583 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1584 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1585 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1586 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1587 | } |
| 1588 | |
| 1589 | // assignment: |
| 1590 | // | NAME ':' expression ['=' annotated_rhs] |
| 1591 | // | ('(' 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] | 1592 | // | ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1593 | // | target augassign (yield_expr | star_expressions) |
| 1594 | // | invalid_assignment |
Lysandros Nikolaou | 999ec9a | 2020-05-06 21:11:04 +0300 | [diff] [blame] | 1595 | static stmt_ty |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1596 | assignment_rule(Parser *p) |
| 1597 | { |
| 1598 | if (p->error_indicator) { |
| 1599 | return NULL; |
| 1600 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1601 | stmt_ty _res = NULL; |
| 1602 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1603 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1604 | p->error_indicator = 1; |
| 1605 | return NULL; |
| 1606 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1607 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1608 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1609 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1610 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1611 | { // NAME ':' expression ['=' annotated_rhs] |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1612 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1613 | expr_ty a; |
| 1614 | expr_ty b; |
| 1615 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1616 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1617 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1618 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1619 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1620 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1621 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1622 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1623 | (c = _tmp_19_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1624 | ) |
| 1625 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1626 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1627 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1628 | return NULL; |
| 1629 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1630 | int _end_lineno = _token->end_lineno; |
| 1631 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1632 | int _end_col_offset = _token->end_col_offset; |
| 1633 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1634 | _res = CHECK_VERSION ( 6 , "Variable annotation syntax is" , _Py_AnnAssign ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , c , 1 , EXTRA ) ); |
| 1635 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1636 | p->error_indicator = 1; |
| 1637 | return NULL; |
| 1638 | } |
| 1639 | goto done; |
| 1640 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1641 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1642 | } |
| 1643 | { // ('(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target) ':' expression ['=' annotated_rhs] |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1644 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1645 | void *a; |
| 1646 | expr_ty b; |
| 1647 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1648 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1649 | (a = _tmp_20_rule(p)) // '(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1650 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1651 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1652 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1653 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1654 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1655 | (c = _tmp_21_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1656 | ) |
| 1657 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1658 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1659 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1660 | return NULL; |
| 1661 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1662 | int _end_lineno = _token->end_lineno; |
| 1663 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1664 | int _end_col_offset = _token->end_col_offset; |
| 1665 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1666 | _res = CHECK_VERSION ( 6 , "Variable annotations syntax is" , _Py_AnnAssign ( a , b , c , 0 , EXTRA ) ); |
| 1667 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1668 | p->error_indicator = 1; |
| 1669 | return NULL; |
| 1670 | } |
| 1671 | goto done; |
| 1672 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1673 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1674 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1675 | { // ((star_targets '='))+ (yield_expr | star_expressions) TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1676 | asdl_seq * a; |
| 1677 | void *b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1678 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1679 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1680 | (a = _loop1_22_rule(p)) // ((star_targets '='))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1681 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1682 | (b = _tmp_23_rule(p)) // yield_expr | star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 1683 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1684 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1685 | ) |
| 1686 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1687 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1688 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1689 | return NULL; |
| 1690 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1691 | int _end_lineno = _token->end_lineno; |
| 1692 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1693 | int _end_col_offset = _token->end_col_offset; |
| 1694 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1695 | _res = _Py_Assign ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 1696 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1697 | p->error_indicator = 1; |
| 1698 | return NULL; |
| 1699 | } |
| 1700 | goto done; |
| 1701 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1702 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1703 | } |
| 1704 | { // target augassign (yield_expr | star_expressions) |
| 1705 | expr_ty a; |
| 1706 | AugOperator* b; |
| 1707 | void *c; |
| 1708 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1709 | (a = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1710 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1711 | (b = augassign_rule(p)) // augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1712 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1713 | (c = _tmp_24_rule(p)) // yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1714 | ) |
| 1715 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1716 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1717 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1718 | return NULL; |
| 1719 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1720 | int _end_lineno = _token->end_lineno; |
| 1721 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 1722 | int _end_col_offset = _token->end_col_offset; |
| 1723 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 1724 | _res = _Py_AugAssign ( a , b -> kind , c , EXTRA ); |
| 1725 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1726 | p->error_indicator = 1; |
| 1727 | return NULL; |
| 1728 | } |
| 1729 | goto done; |
| 1730 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1731 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1732 | } |
| 1733 | { // invalid_assignment |
| 1734 | void *invalid_assignment_var; |
| 1735 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1736 | (invalid_assignment_var = invalid_assignment_rule(p)) // invalid_assignment |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1737 | ) |
| 1738 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1739 | _res = invalid_assignment_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1740 | goto done; |
| 1741 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1742 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1743 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1744 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1745 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1746 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1747 | } |
| 1748 | |
| 1749 | // augassign: |
| 1750 | // | '+=' |
| 1751 | // | '-=' |
| 1752 | // | '*=' |
| 1753 | // | '@=' |
| 1754 | // | '/=' |
| 1755 | // | '%=' |
| 1756 | // | '&=' |
| 1757 | // | '|=' |
| 1758 | // | '^=' |
| 1759 | // | '<<=' |
| 1760 | // | '>>=' |
| 1761 | // | '**=' |
| 1762 | // | '//=' |
| 1763 | static AugOperator* |
| 1764 | augassign_rule(Parser *p) |
| 1765 | { |
| 1766 | if (p->error_indicator) { |
| 1767 | return NULL; |
| 1768 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1769 | AugOperator* _res = NULL; |
| 1770 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1771 | { // '+=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1772 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1773 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1774 | (_literal = _PyPegen_expect_token(p, 36)) // token='+=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1775 | ) |
| 1776 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1777 | _res = _PyPegen_augoperator ( p , Add ); |
| 1778 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1779 | p->error_indicator = 1; |
| 1780 | return NULL; |
| 1781 | } |
| 1782 | goto done; |
| 1783 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1784 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1785 | } |
| 1786 | { // '-=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1787 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1788 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1789 | (_literal = _PyPegen_expect_token(p, 37)) // token='-=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1790 | ) |
| 1791 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1792 | _res = _PyPegen_augoperator ( p , Sub ); |
| 1793 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1794 | p->error_indicator = 1; |
| 1795 | return NULL; |
| 1796 | } |
| 1797 | goto done; |
| 1798 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1799 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1800 | } |
| 1801 | { // '*=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1802 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1803 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1804 | (_literal = _PyPegen_expect_token(p, 38)) // token='*=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1805 | ) |
| 1806 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1807 | _res = _PyPegen_augoperator ( p , Mult ); |
| 1808 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1809 | p->error_indicator = 1; |
| 1810 | return NULL; |
| 1811 | } |
| 1812 | goto done; |
| 1813 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1814 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1815 | } |
| 1816 | { // '@=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1817 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1818 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1819 | (_literal = _PyPegen_expect_token(p, 50)) // token='@=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1820 | ) |
| 1821 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1822 | _res = CHECK_VERSION ( 5 , "The '@' operator is" , _PyPegen_augoperator ( p , MatMult ) ); |
| 1823 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1824 | p->error_indicator = 1; |
| 1825 | return NULL; |
| 1826 | } |
| 1827 | goto done; |
| 1828 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1829 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1830 | } |
| 1831 | { // '/=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1832 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1833 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1834 | (_literal = _PyPegen_expect_token(p, 39)) // token='/=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1835 | ) |
| 1836 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1837 | _res = _PyPegen_augoperator ( p , Div ); |
| 1838 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1839 | p->error_indicator = 1; |
| 1840 | return NULL; |
| 1841 | } |
| 1842 | goto done; |
| 1843 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1844 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1845 | } |
| 1846 | { // '%=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1847 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1848 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1849 | (_literal = _PyPegen_expect_token(p, 40)) // token='%=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1850 | ) |
| 1851 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1852 | _res = _PyPegen_augoperator ( p , Mod ); |
| 1853 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1854 | p->error_indicator = 1; |
| 1855 | return NULL; |
| 1856 | } |
| 1857 | goto done; |
| 1858 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1859 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1860 | } |
| 1861 | { // '&=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1862 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1863 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1864 | (_literal = _PyPegen_expect_token(p, 41)) // token='&=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1865 | ) |
| 1866 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1867 | _res = _PyPegen_augoperator ( p , BitAnd ); |
| 1868 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1869 | p->error_indicator = 1; |
| 1870 | return NULL; |
| 1871 | } |
| 1872 | goto done; |
| 1873 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1874 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1875 | } |
| 1876 | { // '|=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1877 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1878 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1879 | (_literal = _PyPegen_expect_token(p, 42)) // token='|=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1880 | ) |
| 1881 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1882 | _res = _PyPegen_augoperator ( p , BitOr ); |
| 1883 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1884 | p->error_indicator = 1; |
| 1885 | return NULL; |
| 1886 | } |
| 1887 | goto done; |
| 1888 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1889 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1890 | } |
| 1891 | { // '^=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1892 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1893 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1894 | (_literal = _PyPegen_expect_token(p, 43)) // token='^=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1895 | ) |
| 1896 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1897 | _res = _PyPegen_augoperator ( p , BitXor ); |
| 1898 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1899 | p->error_indicator = 1; |
| 1900 | return NULL; |
| 1901 | } |
| 1902 | goto done; |
| 1903 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1904 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1905 | } |
| 1906 | { // '<<=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1907 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1908 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1909 | (_literal = _PyPegen_expect_token(p, 44)) // token='<<=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1910 | ) |
| 1911 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1912 | _res = _PyPegen_augoperator ( p , LShift ); |
| 1913 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1914 | p->error_indicator = 1; |
| 1915 | return NULL; |
| 1916 | } |
| 1917 | goto done; |
| 1918 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1919 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1920 | } |
| 1921 | { // '>>=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1922 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1923 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1924 | (_literal = _PyPegen_expect_token(p, 45)) // token='>>=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1925 | ) |
| 1926 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1927 | _res = _PyPegen_augoperator ( p , RShift ); |
| 1928 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1929 | p->error_indicator = 1; |
| 1930 | return NULL; |
| 1931 | } |
| 1932 | goto done; |
| 1933 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1934 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1935 | } |
| 1936 | { // '**=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1937 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1938 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1939 | (_literal = _PyPegen_expect_token(p, 46)) // token='**=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1940 | ) |
| 1941 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1942 | _res = _PyPegen_augoperator ( p , Pow ); |
| 1943 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1944 | p->error_indicator = 1; |
| 1945 | return NULL; |
| 1946 | } |
| 1947 | goto done; |
| 1948 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1949 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1950 | } |
| 1951 | { // '//=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1952 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1953 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1954 | (_literal = _PyPegen_expect_token(p, 48)) // token='//=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1955 | ) |
| 1956 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1957 | _res = _PyPegen_augoperator ( p , FloorDiv ); |
| 1958 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1959 | p->error_indicator = 1; |
| 1960 | return NULL; |
| 1961 | } |
| 1962 | goto done; |
| 1963 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1964 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1965 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1966 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1967 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1968 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1969 | } |
| 1970 | |
| 1971 | // global_stmt: 'global' ','.NAME+ |
| 1972 | static stmt_ty |
| 1973 | global_stmt_rule(Parser *p) |
| 1974 | { |
| 1975 | if (p->error_indicator) { |
| 1976 | return NULL; |
| 1977 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1978 | stmt_ty _res = NULL; |
| 1979 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1980 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 1981 | p->error_indicator = 1; |
| 1982 | return NULL; |
| 1983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1984 | int _start_lineno = p->tokens[_mark]->lineno; |
| 1985 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 1986 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 1987 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1988 | { // 'global' ','.NAME+ |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1989 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1990 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1991 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1992 | (_keyword = _PyPegen_expect_token(p, 508)) // token='global' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1993 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 1994 | (a = _gather_25_rule(p)) // ','.NAME+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1995 | ) |
| 1996 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 1997 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 1998 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 1999 | return NULL; |
| 2000 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2001 | int _end_lineno = _token->end_lineno; |
| 2002 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2003 | int _end_col_offset = _token->end_col_offset; |
| 2004 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2005 | _res = _Py_Global ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
| 2006 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2007 | p->error_indicator = 1; |
| 2008 | return NULL; |
| 2009 | } |
| 2010 | goto done; |
| 2011 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2012 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2013 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2014 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2015 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2016 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2017 | } |
| 2018 | |
| 2019 | // nonlocal_stmt: 'nonlocal' ','.NAME+ |
| 2020 | static stmt_ty |
| 2021 | nonlocal_stmt_rule(Parser *p) |
| 2022 | { |
| 2023 | if (p->error_indicator) { |
| 2024 | return NULL; |
| 2025 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2026 | stmt_ty _res = NULL; |
| 2027 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2028 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2029 | p->error_indicator = 1; |
| 2030 | return NULL; |
| 2031 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2032 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2033 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2034 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2035 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2036 | { // 'nonlocal' ','.NAME+ |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2037 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2038 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2039 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2040 | (_keyword = _PyPegen_expect_token(p, 509)) // token='nonlocal' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2041 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2042 | (a = _gather_27_rule(p)) // ','.NAME+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2043 | ) |
| 2044 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2045 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2046 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2047 | return NULL; |
| 2048 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2049 | int _end_lineno = _token->end_lineno; |
| 2050 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2051 | int _end_col_offset = _token->end_col_offset; |
| 2052 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2053 | _res = _Py_Nonlocal ( CHECK ( _PyPegen_map_names_to_ids ( p , a ) ) , EXTRA ); |
| 2054 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2055 | p->error_indicator = 1; |
| 2056 | return NULL; |
| 2057 | } |
| 2058 | goto done; |
| 2059 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2060 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2061 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2062 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2063 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2064 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2065 | } |
| 2066 | |
| 2067 | // yield_stmt: yield_expr |
| 2068 | static stmt_ty |
| 2069 | yield_stmt_rule(Parser *p) |
| 2070 | { |
| 2071 | if (p->error_indicator) { |
| 2072 | return NULL; |
| 2073 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2074 | stmt_ty _res = NULL; |
| 2075 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2076 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2077 | p->error_indicator = 1; |
| 2078 | return NULL; |
| 2079 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2080 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2081 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2082 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2083 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2084 | { // yield_expr |
| 2085 | expr_ty y; |
| 2086 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2087 | (y = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2088 | ) |
| 2089 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2090 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2091 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2092 | return NULL; |
| 2093 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2094 | int _end_lineno = _token->end_lineno; |
| 2095 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2096 | int _end_col_offset = _token->end_col_offset; |
| 2097 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2098 | _res = _Py_Expr ( y , EXTRA ); |
| 2099 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2100 | p->error_indicator = 1; |
| 2101 | return NULL; |
| 2102 | } |
| 2103 | goto done; |
| 2104 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2105 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2106 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2107 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2108 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2109 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2110 | } |
| 2111 | |
| 2112 | // assert_stmt: 'assert' expression [',' expression] |
| 2113 | static stmt_ty |
| 2114 | assert_stmt_rule(Parser *p) |
| 2115 | { |
| 2116 | if (p->error_indicator) { |
| 2117 | return NULL; |
| 2118 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2119 | stmt_ty _res = NULL; |
| 2120 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2121 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2122 | p->error_indicator = 1; |
| 2123 | return NULL; |
| 2124 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2125 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2126 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2127 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2128 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2129 | { // 'assert' expression [',' expression] |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2130 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2131 | expr_ty a; |
| 2132 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2133 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2134 | (_keyword = _PyPegen_expect_token(p, 505)) // token='assert' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2135 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2136 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2137 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2138 | (b = _tmp_29_rule(p), 1) // [',' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2139 | ) |
| 2140 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2141 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2142 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2143 | return NULL; |
| 2144 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2145 | int _end_lineno = _token->end_lineno; |
| 2146 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2147 | int _end_col_offset = _token->end_col_offset; |
| 2148 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2149 | _res = _Py_Assert ( a , b , EXTRA ); |
| 2150 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2151 | p->error_indicator = 1; |
| 2152 | return NULL; |
| 2153 | } |
| 2154 | goto done; |
| 2155 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2156 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2157 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2158 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2159 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2160 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2161 | } |
| 2162 | |
| 2163 | // del_stmt: 'del' del_targets |
| 2164 | static stmt_ty |
| 2165 | del_stmt_rule(Parser *p) |
| 2166 | { |
| 2167 | if (p->error_indicator) { |
| 2168 | return NULL; |
| 2169 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2170 | stmt_ty _res = NULL; |
| 2171 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2172 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2173 | p->error_indicator = 1; |
| 2174 | return NULL; |
| 2175 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2176 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2177 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2178 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2179 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2180 | { // 'del' del_targets |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2181 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2182 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2183 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2184 | (_keyword = _PyPegen_expect_token(p, 503)) // token='del' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2185 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2186 | (a = del_targets_rule(p)) // del_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2187 | ) |
| 2188 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2189 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2190 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2191 | return NULL; |
| 2192 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2193 | int _end_lineno = _token->end_lineno; |
| 2194 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2195 | int _end_col_offset = _token->end_col_offset; |
| 2196 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2197 | _res = _Py_Delete ( a , EXTRA ); |
| 2198 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2199 | p->error_indicator = 1; |
| 2200 | return NULL; |
| 2201 | } |
| 2202 | goto done; |
| 2203 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2204 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2205 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2206 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2207 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2208 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2209 | } |
| 2210 | |
| 2211 | // import_stmt: import_name | import_from |
| 2212 | static stmt_ty |
| 2213 | import_stmt_rule(Parser *p) |
| 2214 | { |
| 2215 | if (p->error_indicator) { |
| 2216 | return NULL; |
| 2217 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2218 | stmt_ty _res = NULL; |
| 2219 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2220 | { // import_name |
| 2221 | stmt_ty import_name_var; |
| 2222 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2223 | (import_name_var = import_name_rule(p)) // import_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2224 | ) |
| 2225 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2226 | _res = import_name_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2227 | goto done; |
| 2228 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2229 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2230 | } |
| 2231 | { // import_from |
| 2232 | stmt_ty import_from_var; |
| 2233 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2234 | (import_from_var = import_from_rule(p)) // import_from |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2235 | ) |
| 2236 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2237 | _res = import_from_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2238 | goto done; |
| 2239 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2240 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2241 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2242 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2243 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2244 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2245 | } |
| 2246 | |
| 2247 | // import_name: 'import' dotted_as_names |
| 2248 | static stmt_ty |
| 2249 | import_name_rule(Parser *p) |
| 2250 | { |
| 2251 | if (p->error_indicator) { |
| 2252 | return NULL; |
| 2253 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2254 | stmt_ty _res = NULL; |
| 2255 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2256 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2257 | p->error_indicator = 1; |
| 2258 | return NULL; |
| 2259 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2260 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2261 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2262 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2263 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2264 | { // 'import' dotted_as_names |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2265 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2266 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2267 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2268 | (_keyword = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2269 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2270 | (a = dotted_as_names_rule(p)) // dotted_as_names |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2271 | ) |
| 2272 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2273 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2274 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2275 | return NULL; |
| 2276 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2277 | int _end_lineno = _token->end_lineno; |
| 2278 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2279 | int _end_col_offset = _token->end_col_offset; |
| 2280 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2281 | _res = _Py_Import ( a , EXTRA ); |
| 2282 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2283 | p->error_indicator = 1; |
| 2284 | return NULL; |
| 2285 | } |
| 2286 | goto done; |
| 2287 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2288 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2289 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2290 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2291 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2292 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2293 | } |
| 2294 | |
| 2295 | // import_from: |
| 2296 | // | 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
| 2297 | // | 'from' (('.' | '...'))+ 'import' import_from_targets |
| 2298 | static stmt_ty |
| 2299 | import_from_rule(Parser *p) |
| 2300 | { |
| 2301 | if (p->error_indicator) { |
| 2302 | return NULL; |
| 2303 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2304 | stmt_ty _res = NULL; |
| 2305 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2306 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2307 | p->error_indicator = 1; |
| 2308 | return NULL; |
| 2309 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2310 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2311 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2312 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2313 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2314 | { // 'from' (('.' | '...'))* dotted_name 'import' import_from_targets |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2315 | Token * _keyword; |
| 2316 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2317 | asdl_seq * a; |
| 2318 | expr_ty b; |
| 2319 | asdl_seq* c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2320 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2321 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2322 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2323 | (a = _loop0_30_rule(p)) // (('.' | '...'))* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2324 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2325 | (b = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2326 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2327 | (_keyword_1 = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2328 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2329 | (c = import_from_targets_rule(p)) // import_from_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2330 | ) |
| 2331 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2332 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2333 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2334 | return NULL; |
| 2335 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2336 | int _end_lineno = _token->end_lineno; |
| 2337 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2338 | int _end_col_offset = _token->end_col_offset; |
| 2339 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2340 | _res = _Py_ImportFrom ( b -> v . Name . id , c , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
| 2341 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2342 | p->error_indicator = 1; |
| 2343 | return NULL; |
| 2344 | } |
| 2345 | goto done; |
| 2346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2347 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2348 | } |
| 2349 | { // 'from' (('.' | '...'))+ 'import' import_from_targets |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2350 | Token * _keyword; |
| 2351 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2352 | asdl_seq * a; |
| 2353 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2354 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2355 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2356 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2357 | (a = _loop1_31_rule(p)) // (('.' | '...'))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2358 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2359 | (_keyword_1 = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2360 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2361 | (b = import_from_targets_rule(p)) // import_from_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2362 | ) |
| 2363 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2364 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2365 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2366 | return NULL; |
| 2367 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2368 | int _end_lineno = _token->end_lineno; |
| 2369 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2370 | int _end_col_offset = _token->end_col_offset; |
| 2371 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2372 | _res = _Py_ImportFrom ( NULL , b , _PyPegen_seq_count_dots ( a ) , EXTRA ); |
| 2373 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2374 | p->error_indicator = 1; |
| 2375 | return NULL; |
| 2376 | } |
| 2377 | goto done; |
| 2378 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2379 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2380 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2381 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2382 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2383 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2384 | } |
| 2385 | |
| 2386 | // import_from_targets: '(' import_from_as_names ','? ')' | import_from_as_names | '*' |
| 2387 | static asdl_seq* |
| 2388 | import_from_targets_rule(Parser *p) |
| 2389 | { |
| 2390 | if (p->error_indicator) { |
| 2391 | return NULL; |
| 2392 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2393 | asdl_seq* _res = NULL; |
| 2394 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2395 | { // '(' import_from_as_names ','? ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2396 | Token * _literal; |
| 2397 | Token * _literal_1; |
| 2398 | void *_opt_var; |
| 2399 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2400 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2401 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2402 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2403 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2404 | (a = import_from_as_names_rule(p)) // import_from_as_names |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2405 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2406 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2407 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2408 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2409 | ) |
| 2410 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2411 | _res = a; |
| 2412 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2413 | p->error_indicator = 1; |
| 2414 | return NULL; |
| 2415 | } |
| 2416 | goto done; |
| 2417 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2418 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2419 | } |
| 2420 | { // import_from_as_names |
| 2421 | asdl_seq* import_from_as_names_var; |
| 2422 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2423 | (import_from_as_names_var = import_from_as_names_rule(p)) // import_from_as_names |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2424 | ) |
| 2425 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2426 | _res = import_from_as_names_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2427 | goto done; |
| 2428 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2429 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2430 | } |
| 2431 | { // '*' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2432 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2433 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2434 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2435 | ) |
| 2436 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2437 | _res = _PyPegen_singleton_seq ( p , CHECK ( _PyPegen_alias_for_star ( p ) ) ); |
| 2438 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2439 | p->error_indicator = 1; |
| 2440 | return NULL; |
| 2441 | } |
| 2442 | goto done; |
| 2443 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2444 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2445 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2446 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2447 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2448 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2449 | } |
| 2450 | |
| 2451 | // import_from_as_names: ','.import_from_as_name+ |
| 2452 | static asdl_seq* |
| 2453 | import_from_as_names_rule(Parser *p) |
| 2454 | { |
| 2455 | if (p->error_indicator) { |
| 2456 | return NULL; |
| 2457 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2458 | asdl_seq* _res = NULL; |
| 2459 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2460 | { // ','.import_from_as_name+ |
| 2461 | asdl_seq * a; |
| 2462 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2463 | (a = _gather_32_rule(p)) // ','.import_from_as_name+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2464 | ) |
| 2465 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2466 | _res = a; |
| 2467 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2468 | p->error_indicator = 1; |
| 2469 | return NULL; |
| 2470 | } |
| 2471 | goto done; |
| 2472 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2473 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2474 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2475 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2476 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2477 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2478 | } |
| 2479 | |
| 2480 | // import_from_as_name: NAME ['as' NAME] |
| 2481 | static alias_ty |
| 2482 | import_from_as_name_rule(Parser *p) |
| 2483 | { |
| 2484 | if (p->error_indicator) { |
| 2485 | return NULL; |
| 2486 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2487 | alias_ty _res = NULL; |
| 2488 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2489 | { // NAME ['as' NAME] |
| 2490 | expr_ty a; |
| 2491 | void *b; |
| 2492 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2493 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2494 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2495 | (b = _tmp_34_rule(p), 1) // ['as' NAME] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2496 | ) |
| 2497 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2498 | _res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena ); |
| 2499 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2500 | p->error_indicator = 1; |
| 2501 | return NULL; |
| 2502 | } |
| 2503 | goto done; |
| 2504 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2505 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2506 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2507 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2508 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2509 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2510 | } |
| 2511 | |
| 2512 | // dotted_as_names: ','.dotted_as_name+ |
| 2513 | static asdl_seq* |
| 2514 | dotted_as_names_rule(Parser *p) |
| 2515 | { |
| 2516 | if (p->error_indicator) { |
| 2517 | return NULL; |
| 2518 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2519 | asdl_seq* _res = NULL; |
| 2520 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2521 | { // ','.dotted_as_name+ |
| 2522 | asdl_seq * a; |
| 2523 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2524 | (a = _gather_35_rule(p)) // ','.dotted_as_name+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2525 | ) |
| 2526 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2527 | _res = a; |
| 2528 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2529 | p->error_indicator = 1; |
| 2530 | return NULL; |
| 2531 | } |
| 2532 | goto done; |
| 2533 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2534 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2535 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2536 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2537 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2538 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2539 | } |
| 2540 | |
| 2541 | // dotted_as_name: dotted_name ['as' NAME] |
| 2542 | static alias_ty |
| 2543 | dotted_as_name_rule(Parser *p) |
| 2544 | { |
| 2545 | if (p->error_indicator) { |
| 2546 | return NULL; |
| 2547 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2548 | alias_ty _res = NULL; |
| 2549 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2550 | { // dotted_name ['as' NAME] |
| 2551 | expr_ty a; |
| 2552 | void *b; |
| 2553 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2554 | (a = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2555 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2556 | (b = _tmp_37_rule(p), 1) // ['as' NAME] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2557 | ) |
| 2558 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2559 | _res = _Py_alias ( a -> v . Name . id , ( b ) ? ( ( expr_ty ) b ) -> v . Name . id : NULL , p -> arena ); |
| 2560 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2561 | p->error_indicator = 1; |
| 2562 | return NULL; |
| 2563 | } |
| 2564 | goto done; |
| 2565 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2566 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2567 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2568 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2569 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2570 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2571 | } |
| 2572 | |
| 2573 | // Left-recursive |
| 2574 | // dotted_name: dotted_name '.' NAME | NAME |
| 2575 | static expr_ty dotted_name_raw(Parser *); |
| 2576 | static expr_ty |
| 2577 | dotted_name_rule(Parser *p) |
| 2578 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2579 | expr_ty _res = NULL; |
| 2580 | if (_PyPegen_is_memoized(p, dotted_name_type, &_res)) |
| 2581 | return _res; |
| 2582 | int _mark = p->mark; |
| 2583 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2584 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2585 | int tmpvar_0 = _PyPegen_update_memo(p, _mark, dotted_name_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2586 | if (tmpvar_0) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2587 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2588 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2589 | p->mark = _mark; |
| 2590 | void *_raw = dotted_name_raw(p); |
| 2591 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2592 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2593 | _resmark = p->mark; |
| 2594 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2595 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2596 | p->mark = _resmark; |
| 2597 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2598 | } |
| 2599 | static expr_ty |
| 2600 | dotted_name_raw(Parser *p) |
| 2601 | { |
| 2602 | if (p->error_indicator) { |
| 2603 | return NULL; |
| 2604 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2605 | expr_ty _res = NULL; |
| 2606 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2607 | { // dotted_name '.' NAME |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2608 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2609 | expr_ty a; |
| 2610 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2611 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2612 | (a = dotted_name_rule(p)) // dotted_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2613 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2614 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2615 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2616 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2617 | ) |
| 2618 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2619 | _res = _PyPegen_join_names_with_dot ( p , a , b ); |
| 2620 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2621 | p->error_indicator = 1; |
| 2622 | return NULL; |
| 2623 | } |
| 2624 | goto done; |
| 2625 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2626 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2627 | } |
| 2628 | { // NAME |
| 2629 | expr_ty name_var; |
| 2630 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2631 | (name_var = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2632 | ) |
| 2633 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2634 | _res = name_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2635 | goto done; |
| 2636 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2637 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2638 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2639 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2640 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2641 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2642 | } |
| 2643 | |
| 2644 | // if_stmt: |
| 2645 | // | 'if' named_expression ':' block elif_stmt |
| 2646 | // | 'if' named_expression ':' block else_block? |
| 2647 | static stmt_ty |
| 2648 | if_stmt_rule(Parser *p) |
| 2649 | { |
| 2650 | if (p->error_indicator) { |
| 2651 | return NULL; |
| 2652 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2653 | stmt_ty _res = NULL; |
| 2654 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2655 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2656 | p->error_indicator = 1; |
| 2657 | return NULL; |
| 2658 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2659 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2660 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2661 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2662 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2663 | { // 'if' named_expression ':' block elif_stmt |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2664 | Token * _keyword; |
| 2665 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2666 | expr_ty a; |
| 2667 | asdl_seq* b; |
| 2668 | stmt_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2669 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2670 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2671 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2672 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2673 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2674 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2675 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2676 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2677 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2678 | (c = elif_stmt_rule(p)) // elif_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2679 | ) |
| 2680 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2681 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2682 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2683 | return NULL; |
| 2684 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2685 | int _end_lineno = _token->end_lineno; |
| 2686 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2687 | int _end_col_offset = _token->end_col_offset; |
| 2688 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2689 | _res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
| 2690 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2691 | p->error_indicator = 1; |
| 2692 | return NULL; |
| 2693 | } |
| 2694 | goto done; |
| 2695 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2696 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2697 | } |
| 2698 | { // 'if' named_expression ':' block else_block? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2699 | Token * _keyword; |
| 2700 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2701 | expr_ty a; |
| 2702 | asdl_seq* b; |
| 2703 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2704 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2705 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2706 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2707 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2708 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2709 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2710 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2711 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2712 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2713 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2714 | ) |
| 2715 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2716 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2717 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2718 | return NULL; |
| 2719 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2720 | int _end_lineno = _token->end_lineno; |
| 2721 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2722 | int _end_col_offset = _token->end_col_offset; |
| 2723 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2724 | _res = _Py_If ( a , b , c , EXTRA ); |
| 2725 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2726 | p->error_indicator = 1; |
| 2727 | return NULL; |
| 2728 | } |
| 2729 | goto done; |
| 2730 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2731 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2732 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2733 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2734 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2735 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2736 | } |
| 2737 | |
| 2738 | // elif_stmt: |
| 2739 | // | 'elif' named_expression ':' block elif_stmt |
| 2740 | // | 'elif' named_expression ':' block else_block? |
| 2741 | static stmt_ty |
| 2742 | elif_stmt_rule(Parser *p) |
| 2743 | { |
| 2744 | if (p->error_indicator) { |
| 2745 | return NULL; |
| 2746 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2747 | stmt_ty _res = NULL; |
| 2748 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2749 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2750 | p->error_indicator = 1; |
| 2751 | return NULL; |
| 2752 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2753 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2754 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2755 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2756 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2757 | { // 'elif' named_expression ':' block elif_stmt |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2758 | Token * _keyword; |
| 2759 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2760 | expr_ty a; |
| 2761 | asdl_seq* b; |
| 2762 | stmt_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2763 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2764 | (_keyword = _PyPegen_expect_token(p, 515)) // token='elif' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2765 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2766 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2767 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2768 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2769 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2770 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2771 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2772 | (c = elif_stmt_rule(p)) // elif_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2773 | ) |
| 2774 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2775 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2776 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2777 | return NULL; |
| 2778 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2779 | int _end_lineno = _token->end_lineno; |
| 2780 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2781 | int _end_col_offset = _token->end_col_offset; |
| 2782 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2783 | _res = _Py_If ( a , b , CHECK ( _PyPegen_singleton_seq ( p , c ) ) , EXTRA ); |
| 2784 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2785 | p->error_indicator = 1; |
| 2786 | return NULL; |
| 2787 | } |
| 2788 | goto done; |
| 2789 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2790 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2791 | } |
| 2792 | { // 'elif' named_expression ':' block else_block? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2793 | Token * _keyword; |
| 2794 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2795 | expr_ty a; |
| 2796 | asdl_seq* b; |
| 2797 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2798 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2799 | (_keyword = _PyPegen_expect_token(p, 515)) // token='elif' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2800 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2801 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2802 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2803 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2804 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2805 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2806 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2807 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2808 | ) |
| 2809 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2810 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2811 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2812 | return NULL; |
| 2813 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2814 | int _end_lineno = _token->end_lineno; |
| 2815 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2816 | int _end_col_offset = _token->end_col_offset; |
| 2817 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2818 | _res = _Py_If ( a , b , c , EXTRA ); |
| 2819 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2820 | p->error_indicator = 1; |
| 2821 | return NULL; |
| 2822 | } |
| 2823 | goto done; |
| 2824 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2825 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2826 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2827 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2828 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2829 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2830 | } |
| 2831 | |
| 2832 | // else_block: 'else' ':' block |
| 2833 | static asdl_seq* |
| 2834 | else_block_rule(Parser *p) |
| 2835 | { |
| 2836 | if (p->error_indicator) { |
| 2837 | return NULL; |
| 2838 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2839 | asdl_seq* _res = NULL; |
| 2840 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2841 | { // 'else' ':' block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2842 | Token * _keyword; |
| 2843 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2844 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2845 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2846 | (_keyword = _PyPegen_expect_token(p, 516)) // token='else' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2847 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2848 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2849 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2850 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2851 | ) |
| 2852 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2853 | _res = b; |
| 2854 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2855 | p->error_indicator = 1; |
| 2856 | return NULL; |
| 2857 | } |
| 2858 | goto done; |
| 2859 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2860 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2861 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2862 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2863 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2864 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2865 | } |
| 2866 | |
| 2867 | // while_stmt: 'while' named_expression ':' block else_block? |
| 2868 | static stmt_ty |
| 2869 | while_stmt_rule(Parser *p) |
| 2870 | { |
| 2871 | if (p->error_indicator) { |
| 2872 | return NULL; |
| 2873 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2874 | stmt_ty _res = NULL; |
| 2875 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2876 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2877 | p->error_indicator = 1; |
| 2878 | return NULL; |
| 2879 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2880 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2881 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2882 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2883 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2884 | { // 'while' named_expression ':' block else_block? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2885 | Token * _keyword; |
| 2886 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2887 | expr_ty a; |
| 2888 | asdl_seq* b; |
| 2889 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2890 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2891 | (_keyword = _PyPegen_expect_token(p, 512)) // token='while' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2892 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2893 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2894 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2895 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2896 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2897 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2898 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2899 | (c = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2900 | ) |
| 2901 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2902 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2903 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2904 | return NULL; |
| 2905 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2906 | int _end_lineno = _token->end_lineno; |
| 2907 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2908 | int _end_col_offset = _token->end_col_offset; |
| 2909 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2910 | _res = _Py_While ( a , b , c , EXTRA ); |
| 2911 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2912 | p->error_indicator = 1; |
| 2913 | return NULL; |
| 2914 | } |
| 2915 | goto done; |
| 2916 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2917 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2918 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2919 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2920 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2921 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2922 | } |
| 2923 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2924 | // for_stmt: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2925 | // | 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
| 2926 | // | ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2927 | static stmt_ty |
| 2928 | for_stmt_rule(Parser *p) |
| 2929 | { |
| 2930 | if (p->error_indicator) { |
| 2931 | return NULL; |
| 2932 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2933 | stmt_ty _res = NULL; |
| 2934 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2935 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 2936 | p->error_indicator = 1; |
| 2937 | return NULL; |
| 2938 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2939 | int _start_lineno = p->tokens[_mark]->lineno; |
| 2940 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 2941 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 2942 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2943 | { // 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2944 | Token * _keyword; |
| 2945 | Token * _keyword_1; |
| 2946 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2947 | asdl_seq* b; |
| 2948 | void *el; |
| 2949 | expr_ty ex; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2950 | expr_ty t; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 2951 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2952 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2953 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2954 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2955 | (t = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2956 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2957 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2958 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2959 | (ex = star_expressions_rule(p)) // star_expressions |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2960 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2961 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2962 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2963 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2964 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2965 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2966 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2967 | (el = else_block_rule(p), 1) // else_block? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2968 | ) |
| 2969 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2970 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 2971 | if (_token == NULL) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2972 | return NULL; |
| 2973 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2974 | int _end_lineno = _token->end_lineno; |
| 2975 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 2976 | int _end_col_offset = _token->end_col_offset; |
| 2977 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 2978 | _res = _Py_For ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 2979 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2980 | p->error_indicator = 1; |
| 2981 | return NULL; |
| 2982 | } |
| 2983 | goto done; |
| 2984 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2985 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2986 | } |
| 2987 | { // ASYNC 'for' star_targets 'in' star_expressions ':' TYPE_COMMENT? block else_block? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 2988 | Token * _keyword; |
| 2989 | Token * _keyword_1; |
| 2990 | Token * _literal; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 2991 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2992 | asdl_seq* b; |
| 2993 | void *el; |
| 2994 | expr_ty ex; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 2995 | expr_ty t; |
| 2996 | void *tc; |
| 2997 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 2998 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 2999 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3000 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3001 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3002 | (t = star_targets_rule(p)) // star_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3003 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3004 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3005 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3006 | (ex = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3007 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3008 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3009 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3010 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3011 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3012 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3013 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3014 | (el = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3015 | ) |
| 3016 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3017 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3018 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3019 | return NULL; |
| 3020 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3021 | int _end_lineno = _token->end_lineno; |
| 3022 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3023 | int _end_col_offset = _token->end_col_offset; |
| 3024 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3025 | _res = CHECK_VERSION ( 5 , "Async for loops are" , _Py_AsyncFor ( t , ex , b , el , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
| 3026 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3027 | p->error_indicator = 1; |
| 3028 | return NULL; |
| 3029 | } |
| 3030 | goto done; |
| 3031 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3032 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3033 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3034 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3035 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3036 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3037 | } |
| 3038 | |
| 3039 | // with_stmt: |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3040 | // | 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3041 | // | 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3042 | // | ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3043 | // | ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3044 | static stmt_ty |
| 3045 | with_stmt_rule(Parser *p) |
| 3046 | { |
| 3047 | if (p->error_indicator) { |
| 3048 | return NULL; |
| 3049 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3050 | stmt_ty _res = NULL; |
| 3051 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3052 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3053 | p->error_indicator = 1; |
| 3054 | return NULL; |
| 3055 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3056 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3057 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3058 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3059 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3060 | { // 'with' '(' ','.with_item+ ','? ')' ':' block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3061 | Token * _keyword; |
| 3062 | Token * _literal; |
| 3063 | Token * _literal_1; |
| 3064 | Token * _literal_2; |
| 3065 | void *_opt_var; |
| 3066 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3067 | asdl_seq * a; |
| 3068 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3069 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3070 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3071 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3072 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3073 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3074 | (a = _gather_38_rule(p)) // ','.with_item+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3075 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3076 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3077 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3078 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3079 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3080 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3081 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3082 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3083 | ) |
| 3084 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3085 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3086 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3087 | return NULL; |
| 3088 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3089 | int _end_lineno = _token->end_lineno; |
| 3090 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3091 | int _end_col_offset = _token->end_col_offset; |
| 3092 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3093 | _res = _Py_With ( a , b , NULL , EXTRA ); |
| 3094 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3095 | p->error_indicator = 1; |
| 3096 | return NULL; |
| 3097 | } |
| 3098 | goto done; |
| 3099 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3100 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3101 | } |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3102 | { // 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3103 | Token * _keyword; |
| 3104 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3105 | asdl_seq * a; |
| 3106 | asdl_seq* b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3107 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3108 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3109 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3110 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3111 | (a = _gather_40_rule(p)) // ','.with_item+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3112 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3113 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3114 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3115 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3116 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3117 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3118 | ) |
| 3119 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3120 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3121 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3122 | return NULL; |
| 3123 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3124 | int _end_lineno = _token->end_lineno; |
| 3125 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3126 | int _end_col_offset = _token->end_col_offset; |
| 3127 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3128 | _res = _Py_With ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 3129 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3130 | p->error_indicator = 1; |
| 3131 | return NULL; |
| 3132 | } |
| 3133 | goto done; |
| 3134 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3135 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3136 | } |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3137 | { // ASYNC 'with' '(' ','.with_item+ ','? ')' ':' block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3138 | Token * _keyword; |
| 3139 | Token * _literal; |
| 3140 | Token * _literal_1; |
| 3141 | Token * _literal_2; |
| 3142 | void *_opt_var; |
| 3143 | UNUSED(_opt_var); // Silence compiler warnings |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3144 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3145 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3146 | asdl_seq* b; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3147 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3148 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3149 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3150 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3151 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3152 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3153 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3154 | (a = _gather_42_rule(p)) // ','.with_item+ |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3155 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3156 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | 99db2a1 | 2020-05-06 22:54:34 +0100 | [diff] [blame] | 3157 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3158 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3159 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3160 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3161 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3162 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3163 | ) |
| 3164 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3165 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3166 | if (_token == NULL) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3167 | return NULL; |
| 3168 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3169 | int _end_lineno = _token->end_lineno; |
| 3170 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3171 | int _end_col_offset = _token->end_col_offset; |
| 3172 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3173 | _res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NULL , EXTRA ) ); |
| 3174 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3175 | p->error_indicator = 1; |
| 3176 | return NULL; |
| 3177 | } |
| 3178 | goto done; |
| 3179 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3180 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3181 | } |
| 3182 | { // ASYNC 'with' ','.with_item+ ':' TYPE_COMMENT? block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3183 | Token * _keyword; |
| 3184 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3185 | asdl_seq * a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3186 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3187 | asdl_seq* b; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3188 | void *tc; |
| 3189 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3190 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3191 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3192 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3193 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3194 | (a = _gather_44_rule(p)) // ','.with_item+ |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3195 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3196 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3197 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3198 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3199 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3200 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3201 | ) |
| 3202 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3203 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3204 | if (_token == NULL) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3205 | return NULL; |
| 3206 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3207 | int _end_lineno = _token->end_lineno; |
| 3208 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3209 | int _end_col_offset = _token->end_col_offset; |
| 3210 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3211 | _res = CHECK_VERSION ( 5 , "Async with statements are" , _Py_AsyncWith ( a , b , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ) ); |
| 3212 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3213 | p->error_indicator = 1; |
| 3214 | return NULL; |
| 3215 | } |
| 3216 | goto done; |
| 3217 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3218 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3219 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3220 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3221 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3222 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3223 | } |
| 3224 | |
| 3225 | // with_item: expression ['as' target] |
| 3226 | static withitem_ty |
| 3227 | with_item_rule(Parser *p) |
| 3228 | { |
| 3229 | if (p->error_indicator) { |
| 3230 | return NULL; |
| 3231 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3232 | withitem_ty _res = NULL; |
| 3233 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3234 | { // expression ['as' target] |
| 3235 | expr_ty e; |
| 3236 | void *o; |
| 3237 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3238 | (e = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3239 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3240 | (o = _tmp_46_rule(p), 1) // ['as' target] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3241 | ) |
| 3242 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3243 | _res = _Py_withitem ( e , o , p -> arena ); |
| 3244 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3245 | p->error_indicator = 1; |
| 3246 | return NULL; |
| 3247 | } |
| 3248 | goto done; |
| 3249 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3250 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3251 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3252 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3253 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3254 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3255 | } |
| 3256 | |
| 3257 | // try_stmt: |
| 3258 | // | 'try' ':' block finally_block |
| 3259 | // | 'try' ':' block except_block+ else_block? finally_block? |
| 3260 | static stmt_ty |
| 3261 | try_stmt_rule(Parser *p) |
| 3262 | { |
| 3263 | if (p->error_indicator) { |
| 3264 | return NULL; |
| 3265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3266 | stmt_ty _res = NULL; |
| 3267 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3268 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3269 | p->error_indicator = 1; |
| 3270 | return NULL; |
| 3271 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3272 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3273 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3274 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3275 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3276 | { // 'try' ':' block finally_block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3277 | Token * _keyword; |
| 3278 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3279 | asdl_seq* b; |
| 3280 | asdl_seq* f; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3281 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3282 | (_keyword = _PyPegen_expect_token(p, 511)) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3283 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3284 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3285 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3286 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3287 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3288 | (f = finally_block_rule(p)) // finally_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3289 | ) |
| 3290 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3291 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3292 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3293 | return NULL; |
| 3294 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3295 | int _end_lineno = _token->end_lineno; |
| 3296 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3297 | int _end_col_offset = _token->end_col_offset; |
| 3298 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3299 | _res = _Py_Try ( b , NULL , NULL , f , EXTRA ); |
| 3300 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3301 | p->error_indicator = 1; |
| 3302 | return NULL; |
| 3303 | } |
| 3304 | goto done; |
| 3305 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3306 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3307 | } |
| 3308 | { // 'try' ':' block except_block+ else_block? finally_block? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3309 | Token * _keyword; |
| 3310 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3311 | asdl_seq* b; |
| 3312 | void *el; |
| 3313 | asdl_seq * ex; |
| 3314 | void *f; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3315 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3316 | (_keyword = _PyPegen_expect_token(p, 511)) // token='try' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3317 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3318 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3319 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3320 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3321 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3322 | (ex = _loop1_47_rule(p)) // except_block+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3323 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3324 | (el = else_block_rule(p), 1) // else_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3325 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3326 | (f = finally_block_rule(p), 1) // finally_block? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3327 | ) |
| 3328 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3329 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3330 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3331 | return NULL; |
| 3332 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3333 | int _end_lineno = _token->end_lineno; |
| 3334 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3335 | int _end_col_offset = _token->end_col_offset; |
| 3336 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3337 | _res = _Py_Try ( b , ex , el , f , EXTRA ); |
| 3338 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3339 | p->error_indicator = 1; |
| 3340 | return NULL; |
| 3341 | } |
| 3342 | goto done; |
| 3343 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3344 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3345 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3346 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3347 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3348 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3349 | } |
| 3350 | |
| 3351 | // except_block: 'except' expression ['as' target] ':' block | 'except' ':' block |
| 3352 | static excepthandler_ty |
| 3353 | except_block_rule(Parser *p) |
| 3354 | { |
| 3355 | if (p->error_indicator) { |
| 3356 | return NULL; |
| 3357 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3358 | excepthandler_ty _res = NULL; |
| 3359 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3360 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3361 | p->error_indicator = 1; |
| 3362 | return NULL; |
| 3363 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3364 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3365 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3366 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3367 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3368 | { // 'except' expression ['as' target] ':' block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3369 | Token * _keyword; |
| 3370 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3371 | asdl_seq* b; |
| 3372 | expr_ty e; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3373 | void *t; |
| 3374 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3375 | (_keyword = _PyPegen_expect_token(p, 520)) // token='except' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3376 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3377 | (e = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3378 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3379 | (t = _tmp_48_rule(p), 1) // ['as' target] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3380 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3381 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3382 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3383 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3384 | ) |
| 3385 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3386 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3387 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3388 | return NULL; |
| 3389 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3390 | int _end_lineno = _token->end_lineno; |
| 3391 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3392 | int _end_col_offset = _token->end_col_offset; |
| 3393 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3394 | _res = _Py_ExceptHandler ( e , ( t ) ? ( ( expr_ty ) t ) -> v . Name . id : NULL , b , EXTRA ); |
| 3395 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3396 | p->error_indicator = 1; |
| 3397 | return NULL; |
| 3398 | } |
| 3399 | goto done; |
| 3400 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3401 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3402 | } |
| 3403 | { // 'except' ':' block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3404 | Token * _keyword; |
| 3405 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3406 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3407 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3408 | (_keyword = _PyPegen_expect_token(p, 520)) // token='except' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3409 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3410 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3411 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3412 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3413 | ) |
| 3414 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3415 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3416 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3417 | return NULL; |
| 3418 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3419 | int _end_lineno = _token->end_lineno; |
| 3420 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3421 | int _end_col_offset = _token->end_col_offset; |
| 3422 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3423 | _res = _Py_ExceptHandler ( NULL , NULL , b , EXTRA ); |
| 3424 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3425 | p->error_indicator = 1; |
| 3426 | return NULL; |
| 3427 | } |
| 3428 | goto done; |
| 3429 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3430 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3431 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3432 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3433 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3434 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3435 | } |
| 3436 | |
| 3437 | // finally_block: 'finally' ':' block |
| 3438 | static asdl_seq* |
| 3439 | finally_block_rule(Parser *p) |
| 3440 | { |
| 3441 | if (p->error_indicator) { |
| 3442 | return NULL; |
| 3443 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3444 | asdl_seq* _res = NULL; |
| 3445 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3446 | { // 'finally' ':' block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3447 | Token * _keyword; |
| 3448 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3449 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3450 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3451 | (_keyword = _PyPegen_expect_token(p, 521)) // token='finally' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3452 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3453 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3454 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3455 | (a = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3456 | ) |
| 3457 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3458 | _res = a; |
| 3459 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3460 | p->error_indicator = 1; |
| 3461 | return NULL; |
| 3462 | } |
| 3463 | goto done; |
| 3464 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3465 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3466 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3467 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3468 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3469 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3470 | } |
| 3471 | |
| 3472 | // return_stmt: 'return' star_expressions? |
| 3473 | static stmt_ty |
| 3474 | return_stmt_rule(Parser *p) |
| 3475 | { |
| 3476 | if (p->error_indicator) { |
| 3477 | return NULL; |
| 3478 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3479 | stmt_ty _res = NULL; |
| 3480 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3481 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3482 | p->error_indicator = 1; |
| 3483 | return NULL; |
| 3484 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3485 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3486 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3487 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3488 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3489 | { // 'return' star_expressions? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3490 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3491 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3492 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3493 | (_keyword = _PyPegen_expect_token(p, 500)) // token='return' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3494 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3495 | (a = star_expressions_rule(p), 1) // star_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3496 | ) |
| 3497 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3498 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3499 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3500 | return NULL; |
| 3501 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3502 | int _end_lineno = _token->end_lineno; |
| 3503 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3504 | int _end_col_offset = _token->end_col_offset; |
| 3505 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3506 | _res = _Py_Return ( a , EXTRA ); |
| 3507 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3508 | p->error_indicator = 1; |
| 3509 | return NULL; |
| 3510 | } |
| 3511 | goto done; |
| 3512 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3513 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3514 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3515 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3516 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3517 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3518 | } |
| 3519 | |
| 3520 | // raise_stmt: 'raise' expression ['from' expression] | 'raise' |
| 3521 | static stmt_ty |
| 3522 | raise_stmt_rule(Parser *p) |
| 3523 | { |
| 3524 | if (p->error_indicator) { |
| 3525 | return NULL; |
| 3526 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3527 | stmt_ty _res = NULL; |
| 3528 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3529 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3530 | p->error_indicator = 1; |
| 3531 | return NULL; |
| 3532 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3533 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3534 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3535 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3536 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3537 | { // 'raise' expression ['from' expression] |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3538 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3539 | expr_ty a; |
| 3540 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3541 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3542 | (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3543 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3544 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3545 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3546 | (b = _tmp_49_rule(p), 1) // ['from' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3547 | ) |
| 3548 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3549 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3550 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3551 | return NULL; |
| 3552 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3553 | int _end_lineno = _token->end_lineno; |
| 3554 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3555 | int _end_col_offset = _token->end_col_offset; |
| 3556 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3557 | _res = _Py_Raise ( a , b , EXTRA ); |
| 3558 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3559 | p->error_indicator = 1; |
| 3560 | return NULL; |
| 3561 | } |
| 3562 | goto done; |
| 3563 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3564 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3565 | } |
| 3566 | { // 'raise' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3567 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3568 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3569 | (_keyword = _PyPegen_expect_token(p, 501)) // token='raise' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3570 | ) |
| 3571 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3572 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3573 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3574 | return NULL; |
| 3575 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3576 | int _end_lineno = _token->end_lineno; |
| 3577 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3578 | int _end_col_offset = _token->end_col_offset; |
| 3579 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3580 | _res = _Py_Raise ( NULL , NULL , EXTRA ); |
| 3581 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3582 | p->error_indicator = 1; |
| 3583 | return NULL; |
| 3584 | } |
| 3585 | goto done; |
| 3586 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3587 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3588 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3589 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3590 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3591 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3592 | } |
| 3593 | |
| 3594 | // function_def: decorators function_def_raw | function_def_raw |
| 3595 | static stmt_ty |
| 3596 | function_def_rule(Parser *p) |
| 3597 | { |
| 3598 | if (p->error_indicator) { |
| 3599 | return NULL; |
| 3600 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3601 | stmt_ty _res = NULL; |
| 3602 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3603 | { // decorators function_def_raw |
| 3604 | asdl_seq* d; |
| 3605 | stmt_ty f; |
| 3606 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3607 | (d = decorators_rule(p)) // decorators |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3608 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3609 | (f = function_def_raw_rule(p)) // function_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3610 | ) |
| 3611 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3612 | _res = _PyPegen_function_def_decorators ( p , d , f ); |
| 3613 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3614 | p->error_indicator = 1; |
| 3615 | return NULL; |
| 3616 | } |
| 3617 | goto done; |
| 3618 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3619 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3620 | } |
| 3621 | { // function_def_raw |
| 3622 | stmt_ty function_def_raw_var; |
| 3623 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3624 | (function_def_raw_var = function_def_raw_rule(p)) // function_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3625 | ) |
| 3626 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3627 | _res = function_def_raw_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3628 | goto done; |
| 3629 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3630 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3631 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3632 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3633 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3634 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3635 | } |
| 3636 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3637 | // function_def_raw: |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3638 | // | 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
| 3639 | // | ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3640 | static stmt_ty |
| 3641 | function_def_raw_rule(Parser *p) |
| 3642 | { |
| 3643 | if (p->error_indicator) { |
| 3644 | return NULL; |
| 3645 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3646 | stmt_ty _res = NULL; |
| 3647 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3648 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 3649 | p->error_indicator = 1; |
| 3650 | return NULL; |
| 3651 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3652 | int _start_lineno = p->tokens[_mark]->lineno; |
| 3653 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 3654 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 3655 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3656 | { // 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3657 | Token * _keyword; |
| 3658 | Token * _literal; |
| 3659 | Token * _literal_1; |
| 3660 | Token * _literal_2; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3661 | void *a; |
| 3662 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3663 | expr_ty n; |
| 3664 | void *params; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3665 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3666 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3667 | (_keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3668 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3669 | (n = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3670 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3671 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3672 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3673 | (params = params_rule(p), 1) // params? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3674 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3675 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3676 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3677 | (a = _tmp_50_rule(p), 1) // ['->' expression] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3678 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3679 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3680 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3681 | (tc = func_type_comment_rule(p), 1) // func_type_comment? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3682 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3683 | (b = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3684 | ) |
| 3685 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3686 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3687 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3688 | return NULL; |
| 3689 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3690 | int _end_lineno = _token->end_lineno; |
| 3691 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3692 | int _end_col_offset = _token->end_col_offset; |
| 3693 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3694 | _res = _Py_FunctionDef ( n -> v . Name . id , ( params ) ? params : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , NULL , a , NEW_TYPE_COMMENT ( p , tc ) , EXTRA ); |
| 3695 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3696 | p->error_indicator = 1; |
| 3697 | return NULL; |
| 3698 | } |
| 3699 | goto done; |
| 3700 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3701 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3702 | } |
| 3703 | { // ASYNC 'def' NAME '(' params? ')' ['->' expression] ':' func_type_comment? block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3704 | Token * _keyword; |
| 3705 | Token * _literal; |
| 3706 | Token * _literal_1; |
| 3707 | Token * _literal_2; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3708 | void *a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3709 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3710 | asdl_seq* b; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3711 | expr_ty n; |
| 3712 | void *params; |
| 3713 | void *tc; |
| 3714 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3715 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3716 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3717 | (_keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3718 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3719 | (n = _PyPegen_name_token(p)) // NAME |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3720 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3721 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3722 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3723 | (params = params_rule(p), 1) // params? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3724 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3725 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3726 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3727 | (a = _tmp_51_rule(p), 1) // ['->' expression] |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3728 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3729 | (_literal_2 = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3730 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3731 | (tc = func_type_comment_rule(p), 1) // func_type_comment? |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3732 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3733 | (b = block_rule(p)) // block |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3734 | ) |
| 3735 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3736 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 3737 | if (_token == NULL) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3738 | return NULL; |
| 3739 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3740 | int _end_lineno = _token->end_lineno; |
| 3741 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 3742 | int _end_col_offset = _token->end_col_offset; |
| 3743 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 3744 | _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 ) ); |
| 3745 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3746 | p->error_indicator = 1; |
| 3747 | return NULL; |
| 3748 | } |
| 3749 | goto done; |
| 3750 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3751 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3752 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3753 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3754 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3755 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3756 | } |
| 3757 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3758 | // func_type_comment: |
| 3759 | // | NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
| 3760 | // | invalid_double_type_comments |
| 3761 | // | TYPE_COMMENT |
Pablo Galindo | d955241 | 2020-05-01 16:32:09 +0100 | [diff] [blame] | 3762 | static Token* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3763 | func_type_comment_rule(Parser *p) |
| 3764 | { |
| 3765 | if (p->error_indicator) { |
| 3766 | return NULL; |
| 3767 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3768 | Token* _res = NULL; |
| 3769 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3770 | { // NEWLINE TYPE_COMMENT &(NEWLINE INDENT) |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3771 | Token * newline_var; |
| 3772 | Token * t; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3773 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3774 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3775 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3776 | (t = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3777 | && |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 3778 | _PyPegen_lookahead(1, _tmp_52_rule, p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3779 | ) |
| 3780 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3781 | _res = t; |
| 3782 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3783 | p->error_indicator = 1; |
| 3784 | return NULL; |
| 3785 | } |
| 3786 | goto done; |
| 3787 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3788 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3789 | } |
| 3790 | { // invalid_double_type_comments |
| 3791 | void *invalid_double_type_comments_var; |
| 3792 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3793 | (invalid_double_type_comments_var = invalid_double_type_comments_rule(p)) // invalid_double_type_comments |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3794 | ) |
| 3795 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3796 | _res = invalid_double_type_comments_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3797 | goto done; |
| 3798 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3799 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3800 | } |
| 3801 | { // TYPE_COMMENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 3802 | Token * type_comment_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3803 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3804 | (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3805 | ) |
| 3806 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3807 | _res = type_comment_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3808 | goto done; |
| 3809 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3810 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3811 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3812 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3813 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3814 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3815 | } |
| 3816 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3817 | // params: invalid_parameters | parameters |
| 3818 | static arguments_ty |
| 3819 | params_rule(Parser *p) |
| 3820 | { |
| 3821 | if (p->error_indicator) { |
| 3822 | return NULL; |
| 3823 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3824 | arguments_ty _res = NULL; |
| 3825 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3826 | { // invalid_parameters |
| 3827 | void *invalid_parameters_var; |
| 3828 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3829 | (invalid_parameters_var = invalid_parameters_rule(p)) // invalid_parameters |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3830 | ) |
| 3831 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3832 | _res = invalid_parameters_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3833 | goto done; |
| 3834 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3835 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3836 | } |
| 3837 | { // parameters |
| 3838 | arguments_ty parameters_var; |
| 3839 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3840 | (parameters_var = parameters_rule(p)) // parameters |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3841 | ) |
| 3842 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3843 | _res = parameters_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3844 | goto done; |
| 3845 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3846 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3847 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3848 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3849 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3850 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3851 | } |
| 3852 | |
| 3853 | // parameters: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3854 | // | slash_no_default param_no_default* param_with_default* star_etc? |
| 3855 | // | slash_with_default param_with_default* star_etc? |
| 3856 | // | param_no_default+ param_with_default* star_etc? |
| 3857 | // | param_with_default+ star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3858 | // | star_etc |
| 3859 | static arguments_ty |
| 3860 | parameters_rule(Parser *p) |
| 3861 | { |
| 3862 | if (p->error_indicator) { |
| 3863 | return NULL; |
| 3864 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3865 | arguments_ty _res = NULL; |
| 3866 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3867 | { // slash_no_default param_no_default* param_with_default* star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3868 | asdl_seq* a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3869 | asdl_seq * b; |
| 3870 | asdl_seq * c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3871 | void *d; |
| 3872 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3873 | (a = slash_no_default_rule(p)) // slash_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3874 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3875 | (b = _loop0_53_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3876 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3877 | (c = _loop0_54_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3878 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3879 | (d = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3880 | ) |
| 3881 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3882 | _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 3883 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3884 | p->error_indicator = 1; |
| 3885 | return NULL; |
| 3886 | } |
| 3887 | goto done; |
| 3888 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3889 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3890 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3891 | { // slash_with_default param_with_default* star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3892 | SlashWithDefault* a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3893 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3894 | void *c; |
| 3895 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3896 | (a = slash_with_default_rule(p)) // slash_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3897 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3898 | (b = _loop0_55_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3899 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3900 | (c = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3901 | ) |
| 3902 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3903 | _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 3904 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3905 | p->error_indicator = 1; |
| 3906 | return NULL; |
| 3907 | } |
| 3908 | goto done; |
| 3909 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3910 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3911 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3912 | { // param_no_default+ param_with_default* star_etc? |
| 3913 | asdl_seq * a; |
| 3914 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3915 | void *c; |
| 3916 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3917 | (a = _loop1_56_rule(p)) // param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3918 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3919 | (b = _loop0_57_rule(p)) // param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3920 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3921 | (c = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3922 | ) |
| 3923 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3924 | _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 3925 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3926 | p->error_indicator = 1; |
| 3927 | return NULL; |
| 3928 | } |
| 3929 | goto done; |
| 3930 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3931 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3932 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3933 | { // param_with_default+ star_etc? |
| 3934 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3935 | void *b; |
| 3936 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3937 | (a = _loop1_58_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3938 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3939 | (b = star_etc_rule(p), 1) // star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3940 | ) |
| 3941 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3942 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 3943 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3944 | p->error_indicator = 1; |
| 3945 | return NULL; |
| 3946 | } |
| 3947 | goto done; |
| 3948 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3949 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3950 | } |
| 3951 | { // star_etc |
| 3952 | StarEtc* a; |
| 3953 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3954 | (a = star_etc_rule(p)) // star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3955 | ) |
| 3956 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3957 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 3958 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3959 | p->error_indicator = 1; |
| 3960 | return NULL; |
| 3961 | } |
| 3962 | goto done; |
| 3963 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3964 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3965 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3966 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3967 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3968 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3969 | } |
| 3970 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3971 | // slash_no_default: param_no_default+ '/' ',' | param_no_default+ '/' &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3972 | static asdl_seq* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3973 | slash_no_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3974 | { |
| 3975 | if (p->error_indicator) { |
| 3976 | return NULL; |
| 3977 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3978 | asdl_seq* _res = NULL; |
| 3979 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3980 | { // param_no_default+ '/' ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3981 | Token * _literal; |
| 3982 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3983 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3984 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 3985 | (a = _loop1_59_rule(p)) // param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3986 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3987 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 3988 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3989 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3990 | ) |
| 3991 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3992 | _res = a; |
| 3993 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 3994 | p->error_indicator = 1; |
| 3995 | return NULL; |
| 3996 | } |
| 3997 | goto done; |
| 3998 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 3999 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4000 | } |
| 4001 | { // param_no_default+ '/' &')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4002 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4003 | asdl_seq * a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4004 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4005 | (a = _loop1_60_rule(p)) // param_no_default+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4006 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4007 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4008 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4009 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4010 | ) |
| 4011 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4012 | _res = a; |
| 4013 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4014 | p->error_indicator = 1; |
| 4015 | return NULL; |
| 4016 | } |
| 4017 | goto done; |
| 4018 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4019 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4020 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4021 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4022 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4023 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4024 | } |
| 4025 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4026 | // slash_with_default: |
| 4027 | // | param_no_default* param_with_default+ '/' ',' |
| 4028 | // | param_no_default* param_with_default+ '/' &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4029 | static SlashWithDefault* |
| 4030 | slash_with_default_rule(Parser *p) |
| 4031 | { |
| 4032 | if (p->error_indicator) { |
| 4033 | return NULL; |
| 4034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4035 | SlashWithDefault* _res = NULL; |
| 4036 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4037 | { // param_no_default* param_with_default+ '/' ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4038 | Token * _literal; |
| 4039 | Token * _literal_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4040 | asdl_seq * a; |
| 4041 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4042 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4043 | (a = _loop0_61_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4044 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4045 | (b = _loop1_62_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4046 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4047 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4048 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4049 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4050 | ) |
| 4051 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4052 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 4053 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4054 | p->error_indicator = 1; |
| 4055 | return NULL; |
| 4056 | } |
| 4057 | goto done; |
| 4058 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4059 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4060 | } |
| 4061 | { // param_no_default* param_with_default+ '/' &')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4062 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4063 | asdl_seq * a; |
| 4064 | asdl_seq * b; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4065 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4066 | (a = _loop0_63_rule(p)) // param_no_default* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4067 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4068 | (b = _loop1_64_rule(p)) // param_with_default+ |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4069 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4070 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4071 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4072 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4073 | ) |
| 4074 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4075 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 4076 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4077 | p->error_indicator = 1; |
| 4078 | return NULL; |
| 4079 | } |
| 4080 | goto done; |
| 4081 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4082 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4083 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4084 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4085 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4086 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4087 | } |
| 4088 | |
| 4089 | // star_etc: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4090 | // | '*' param_no_default param_maybe_default* kwds? |
| 4091 | // | '*' ',' param_maybe_default+ kwds? |
| 4092 | // | kwds |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4093 | // | invalid_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4094 | static StarEtc* |
| 4095 | star_etc_rule(Parser *p) |
| 4096 | { |
| 4097 | if (p->error_indicator) { |
| 4098 | return NULL; |
| 4099 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4100 | StarEtc* _res = NULL; |
| 4101 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4102 | { // '*' param_no_default param_maybe_default* kwds? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4103 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4104 | arg_ty a; |
| 4105 | asdl_seq * b; |
| 4106 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4107 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4108 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4109 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4110 | (a = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4111 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4112 | (b = _loop0_65_rule(p)) // param_maybe_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4113 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4114 | (c = kwds_rule(p), 1) // kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4115 | ) |
| 4116 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4117 | _res = _PyPegen_star_etc ( p , a , b , c ); |
| 4118 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4119 | p->error_indicator = 1; |
| 4120 | return NULL; |
| 4121 | } |
| 4122 | goto done; |
| 4123 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4124 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4125 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4126 | { // '*' ',' param_maybe_default+ kwds? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4127 | Token * _literal; |
| 4128 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4129 | asdl_seq * b; |
| 4130 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4131 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4132 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4133 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4134 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4135 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4136 | (b = _loop1_66_rule(p)) // param_maybe_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4137 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4138 | (c = kwds_rule(p), 1) // kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4139 | ) |
| 4140 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4141 | _res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 4142 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4143 | p->error_indicator = 1; |
| 4144 | return NULL; |
| 4145 | } |
| 4146 | goto done; |
| 4147 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4148 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4149 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4150 | { // kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4151 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4152 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4153 | (a = kwds_rule(p)) // kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4154 | ) |
| 4155 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4156 | _res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 4157 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4158 | p->error_indicator = 1; |
| 4159 | return NULL; |
| 4160 | } |
| 4161 | goto done; |
| 4162 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4163 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4164 | } |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4165 | { // invalid_star_etc |
| 4166 | void *invalid_star_etc_var; |
| 4167 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4168 | (invalid_star_etc_var = invalid_star_etc_rule(p)) // invalid_star_etc |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4169 | ) |
| 4170 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4171 | _res = invalid_star_etc_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4172 | goto done; |
| 4173 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4174 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 4175 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4176 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4177 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4178 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4179 | } |
| 4180 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4181 | // kwds: '**' param_no_default |
| 4182 | static arg_ty |
| 4183 | kwds_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4184 | { |
| 4185 | if (p->error_indicator) { |
| 4186 | return NULL; |
| 4187 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4188 | arg_ty _res = NULL; |
| 4189 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4190 | { // '**' param_no_default |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4191 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4192 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4193 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4194 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4195 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4196 | (a = param_no_default_rule(p)) // param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4197 | ) |
| 4198 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4199 | _res = a; |
| 4200 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4201 | p->error_indicator = 1; |
| 4202 | return NULL; |
| 4203 | } |
| 4204 | goto done; |
| 4205 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4206 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4207 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4208 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4209 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4210 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4211 | } |
| 4212 | |
| 4213 | // param_no_default: param ',' TYPE_COMMENT? | param TYPE_COMMENT? &')' |
| 4214 | static arg_ty |
| 4215 | param_no_default_rule(Parser *p) |
| 4216 | { |
| 4217 | if (p->error_indicator) { |
| 4218 | return NULL; |
| 4219 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4220 | arg_ty _res = NULL; |
| 4221 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4222 | { // param ',' TYPE_COMMENT? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4223 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4224 | arg_ty a; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4225 | void *tc; |
| 4226 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4227 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4228 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4229 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4230 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4231 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4232 | ) |
| 4233 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4234 | _res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
| 4235 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4236 | p->error_indicator = 1; |
| 4237 | return NULL; |
| 4238 | } |
| 4239 | goto done; |
| 4240 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4241 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4242 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4243 | { // param TYPE_COMMENT? &')' |
| 4244 | arg_ty a; |
| 4245 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4246 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4247 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4248 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4249 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4250 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4251 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4252 | ) |
| 4253 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4254 | _res = _PyPegen_add_type_comment_to_arg ( p , a , tc ); |
| 4255 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4256 | p->error_indicator = 1; |
| 4257 | return NULL; |
| 4258 | } |
| 4259 | goto done; |
| 4260 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4261 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4262 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4263 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4264 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4265 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4266 | } |
| 4267 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4268 | // param_with_default: param default ',' TYPE_COMMENT? | param default TYPE_COMMENT? &')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4269 | static NameDefaultPair* |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4270 | param_with_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4271 | { |
| 4272 | if (p->error_indicator) { |
| 4273 | return NULL; |
| 4274 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4275 | NameDefaultPair* _res = NULL; |
| 4276 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4277 | { // param default ',' TYPE_COMMENT? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4278 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4279 | arg_ty a; |
| 4280 | expr_ty c; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4281 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4282 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4283 | (a = param_rule(p)) // param |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4284 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4285 | (c = default_rule(p)) // default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4286 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4287 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4288 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4289 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4290 | ) |
| 4291 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4292 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4293 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4294 | p->error_indicator = 1; |
| 4295 | return NULL; |
| 4296 | } |
| 4297 | goto done; |
| 4298 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4299 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4300 | } |
| 4301 | { // param default TYPE_COMMENT? &')' |
| 4302 | arg_ty a; |
| 4303 | expr_ty c; |
| 4304 | void *tc; |
| 4305 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4306 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4307 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4308 | (c = default_rule(p)) // default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4309 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4310 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4311 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4312 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4313 | ) |
| 4314 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4315 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4316 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4317 | p->error_indicator = 1; |
| 4318 | return NULL; |
| 4319 | } |
| 4320 | goto done; |
| 4321 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4322 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4323 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4324 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4325 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4326 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4327 | } |
| 4328 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4329 | // param_maybe_default: |
| 4330 | // | param default? ',' TYPE_COMMENT? |
| 4331 | // | param default? TYPE_COMMENT? &')' |
| 4332 | static NameDefaultPair* |
| 4333 | param_maybe_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4334 | { |
| 4335 | if (p->error_indicator) { |
| 4336 | return NULL; |
| 4337 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4338 | NameDefaultPair* _res = NULL; |
| 4339 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4340 | { // param default? ',' TYPE_COMMENT? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4341 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4342 | arg_ty a; |
| 4343 | void *c; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4344 | void *tc; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4345 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4346 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4347 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4348 | (c = default_rule(p), 1) // default? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4349 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4350 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4351 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4352 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4353 | ) |
| 4354 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4355 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4356 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4357 | p->error_indicator = 1; |
| 4358 | return NULL; |
| 4359 | } |
| 4360 | goto done; |
| 4361 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4362 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4363 | } |
| 4364 | { // param default? TYPE_COMMENT? &')' |
| 4365 | arg_ty a; |
| 4366 | void *c; |
| 4367 | void *tc; |
| 4368 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4369 | (a = param_rule(p)) // param |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4370 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4371 | (c = default_rule(p), 1) // default? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4372 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4373 | (tc = _PyPegen_expect_token(p, TYPE_COMMENT), 1) // TYPE_COMMENT? |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4374 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4375 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4376 | ) |
| 4377 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4378 | _res = _PyPegen_name_default_pair ( p , a , c , tc ); |
| 4379 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4380 | p->error_indicator = 1; |
| 4381 | return NULL; |
| 4382 | } |
| 4383 | goto done; |
| 4384 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4385 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4386 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4387 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4388 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4389 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4390 | } |
| 4391 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4392 | // param: NAME annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4393 | static arg_ty |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4394 | param_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4395 | { |
| 4396 | if (p->error_indicator) { |
| 4397 | return NULL; |
| 4398 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4399 | arg_ty _res = NULL; |
| 4400 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4401 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4402 | p->error_indicator = 1; |
| 4403 | return NULL; |
| 4404 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4405 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4406 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4407 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4408 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4409 | { // NAME annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4410 | expr_ty a; |
| 4411 | void *b; |
| 4412 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4413 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4414 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4415 | (b = annotation_rule(p), 1) // annotation? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4416 | ) |
| 4417 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4418 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4419 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4420 | return NULL; |
| 4421 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4422 | int _end_lineno = _token->end_lineno; |
| 4423 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4424 | int _end_col_offset = _token->end_col_offset; |
| 4425 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4426 | _res = _Py_arg ( a -> v . Name . id , b , NULL , EXTRA ); |
| 4427 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4428 | p->error_indicator = 1; |
| 4429 | return NULL; |
| 4430 | } |
| 4431 | goto done; |
| 4432 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4433 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4434 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4435 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4436 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4437 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4438 | } |
| 4439 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4440 | // annotation: ':' expression |
| 4441 | static expr_ty |
| 4442 | annotation_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4443 | { |
| 4444 | if (p->error_indicator) { |
| 4445 | return NULL; |
| 4446 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4447 | expr_ty _res = NULL; |
| 4448 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4449 | { // ':' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4450 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4451 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4452 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4453 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4454 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4455 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4456 | ) |
| 4457 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4458 | _res = a; |
| 4459 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4460 | p->error_indicator = 1; |
| 4461 | return NULL; |
| 4462 | } |
| 4463 | goto done; |
| 4464 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4465 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4466 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4467 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4468 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4469 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4470 | } |
| 4471 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4472 | // default: '=' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4473 | static expr_ty |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4474 | default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4475 | { |
| 4476 | if (p->error_indicator) { |
| 4477 | return NULL; |
| 4478 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4479 | expr_ty _res = NULL; |
| 4480 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4481 | { // '=' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4482 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4483 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4484 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4485 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4486 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4487 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4488 | ) |
| 4489 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4490 | _res = a; |
| 4491 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 4492 | p->error_indicator = 1; |
| 4493 | return NULL; |
| 4494 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4495 | goto done; |
| 4496 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4497 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4498 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4499 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4500 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4501 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4502 | } |
| 4503 | |
| 4504 | // decorators: (('@' named_expression NEWLINE))+ |
| 4505 | static asdl_seq* |
| 4506 | decorators_rule(Parser *p) |
| 4507 | { |
| 4508 | if (p->error_indicator) { |
| 4509 | return NULL; |
| 4510 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4511 | asdl_seq* _res = NULL; |
| 4512 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4513 | { // (('@' named_expression NEWLINE))+ |
| 4514 | asdl_seq * a; |
| 4515 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4516 | (a = _loop1_67_rule(p)) // (('@' named_expression NEWLINE))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4517 | ) |
| 4518 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4519 | _res = a; |
| 4520 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4521 | p->error_indicator = 1; |
| 4522 | return NULL; |
| 4523 | } |
| 4524 | goto done; |
| 4525 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4526 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4527 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4528 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4529 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4530 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4531 | } |
| 4532 | |
| 4533 | // class_def: decorators class_def_raw | class_def_raw |
| 4534 | static stmt_ty |
| 4535 | class_def_rule(Parser *p) |
| 4536 | { |
| 4537 | if (p->error_indicator) { |
| 4538 | return NULL; |
| 4539 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4540 | stmt_ty _res = NULL; |
| 4541 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4542 | { // decorators class_def_raw |
| 4543 | asdl_seq* a; |
| 4544 | stmt_ty b; |
| 4545 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4546 | (a = decorators_rule(p)) // decorators |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4547 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4548 | (b = class_def_raw_rule(p)) // class_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4549 | ) |
| 4550 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4551 | _res = _PyPegen_class_def_decorators ( p , a , b ); |
| 4552 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4553 | p->error_indicator = 1; |
| 4554 | return NULL; |
| 4555 | } |
| 4556 | goto done; |
| 4557 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4558 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4559 | } |
| 4560 | { // class_def_raw |
| 4561 | stmt_ty class_def_raw_var; |
| 4562 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4563 | (class_def_raw_var = class_def_raw_rule(p)) // class_def_raw |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4564 | ) |
| 4565 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4566 | _res = class_def_raw_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4567 | goto done; |
| 4568 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4569 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4570 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4571 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4572 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4573 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4574 | } |
| 4575 | |
| 4576 | // class_def_raw: 'class' NAME ['(' arguments? ')'] ':' block |
| 4577 | static stmt_ty |
| 4578 | class_def_raw_rule(Parser *p) |
| 4579 | { |
| 4580 | if (p->error_indicator) { |
| 4581 | return NULL; |
| 4582 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4583 | stmt_ty _res = NULL; |
| 4584 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4585 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4586 | p->error_indicator = 1; |
| 4587 | return NULL; |
| 4588 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4589 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4590 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4591 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4592 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4593 | { // 'class' NAME ['(' arguments? ')'] ':' block |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4594 | Token * _keyword; |
| 4595 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4596 | expr_ty a; |
| 4597 | void *b; |
| 4598 | asdl_seq* c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4599 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4600 | (_keyword = _PyPegen_expect_token(p, 523)) // token='class' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4601 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4602 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4603 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4604 | (b = _tmp_68_rule(p), 1) // ['(' arguments? ')'] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4605 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4606 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4607 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4608 | (c = block_rule(p)) // block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4609 | ) |
| 4610 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4611 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4612 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4613 | return NULL; |
| 4614 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4615 | int _end_lineno = _token->end_lineno; |
| 4616 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4617 | int _end_col_offset = _token->end_col_offset; |
| 4618 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4619 | _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 ); |
| 4620 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4621 | p->error_indicator = 1; |
| 4622 | return NULL; |
| 4623 | } |
| 4624 | goto done; |
| 4625 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4626 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4627 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4628 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4629 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4630 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4631 | } |
| 4632 | |
| 4633 | // block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block |
| 4634 | static asdl_seq* |
| 4635 | block_rule(Parser *p) |
| 4636 | { |
| 4637 | if (p->error_indicator) { |
| 4638 | return NULL; |
| 4639 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4640 | asdl_seq* _res = NULL; |
| 4641 | if (_PyPegen_is_memoized(p, block_type, &_res)) |
| 4642 | return _res; |
| 4643 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4644 | { // NEWLINE INDENT statements DEDENT |
| 4645 | asdl_seq* a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 4646 | Token * dedent_var; |
| 4647 | Token * indent_var; |
| 4648 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4649 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4650 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4651 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4652 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4653 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4654 | (a = statements_rule(p)) // statements |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4655 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4656 | (dedent_var = _PyPegen_expect_token(p, DEDENT)) // token='DEDENT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4657 | ) |
| 4658 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4659 | _res = a; |
| 4660 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4661 | p->error_indicator = 1; |
| 4662 | return NULL; |
| 4663 | } |
| 4664 | goto done; |
| 4665 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4666 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4667 | } |
| 4668 | { // simple_stmt |
| 4669 | asdl_seq* simple_stmt_var; |
| 4670 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4671 | (simple_stmt_var = simple_stmt_rule(p)) // simple_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4672 | ) |
| 4673 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4674 | _res = simple_stmt_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4675 | goto done; |
| 4676 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4677 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4678 | } |
| 4679 | { // invalid_block |
| 4680 | void *invalid_block_var; |
| 4681 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4682 | (invalid_block_var = invalid_block_rule(p)) // invalid_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4683 | ) |
| 4684 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4685 | _res = invalid_block_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4686 | goto done; |
| 4687 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4688 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4689 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4690 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4691 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4692 | _PyPegen_insert_memo(p, _mark, block_type, _res); |
| 4693 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4694 | } |
| 4695 | |
| 4696 | // expressions_list: ','.star_expression+ ','? |
| 4697 | static asdl_seq* |
| 4698 | expressions_list_rule(Parser *p) |
| 4699 | { |
| 4700 | if (p->error_indicator) { |
| 4701 | return NULL; |
| 4702 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4703 | asdl_seq* _res = NULL; |
| 4704 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4705 | { // ','.star_expression+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4706 | void *_opt_var; |
| 4707 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4708 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4709 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4710 | (a = _gather_69_rule(p)) // ','.star_expression+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4711 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4712 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4713 | ) |
| 4714 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4715 | _res = a; |
| 4716 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4717 | p->error_indicator = 1; |
| 4718 | return NULL; |
| 4719 | } |
| 4720 | goto done; |
| 4721 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4722 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4723 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4724 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4725 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4726 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4727 | } |
| 4728 | |
| 4729 | // star_expressions: |
| 4730 | // | star_expression ((',' star_expression))+ ','? |
| 4731 | // | star_expression ',' |
| 4732 | // | star_expression |
| 4733 | static expr_ty |
| 4734 | star_expressions_rule(Parser *p) |
| 4735 | { |
| 4736 | if (p->error_indicator) { |
| 4737 | return NULL; |
| 4738 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4739 | expr_ty _res = NULL; |
| 4740 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4741 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4742 | p->error_indicator = 1; |
| 4743 | return NULL; |
| 4744 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4745 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4746 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4747 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4748 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4749 | { // star_expression ((',' star_expression))+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4750 | void *_opt_var; |
| 4751 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4752 | expr_ty a; |
| 4753 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4754 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4755 | (a = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4756 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4757 | (b = _loop1_71_rule(p)) // ((',' star_expression))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4758 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4759 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4760 | ) |
| 4761 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4762 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4763 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4764 | return NULL; |
| 4765 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4766 | int _end_lineno = _token->end_lineno; |
| 4767 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4768 | int _end_col_offset = _token->end_col_offset; |
| 4769 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4770 | _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
| 4771 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4772 | p->error_indicator = 1; |
| 4773 | return NULL; |
| 4774 | } |
| 4775 | goto done; |
| 4776 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4777 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4778 | } |
| 4779 | { // star_expression ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4780 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4781 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4782 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4783 | (a = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4784 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4785 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4786 | ) |
| 4787 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4788 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4789 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4790 | return NULL; |
| 4791 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4792 | int _end_lineno = _token->end_lineno; |
| 4793 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4794 | int _end_col_offset = _token->end_col_offset; |
| 4795 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4796 | _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
| 4797 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4798 | p->error_indicator = 1; |
| 4799 | return NULL; |
| 4800 | } |
| 4801 | goto done; |
| 4802 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4803 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4804 | } |
| 4805 | { // star_expression |
| 4806 | expr_ty star_expression_var; |
| 4807 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4808 | (star_expression_var = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4809 | ) |
| 4810 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4811 | _res = star_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4812 | goto done; |
| 4813 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4814 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4815 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4816 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4817 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4818 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4819 | } |
| 4820 | |
| 4821 | // star_expression: '*' bitwise_or | expression |
| 4822 | static expr_ty |
| 4823 | star_expression_rule(Parser *p) |
| 4824 | { |
| 4825 | if (p->error_indicator) { |
| 4826 | return NULL; |
| 4827 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4828 | expr_ty _res = NULL; |
| 4829 | if (_PyPegen_is_memoized(p, star_expression_type, &_res)) |
| 4830 | return _res; |
| 4831 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4832 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4833 | p->error_indicator = 1; |
| 4834 | return NULL; |
| 4835 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4836 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4837 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4838 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4839 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4840 | { // '*' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4841 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4842 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4843 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4844 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4845 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4846 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4847 | ) |
| 4848 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4849 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4850 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4851 | return NULL; |
| 4852 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4853 | int _end_lineno = _token->end_lineno; |
| 4854 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4855 | int _end_col_offset = _token->end_col_offset; |
| 4856 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4857 | _res = _Py_Starred ( a , Load , EXTRA ); |
| 4858 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4859 | p->error_indicator = 1; |
| 4860 | return NULL; |
| 4861 | } |
| 4862 | goto done; |
| 4863 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4864 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4865 | } |
| 4866 | { // expression |
| 4867 | expr_ty expression_var; |
| 4868 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4869 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4870 | ) |
| 4871 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4872 | _res = expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4873 | goto done; |
| 4874 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4875 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4876 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4877 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4878 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4879 | _PyPegen_insert_memo(p, _mark, star_expression_type, _res); |
| 4880 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4881 | } |
| 4882 | |
| 4883 | // star_named_expressions: ','.star_named_expression+ ','? |
| 4884 | static asdl_seq* |
| 4885 | star_named_expressions_rule(Parser *p) |
| 4886 | { |
| 4887 | if (p->error_indicator) { |
| 4888 | return NULL; |
| 4889 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4890 | asdl_seq* _res = NULL; |
| 4891 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4892 | { // ','.star_named_expression+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4893 | void *_opt_var; |
| 4894 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4895 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4896 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4897 | (a = _gather_72_rule(p)) // ','.star_named_expression+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4898 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4899 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4900 | ) |
| 4901 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4902 | _res = a; |
| 4903 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4904 | p->error_indicator = 1; |
| 4905 | return NULL; |
| 4906 | } |
| 4907 | goto done; |
| 4908 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4909 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4910 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4911 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4912 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4913 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4914 | } |
| 4915 | |
| 4916 | // star_named_expression: '*' bitwise_or | named_expression |
| 4917 | static expr_ty |
| 4918 | star_named_expression_rule(Parser *p) |
| 4919 | { |
| 4920 | if (p->error_indicator) { |
| 4921 | return NULL; |
| 4922 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4923 | expr_ty _res = NULL; |
| 4924 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4925 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4926 | p->error_indicator = 1; |
| 4927 | return NULL; |
| 4928 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4929 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4930 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4931 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4932 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4933 | { // '*' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4934 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4935 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4936 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4937 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4938 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4939 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4940 | ) |
| 4941 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4942 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 4943 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4944 | return NULL; |
| 4945 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4946 | int _end_lineno = _token->end_lineno; |
| 4947 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 4948 | int _end_col_offset = _token->end_col_offset; |
| 4949 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 4950 | _res = _Py_Starred ( a , Load , EXTRA ); |
| 4951 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4952 | p->error_indicator = 1; |
| 4953 | return NULL; |
| 4954 | } |
| 4955 | goto done; |
| 4956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4957 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4958 | } |
| 4959 | { // named_expression |
| 4960 | expr_ty named_expression_var; |
| 4961 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4962 | (named_expression_var = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4963 | ) |
| 4964 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4965 | _res = named_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4966 | goto done; |
| 4967 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4968 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4969 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4970 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4971 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4972 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4973 | } |
| 4974 | |
| 4975 | // named_expression: NAME ':=' expression | expression !':=' | invalid_named_expression |
| 4976 | static expr_ty |
| 4977 | named_expression_rule(Parser *p) |
| 4978 | { |
| 4979 | if (p->error_indicator) { |
| 4980 | return NULL; |
| 4981 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4982 | expr_ty _res = NULL; |
| 4983 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4984 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 4985 | p->error_indicator = 1; |
| 4986 | return NULL; |
| 4987 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4988 | int _start_lineno = p->tokens[_mark]->lineno; |
| 4989 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 4990 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 4991 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4992 | { // NAME ':=' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4993 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4994 | expr_ty a; |
| 4995 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4996 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 4997 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 4998 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 4999 | (_literal = _PyPegen_expect_token(p, 53)) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5000 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5001 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5002 | ) |
| 5003 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5004 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5005 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5006 | return NULL; |
| 5007 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5008 | int _end_lineno = _token->end_lineno; |
| 5009 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5010 | int _end_col_offset = _token->end_col_offset; |
| 5011 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5012 | _res = _Py_NamedExpr ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , b , EXTRA ); |
| 5013 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5014 | p->error_indicator = 1; |
| 5015 | return NULL; |
| 5016 | } |
| 5017 | goto done; |
| 5018 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5019 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5020 | } |
| 5021 | { // expression !':=' |
| 5022 | expr_ty expression_var; |
| 5023 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5024 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5025 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5026 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 53) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5027 | ) |
| 5028 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5029 | _res = expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5030 | goto done; |
| 5031 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5032 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5033 | } |
| 5034 | { // invalid_named_expression |
| 5035 | void *invalid_named_expression_var; |
| 5036 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5037 | (invalid_named_expression_var = invalid_named_expression_rule(p)) // invalid_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5038 | ) |
| 5039 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5040 | _res = invalid_named_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5041 | goto done; |
| 5042 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5043 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5044 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5045 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5046 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5047 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5048 | } |
| 5049 | |
| 5050 | // annotated_rhs: yield_expr | star_expressions |
| 5051 | static expr_ty |
| 5052 | annotated_rhs_rule(Parser *p) |
| 5053 | { |
| 5054 | if (p->error_indicator) { |
| 5055 | return NULL; |
| 5056 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5057 | expr_ty _res = NULL; |
| 5058 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5059 | { // yield_expr |
| 5060 | expr_ty yield_expr_var; |
| 5061 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5062 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5063 | ) |
| 5064 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5065 | _res = yield_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5066 | goto done; |
| 5067 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5068 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5069 | } |
| 5070 | { // star_expressions |
| 5071 | expr_ty star_expressions_var; |
| 5072 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5073 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5074 | ) |
| 5075 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5076 | _res = star_expressions_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5077 | goto done; |
| 5078 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5079 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5080 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5081 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5082 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5083 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5084 | } |
| 5085 | |
| 5086 | // expressions: expression ((',' expression))+ ','? | expression ',' | expression |
| 5087 | static expr_ty |
| 5088 | expressions_rule(Parser *p) |
| 5089 | { |
| 5090 | if (p->error_indicator) { |
| 5091 | return NULL; |
| 5092 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5093 | expr_ty _res = NULL; |
| 5094 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5095 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5096 | p->error_indicator = 1; |
| 5097 | return NULL; |
| 5098 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5099 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5100 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5101 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5102 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5103 | { // expression ((',' expression))+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5104 | void *_opt_var; |
| 5105 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5106 | expr_ty a; |
| 5107 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5108 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5109 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5110 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5111 | (b = _loop1_74_rule(p)) // ((',' expression))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5112 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5113 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5114 | ) |
| 5115 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5116 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5117 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5118 | return NULL; |
| 5119 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5120 | int _end_lineno = _token->end_lineno; |
| 5121 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5122 | int _end_col_offset = _token->end_col_offset; |
| 5123 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5124 | _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Load , EXTRA ); |
| 5125 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5126 | p->error_indicator = 1; |
| 5127 | return NULL; |
| 5128 | } |
| 5129 | goto done; |
| 5130 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5131 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5132 | } |
| 5133 | { // expression ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5134 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5135 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5136 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5137 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5138 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5139 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5140 | ) |
| 5141 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5142 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5143 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5144 | return NULL; |
| 5145 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5146 | int _end_lineno = _token->end_lineno; |
| 5147 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5148 | int _end_col_offset = _token->end_col_offset; |
| 5149 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5150 | _res = _Py_Tuple ( CHECK ( _PyPegen_singleton_seq ( p , a ) ) , Load , EXTRA ); |
| 5151 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5152 | p->error_indicator = 1; |
| 5153 | return NULL; |
| 5154 | } |
| 5155 | goto done; |
| 5156 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5157 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5158 | } |
| 5159 | { // expression |
| 5160 | expr_ty expression_var; |
| 5161 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5162 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5163 | ) |
| 5164 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5165 | _res = expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5166 | goto done; |
| 5167 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5168 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5169 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5170 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5171 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5172 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5173 | } |
| 5174 | |
| 5175 | // expression: disjunction 'if' disjunction 'else' expression | disjunction | lambdef |
| 5176 | static expr_ty |
| 5177 | expression_rule(Parser *p) |
| 5178 | { |
| 5179 | if (p->error_indicator) { |
| 5180 | return NULL; |
| 5181 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5182 | expr_ty _res = NULL; |
| 5183 | if (_PyPegen_is_memoized(p, expression_type, &_res)) |
| 5184 | return _res; |
| 5185 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5186 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5187 | p->error_indicator = 1; |
| 5188 | return NULL; |
| 5189 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5190 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5191 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5192 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5193 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5194 | { // disjunction 'if' disjunction 'else' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5195 | Token * _keyword; |
| 5196 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5197 | expr_ty a; |
| 5198 | expr_ty b; |
| 5199 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5200 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5201 | (a = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5202 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5203 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5204 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5205 | (b = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5206 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5207 | (_keyword_1 = _PyPegen_expect_token(p, 516)) // token='else' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5208 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5209 | (c = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5210 | ) |
| 5211 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5212 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5213 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5214 | return NULL; |
| 5215 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5216 | int _end_lineno = _token->end_lineno; |
| 5217 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5218 | int _end_col_offset = _token->end_col_offset; |
| 5219 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5220 | _res = _Py_IfExp ( b , a , c , EXTRA ); |
| 5221 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5222 | p->error_indicator = 1; |
| 5223 | return NULL; |
| 5224 | } |
| 5225 | goto done; |
| 5226 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5227 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5228 | } |
| 5229 | { // disjunction |
| 5230 | expr_ty disjunction_var; |
| 5231 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5232 | (disjunction_var = disjunction_rule(p)) // disjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5233 | ) |
| 5234 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5235 | _res = disjunction_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5236 | goto done; |
| 5237 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5238 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5239 | } |
| 5240 | { // lambdef |
| 5241 | expr_ty lambdef_var; |
| 5242 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5243 | (lambdef_var = lambdef_rule(p)) // lambdef |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5244 | ) |
| 5245 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5246 | _res = lambdef_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5247 | goto done; |
| 5248 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5249 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5250 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5251 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5252 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5253 | _PyPegen_insert_memo(p, _mark, expression_type, _res); |
| 5254 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5255 | } |
| 5256 | |
| 5257 | // lambdef: 'lambda' lambda_parameters? ':' expression |
| 5258 | static expr_ty |
| 5259 | lambdef_rule(Parser *p) |
| 5260 | { |
| 5261 | if (p->error_indicator) { |
| 5262 | return NULL; |
| 5263 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5264 | expr_ty _res = NULL; |
| 5265 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5266 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5267 | p->error_indicator = 1; |
| 5268 | return NULL; |
| 5269 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5270 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5271 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5272 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5273 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5274 | { // 'lambda' lambda_parameters? ':' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5275 | Token * _keyword; |
| 5276 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5277 | void *a; |
| 5278 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5279 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5280 | (_keyword = _PyPegen_expect_token(p, 524)) // token='lambda' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5281 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5282 | (a = lambda_parameters_rule(p), 1) // lambda_parameters? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5283 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5284 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5285 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5286 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5287 | ) |
| 5288 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5289 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5290 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5291 | return NULL; |
| 5292 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5293 | int _end_lineno = _token->end_lineno; |
| 5294 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5295 | int _end_col_offset = _token->end_col_offset; |
| 5296 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5297 | _res = _Py_Lambda ( ( a ) ? a : CHECK ( _PyPegen_empty_arguments ( p ) ) , b , EXTRA ); |
| 5298 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5299 | p->error_indicator = 1; |
| 5300 | return NULL; |
| 5301 | } |
| 5302 | goto done; |
| 5303 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5304 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5305 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5306 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5307 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5308 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5309 | } |
| 5310 | |
| 5311 | // lambda_parameters: |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5312 | // | lambda_slash_no_default lambda_param_no_default* lambda_param_with_default* lambda_star_etc? |
| 5313 | // | lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
| 5314 | // | lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
| 5315 | // | lambda_param_with_default+ lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5316 | // | lambda_star_etc |
| 5317 | static arguments_ty |
| 5318 | lambda_parameters_rule(Parser *p) |
| 5319 | { |
| 5320 | if (p->error_indicator) { |
| 5321 | return NULL; |
| 5322 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5323 | arguments_ty _res = NULL; |
| 5324 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5325 | { // 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] | 5326 | asdl_seq* a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5327 | asdl_seq * b; |
| 5328 | asdl_seq * c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5329 | void *d; |
| 5330 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5331 | (a = lambda_slash_no_default_rule(p)) // lambda_slash_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5332 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5333 | (b = _loop0_75_rule(p)) // lambda_param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5334 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5335 | (c = _loop0_76_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5336 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5337 | (d = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5338 | ) |
| 5339 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5340 | _res = _PyPegen_make_arguments ( p , a , NULL , b , c , d ); |
| 5341 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5342 | p->error_indicator = 1; |
| 5343 | return NULL; |
| 5344 | } |
| 5345 | goto done; |
| 5346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5347 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5348 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5349 | { // lambda_slash_with_default lambda_param_with_default* lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5350 | SlashWithDefault* a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5351 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5352 | void *c; |
| 5353 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5354 | (a = lambda_slash_with_default_rule(p)) // lambda_slash_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5355 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5356 | (b = _loop0_77_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5357 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5358 | (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5359 | ) |
| 5360 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5361 | _res = _PyPegen_make_arguments ( p , NULL , a , NULL , b , c ); |
| 5362 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5363 | p->error_indicator = 1; |
| 5364 | return NULL; |
| 5365 | } |
| 5366 | goto done; |
| 5367 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5368 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5369 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5370 | { // lambda_param_no_default+ lambda_param_with_default* lambda_star_etc? |
| 5371 | asdl_seq * a; |
| 5372 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5373 | void *c; |
| 5374 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5375 | (a = _loop1_78_rule(p)) // lambda_param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5376 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5377 | (b = _loop0_79_rule(p)) // lambda_param_with_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5378 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5379 | (c = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5380 | ) |
| 5381 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5382 | _res = _PyPegen_make_arguments ( p , NULL , NULL , a , b , c ); |
| 5383 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5384 | p->error_indicator = 1; |
| 5385 | return NULL; |
| 5386 | } |
| 5387 | goto done; |
| 5388 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5389 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5390 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5391 | { // lambda_param_with_default+ lambda_star_etc? |
| 5392 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5393 | void *b; |
| 5394 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5395 | (a = _loop1_80_rule(p)) // lambda_param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5396 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5397 | (b = lambda_star_etc_rule(p), 1) // lambda_star_etc? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5398 | ) |
| 5399 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5400 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , a , b ); |
| 5401 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5402 | p->error_indicator = 1; |
| 5403 | return NULL; |
| 5404 | } |
| 5405 | goto done; |
| 5406 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5407 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5408 | } |
| 5409 | { // lambda_star_etc |
| 5410 | StarEtc* a; |
| 5411 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5412 | (a = lambda_star_etc_rule(p)) // lambda_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5413 | ) |
| 5414 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5415 | _res = _PyPegen_make_arguments ( p , NULL , NULL , NULL , NULL , a ); |
| 5416 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5417 | p->error_indicator = 1; |
| 5418 | return NULL; |
| 5419 | } |
| 5420 | goto done; |
| 5421 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5422 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5423 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5424 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5425 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5426 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5427 | } |
| 5428 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5429 | // lambda_slash_no_default: |
| 5430 | // | lambda_param_no_default+ '/' ',' |
| 5431 | // | lambda_param_no_default+ '/' &':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5432 | static asdl_seq* |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5433 | lambda_slash_no_default_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5434 | { |
| 5435 | if (p->error_indicator) { |
| 5436 | return NULL; |
| 5437 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5438 | asdl_seq* _res = NULL; |
| 5439 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5440 | { // lambda_param_no_default+ '/' ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5441 | Token * _literal; |
| 5442 | Token * _literal_1; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5443 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5444 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5445 | (a = _loop1_81_rule(p)) // lambda_param_no_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5446 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5447 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5448 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5449 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5450 | ) |
| 5451 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5452 | _res = a; |
| 5453 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5454 | p->error_indicator = 1; |
| 5455 | return NULL; |
| 5456 | } |
| 5457 | goto done; |
| 5458 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5459 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5460 | } |
| 5461 | { // lambda_param_no_default+ '/' &':' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5462 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5463 | asdl_seq * a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5464 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5465 | (a = _loop1_82_rule(p)) // lambda_param_no_default+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5466 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5467 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5468 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5469 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5470 | ) |
| 5471 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5472 | _res = a; |
| 5473 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5474 | p->error_indicator = 1; |
| 5475 | return NULL; |
| 5476 | } |
| 5477 | goto done; |
| 5478 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5479 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5480 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5481 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5482 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5483 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5484 | } |
| 5485 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5486 | // lambda_slash_with_default: |
| 5487 | // | lambda_param_no_default* lambda_param_with_default+ '/' ',' |
| 5488 | // | lambda_param_no_default* lambda_param_with_default+ '/' &':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5489 | static SlashWithDefault* |
| 5490 | lambda_slash_with_default_rule(Parser *p) |
| 5491 | { |
| 5492 | if (p->error_indicator) { |
| 5493 | return NULL; |
| 5494 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5495 | SlashWithDefault* _res = NULL; |
| 5496 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5497 | { // lambda_param_no_default* lambda_param_with_default+ '/' ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5498 | Token * _literal; |
| 5499 | Token * _literal_1; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5500 | asdl_seq * a; |
| 5501 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5502 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5503 | (a = _loop0_83_rule(p)) // lambda_param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5504 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5505 | (b = _loop1_84_rule(p)) // lambda_param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5506 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5507 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5508 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5509 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5510 | ) |
| 5511 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5512 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 5513 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5514 | p->error_indicator = 1; |
| 5515 | return NULL; |
| 5516 | } |
| 5517 | goto done; |
| 5518 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5519 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5520 | } |
| 5521 | { // lambda_param_no_default* lambda_param_with_default+ '/' &':' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5522 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5523 | asdl_seq * a; |
| 5524 | asdl_seq * b; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5525 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5526 | (a = _loop0_85_rule(p)) // lambda_param_no_default* |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5527 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5528 | (b = _loop1_86_rule(p)) // lambda_param_with_default+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5529 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5530 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5531 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5532 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5533 | ) |
| 5534 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5535 | _res = _PyPegen_slash_with_default ( p , a , b ); |
| 5536 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5537 | p->error_indicator = 1; |
| 5538 | return NULL; |
| 5539 | } |
| 5540 | goto done; |
| 5541 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5542 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5543 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5544 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5545 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5546 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5547 | } |
| 5548 | |
| 5549 | // lambda_star_etc: |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5550 | // | '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
| 5551 | // | '*' ',' lambda_param_maybe_default+ lambda_kwds? |
| 5552 | // | lambda_kwds |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5553 | // | invalid_lambda_star_etc |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5554 | static StarEtc* |
| 5555 | lambda_star_etc_rule(Parser *p) |
| 5556 | { |
| 5557 | if (p->error_indicator) { |
| 5558 | return NULL; |
| 5559 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5560 | StarEtc* _res = NULL; |
| 5561 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5562 | { // '*' lambda_param_no_default lambda_param_maybe_default* lambda_kwds? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5563 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5564 | arg_ty a; |
| 5565 | asdl_seq * b; |
| 5566 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5567 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5568 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5569 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5570 | (a = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5571 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5572 | (b = _loop0_87_rule(p)) // lambda_param_maybe_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5573 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5574 | (c = lambda_kwds_rule(p), 1) // lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5575 | ) |
| 5576 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5577 | _res = _PyPegen_star_etc ( p , a , b , c ); |
| 5578 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5579 | p->error_indicator = 1; |
| 5580 | return NULL; |
| 5581 | } |
| 5582 | goto done; |
| 5583 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5584 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5585 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5586 | { // '*' ',' lambda_param_maybe_default+ lambda_kwds? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5587 | Token * _literal; |
| 5588 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5589 | asdl_seq * b; |
| 5590 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5591 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5592 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5593 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5594 | (_literal_1 = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5595 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5596 | (b = _loop1_88_rule(p)) // lambda_param_maybe_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5597 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5598 | (c = lambda_kwds_rule(p), 1) // lambda_kwds? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5599 | ) |
| 5600 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5601 | _res = _PyPegen_star_etc ( p , NULL , b , c ); |
| 5602 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5603 | p->error_indicator = 1; |
| 5604 | return NULL; |
| 5605 | } |
| 5606 | goto done; |
| 5607 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5608 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5609 | } |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5610 | { // lambda_kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5611 | arg_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5612 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5613 | (a = lambda_kwds_rule(p)) // lambda_kwds |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5614 | ) |
| 5615 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5616 | _res = _PyPegen_star_etc ( p , NULL , NULL , a ); |
| 5617 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5618 | p->error_indicator = 1; |
| 5619 | return NULL; |
| 5620 | } |
| 5621 | goto done; |
| 5622 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5623 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5624 | } |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5625 | { // invalid_lambda_star_etc |
| 5626 | void *invalid_lambda_star_etc_var; |
| 5627 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5628 | (invalid_lambda_star_etc_var = invalid_lambda_star_etc_rule(p)) // invalid_lambda_star_etc |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5629 | ) |
| 5630 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5631 | _res = invalid_lambda_star_etc_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5632 | goto done; |
| 5633 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5634 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 5635 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5636 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5637 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5638 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5639 | } |
| 5640 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5641 | // lambda_kwds: '**' lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5642 | static arg_ty |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5643 | lambda_kwds_rule(Parser *p) |
| 5644 | { |
| 5645 | if (p->error_indicator) { |
| 5646 | return NULL; |
| 5647 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5648 | arg_ty _res = NULL; |
| 5649 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5650 | { // '**' lambda_param_no_default |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5651 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5652 | arg_ty a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5653 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5654 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5655 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5656 | (a = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5657 | ) |
| 5658 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5659 | _res = a; |
| 5660 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5661 | p->error_indicator = 1; |
| 5662 | return NULL; |
| 5663 | } |
| 5664 | goto done; |
| 5665 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5666 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5667 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5668 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5669 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5670 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5671 | } |
| 5672 | |
| 5673 | // lambda_param_no_default: lambda_param ',' | lambda_param &':' |
| 5674 | static arg_ty |
| 5675 | lambda_param_no_default_rule(Parser *p) |
| 5676 | { |
| 5677 | if (p->error_indicator) { |
| 5678 | return NULL; |
| 5679 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5680 | arg_ty _res = NULL; |
| 5681 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5682 | { // lambda_param ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5683 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5684 | arg_ty a; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5685 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5686 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5687 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5688 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5689 | ) |
| 5690 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5691 | _res = a; |
| 5692 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5693 | p->error_indicator = 1; |
| 5694 | return NULL; |
| 5695 | } |
| 5696 | goto done; |
| 5697 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5698 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5699 | } |
| 5700 | { // lambda_param &':' |
| 5701 | arg_ty a; |
| 5702 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5703 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5704 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5705 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5706 | ) |
| 5707 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5708 | _res = a; |
| 5709 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5710 | p->error_indicator = 1; |
| 5711 | return NULL; |
| 5712 | } |
| 5713 | goto done; |
| 5714 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5715 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5716 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5717 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5718 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5719 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5720 | } |
| 5721 | |
| 5722 | // lambda_param_with_default: lambda_param default ',' | lambda_param default &':' |
| 5723 | static NameDefaultPair* |
| 5724 | lambda_param_with_default_rule(Parser *p) |
| 5725 | { |
| 5726 | if (p->error_indicator) { |
| 5727 | return NULL; |
| 5728 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5729 | NameDefaultPair* _res = NULL; |
| 5730 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5731 | { // lambda_param default ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5732 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5733 | arg_ty a; |
| 5734 | expr_ty c; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5735 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5736 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5737 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5738 | (c = default_rule(p)) // default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5739 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5740 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5741 | ) |
| 5742 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5743 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5744 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5745 | p->error_indicator = 1; |
| 5746 | return NULL; |
| 5747 | } |
| 5748 | goto done; |
| 5749 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5750 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5751 | } |
| 5752 | { // lambda_param default &':' |
| 5753 | arg_ty a; |
| 5754 | expr_ty c; |
| 5755 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5756 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5757 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5758 | (c = default_rule(p)) // default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5759 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5760 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5761 | ) |
| 5762 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5763 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5764 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5765 | p->error_indicator = 1; |
| 5766 | return NULL; |
| 5767 | } |
| 5768 | goto done; |
| 5769 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5770 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5771 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5772 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5773 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5774 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5775 | } |
| 5776 | |
| 5777 | // lambda_param_maybe_default: lambda_param default? ',' | lambda_param default? &':' |
| 5778 | static NameDefaultPair* |
| 5779 | lambda_param_maybe_default_rule(Parser *p) |
| 5780 | { |
| 5781 | if (p->error_indicator) { |
| 5782 | return NULL; |
| 5783 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5784 | NameDefaultPair* _res = NULL; |
| 5785 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5786 | { // lambda_param default? ',' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5787 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5788 | arg_ty a; |
| 5789 | void *c; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5790 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5791 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5792 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5793 | (c = default_rule(p), 1) // default? |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5794 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5795 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5796 | ) |
| 5797 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5798 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5799 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5800 | p->error_indicator = 1; |
| 5801 | return NULL; |
| 5802 | } |
| 5803 | goto done; |
| 5804 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5805 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5806 | } |
| 5807 | { // lambda_param default? &':' |
| 5808 | arg_ty a; |
| 5809 | void *c; |
| 5810 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5811 | (a = lambda_param_rule(p)) // lambda_param |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5812 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5813 | (c = default_rule(p), 1) // default? |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5814 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5815 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 11) // token=':' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5816 | ) |
| 5817 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5818 | _res = _PyPegen_name_default_pair ( p , a , c , NULL ); |
| 5819 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5820 | p->error_indicator = 1; |
| 5821 | return NULL; |
| 5822 | } |
| 5823 | goto done; |
| 5824 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5825 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5826 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5827 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5828 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5829 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 5830 | } |
| 5831 | |
| 5832 | // lambda_param: NAME |
| 5833 | static arg_ty |
| 5834 | lambda_param_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5835 | { |
| 5836 | if (p->error_indicator) { |
| 5837 | return NULL; |
| 5838 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5839 | arg_ty _res = NULL; |
| 5840 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5841 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5842 | p->error_indicator = 1; |
| 5843 | return NULL; |
| 5844 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5845 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5846 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5847 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5848 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5849 | { // NAME |
| 5850 | expr_ty a; |
| 5851 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5852 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5853 | ) |
| 5854 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5855 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5856 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5857 | return NULL; |
| 5858 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 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_arg ( a -> v . Name . id , NULL , NULL , EXTRA ); |
| 5864 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5865 | p->error_indicator = 1; |
| 5866 | return NULL; |
| 5867 | } |
| 5868 | goto done; |
| 5869 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5870 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5871 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5872 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5873 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5874 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5875 | } |
| 5876 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5877 | // disjunction: conjunction (('or' conjunction))+ | conjunction |
| 5878 | static expr_ty |
| 5879 | disjunction_rule(Parser *p) |
| 5880 | { |
| 5881 | if (p->error_indicator) { |
| 5882 | return NULL; |
| 5883 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5884 | expr_ty _res = NULL; |
| 5885 | if (_PyPegen_is_memoized(p, disjunction_type, &_res)) |
| 5886 | return _res; |
| 5887 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5888 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5889 | p->error_indicator = 1; |
| 5890 | return NULL; |
| 5891 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5892 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5893 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5894 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5895 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5896 | { // conjunction (('or' conjunction))+ |
| 5897 | expr_ty a; |
| 5898 | asdl_seq * b; |
| 5899 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5900 | (a = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5901 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5902 | (b = _loop1_89_rule(p)) // (('or' conjunction))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5903 | ) |
| 5904 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5905 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5906 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5907 | return NULL; |
| 5908 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5909 | int _end_lineno = _token->end_lineno; |
| 5910 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5911 | int _end_col_offset = _token->end_col_offset; |
| 5912 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5913 | _res = _Py_BoolOp ( Or , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
| 5914 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5915 | p->error_indicator = 1; |
| 5916 | return NULL; |
| 5917 | } |
| 5918 | goto done; |
| 5919 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5920 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5921 | } |
| 5922 | { // conjunction |
| 5923 | expr_ty conjunction_var; |
| 5924 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5925 | (conjunction_var = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5926 | ) |
| 5927 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5928 | _res = conjunction_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5929 | goto done; |
| 5930 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5931 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5932 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5933 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5934 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5935 | _PyPegen_insert_memo(p, _mark, disjunction_type, _res); |
| 5936 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5937 | } |
| 5938 | |
| 5939 | // conjunction: inversion (('and' inversion))+ | inversion |
| 5940 | static expr_ty |
| 5941 | conjunction_rule(Parser *p) |
| 5942 | { |
| 5943 | if (p->error_indicator) { |
| 5944 | return NULL; |
| 5945 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5946 | expr_ty _res = NULL; |
| 5947 | if (_PyPegen_is_memoized(p, conjunction_type, &_res)) |
| 5948 | return _res; |
| 5949 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5950 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 5951 | p->error_indicator = 1; |
| 5952 | return NULL; |
| 5953 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5954 | int _start_lineno = p->tokens[_mark]->lineno; |
| 5955 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 5956 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 5957 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5958 | { // inversion (('and' inversion))+ |
| 5959 | expr_ty a; |
| 5960 | asdl_seq * b; |
| 5961 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5962 | (a = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5963 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5964 | (b = _loop1_90_rule(p)) // (('and' inversion))+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5965 | ) |
| 5966 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5967 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 5968 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5969 | return NULL; |
| 5970 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5971 | int _end_lineno = _token->end_lineno; |
| 5972 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 5973 | int _end_col_offset = _token->end_col_offset; |
| 5974 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 5975 | _res = _Py_BoolOp ( And , CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , EXTRA ); |
| 5976 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5977 | p->error_indicator = 1; |
| 5978 | return NULL; |
| 5979 | } |
| 5980 | goto done; |
| 5981 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5982 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5983 | } |
| 5984 | { // inversion |
| 5985 | expr_ty inversion_var; |
| 5986 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 5987 | (inversion_var = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5988 | ) |
| 5989 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5990 | _res = inversion_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5991 | goto done; |
| 5992 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5993 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5994 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5995 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5996 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 5997 | _PyPegen_insert_memo(p, _mark, conjunction_type, _res); |
| 5998 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 5999 | } |
| 6000 | |
| 6001 | // inversion: 'not' inversion | comparison |
| 6002 | static expr_ty |
| 6003 | inversion_rule(Parser *p) |
| 6004 | { |
| 6005 | if (p->error_indicator) { |
| 6006 | return NULL; |
| 6007 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6008 | expr_ty _res = NULL; |
| 6009 | if (_PyPegen_is_memoized(p, inversion_type, &_res)) |
| 6010 | return _res; |
| 6011 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6012 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6013 | p->error_indicator = 1; |
| 6014 | return NULL; |
| 6015 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6016 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6017 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6018 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6019 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6020 | { // 'not' inversion |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6021 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6022 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6023 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6024 | (_keyword = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6025 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6026 | (a = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6027 | ) |
| 6028 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6029 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6030 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6031 | return NULL; |
| 6032 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6033 | int _end_lineno = _token->end_lineno; |
| 6034 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6035 | int _end_col_offset = _token->end_col_offset; |
| 6036 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6037 | _res = _Py_UnaryOp ( Not , a , EXTRA ); |
| 6038 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6039 | p->error_indicator = 1; |
| 6040 | return NULL; |
| 6041 | } |
| 6042 | goto done; |
| 6043 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6044 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6045 | } |
| 6046 | { // comparison |
| 6047 | expr_ty comparison_var; |
| 6048 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6049 | (comparison_var = comparison_rule(p)) // comparison |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6050 | ) |
| 6051 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6052 | _res = comparison_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6053 | goto done; |
| 6054 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6055 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6056 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6057 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6058 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6059 | _PyPegen_insert_memo(p, _mark, inversion_type, _res); |
| 6060 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6061 | } |
| 6062 | |
| 6063 | // comparison: bitwise_or compare_op_bitwise_or_pair+ | bitwise_or |
| 6064 | static expr_ty |
| 6065 | comparison_rule(Parser *p) |
| 6066 | { |
| 6067 | if (p->error_indicator) { |
| 6068 | return NULL; |
| 6069 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6070 | expr_ty _res = NULL; |
| 6071 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6072 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6073 | p->error_indicator = 1; |
| 6074 | return NULL; |
| 6075 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6076 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6077 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6078 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6079 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6080 | { // bitwise_or compare_op_bitwise_or_pair+ |
| 6081 | expr_ty a; |
| 6082 | asdl_seq * b; |
| 6083 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6084 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6085 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6086 | (b = _loop1_91_rule(p)) // compare_op_bitwise_or_pair+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6087 | ) |
| 6088 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6089 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6090 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6091 | return NULL; |
| 6092 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6093 | int _end_lineno = _token->end_lineno; |
| 6094 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6095 | int _end_col_offset = _token->end_col_offset; |
| 6096 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6097 | _res = _Py_Compare ( a , CHECK ( _PyPegen_get_cmpops ( p , b ) ) , CHECK ( _PyPegen_get_exprs ( p , b ) ) , EXTRA ); |
| 6098 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6099 | p->error_indicator = 1; |
| 6100 | return NULL; |
| 6101 | } |
| 6102 | goto done; |
| 6103 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6104 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6105 | } |
| 6106 | { // bitwise_or |
| 6107 | expr_ty bitwise_or_var; |
| 6108 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6109 | (bitwise_or_var = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6110 | ) |
| 6111 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6112 | _res = bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6113 | goto done; |
| 6114 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6115 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6116 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6117 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6118 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6119 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6120 | } |
| 6121 | |
| 6122 | // compare_op_bitwise_or_pair: |
| 6123 | // | eq_bitwise_or |
| 6124 | // | noteq_bitwise_or |
| 6125 | // | lte_bitwise_or |
| 6126 | // | lt_bitwise_or |
| 6127 | // | gte_bitwise_or |
| 6128 | // | gt_bitwise_or |
| 6129 | // | notin_bitwise_or |
| 6130 | // | in_bitwise_or |
| 6131 | // | isnot_bitwise_or |
| 6132 | // | is_bitwise_or |
| 6133 | static CmpopExprPair* |
| 6134 | compare_op_bitwise_or_pair_rule(Parser *p) |
| 6135 | { |
| 6136 | if (p->error_indicator) { |
| 6137 | return NULL; |
| 6138 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6139 | CmpopExprPair* _res = NULL; |
| 6140 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6141 | { // eq_bitwise_or |
| 6142 | CmpopExprPair* eq_bitwise_or_var; |
| 6143 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6144 | (eq_bitwise_or_var = eq_bitwise_or_rule(p)) // eq_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6145 | ) |
| 6146 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6147 | _res = eq_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6148 | goto done; |
| 6149 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6150 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6151 | } |
| 6152 | { // noteq_bitwise_or |
| 6153 | CmpopExprPair* noteq_bitwise_or_var; |
| 6154 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6155 | (noteq_bitwise_or_var = noteq_bitwise_or_rule(p)) // noteq_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6156 | ) |
| 6157 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6158 | _res = noteq_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6159 | goto done; |
| 6160 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6161 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6162 | } |
| 6163 | { // lte_bitwise_or |
| 6164 | CmpopExprPair* lte_bitwise_or_var; |
| 6165 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6166 | (lte_bitwise_or_var = lte_bitwise_or_rule(p)) // lte_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6167 | ) |
| 6168 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6169 | _res = lte_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6170 | goto done; |
| 6171 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6172 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6173 | } |
| 6174 | { // lt_bitwise_or |
| 6175 | CmpopExprPair* lt_bitwise_or_var; |
| 6176 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6177 | (lt_bitwise_or_var = lt_bitwise_or_rule(p)) // lt_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6178 | ) |
| 6179 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6180 | _res = lt_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6181 | goto done; |
| 6182 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6183 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6184 | } |
| 6185 | { // gte_bitwise_or |
| 6186 | CmpopExprPair* gte_bitwise_or_var; |
| 6187 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6188 | (gte_bitwise_or_var = gte_bitwise_or_rule(p)) // gte_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6189 | ) |
| 6190 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6191 | _res = gte_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6192 | goto done; |
| 6193 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6194 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6195 | } |
| 6196 | { // gt_bitwise_or |
| 6197 | CmpopExprPair* gt_bitwise_or_var; |
| 6198 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6199 | (gt_bitwise_or_var = gt_bitwise_or_rule(p)) // gt_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6200 | ) |
| 6201 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6202 | _res = gt_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6203 | goto done; |
| 6204 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6205 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6206 | } |
| 6207 | { // notin_bitwise_or |
| 6208 | CmpopExprPair* notin_bitwise_or_var; |
| 6209 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6210 | (notin_bitwise_or_var = notin_bitwise_or_rule(p)) // notin_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6211 | ) |
| 6212 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6213 | _res = notin_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6214 | goto done; |
| 6215 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6216 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6217 | } |
| 6218 | { // in_bitwise_or |
| 6219 | CmpopExprPair* in_bitwise_or_var; |
| 6220 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6221 | (in_bitwise_or_var = in_bitwise_or_rule(p)) // in_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6222 | ) |
| 6223 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6224 | _res = in_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6225 | goto done; |
| 6226 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6227 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6228 | } |
| 6229 | { // isnot_bitwise_or |
| 6230 | CmpopExprPair* isnot_bitwise_or_var; |
| 6231 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6232 | (isnot_bitwise_or_var = isnot_bitwise_or_rule(p)) // isnot_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6233 | ) |
| 6234 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6235 | _res = isnot_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6236 | goto done; |
| 6237 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6238 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6239 | } |
| 6240 | { // is_bitwise_or |
| 6241 | CmpopExprPair* is_bitwise_or_var; |
| 6242 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6243 | (is_bitwise_or_var = is_bitwise_or_rule(p)) // is_bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6244 | ) |
| 6245 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6246 | _res = is_bitwise_or_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6247 | goto done; |
| 6248 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6249 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6250 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6251 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6252 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6253 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6254 | } |
| 6255 | |
| 6256 | // eq_bitwise_or: '==' bitwise_or |
| 6257 | static CmpopExprPair* |
| 6258 | eq_bitwise_or_rule(Parser *p) |
| 6259 | { |
| 6260 | if (p->error_indicator) { |
| 6261 | return NULL; |
| 6262 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6263 | CmpopExprPair* _res = NULL; |
| 6264 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6265 | { // '==' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6266 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6267 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6268 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6269 | (_literal = _PyPegen_expect_token(p, 27)) // token='==' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6270 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6271 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6272 | ) |
| 6273 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6274 | _res = _PyPegen_cmpop_expr_pair ( p , Eq , a ); |
| 6275 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6276 | p->error_indicator = 1; |
| 6277 | return NULL; |
| 6278 | } |
| 6279 | goto done; |
| 6280 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6281 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6282 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6283 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6284 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6285 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6286 | } |
| 6287 | |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 6288 | // noteq_bitwise_or: ('!=') bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6289 | static CmpopExprPair* |
| 6290 | noteq_bitwise_or_rule(Parser *p) |
| 6291 | { |
| 6292 | if (p->error_indicator) { |
| 6293 | return NULL; |
| 6294 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6295 | CmpopExprPair* _res = NULL; |
| 6296 | int _mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 6297 | { // ('!=') bitwise_or |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 6298 | void *_tmp_92_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6299 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6300 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6301 | (_tmp_92_var = _tmp_92_rule(p)) // '!=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6302 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6303 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6304 | ) |
| 6305 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6306 | _res = _PyPegen_cmpop_expr_pair ( p , NotEq , a ); |
| 6307 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6308 | p->error_indicator = 1; |
| 6309 | return NULL; |
| 6310 | } |
| 6311 | goto done; |
| 6312 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6313 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6314 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6315 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6316 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6317 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6318 | } |
| 6319 | |
| 6320 | // lte_bitwise_or: '<=' bitwise_or |
| 6321 | static CmpopExprPair* |
| 6322 | lte_bitwise_or_rule(Parser *p) |
| 6323 | { |
| 6324 | if (p->error_indicator) { |
| 6325 | return NULL; |
| 6326 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6327 | CmpopExprPair* _res = NULL; |
| 6328 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6329 | { // '<=' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6330 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6331 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6332 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6333 | (_literal = _PyPegen_expect_token(p, 29)) // token='<=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6334 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6335 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6336 | ) |
| 6337 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6338 | _res = _PyPegen_cmpop_expr_pair ( p , LtE , a ); |
| 6339 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6340 | p->error_indicator = 1; |
| 6341 | return NULL; |
| 6342 | } |
| 6343 | goto done; |
| 6344 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6345 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6347 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6348 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6349 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6350 | } |
| 6351 | |
| 6352 | // lt_bitwise_or: '<' bitwise_or |
| 6353 | static CmpopExprPair* |
| 6354 | lt_bitwise_or_rule(Parser *p) |
| 6355 | { |
| 6356 | if (p->error_indicator) { |
| 6357 | return NULL; |
| 6358 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6359 | CmpopExprPair* _res = NULL; |
| 6360 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6361 | { // '<' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6362 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6363 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6364 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6365 | (_literal = _PyPegen_expect_token(p, 20)) // token='<' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6366 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6367 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6368 | ) |
| 6369 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6370 | _res = _PyPegen_cmpop_expr_pair ( p , Lt , a ); |
| 6371 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6372 | p->error_indicator = 1; |
| 6373 | return NULL; |
| 6374 | } |
| 6375 | goto done; |
| 6376 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6377 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6378 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6379 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6380 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6381 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6382 | } |
| 6383 | |
| 6384 | // gte_bitwise_or: '>=' bitwise_or |
| 6385 | static CmpopExprPair* |
| 6386 | gte_bitwise_or_rule(Parser *p) |
| 6387 | { |
| 6388 | if (p->error_indicator) { |
| 6389 | return NULL; |
| 6390 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6391 | CmpopExprPair* _res = NULL; |
| 6392 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6393 | { // '>=' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6394 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6395 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6396 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6397 | (_literal = _PyPegen_expect_token(p, 30)) // token='>=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6398 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6399 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6400 | ) |
| 6401 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6402 | _res = _PyPegen_cmpop_expr_pair ( p , GtE , a ); |
| 6403 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6404 | p->error_indicator = 1; |
| 6405 | return NULL; |
| 6406 | } |
| 6407 | goto done; |
| 6408 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6409 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6410 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6411 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6412 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6413 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6414 | } |
| 6415 | |
| 6416 | // gt_bitwise_or: '>' bitwise_or |
| 6417 | static CmpopExprPair* |
| 6418 | gt_bitwise_or_rule(Parser *p) |
| 6419 | { |
| 6420 | if (p->error_indicator) { |
| 6421 | return NULL; |
| 6422 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6423 | CmpopExprPair* _res = NULL; |
| 6424 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6425 | { // '>' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6426 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6427 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6428 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6429 | (_literal = _PyPegen_expect_token(p, 21)) // token='>' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6430 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6431 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6432 | ) |
| 6433 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6434 | _res = _PyPegen_cmpop_expr_pair ( p , Gt , a ); |
| 6435 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6436 | p->error_indicator = 1; |
| 6437 | return NULL; |
| 6438 | } |
| 6439 | goto done; |
| 6440 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6441 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6442 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6443 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6444 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6445 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6446 | } |
| 6447 | |
| 6448 | // notin_bitwise_or: 'not' 'in' bitwise_or |
| 6449 | static CmpopExprPair* |
| 6450 | notin_bitwise_or_rule(Parser *p) |
| 6451 | { |
| 6452 | if (p->error_indicator) { |
| 6453 | return NULL; |
| 6454 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6455 | CmpopExprPair* _res = NULL; |
| 6456 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6457 | { // 'not' 'in' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6458 | Token * _keyword; |
| 6459 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6460 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6461 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6462 | (_keyword = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6463 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6464 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6465 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6466 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6467 | ) |
| 6468 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6469 | _res = _PyPegen_cmpop_expr_pair ( p , NotIn , a ); |
| 6470 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6471 | p->error_indicator = 1; |
| 6472 | return NULL; |
| 6473 | } |
| 6474 | goto done; |
| 6475 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6476 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6477 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6478 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6479 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6480 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6481 | } |
| 6482 | |
| 6483 | // in_bitwise_or: 'in' bitwise_or |
| 6484 | static CmpopExprPair* |
| 6485 | in_bitwise_or_rule(Parser *p) |
| 6486 | { |
| 6487 | if (p->error_indicator) { |
| 6488 | return NULL; |
| 6489 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6490 | CmpopExprPair* _res = NULL; |
| 6491 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6492 | { // 'in' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6493 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6494 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6495 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6496 | (_keyword = _PyPegen_expect_token(p, 518)) // token='in' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6497 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6498 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6499 | ) |
| 6500 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6501 | _res = _PyPegen_cmpop_expr_pair ( p , In , a ); |
| 6502 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6503 | p->error_indicator = 1; |
| 6504 | return NULL; |
| 6505 | } |
| 6506 | goto done; |
| 6507 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6508 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6509 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6510 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6511 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6512 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6513 | } |
| 6514 | |
| 6515 | // isnot_bitwise_or: 'is' 'not' bitwise_or |
| 6516 | static CmpopExprPair* |
| 6517 | isnot_bitwise_or_rule(Parser *p) |
| 6518 | { |
| 6519 | if (p->error_indicator) { |
| 6520 | return NULL; |
| 6521 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6522 | CmpopExprPair* _res = NULL; |
| 6523 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6524 | { // 'is' 'not' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6525 | Token * _keyword; |
| 6526 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6527 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6528 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6529 | (_keyword = _PyPegen_expect_token(p, 526)) // token='is' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6530 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6531 | (_keyword_1 = _PyPegen_expect_token(p, 525)) // token='not' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6532 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6533 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6534 | ) |
| 6535 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6536 | _res = _PyPegen_cmpop_expr_pair ( p , IsNot , a ); |
| 6537 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6538 | p->error_indicator = 1; |
| 6539 | return NULL; |
| 6540 | } |
| 6541 | goto done; |
| 6542 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6543 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6544 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6545 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6546 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6547 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6548 | } |
| 6549 | |
| 6550 | // is_bitwise_or: 'is' bitwise_or |
| 6551 | static CmpopExprPair* |
| 6552 | is_bitwise_or_rule(Parser *p) |
| 6553 | { |
| 6554 | if (p->error_indicator) { |
| 6555 | return NULL; |
| 6556 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6557 | CmpopExprPair* _res = NULL; |
| 6558 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6559 | { // 'is' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6560 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6561 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6562 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6563 | (_keyword = _PyPegen_expect_token(p, 526)) // token='is' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6564 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6565 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6566 | ) |
| 6567 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6568 | _res = _PyPegen_cmpop_expr_pair ( p , Is , a ); |
| 6569 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6570 | p->error_indicator = 1; |
| 6571 | return NULL; |
| 6572 | } |
| 6573 | goto done; |
| 6574 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6575 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6576 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6577 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6578 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6579 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6580 | } |
| 6581 | |
| 6582 | // Left-recursive |
| 6583 | // bitwise_or: bitwise_or '|' bitwise_xor | bitwise_xor |
| 6584 | static expr_ty bitwise_or_raw(Parser *); |
| 6585 | static expr_ty |
| 6586 | bitwise_or_rule(Parser *p) |
| 6587 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6588 | expr_ty _res = NULL; |
| 6589 | if (_PyPegen_is_memoized(p, bitwise_or_type, &_res)) |
| 6590 | return _res; |
| 6591 | int _mark = p->mark; |
| 6592 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6593 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6594 | int tmpvar_1 = _PyPegen_update_memo(p, _mark, bitwise_or_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6595 | if (tmpvar_1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6596 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6597 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6598 | p->mark = _mark; |
| 6599 | void *_raw = bitwise_or_raw(p); |
| 6600 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6601 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6602 | _resmark = p->mark; |
| 6603 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6604 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6605 | p->mark = _resmark; |
| 6606 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6607 | } |
| 6608 | static expr_ty |
| 6609 | bitwise_or_raw(Parser *p) |
| 6610 | { |
| 6611 | if (p->error_indicator) { |
| 6612 | return NULL; |
| 6613 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6614 | expr_ty _res = NULL; |
| 6615 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6616 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6617 | p->error_indicator = 1; |
| 6618 | return NULL; |
| 6619 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6620 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6621 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6622 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6623 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6624 | { // bitwise_or '|' bitwise_xor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6625 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6626 | expr_ty a; |
| 6627 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6628 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6629 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6630 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6631 | (_literal = _PyPegen_expect_token(p, 18)) // token='|' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6632 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6633 | (b = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6634 | ) |
| 6635 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6636 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6637 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6638 | return NULL; |
| 6639 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6640 | int _end_lineno = _token->end_lineno; |
| 6641 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6642 | int _end_col_offset = _token->end_col_offset; |
| 6643 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6644 | _res = _Py_BinOp ( a , BitOr , b , EXTRA ); |
| 6645 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6646 | p->error_indicator = 1; |
| 6647 | return NULL; |
| 6648 | } |
| 6649 | goto done; |
| 6650 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6651 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6652 | } |
| 6653 | { // bitwise_xor |
| 6654 | expr_ty bitwise_xor_var; |
| 6655 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6656 | (bitwise_xor_var = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6657 | ) |
| 6658 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6659 | _res = bitwise_xor_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6660 | goto done; |
| 6661 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6662 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6663 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6664 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6665 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6666 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6667 | } |
| 6668 | |
| 6669 | // Left-recursive |
| 6670 | // bitwise_xor: bitwise_xor '^' bitwise_and | bitwise_and |
| 6671 | static expr_ty bitwise_xor_raw(Parser *); |
| 6672 | static expr_ty |
| 6673 | bitwise_xor_rule(Parser *p) |
| 6674 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6675 | expr_ty _res = NULL; |
| 6676 | if (_PyPegen_is_memoized(p, bitwise_xor_type, &_res)) |
| 6677 | return _res; |
| 6678 | int _mark = p->mark; |
| 6679 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6680 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6681 | int tmpvar_2 = _PyPegen_update_memo(p, _mark, bitwise_xor_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6682 | if (tmpvar_2) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6683 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6684 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6685 | p->mark = _mark; |
| 6686 | void *_raw = bitwise_xor_raw(p); |
| 6687 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6688 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6689 | _resmark = p->mark; |
| 6690 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6691 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6692 | p->mark = _resmark; |
| 6693 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6694 | } |
| 6695 | static expr_ty |
| 6696 | bitwise_xor_raw(Parser *p) |
| 6697 | { |
| 6698 | if (p->error_indicator) { |
| 6699 | return NULL; |
| 6700 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6701 | expr_ty _res = NULL; |
| 6702 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6703 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6704 | p->error_indicator = 1; |
| 6705 | return NULL; |
| 6706 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6707 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6708 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6709 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6710 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6711 | { // bitwise_xor '^' bitwise_and |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6712 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6713 | expr_ty a; |
| 6714 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6715 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6716 | (a = bitwise_xor_rule(p)) // bitwise_xor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6717 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6718 | (_literal = _PyPegen_expect_token(p, 32)) // token='^' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6719 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6720 | (b = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6721 | ) |
| 6722 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6723 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6724 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6725 | return NULL; |
| 6726 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6727 | int _end_lineno = _token->end_lineno; |
| 6728 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6729 | int _end_col_offset = _token->end_col_offset; |
| 6730 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6731 | _res = _Py_BinOp ( a , BitXor , b , EXTRA ); |
| 6732 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6733 | p->error_indicator = 1; |
| 6734 | return NULL; |
| 6735 | } |
| 6736 | goto done; |
| 6737 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6738 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6739 | } |
| 6740 | { // bitwise_and |
| 6741 | expr_ty bitwise_and_var; |
| 6742 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6743 | (bitwise_and_var = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6744 | ) |
| 6745 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6746 | _res = bitwise_and_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6747 | goto done; |
| 6748 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6749 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6750 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6751 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6752 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6753 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6754 | } |
| 6755 | |
| 6756 | // Left-recursive |
| 6757 | // bitwise_and: bitwise_and '&' shift_expr | shift_expr |
| 6758 | static expr_ty bitwise_and_raw(Parser *); |
| 6759 | static expr_ty |
| 6760 | bitwise_and_rule(Parser *p) |
| 6761 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6762 | expr_ty _res = NULL; |
| 6763 | if (_PyPegen_is_memoized(p, bitwise_and_type, &_res)) |
| 6764 | return _res; |
| 6765 | int _mark = p->mark; |
| 6766 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6767 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6768 | int tmpvar_3 = _PyPegen_update_memo(p, _mark, bitwise_and_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6769 | if (tmpvar_3) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6770 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6771 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6772 | p->mark = _mark; |
| 6773 | void *_raw = bitwise_and_raw(p); |
| 6774 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6775 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6776 | _resmark = p->mark; |
| 6777 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6778 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6779 | p->mark = _resmark; |
| 6780 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6781 | } |
| 6782 | static expr_ty |
| 6783 | bitwise_and_raw(Parser *p) |
| 6784 | { |
| 6785 | if (p->error_indicator) { |
| 6786 | return NULL; |
| 6787 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6788 | expr_ty _res = NULL; |
| 6789 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6790 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6791 | p->error_indicator = 1; |
| 6792 | return NULL; |
| 6793 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6794 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6795 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6796 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6797 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6798 | { // bitwise_and '&' shift_expr |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6799 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6800 | expr_ty a; |
| 6801 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6802 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6803 | (a = bitwise_and_rule(p)) // bitwise_and |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6804 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6805 | (_literal = _PyPegen_expect_token(p, 19)) // token='&' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6806 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6807 | (b = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6808 | ) |
| 6809 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6810 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6811 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6812 | return NULL; |
| 6813 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6814 | int _end_lineno = _token->end_lineno; |
| 6815 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6816 | int _end_col_offset = _token->end_col_offset; |
| 6817 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6818 | _res = _Py_BinOp ( a , BitAnd , b , EXTRA ); |
| 6819 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6820 | p->error_indicator = 1; |
| 6821 | return NULL; |
| 6822 | } |
| 6823 | goto done; |
| 6824 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6825 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6826 | } |
| 6827 | { // shift_expr |
| 6828 | expr_ty shift_expr_var; |
| 6829 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6830 | (shift_expr_var = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6831 | ) |
| 6832 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6833 | _res = shift_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6834 | goto done; |
| 6835 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6836 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6837 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6838 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6839 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6840 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6841 | } |
| 6842 | |
| 6843 | // Left-recursive |
| 6844 | // shift_expr: shift_expr '<<' sum | shift_expr '>>' sum | sum |
| 6845 | static expr_ty shift_expr_raw(Parser *); |
| 6846 | static expr_ty |
| 6847 | shift_expr_rule(Parser *p) |
| 6848 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6849 | expr_ty _res = NULL; |
| 6850 | if (_PyPegen_is_memoized(p, shift_expr_type, &_res)) |
| 6851 | return _res; |
| 6852 | int _mark = p->mark; |
| 6853 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6854 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6855 | int tmpvar_4 = _PyPegen_update_memo(p, _mark, shift_expr_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6856 | if (tmpvar_4) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6857 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6858 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6859 | p->mark = _mark; |
| 6860 | void *_raw = shift_expr_raw(p); |
| 6861 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6862 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6863 | _resmark = p->mark; |
| 6864 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6865 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6866 | p->mark = _resmark; |
| 6867 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6868 | } |
| 6869 | static expr_ty |
| 6870 | shift_expr_raw(Parser *p) |
| 6871 | { |
| 6872 | if (p->error_indicator) { |
| 6873 | return NULL; |
| 6874 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6875 | expr_ty _res = NULL; |
| 6876 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6877 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6878 | p->error_indicator = 1; |
| 6879 | return NULL; |
| 6880 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6881 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6882 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6883 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 6884 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6885 | { // shift_expr '<<' sum |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6886 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6887 | expr_ty a; |
| 6888 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6889 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6890 | (a = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6891 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6892 | (_literal = _PyPegen_expect_token(p, 33)) // token='<<' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6893 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6894 | (b = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6895 | ) |
| 6896 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6897 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6898 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6899 | return NULL; |
| 6900 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6901 | int _end_lineno = _token->end_lineno; |
| 6902 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6903 | int _end_col_offset = _token->end_col_offset; |
| 6904 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6905 | _res = _Py_BinOp ( a , LShift , b , EXTRA ); |
| 6906 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6907 | p->error_indicator = 1; |
| 6908 | return NULL; |
| 6909 | } |
| 6910 | goto done; |
| 6911 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6912 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6913 | } |
| 6914 | { // shift_expr '>>' sum |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6915 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6916 | expr_ty a; |
| 6917 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6918 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6919 | (a = shift_expr_rule(p)) // shift_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6920 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6921 | (_literal = _PyPegen_expect_token(p, 34)) // token='>>' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6922 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6923 | (b = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6924 | ) |
| 6925 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6926 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 6927 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6928 | return NULL; |
| 6929 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6930 | int _end_lineno = _token->end_lineno; |
| 6931 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 6932 | int _end_col_offset = _token->end_col_offset; |
| 6933 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 6934 | _res = _Py_BinOp ( a , RShift , b , EXTRA ); |
| 6935 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6936 | p->error_indicator = 1; |
| 6937 | return NULL; |
| 6938 | } |
| 6939 | goto done; |
| 6940 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6941 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6942 | } |
| 6943 | { // sum |
| 6944 | expr_ty sum_var; |
| 6945 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 6946 | (sum_var = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6947 | ) |
| 6948 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6949 | _res = sum_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6950 | goto done; |
| 6951 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6952 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6953 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6954 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6955 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6956 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6957 | } |
| 6958 | |
| 6959 | // Left-recursive |
| 6960 | // sum: sum '+' term | sum '-' term | term |
| 6961 | static expr_ty sum_raw(Parser *); |
| 6962 | static expr_ty |
| 6963 | sum_rule(Parser *p) |
| 6964 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6965 | expr_ty _res = NULL; |
| 6966 | if (_PyPegen_is_memoized(p, sum_type, &_res)) |
| 6967 | return _res; |
| 6968 | int _mark = p->mark; |
| 6969 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6970 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6971 | int tmpvar_5 = _PyPegen_update_memo(p, _mark, sum_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6972 | if (tmpvar_5) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6973 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6974 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6975 | p->mark = _mark; |
| 6976 | void *_raw = sum_raw(p); |
| 6977 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6978 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6979 | _resmark = p->mark; |
| 6980 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6981 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6982 | p->mark = _resmark; |
| 6983 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6984 | } |
| 6985 | static expr_ty |
| 6986 | sum_raw(Parser *p) |
| 6987 | { |
| 6988 | if (p->error_indicator) { |
| 6989 | return NULL; |
| 6990 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6991 | expr_ty _res = NULL; |
| 6992 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 6993 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 6994 | p->error_indicator = 1; |
| 6995 | return NULL; |
| 6996 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 6997 | int _start_lineno = p->tokens[_mark]->lineno; |
| 6998 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 6999 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7000 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7001 | { // sum '+' term |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7002 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7003 | expr_ty a; |
| 7004 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7005 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7006 | (a = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7007 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7008 | (_literal = _PyPegen_expect_token(p, 14)) // token='+' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7009 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7010 | (b = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7011 | ) |
| 7012 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7013 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7014 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7015 | return NULL; |
| 7016 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7017 | int _end_lineno = _token->end_lineno; |
| 7018 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7019 | int _end_col_offset = _token->end_col_offset; |
| 7020 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7021 | _res = _Py_BinOp ( a , Add , b , EXTRA ); |
| 7022 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7023 | p->error_indicator = 1; |
| 7024 | return NULL; |
| 7025 | } |
| 7026 | goto done; |
| 7027 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7028 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7029 | } |
| 7030 | { // sum '-' term |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7031 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7032 | expr_ty a; |
| 7033 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7034 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7035 | (a = sum_rule(p)) // sum |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7036 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7037 | (_literal = _PyPegen_expect_token(p, 15)) // token='-' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7038 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7039 | (b = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7040 | ) |
| 7041 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7042 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7043 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7044 | return NULL; |
| 7045 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7046 | int _end_lineno = _token->end_lineno; |
| 7047 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7048 | int _end_col_offset = _token->end_col_offset; |
| 7049 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7050 | _res = _Py_BinOp ( a , Sub , b , EXTRA ); |
| 7051 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7052 | p->error_indicator = 1; |
| 7053 | return NULL; |
| 7054 | } |
| 7055 | goto done; |
| 7056 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7057 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7058 | } |
| 7059 | { // term |
| 7060 | expr_ty term_var; |
| 7061 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7062 | (term_var = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7063 | ) |
| 7064 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7065 | _res = term_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7066 | goto done; |
| 7067 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7068 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7069 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7070 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7071 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7072 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7073 | } |
| 7074 | |
| 7075 | // Left-recursive |
| 7076 | // term: |
| 7077 | // | term '*' factor |
| 7078 | // | term '/' factor |
| 7079 | // | term '//' factor |
| 7080 | // | term '%' factor |
| 7081 | // | term '@' factor |
| 7082 | // | factor |
| 7083 | static expr_ty term_raw(Parser *); |
| 7084 | static expr_ty |
| 7085 | term_rule(Parser *p) |
| 7086 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7087 | expr_ty _res = NULL; |
| 7088 | if (_PyPegen_is_memoized(p, term_type, &_res)) |
| 7089 | return _res; |
| 7090 | int _mark = p->mark; |
| 7091 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7092 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7093 | int tmpvar_6 = _PyPegen_update_memo(p, _mark, term_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7094 | if (tmpvar_6) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7095 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7096 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7097 | p->mark = _mark; |
| 7098 | void *_raw = term_raw(p); |
| 7099 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7100 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7101 | _resmark = p->mark; |
| 7102 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7103 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7104 | p->mark = _resmark; |
| 7105 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7106 | } |
| 7107 | static expr_ty |
| 7108 | term_raw(Parser *p) |
| 7109 | { |
| 7110 | if (p->error_indicator) { |
| 7111 | return NULL; |
| 7112 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7113 | expr_ty _res = NULL; |
| 7114 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7115 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7116 | p->error_indicator = 1; |
| 7117 | return NULL; |
| 7118 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7119 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7120 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7121 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7122 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7123 | { // term '*' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7124 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7125 | expr_ty a; |
| 7126 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7127 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7128 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7129 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7130 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7131 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7132 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7133 | ) |
| 7134 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7135 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7136 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7137 | return NULL; |
| 7138 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7139 | int _end_lineno = _token->end_lineno; |
| 7140 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7141 | int _end_col_offset = _token->end_col_offset; |
| 7142 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7143 | _res = _Py_BinOp ( a , Mult , b , EXTRA ); |
| 7144 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7145 | p->error_indicator = 1; |
| 7146 | return NULL; |
| 7147 | } |
| 7148 | goto done; |
| 7149 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7150 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7151 | } |
| 7152 | { // term '/' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7153 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7154 | expr_ty a; |
| 7155 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7156 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7157 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7158 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7159 | (_literal = _PyPegen_expect_token(p, 17)) // token='/' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7160 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7161 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7162 | ) |
| 7163 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7164 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7165 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7166 | return NULL; |
| 7167 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7168 | int _end_lineno = _token->end_lineno; |
| 7169 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7170 | int _end_col_offset = _token->end_col_offset; |
| 7171 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7172 | _res = _Py_BinOp ( a , Div , b , EXTRA ); |
| 7173 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7174 | p->error_indicator = 1; |
| 7175 | return NULL; |
| 7176 | } |
| 7177 | goto done; |
| 7178 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7179 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7180 | } |
| 7181 | { // term '//' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7182 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7183 | expr_ty a; |
| 7184 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7185 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7186 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7187 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7188 | (_literal = _PyPegen_expect_token(p, 47)) // token='//' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7189 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7190 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7191 | ) |
| 7192 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7193 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7194 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7195 | return NULL; |
| 7196 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7197 | int _end_lineno = _token->end_lineno; |
| 7198 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7199 | int _end_col_offset = _token->end_col_offset; |
| 7200 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7201 | _res = _Py_BinOp ( a , FloorDiv , b , EXTRA ); |
| 7202 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7203 | p->error_indicator = 1; |
| 7204 | return NULL; |
| 7205 | } |
| 7206 | goto done; |
| 7207 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7208 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7209 | } |
| 7210 | { // term '%' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7211 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7212 | expr_ty a; |
| 7213 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7214 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7215 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7216 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7217 | (_literal = _PyPegen_expect_token(p, 24)) // token='%' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7218 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7219 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7220 | ) |
| 7221 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7222 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7223 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7224 | return NULL; |
| 7225 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7226 | int _end_lineno = _token->end_lineno; |
| 7227 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7228 | int _end_col_offset = _token->end_col_offset; |
| 7229 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7230 | _res = _Py_BinOp ( a , Mod , b , EXTRA ); |
| 7231 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7232 | p->error_indicator = 1; |
| 7233 | return NULL; |
| 7234 | } |
| 7235 | goto done; |
| 7236 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7237 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7238 | } |
| 7239 | { // term '@' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7240 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7241 | expr_ty a; |
| 7242 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7243 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7244 | (a = term_rule(p)) // term |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7245 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7246 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7247 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7248 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7249 | ) |
| 7250 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7251 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7252 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7253 | return NULL; |
| 7254 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7255 | int _end_lineno = _token->end_lineno; |
| 7256 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7257 | int _end_col_offset = _token->end_col_offset; |
| 7258 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7259 | _res = CHECK_VERSION ( 5 , "The '@' operator is" , _Py_BinOp ( a , MatMult , b , EXTRA ) ); |
| 7260 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7261 | p->error_indicator = 1; |
| 7262 | return NULL; |
| 7263 | } |
| 7264 | goto done; |
| 7265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7266 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7267 | } |
| 7268 | { // factor |
| 7269 | expr_ty factor_var; |
| 7270 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7271 | (factor_var = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7272 | ) |
| 7273 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7274 | _res = factor_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7275 | goto done; |
| 7276 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7277 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7278 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7279 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7280 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7281 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7282 | } |
| 7283 | |
| 7284 | // factor: '+' factor | '-' factor | '~' factor | power |
| 7285 | static expr_ty |
| 7286 | factor_rule(Parser *p) |
| 7287 | { |
| 7288 | if (p->error_indicator) { |
| 7289 | return NULL; |
| 7290 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7291 | expr_ty _res = NULL; |
| 7292 | if (_PyPegen_is_memoized(p, factor_type, &_res)) |
| 7293 | return _res; |
| 7294 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7295 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7296 | p->error_indicator = 1; |
| 7297 | return NULL; |
| 7298 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7299 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7300 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7301 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7302 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7303 | { // '+' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7304 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7305 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7306 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7307 | (_literal = _PyPegen_expect_token(p, 14)) // token='+' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7308 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7309 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7310 | ) |
| 7311 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7312 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7313 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7314 | return NULL; |
| 7315 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7316 | int _end_lineno = _token->end_lineno; |
| 7317 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7318 | int _end_col_offset = _token->end_col_offset; |
| 7319 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7320 | _res = _Py_UnaryOp ( UAdd , a , EXTRA ); |
| 7321 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7322 | p->error_indicator = 1; |
| 7323 | return NULL; |
| 7324 | } |
| 7325 | goto done; |
| 7326 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7327 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7328 | } |
| 7329 | { // '-' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7330 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7331 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7332 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7333 | (_literal = _PyPegen_expect_token(p, 15)) // token='-' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7334 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7335 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7336 | ) |
| 7337 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7338 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7339 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7340 | return NULL; |
| 7341 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7342 | int _end_lineno = _token->end_lineno; |
| 7343 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7344 | int _end_col_offset = _token->end_col_offset; |
| 7345 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7346 | _res = _Py_UnaryOp ( USub , a , EXTRA ); |
| 7347 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7348 | p->error_indicator = 1; |
| 7349 | return NULL; |
| 7350 | } |
| 7351 | goto done; |
| 7352 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7353 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7354 | } |
| 7355 | { // '~' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7356 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7357 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7358 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7359 | (_literal = _PyPegen_expect_token(p, 31)) // token='~' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7360 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7361 | (a = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7362 | ) |
| 7363 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7364 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7365 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7366 | return NULL; |
| 7367 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7368 | int _end_lineno = _token->end_lineno; |
| 7369 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7370 | int _end_col_offset = _token->end_col_offset; |
| 7371 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7372 | _res = _Py_UnaryOp ( Invert , a , EXTRA ); |
| 7373 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7374 | p->error_indicator = 1; |
| 7375 | return NULL; |
| 7376 | } |
| 7377 | goto done; |
| 7378 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7379 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7380 | } |
| 7381 | { // power |
| 7382 | expr_ty power_var; |
| 7383 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7384 | (power_var = power_rule(p)) // power |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7385 | ) |
| 7386 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7387 | _res = power_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7388 | goto done; |
| 7389 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7390 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7391 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7392 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7393 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7394 | _PyPegen_insert_memo(p, _mark, factor_type, _res); |
| 7395 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7396 | } |
| 7397 | |
| 7398 | // power: await_primary '**' factor | await_primary |
| 7399 | static expr_ty |
| 7400 | power_rule(Parser *p) |
| 7401 | { |
| 7402 | if (p->error_indicator) { |
| 7403 | return NULL; |
| 7404 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7405 | expr_ty _res = NULL; |
| 7406 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7407 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7408 | p->error_indicator = 1; |
| 7409 | return NULL; |
| 7410 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7411 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7412 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7413 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7414 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7415 | { // await_primary '**' factor |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7416 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7417 | expr_ty a; |
| 7418 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7419 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7420 | (a = await_primary_rule(p)) // await_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7421 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7422 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7423 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7424 | (b = factor_rule(p)) // factor |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7425 | ) |
| 7426 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7427 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7428 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7429 | return NULL; |
| 7430 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7431 | int _end_lineno = _token->end_lineno; |
| 7432 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7433 | int _end_col_offset = _token->end_col_offset; |
| 7434 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7435 | _res = _Py_BinOp ( a , Pow , b , EXTRA ); |
| 7436 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7437 | p->error_indicator = 1; |
| 7438 | return NULL; |
| 7439 | } |
| 7440 | goto done; |
| 7441 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7442 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7443 | } |
| 7444 | { // await_primary |
| 7445 | expr_ty await_primary_var; |
| 7446 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7447 | (await_primary_var = await_primary_rule(p)) // await_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7448 | ) |
| 7449 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7450 | _res = await_primary_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7451 | goto done; |
| 7452 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7453 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7454 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7455 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7456 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7457 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7458 | } |
| 7459 | |
| 7460 | // await_primary: AWAIT primary | primary |
| 7461 | static expr_ty |
| 7462 | await_primary_rule(Parser *p) |
| 7463 | { |
| 7464 | if (p->error_indicator) { |
| 7465 | return NULL; |
| 7466 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7467 | expr_ty _res = NULL; |
| 7468 | if (_PyPegen_is_memoized(p, await_primary_type, &_res)) |
| 7469 | return _res; |
| 7470 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7471 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7472 | p->error_indicator = 1; |
| 7473 | return NULL; |
| 7474 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7475 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7476 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7477 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7478 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7479 | { // AWAIT primary |
| 7480 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 7481 | Token * await_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7482 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7483 | (await_var = _PyPegen_expect_token(p, AWAIT)) // token='AWAIT' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7484 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7485 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7486 | ) |
| 7487 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7488 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7489 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7490 | return NULL; |
| 7491 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7492 | int _end_lineno = _token->end_lineno; |
| 7493 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7494 | int _end_col_offset = _token->end_col_offset; |
| 7495 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7496 | _res = CHECK_VERSION ( 5 , "Await expressions are" , _Py_Await ( a , EXTRA ) ); |
| 7497 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7498 | p->error_indicator = 1; |
| 7499 | return NULL; |
| 7500 | } |
| 7501 | goto done; |
| 7502 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7503 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7504 | } |
| 7505 | { // primary |
| 7506 | expr_ty primary_var; |
| 7507 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7508 | (primary_var = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7509 | ) |
| 7510 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7511 | _res = primary_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7512 | goto done; |
| 7513 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7514 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7515 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7516 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7517 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7518 | _PyPegen_insert_memo(p, _mark, await_primary_type, _res); |
| 7519 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7520 | } |
| 7521 | |
| 7522 | // Left-recursive |
| 7523 | // primary: |
| 7524 | // | primary '.' NAME |
| 7525 | // | primary genexp |
| 7526 | // | primary '(' arguments? ')' |
| 7527 | // | primary '[' slices ']' |
| 7528 | // | atom |
| 7529 | static expr_ty primary_raw(Parser *); |
| 7530 | static expr_ty |
| 7531 | primary_rule(Parser *p) |
| 7532 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7533 | expr_ty _res = NULL; |
| 7534 | if (_PyPegen_is_memoized(p, primary_type, &_res)) |
| 7535 | return _res; |
| 7536 | int _mark = p->mark; |
| 7537 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7538 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7539 | int tmpvar_7 = _PyPegen_update_memo(p, _mark, primary_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7540 | if (tmpvar_7) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7541 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7542 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7543 | p->mark = _mark; |
| 7544 | void *_raw = primary_raw(p); |
| 7545 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7546 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7547 | _resmark = p->mark; |
| 7548 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7549 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7550 | p->mark = _resmark; |
| 7551 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7552 | } |
| 7553 | static expr_ty |
| 7554 | primary_raw(Parser *p) |
| 7555 | { |
| 7556 | if (p->error_indicator) { |
| 7557 | return NULL; |
| 7558 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7559 | expr_ty _res = NULL; |
| 7560 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7561 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7562 | p->error_indicator = 1; |
| 7563 | return NULL; |
| 7564 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7565 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7566 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7567 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7568 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7569 | { // primary '.' NAME |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7570 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7571 | expr_ty a; |
| 7572 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7573 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7574 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7575 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7576 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7577 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7578 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7579 | ) |
| 7580 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7581 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7582 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7583 | return NULL; |
| 7584 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7585 | int _end_lineno = _token->end_lineno; |
| 7586 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7587 | int _end_col_offset = _token->end_col_offset; |
| 7588 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7589 | _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
| 7590 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7591 | p->error_indicator = 1; |
| 7592 | return NULL; |
| 7593 | } |
| 7594 | goto done; |
| 7595 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7596 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7597 | } |
| 7598 | { // primary genexp |
| 7599 | expr_ty a; |
| 7600 | expr_ty b; |
| 7601 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7602 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7603 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7604 | (b = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7605 | ) |
| 7606 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7607 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7608 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7609 | return NULL; |
| 7610 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7611 | int _end_lineno = _token->end_lineno; |
| 7612 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7613 | int _end_col_offset = _token->end_col_offset; |
| 7614 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7615 | _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
| 7616 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7617 | p->error_indicator = 1; |
| 7618 | return NULL; |
| 7619 | } |
| 7620 | goto done; |
| 7621 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7622 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7623 | } |
| 7624 | { // primary '(' arguments? ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7625 | Token * _literal; |
| 7626 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7627 | expr_ty a; |
| 7628 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7629 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7630 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7631 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7632 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7633 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7634 | (b = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7635 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7636 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7637 | ) |
| 7638 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7639 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7640 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7641 | return NULL; |
| 7642 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7643 | int _end_lineno = _token->end_lineno; |
| 7644 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7645 | int _end_col_offset = _token->end_col_offset; |
| 7646 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7647 | _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 7648 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7649 | p->error_indicator = 1; |
| 7650 | return NULL; |
| 7651 | } |
| 7652 | goto done; |
| 7653 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7654 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7655 | } |
| 7656 | { // primary '[' slices ']' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7657 | Token * _literal; |
| 7658 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7659 | expr_ty a; |
| 7660 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7661 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7662 | (a = primary_rule(p)) // primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7663 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7664 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7665 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7666 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7667 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7668 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7669 | ) |
| 7670 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7671 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7672 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7673 | return NULL; |
| 7674 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7675 | int _end_lineno = _token->end_lineno; |
| 7676 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7677 | int _end_col_offset = _token->end_col_offset; |
| 7678 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7679 | _res = _Py_Subscript ( a , b , Load , EXTRA ); |
| 7680 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7681 | p->error_indicator = 1; |
| 7682 | return NULL; |
| 7683 | } |
| 7684 | goto done; |
| 7685 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7686 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7687 | } |
| 7688 | { // atom |
| 7689 | expr_ty atom_var; |
| 7690 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7691 | (atom_var = atom_rule(p)) // atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7692 | ) |
| 7693 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7694 | _res = atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7695 | goto done; |
| 7696 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7697 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7698 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7699 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7700 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7701 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7702 | } |
| 7703 | |
| 7704 | // slices: slice !',' | ','.slice+ ','? |
| 7705 | static expr_ty |
| 7706 | slices_rule(Parser *p) |
| 7707 | { |
| 7708 | if (p->error_indicator) { |
| 7709 | return NULL; |
| 7710 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7711 | expr_ty _res = NULL; |
| 7712 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7713 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7714 | p->error_indicator = 1; |
| 7715 | return NULL; |
| 7716 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7717 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7718 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7719 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7720 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7721 | { // slice !',' |
| 7722 | expr_ty a; |
| 7723 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7724 | (a = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7725 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7726 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7727 | ) |
| 7728 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7729 | _res = a; |
| 7730 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7731 | p->error_indicator = 1; |
| 7732 | return NULL; |
| 7733 | } |
| 7734 | goto done; |
| 7735 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7736 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7737 | } |
| 7738 | { // ','.slice+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7739 | void *_opt_var; |
| 7740 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7741 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7742 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7743 | (a = _gather_93_rule(p)) // ','.slice+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7744 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7745 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7746 | ) |
| 7747 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7748 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7749 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7750 | return NULL; |
| 7751 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7752 | int _end_lineno = _token->end_lineno; |
| 7753 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7754 | int _end_col_offset = _token->end_col_offset; |
| 7755 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7756 | _res = _Py_Tuple ( a , Load , EXTRA ); |
| 7757 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7758 | p->error_indicator = 1; |
| 7759 | return NULL; |
| 7760 | } |
| 7761 | goto done; |
| 7762 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7763 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7764 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7765 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7766 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7767 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7768 | } |
| 7769 | |
| 7770 | // slice: expression? ':' expression? [':' expression?] | expression |
| 7771 | static expr_ty |
| 7772 | slice_rule(Parser *p) |
| 7773 | { |
| 7774 | if (p->error_indicator) { |
| 7775 | return NULL; |
| 7776 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7777 | expr_ty _res = NULL; |
| 7778 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7779 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7780 | p->error_indicator = 1; |
| 7781 | return NULL; |
| 7782 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7783 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7784 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7785 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7786 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7787 | { // expression? ':' expression? [':' expression?] |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7788 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7789 | void *a; |
| 7790 | void *b; |
| 7791 | void *c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7792 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7793 | (a = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7794 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7795 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7796 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7797 | (b = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7798 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7799 | (c = _tmp_95_rule(p), 1) // [':' expression?] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7800 | ) |
| 7801 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7802 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7803 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7804 | return NULL; |
| 7805 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7806 | int _end_lineno = _token->end_lineno; |
| 7807 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7808 | int _end_col_offset = _token->end_col_offset; |
| 7809 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7810 | _res = _Py_Slice ( a , b , c , EXTRA ); |
| 7811 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7812 | p->error_indicator = 1; |
| 7813 | return NULL; |
| 7814 | } |
| 7815 | goto done; |
| 7816 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7817 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7818 | } |
| 7819 | { // expression |
| 7820 | expr_ty a; |
| 7821 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7822 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7823 | ) |
| 7824 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7825 | _res = a; |
| 7826 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7827 | p->error_indicator = 1; |
| 7828 | return NULL; |
| 7829 | } |
| 7830 | goto done; |
| 7831 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7832 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7833 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7834 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7835 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7836 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7837 | } |
| 7838 | |
| 7839 | // atom: |
| 7840 | // | NAME |
| 7841 | // | 'True' |
| 7842 | // | 'False' |
| 7843 | // | 'None' |
| 7844 | // | '__new_parser__' |
| 7845 | // | &STRING strings |
| 7846 | // | NUMBER |
| 7847 | // | &'(' (tuple | group | genexp) |
| 7848 | // | &'[' (list | listcomp) |
| 7849 | // | &'{' (dict | set | dictcomp | setcomp) |
| 7850 | // | '...' |
| 7851 | static expr_ty |
| 7852 | atom_rule(Parser *p) |
| 7853 | { |
| 7854 | if (p->error_indicator) { |
| 7855 | return NULL; |
| 7856 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7857 | expr_ty _res = NULL; |
| 7858 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7859 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 7860 | p->error_indicator = 1; |
| 7861 | return NULL; |
| 7862 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7863 | int _start_lineno = p->tokens[_mark]->lineno; |
| 7864 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 7865 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 7866 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7867 | { // NAME |
| 7868 | expr_ty name_var; |
| 7869 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7870 | (name_var = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7871 | ) |
| 7872 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7873 | _res = name_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7874 | goto done; |
| 7875 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7876 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7877 | } |
| 7878 | { // 'True' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7879 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7880 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7881 | (_keyword = _PyPegen_expect_token(p, 527)) // token='True' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7882 | ) |
| 7883 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7884 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7885 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7886 | return NULL; |
| 7887 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7888 | int _end_lineno = _token->end_lineno; |
| 7889 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7890 | int _end_col_offset = _token->end_col_offset; |
| 7891 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7892 | _res = _Py_Constant ( Py_True , NULL , EXTRA ); |
| 7893 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7894 | p->error_indicator = 1; |
| 7895 | return NULL; |
| 7896 | } |
| 7897 | goto done; |
| 7898 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7899 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7900 | } |
| 7901 | { // 'False' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7902 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7903 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7904 | (_keyword = _PyPegen_expect_token(p, 528)) // token='False' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7905 | ) |
| 7906 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7907 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7908 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7909 | return NULL; |
| 7910 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7911 | int _end_lineno = _token->end_lineno; |
| 7912 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7913 | int _end_col_offset = _token->end_col_offset; |
| 7914 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7915 | _res = _Py_Constant ( Py_False , NULL , EXTRA ); |
| 7916 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7917 | p->error_indicator = 1; |
| 7918 | return NULL; |
| 7919 | } |
| 7920 | goto done; |
| 7921 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7922 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7923 | } |
| 7924 | { // 'None' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7925 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7926 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7927 | (_keyword = _PyPegen_expect_token(p, 529)) // token='None' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7928 | ) |
| 7929 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7930 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 7931 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7932 | return NULL; |
| 7933 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7934 | int _end_lineno = _token->end_lineno; |
| 7935 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 7936 | int _end_col_offset = _token->end_col_offset; |
| 7937 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 7938 | _res = _Py_Constant ( Py_None , NULL , EXTRA ); |
| 7939 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7940 | p->error_indicator = 1; |
| 7941 | return NULL; |
| 7942 | } |
| 7943 | goto done; |
| 7944 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7945 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7946 | } |
| 7947 | { // '__new_parser__' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7948 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7949 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7950 | (_keyword = _PyPegen_expect_token(p, 530)) // token='__new_parser__' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7951 | ) |
| 7952 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7953 | _res = RAISE_SYNTAX_ERROR ( "You found it!" ); |
| 7954 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7955 | p->error_indicator = 1; |
| 7956 | return NULL; |
| 7957 | } |
| 7958 | goto done; |
| 7959 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7960 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7961 | } |
| 7962 | { // &STRING strings |
| 7963 | expr_ty strings_var; |
| 7964 | if ( |
| 7965 | _PyPegen_lookahead(1, _PyPegen_string_token, p) |
| 7966 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7967 | (strings_var = strings_rule(p)) // strings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7968 | ) |
| 7969 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7970 | _res = strings_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7971 | goto done; |
| 7972 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7973 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7974 | } |
| 7975 | { // NUMBER |
| 7976 | expr_ty number_var; |
| 7977 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7978 | (number_var = _PyPegen_number_token(p)) // NUMBER |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7979 | ) |
| 7980 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7981 | _res = number_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7982 | goto done; |
| 7983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7984 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7985 | } |
| 7986 | { // &'(' (tuple | group | genexp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 7987 | void *_tmp_96_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7988 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7989 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 7) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7990 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 7991 | (_tmp_96_var = _tmp_96_rule(p)) // tuple | group | genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7992 | ) |
| 7993 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7994 | _res = _tmp_96_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7995 | goto done; |
| 7996 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 7997 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 7998 | } |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 7999 | { // &'[' (list | listcomp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8000 | void *_tmp_97_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8001 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8002 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 9) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8003 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8004 | (_tmp_97_var = _tmp_97_rule(p)) // list | listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8005 | ) |
| 8006 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8007 | _res = _tmp_97_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8008 | goto done; |
| 8009 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8010 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8011 | } |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8012 | { // &'{' (dict | set | dictcomp | setcomp) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8013 | void *_tmp_98_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8014 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8015 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 25) // token='{' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8016 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8017 | (_tmp_98_var = _tmp_98_rule(p)) // dict | set | dictcomp | setcomp |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8018 | ) |
| 8019 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8020 | _res = _tmp_98_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8021 | goto done; |
| 8022 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8023 | p->mark = _mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 8024 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8025 | { // '...' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8026 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8027 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8028 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8029 | ) |
| 8030 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8031 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8032 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8033 | return NULL; |
| 8034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8035 | int _end_lineno = _token->end_lineno; |
| 8036 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8037 | int _end_col_offset = _token->end_col_offset; |
| 8038 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8039 | _res = _Py_Constant ( Py_Ellipsis , NULL , EXTRA ); |
| 8040 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8041 | p->error_indicator = 1; |
| 8042 | return NULL; |
| 8043 | } |
| 8044 | goto done; |
| 8045 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8046 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8047 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8048 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8049 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8050 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8051 | } |
| 8052 | |
| 8053 | // strings: STRING+ |
| 8054 | static expr_ty |
| 8055 | strings_rule(Parser *p) |
| 8056 | { |
| 8057 | if (p->error_indicator) { |
| 8058 | return NULL; |
| 8059 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8060 | expr_ty _res = NULL; |
| 8061 | if (_PyPegen_is_memoized(p, strings_type, &_res)) |
| 8062 | return _res; |
| 8063 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8064 | { // STRING+ |
| 8065 | asdl_seq * a; |
| 8066 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8067 | (a = _loop1_99_rule(p)) // STRING+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8068 | ) |
| 8069 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8070 | _res = _PyPegen_concatenate_strings ( p , a ); |
| 8071 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8072 | p->error_indicator = 1; |
| 8073 | return NULL; |
| 8074 | } |
| 8075 | goto done; |
| 8076 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8077 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8078 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8079 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8080 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8081 | _PyPegen_insert_memo(p, _mark, strings_type, _res); |
| 8082 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8083 | } |
| 8084 | |
| 8085 | // list: '[' star_named_expressions? ']' |
| 8086 | static expr_ty |
| 8087 | list_rule(Parser *p) |
| 8088 | { |
| 8089 | if (p->error_indicator) { |
| 8090 | return NULL; |
| 8091 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8092 | expr_ty _res = NULL; |
| 8093 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8094 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8095 | p->error_indicator = 1; |
| 8096 | return NULL; |
| 8097 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8098 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8099 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8100 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8101 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8102 | { // '[' star_named_expressions? ']' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8103 | Token * _literal; |
| 8104 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8105 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8106 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8107 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8108 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8109 | (a = star_named_expressions_rule(p), 1) // star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8110 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8111 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8112 | ) |
| 8113 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8114 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8115 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8116 | return NULL; |
| 8117 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8118 | int _end_lineno = _token->end_lineno; |
| 8119 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8120 | int _end_col_offset = _token->end_col_offset; |
| 8121 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8122 | _res = _Py_List ( a , Load , EXTRA ); |
| 8123 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8124 | p->error_indicator = 1; |
| 8125 | return NULL; |
| 8126 | } |
| 8127 | goto done; |
| 8128 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8129 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8130 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8131 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8132 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8133 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8134 | } |
| 8135 | |
| 8136 | // listcomp: '[' named_expression for_if_clauses ']' | invalid_comprehension |
| 8137 | static expr_ty |
| 8138 | listcomp_rule(Parser *p) |
| 8139 | { |
| 8140 | if (p->error_indicator) { |
| 8141 | return NULL; |
| 8142 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8143 | expr_ty _res = NULL; |
| 8144 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8145 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8146 | p->error_indicator = 1; |
| 8147 | return NULL; |
| 8148 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8149 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8150 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8151 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8152 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8153 | { // '[' named_expression for_if_clauses ']' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8154 | Token * _literal; |
| 8155 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8156 | expr_ty a; |
| 8157 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8158 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8159 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8160 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8161 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8162 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8163 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8164 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8165 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8166 | ) |
| 8167 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8168 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8169 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8170 | return NULL; |
| 8171 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8172 | int _end_lineno = _token->end_lineno; |
| 8173 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8174 | int _end_col_offset = _token->end_col_offset; |
| 8175 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8176 | _res = _Py_ListComp ( a , b , EXTRA ); |
| 8177 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8178 | p->error_indicator = 1; |
| 8179 | return NULL; |
| 8180 | } |
| 8181 | goto done; |
| 8182 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8183 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8184 | } |
| 8185 | { // invalid_comprehension |
| 8186 | void *invalid_comprehension_var; |
| 8187 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8188 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8189 | ) |
| 8190 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8191 | _res = invalid_comprehension_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8192 | goto done; |
| 8193 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8194 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8195 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8196 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8197 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8198 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8199 | } |
| 8200 | |
| 8201 | // tuple: '(' [star_named_expression ',' star_named_expressions?] ')' |
| 8202 | static expr_ty |
| 8203 | tuple_rule(Parser *p) |
| 8204 | { |
| 8205 | if (p->error_indicator) { |
| 8206 | return NULL; |
| 8207 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8208 | expr_ty _res = NULL; |
| 8209 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8210 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8211 | p->error_indicator = 1; |
| 8212 | return NULL; |
| 8213 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8214 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8215 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8216 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8217 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8218 | { // '(' [star_named_expression ',' star_named_expressions?] ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8219 | Token * _literal; |
| 8220 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8221 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8222 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8223 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8224 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8225 | (a = _tmp_100_rule(p), 1) // [star_named_expression ',' star_named_expressions?] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8226 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8227 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8228 | ) |
| 8229 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8230 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8231 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8232 | return NULL; |
| 8233 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8234 | int _end_lineno = _token->end_lineno; |
| 8235 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8236 | int _end_col_offset = _token->end_col_offset; |
| 8237 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8238 | _res = _Py_Tuple ( a , Load , EXTRA ); |
| 8239 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8240 | p->error_indicator = 1; |
| 8241 | return NULL; |
| 8242 | } |
| 8243 | goto done; |
| 8244 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8245 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8246 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8247 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8248 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8249 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8250 | } |
| 8251 | |
| 8252 | // group: '(' (yield_expr | named_expression) ')' |
| 8253 | static expr_ty |
| 8254 | group_rule(Parser *p) |
| 8255 | { |
| 8256 | if (p->error_indicator) { |
| 8257 | return NULL; |
| 8258 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8259 | expr_ty _res = NULL; |
| 8260 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8261 | { // '(' (yield_expr | named_expression) ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8262 | Token * _literal; |
| 8263 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8264 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8265 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8266 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8267 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8268 | (a = _tmp_101_rule(p)) // yield_expr | named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8269 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8270 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8271 | ) |
| 8272 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8273 | _res = a; |
| 8274 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8275 | p->error_indicator = 1; |
| 8276 | return NULL; |
| 8277 | } |
| 8278 | goto done; |
| 8279 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8280 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8281 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8282 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8283 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8284 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8285 | } |
| 8286 | |
| 8287 | // genexp: '(' expression for_if_clauses ')' | invalid_comprehension |
| 8288 | static expr_ty |
| 8289 | genexp_rule(Parser *p) |
| 8290 | { |
| 8291 | if (p->error_indicator) { |
| 8292 | return NULL; |
| 8293 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8294 | expr_ty _res = NULL; |
| 8295 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8296 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8297 | p->error_indicator = 1; |
| 8298 | return NULL; |
| 8299 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8300 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8301 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8302 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8303 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8304 | { // '(' expression for_if_clauses ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8305 | Token * _literal; |
| 8306 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8307 | expr_ty a; |
| 8308 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8309 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8310 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8311 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8312 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8313 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8314 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8315 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8316 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8317 | ) |
| 8318 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8319 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8320 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8321 | return NULL; |
| 8322 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8323 | int _end_lineno = _token->end_lineno; |
| 8324 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8325 | int _end_col_offset = _token->end_col_offset; |
| 8326 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8327 | _res = _Py_GeneratorExp ( a , b , EXTRA ); |
| 8328 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8329 | p->error_indicator = 1; |
| 8330 | return NULL; |
| 8331 | } |
| 8332 | goto done; |
| 8333 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8334 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8335 | } |
| 8336 | { // invalid_comprehension |
| 8337 | void *invalid_comprehension_var; |
| 8338 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8339 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8340 | ) |
| 8341 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8342 | _res = invalid_comprehension_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8343 | goto done; |
| 8344 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8345 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8347 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8348 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8349 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8350 | } |
| 8351 | |
| 8352 | // set: '{' expressions_list '}' |
| 8353 | static expr_ty |
| 8354 | set_rule(Parser *p) |
| 8355 | { |
| 8356 | if (p->error_indicator) { |
| 8357 | return NULL; |
| 8358 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8359 | expr_ty _res = NULL; |
| 8360 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8361 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8362 | p->error_indicator = 1; |
| 8363 | return NULL; |
| 8364 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8365 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8366 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8367 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8368 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8369 | { // '{' expressions_list '}' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8370 | Token * _literal; |
| 8371 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8372 | asdl_seq* a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8373 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8374 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8375 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8376 | (a = expressions_list_rule(p)) // expressions_list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8377 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8378 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8379 | ) |
| 8380 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8381 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8382 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8383 | return NULL; |
| 8384 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8385 | int _end_lineno = _token->end_lineno; |
| 8386 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8387 | int _end_col_offset = _token->end_col_offset; |
| 8388 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8389 | _res = _Py_Set ( a , EXTRA ); |
| 8390 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8391 | p->error_indicator = 1; |
| 8392 | return NULL; |
| 8393 | } |
| 8394 | goto done; |
| 8395 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8396 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8397 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8398 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8399 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8400 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8401 | } |
| 8402 | |
| 8403 | // setcomp: '{' expression for_if_clauses '}' | invalid_comprehension |
| 8404 | static expr_ty |
| 8405 | setcomp_rule(Parser *p) |
| 8406 | { |
| 8407 | if (p->error_indicator) { |
| 8408 | return NULL; |
| 8409 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8410 | expr_ty _res = NULL; |
| 8411 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8412 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8413 | p->error_indicator = 1; |
| 8414 | return NULL; |
| 8415 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8416 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8417 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8418 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8419 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8420 | { // '{' expression for_if_clauses '}' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8421 | Token * _literal; |
| 8422 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8423 | expr_ty a; |
| 8424 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8425 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8426 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8427 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8428 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8429 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8430 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8431 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8432 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8433 | ) |
| 8434 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8435 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8436 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8437 | return NULL; |
| 8438 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8439 | int _end_lineno = _token->end_lineno; |
| 8440 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8441 | int _end_col_offset = _token->end_col_offset; |
| 8442 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8443 | _res = _Py_SetComp ( a , b , EXTRA ); |
| 8444 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8445 | p->error_indicator = 1; |
| 8446 | return NULL; |
| 8447 | } |
| 8448 | goto done; |
| 8449 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8450 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8451 | } |
| 8452 | { // invalid_comprehension |
| 8453 | void *invalid_comprehension_var; |
| 8454 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8455 | (invalid_comprehension_var = invalid_comprehension_rule(p)) // invalid_comprehension |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8456 | ) |
| 8457 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8458 | _res = invalid_comprehension_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8459 | goto done; |
| 8460 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8461 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8462 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8463 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8464 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8465 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8466 | } |
| 8467 | |
| 8468 | // dict: '{' kvpairs? '}' |
| 8469 | static expr_ty |
| 8470 | dict_rule(Parser *p) |
| 8471 | { |
| 8472 | if (p->error_indicator) { |
| 8473 | return NULL; |
| 8474 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8475 | expr_ty _res = NULL; |
| 8476 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8477 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8478 | p->error_indicator = 1; |
| 8479 | return NULL; |
| 8480 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8481 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8482 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8483 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8484 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8485 | { // '{' kvpairs? '}' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8486 | Token * _literal; |
| 8487 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8488 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8489 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8490 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8491 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8492 | (a = kvpairs_rule(p), 1) // kvpairs? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8493 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8494 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8495 | ) |
| 8496 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8497 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8498 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8499 | return NULL; |
| 8500 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8501 | int _end_lineno = _token->end_lineno; |
| 8502 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8503 | int _end_col_offset = _token->end_col_offset; |
| 8504 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8505 | _res = _Py_Dict ( CHECK ( _PyPegen_get_keys ( p , a ) ) , CHECK ( _PyPegen_get_values ( p , a ) ) , EXTRA ); |
| 8506 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8507 | p->error_indicator = 1; |
| 8508 | return NULL; |
| 8509 | } |
| 8510 | goto done; |
| 8511 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8512 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8513 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8514 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8515 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8516 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8517 | } |
| 8518 | |
| 8519 | // dictcomp: '{' kvpair for_if_clauses '}' |
| 8520 | static expr_ty |
| 8521 | dictcomp_rule(Parser *p) |
| 8522 | { |
| 8523 | if (p->error_indicator) { |
| 8524 | return NULL; |
| 8525 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8526 | expr_ty _res = NULL; |
| 8527 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8528 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8529 | p->error_indicator = 1; |
| 8530 | return NULL; |
| 8531 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8532 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8533 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8534 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8535 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8536 | { // '{' kvpair for_if_clauses '}' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8537 | Token * _literal; |
| 8538 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8539 | KeyValuePair* a; |
| 8540 | asdl_seq* b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8541 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8542 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8543 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8544 | (a = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8545 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8546 | (b = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8547 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8548 | (_literal_1 = _PyPegen_expect_token(p, 26)) // token='}' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8549 | ) |
| 8550 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8551 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8552 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8553 | return NULL; |
| 8554 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8555 | int _end_lineno = _token->end_lineno; |
| 8556 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8557 | int _end_col_offset = _token->end_col_offset; |
| 8558 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8559 | _res = _Py_DictComp ( a -> key , a -> value , b , EXTRA ); |
| 8560 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8561 | p->error_indicator = 1; |
| 8562 | return NULL; |
| 8563 | } |
| 8564 | goto done; |
| 8565 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8566 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8567 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8568 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8569 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8570 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8571 | } |
| 8572 | |
| 8573 | // kvpairs: ','.kvpair+ ','? |
| 8574 | static asdl_seq* |
| 8575 | kvpairs_rule(Parser *p) |
| 8576 | { |
| 8577 | if (p->error_indicator) { |
| 8578 | return NULL; |
| 8579 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8580 | asdl_seq* _res = NULL; |
| 8581 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8582 | { // ','.kvpair+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8583 | void *_opt_var; |
| 8584 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8585 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8586 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8587 | (a = _gather_102_rule(p)) // ','.kvpair+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8588 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8589 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8590 | ) |
| 8591 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8592 | _res = a; |
| 8593 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8594 | p->error_indicator = 1; |
| 8595 | return NULL; |
| 8596 | } |
| 8597 | goto done; |
| 8598 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8599 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8600 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8601 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8602 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8603 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8604 | } |
| 8605 | |
| 8606 | // kvpair: '**' bitwise_or | expression ':' expression |
| 8607 | static KeyValuePair* |
| 8608 | kvpair_rule(Parser *p) |
| 8609 | { |
| 8610 | if (p->error_indicator) { |
| 8611 | return NULL; |
| 8612 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8613 | KeyValuePair* _res = NULL; |
| 8614 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8615 | { // '**' bitwise_or |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8616 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8617 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8618 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8619 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8620 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8621 | (a = bitwise_or_rule(p)) // bitwise_or |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8622 | ) |
| 8623 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8624 | _res = _PyPegen_key_value_pair ( p , NULL , a ); |
| 8625 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8626 | p->error_indicator = 1; |
| 8627 | return NULL; |
| 8628 | } |
| 8629 | goto done; |
| 8630 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8631 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8632 | } |
| 8633 | { // expression ':' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8634 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8635 | expr_ty a; |
| 8636 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8637 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8638 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8639 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8640 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8641 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8642 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8643 | ) |
| 8644 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8645 | _res = _PyPegen_key_value_pair ( p , a , b ); |
| 8646 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8647 | p->error_indicator = 1; |
| 8648 | return NULL; |
| 8649 | } |
| 8650 | goto done; |
| 8651 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8652 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8653 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8654 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8655 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8656 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8657 | } |
| 8658 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8659 | // for_if_clauses: for_if_clause+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8660 | static asdl_seq* |
| 8661 | for_if_clauses_rule(Parser *p) |
| 8662 | { |
| 8663 | if (p->error_indicator) { |
| 8664 | return NULL; |
| 8665 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8666 | asdl_seq* _res = NULL; |
| 8667 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8668 | { // for_if_clause+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 8669 | asdl_seq * _loop1_104_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8670 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8671 | (_loop1_104_var = _loop1_104_rule(p)) // for_if_clause+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8672 | ) |
| 8673 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8674 | _res = _loop1_104_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8675 | goto done; |
| 8676 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8677 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8678 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8679 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8680 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8681 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8682 | } |
| 8683 | |
| 8684 | // for_if_clause: |
| 8685 | // | ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8686 | // | 'for' star_targets 'in' disjunction (('if' disjunction))* |
| 8687 | static comprehension_ty |
| 8688 | for_if_clause_rule(Parser *p) |
| 8689 | { |
| 8690 | if (p->error_indicator) { |
| 8691 | return NULL; |
| 8692 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8693 | comprehension_ty _res = NULL; |
| 8694 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8695 | { // ASYNC 'for' star_targets 'in' disjunction (('if' disjunction))* |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8696 | Token * _keyword; |
| 8697 | Token * _keyword_1; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8698 | expr_ty a; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 8699 | Token * async_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8700 | expr_ty b; |
| 8701 | asdl_seq * c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8702 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8703 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8704 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8705 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8706 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8707 | (a = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8708 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8709 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8710 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8711 | (b = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8712 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8713 | (c = _loop0_105_rule(p)) // (('if' disjunction))* |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8714 | ) |
| 8715 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8716 | _res = CHECK_VERSION ( 6 , "Async comprehensions are" , _Py_comprehension ( a , b , c , 1 , p -> arena ) ); |
| 8717 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8718 | p->error_indicator = 1; |
| 8719 | return NULL; |
| 8720 | } |
| 8721 | goto done; |
| 8722 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8723 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8724 | } |
| 8725 | { // 'for' star_targets 'in' disjunction (('if' disjunction))* |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8726 | Token * _keyword; |
| 8727 | Token * _keyword_1; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8728 | expr_ty a; |
| 8729 | expr_ty b; |
| 8730 | asdl_seq * c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8731 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8732 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8733 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8734 | (a = star_targets_rule(p)) // star_targets |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8735 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8736 | (_keyword_1 = _PyPegen_expect_token(p, 518)) // token='in' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8737 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8738 | (b = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8739 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8740 | (c = _loop0_106_rule(p)) // (('if' disjunction))* |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 8741 | ) |
| 8742 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8743 | _res = _Py_comprehension ( a , b , c , 0 , p -> arena ); |
| 8744 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8745 | p->error_indicator = 1; |
| 8746 | return NULL; |
| 8747 | } |
| 8748 | goto done; |
| 8749 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8750 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8751 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8752 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8753 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8754 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8755 | } |
| 8756 | |
| 8757 | // yield_expr: 'yield' 'from' expression | 'yield' star_expressions? |
| 8758 | static expr_ty |
| 8759 | yield_expr_rule(Parser *p) |
| 8760 | { |
| 8761 | if (p->error_indicator) { |
| 8762 | return NULL; |
| 8763 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8764 | expr_ty _res = NULL; |
| 8765 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8766 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8767 | p->error_indicator = 1; |
| 8768 | return NULL; |
| 8769 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8770 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8771 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8772 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8773 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8774 | { // 'yield' 'from' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8775 | Token * _keyword; |
| 8776 | Token * _keyword_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8777 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8778 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8779 | (_keyword = _PyPegen_expect_token(p, 504)) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8780 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8781 | (_keyword_1 = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8782 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8783 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8784 | ) |
| 8785 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8786 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8787 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8788 | return NULL; |
| 8789 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8790 | int _end_lineno = _token->end_lineno; |
| 8791 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8792 | int _end_col_offset = _token->end_col_offset; |
| 8793 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8794 | _res = _Py_YieldFrom ( a , EXTRA ); |
| 8795 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8796 | p->error_indicator = 1; |
| 8797 | return NULL; |
| 8798 | } |
| 8799 | goto done; |
| 8800 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8801 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8802 | } |
| 8803 | { // 'yield' star_expressions? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8804 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8805 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8806 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8807 | (_keyword = _PyPegen_expect_token(p, 504)) // token='yield' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8808 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8809 | (a = star_expressions_rule(p), 1) // star_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8810 | ) |
| 8811 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8812 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8813 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8814 | return NULL; |
| 8815 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8816 | int _end_lineno = _token->end_lineno; |
| 8817 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8818 | int _end_col_offset = _token->end_col_offset; |
| 8819 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8820 | _res = _Py_Yield ( a , EXTRA ); |
| 8821 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8822 | p->error_indicator = 1; |
| 8823 | return NULL; |
| 8824 | } |
| 8825 | goto done; |
| 8826 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8827 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8828 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8829 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8830 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8831 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8832 | } |
| 8833 | |
| 8834 | // arguments: args ','? &')' | incorrect_arguments |
| 8835 | static expr_ty |
| 8836 | arguments_rule(Parser *p) |
| 8837 | { |
| 8838 | if (p->error_indicator) { |
| 8839 | return NULL; |
| 8840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8841 | expr_ty _res = NULL; |
| 8842 | if (_PyPegen_is_memoized(p, arguments_type, &_res)) |
| 8843 | return _res; |
| 8844 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8845 | { // args ','? &')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8846 | void *_opt_var; |
| 8847 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8848 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8849 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8850 | (a = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8851 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8852 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8853 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8854 | _PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 8) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8855 | ) |
| 8856 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8857 | _res = a; |
| 8858 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8859 | p->error_indicator = 1; |
| 8860 | return NULL; |
| 8861 | } |
| 8862 | goto done; |
| 8863 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8864 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8865 | } |
| 8866 | { // incorrect_arguments |
| 8867 | void *incorrect_arguments_var; |
| 8868 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8869 | (incorrect_arguments_var = incorrect_arguments_rule(p)) // incorrect_arguments |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8870 | ) |
| 8871 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8872 | _res = incorrect_arguments_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8873 | goto done; |
| 8874 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8875 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8876 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8877 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8878 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8879 | _PyPegen_insert_memo(p, _mark, arguments_type, _res); |
| 8880 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8881 | } |
| 8882 | |
| 8883 | // args: starred_expression [',' args] | kwargs | named_expression [',' args] |
| 8884 | static expr_ty |
| 8885 | args_rule(Parser *p) |
| 8886 | { |
| 8887 | if (p->error_indicator) { |
| 8888 | return NULL; |
| 8889 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8890 | expr_ty _res = NULL; |
| 8891 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8892 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 8893 | p->error_indicator = 1; |
| 8894 | return NULL; |
| 8895 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8896 | int _start_lineno = p->tokens[_mark]->lineno; |
| 8897 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 8898 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 8899 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8900 | { // starred_expression [',' args] |
| 8901 | expr_ty a; |
| 8902 | void *b; |
| 8903 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8904 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8905 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8906 | (b = _tmp_107_rule(p), 1) // [',' args] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8907 | ) |
| 8908 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8909 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8910 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8911 | return NULL; |
| 8912 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8913 | int _end_lineno = _token->end_lineno; |
| 8914 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8915 | int _end_col_offset = _token->end_col_offset; |
| 8916 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8917 | _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 ); |
| 8918 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8919 | p->error_indicator = 1; |
| 8920 | return NULL; |
| 8921 | } |
| 8922 | goto done; |
| 8923 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8924 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8925 | } |
| 8926 | { // kwargs |
| 8927 | asdl_seq* a; |
| 8928 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8929 | (a = kwargs_rule(p)) // kwargs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8930 | ) |
| 8931 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8932 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8933 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8934 | return NULL; |
| 8935 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8936 | int _end_lineno = _token->end_lineno; |
| 8937 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8938 | int _end_col_offset = _token->end_col_offset; |
| 8939 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8940 | _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 ); |
| 8941 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8942 | p->error_indicator = 1; |
| 8943 | return NULL; |
| 8944 | } |
| 8945 | goto done; |
| 8946 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8947 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8948 | } |
| 8949 | { // named_expression [',' args] |
| 8950 | expr_ty a; |
| 8951 | void *b; |
| 8952 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8953 | (a = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8954 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8955 | (b = _tmp_108_rule(p), 1) // [',' args] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8956 | ) |
| 8957 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8958 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 8959 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8960 | return NULL; |
| 8961 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8962 | int _end_lineno = _token->end_lineno; |
| 8963 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 8964 | int _end_col_offset = _token->end_col_offset; |
| 8965 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 8966 | _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 ); |
| 8967 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8968 | p->error_indicator = 1; |
| 8969 | return NULL; |
| 8970 | } |
| 8971 | goto done; |
| 8972 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8973 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8974 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8975 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8976 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8977 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8978 | } |
| 8979 | |
| 8980 | // kwargs: |
| 8981 | // | ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
| 8982 | // | ','.kwarg_or_starred+ |
| 8983 | // | ','.kwarg_or_double_starred+ |
| 8984 | static asdl_seq* |
| 8985 | kwargs_rule(Parser *p) |
| 8986 | { |
| 8987 | if (p->error_indicator) { |
| 8988 | return NULL; |
| 8989 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8990 | asdl_seq* _res = NULL; |
| 8991 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8992 | { // ','.kwarg_or_starred+ ',' ','.kwarg_or_double_starred+ |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8993 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8994 | asdl_seq * a; |
| 8995 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8996 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 8997 | (a = _gather_109_rule(p)) // ','.kwarg_or_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 8998 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 8999 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9000 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9001 | (b = _gather_111_rule(p)) // ','.kwarg_or_double_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9002 | ) |
| 9003 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9004 | _res = _PyPegen_join_sequences ( p , a , b ); |
| 9005 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9006 | p->error_indicator = 1; |
| 9007 | return NULL; |
| 9008 | } |
| 9009 | goto done; |
| 9010 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9011 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9012 | } |
| 9013 | { // ','.kwarg_or_starred+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9014 | asdl_seq * _gather_113_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9015 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9016 | (_gather_113_var = _gather_113_rule(p)) // ','.kwarg_or_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9017 | ) |
| 9018 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9019 | _res = _gather_113_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9020 | goto done; |
| 9021 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9022 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9023 | } |
| 9024 | { // ','.kwarg_or_double_starred+ |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 9025 | asdl_seq * _gather_115_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9026 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9027 | (_gather_115_var = _gather_115_rule(p)) // ','.kwarg_or_double_starred+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9028 | ) |
| 9029 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9030 | _res = _gather_115_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9031 | goto done; |
| 9032 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9033 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9035 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9036 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9037 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9038 | } |
| 9039 | |
| 9040 | // starred_expression: '*' expression |
| 9041 | static expr_ty |
| 9042 | starred_expression_rule(Parser *p) |
| 9043 | { |
| 9044 | if (p->error_indicator) { |
| 9045 | return NULL; |
| 9046 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9047 | expr_ty _res = NULL; |
| 9048 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9049 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9050 | p->error_indicator = 1; |
| 9051 | return NULL; |
| 9052 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9053 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9054 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9055 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9056 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9057 | { // '*' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9058 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9059 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9060 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9061 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9062 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9063 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9064 | ) |
| 9065 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9066 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9067 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9068 | return NULL; |
| 9069 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9070 | int _end_lineno = _token->end_lineno; |
| 9071 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9072 | int _end_col_offset = _token->end_col_offset; |
| 9073 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9074 | _res = _Py_Starred ( a , Load , EXTRA ); |
| 9075 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9076 | p->error_indicator = 1; |
| 9077 | return NULL; |
| 9078 | } |
| 9079 | goto done; |
| 9080 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9081 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9082 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9083 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9084 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9085 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9086 | } |
| 9087 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9088 | // kwarg_or_starred: NAME '=' expression | starred_expression | invalid_kwarg |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9089 | static KeywordOrStarred* |
| 9090 | kwarg_or_starred_rule(Parser *p) |
| 9091 | { |
| 9092 | if (p->error_indicator) { |
| 9093 | return NULL; |
| 9094 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9095 | KeywordOrStarred* _res = NULL; |
| 9096 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9097 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9098 | p->error_indicator = 1; |
| 9099 | return NULL; |
| 9100 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9101 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9102 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9103 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9104 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9105 | { // NAME '=' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9106 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9107 | expr_ty a; |
| 9108 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9109 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9110 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9111 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9112 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9113 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9114 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9115 | ) |
| 9116 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9117 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9118 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9119 | return NULL; |
| 9120 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9121 | int _end_lineno = _token->end_lineno; |
| 9122 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9123 | int _end_col_offset = _token->end_col_offset; |
| 9124 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9125 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
| 9126 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9127 | p->error_indicator = 1; |
| 9128 | return NULL; |
| 9129 | } |
| 9130 | goto done; |
| 9131 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9132 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9133 | } |
| 9134 | { // starred_expression |
| 9135 | expr_ty a; |
| 9136 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9137 | (a = starred_expression_rule(p)) // starred_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9138 | ) |
| 9139 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9140 | _res = _PyPegen_keyword_or_starred ( p , a , 0 ); |
| 9141 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9142 | p->error_indicator = 1; |
| 9143 | return NULL; |
| 9144 | } |
| 9145 | goto done; |
| 9146 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9147 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9148 | } |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9149 | { // invalid_kwarg |
| 9150 | void *invalid_kwarg_var; |
| 9151 | if ( |
| 9152 | (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg |
| 9153 | ) |
| 9154 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9155 | _res = invalid_kwarg_var; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9156 | goto done; |
| 9157 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9158 | p->mark = _mark; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9159 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9160 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9161 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9162 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9163 | } |
| 9164 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9165 | // kwarg_or_double_starred: NAME '=' expression | '**' expression | invalid_kwarg |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9166 | static KeywordOrStarred* |
| 9167 | kwarg_or_double_starred_rule(Parser *p) |
| 9168 | { |
| 9169 | if (p->error_indicator) { |
| 9170 | return NULL; |
| 9171 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9172 | KeywordOrStarred* _res = NULL; |
| 9173 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9174 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9175 | p->error_indicator = 1; |
| 9176 | return NULL; |
| 9177 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9178 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9179 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9180 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9181 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9182 | { // NAME '=' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9183 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9184 | expr_ty a; |
| 9185 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9186 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9187 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9188 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9189 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9190 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9191 | (b = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9192 | ) |
| 9193 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9194 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9195 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9196 | return NULL; |
| 9197 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9198 | int _end_lineno = _token->end_lineno; |
| 9199 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9200 | int _end_col_offset = _token->end_col_offset; |
| 9201 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9202 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( a -> v . Name . id , b , EXTRA ) ) , 1 ); |
| 9203 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9204 | p->error_indicator = 1; |
| 9205 | return NULL; |
| 9206 | } |
| 9207 | goto done; |
| 9208 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9209 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9210 | } |
| 9211 | { // '**' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9212 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9213 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9214 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9215 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9216 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9217 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9218 | ) |
| 9219 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9220 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9221 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9222 | return NULL; |
| 9223 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9224 | int _end_lineno = _token->end_lineno; |
| 9225 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9226 | int _end_col_offset = _token->end_col_offset; |
| 9227 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9228 | _res = _PyPegen_keyword_or_starred ( p , CHECK ( _Py_keyword ( NULL , a , EXTRA ) ) , 1 ); |
| 9229 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9230 | p->error_indicator = 1; |
| 9231 | return NULL; |
| 9232 | } |
| 9233 | goto done; |
| 9234 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9235 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9236 | } |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9237 | { // invalid_kwarg |
| 9238 | void *invalid_kwarg_var; |
| 9239 | if ( |
| 9240 | (invalid_kwarg_var = invalid_kwarg_rule(p)) // invalid_kwarg |
| 9241 | ) |
| 9242 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9243 | _res = invalid_kwarg_var; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9244 | goto done; |
| 9245 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9246 | p->mark = _mark; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 9247 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9248 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9249 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9250 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9251 | } |
| 9252 | |
| 9253 | // star_targets: star_target !',' | star_target ((',' star_target))* ','? |
| 9254 | static expr_ty |
| 9255 | star_targets_rule(Parser *p) |
| 9256 | { |
| 9257 | if (p->error_indicator) { |
| 9258 | return NULL; |
| 9259 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9260 | expr_ty _res = NULL; |
| 9261 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9262 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9263 | p->error_indicator = 1; |
| 9264 | return NULL; |
| 9265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9266 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9267 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9268 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9269 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9270 | { // star_target !',' |
| 9271 | expr_ty a; |
| 9272 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9273 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9274 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9275 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 12) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9276 | ) |
| 9277 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9278 | _res = a; |
| 9279 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9280 | p->error_indicator = 1; |
| 9281 | return NULL; |
| 9282 | } |
| 9283 | goto done; |
| 9284 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9285 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9286 | } |
| 9287 | { // star_target ((',' star_target))* ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9288 | void *_opt_var; |
| 9289 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9290 | expr_ty a; |
| 9291 | asdl_seq * b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9292 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9293 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9294 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9295 | (b = _loop0_117_rule(p)) // ((',' star_target))* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9296 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9297 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9298 | ) |
| 9299 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9300 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9301 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9302 | return NULL; |
| 9303 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9304 | int _end_lineno = _token->end_lineno; |
| 9305 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9306 | int _end_col_offset = _token->end_col_offset; |
| 9307 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9308 | _res = _Py_Tuple ( CHECK ( _PyPegen_seq_insert_in_front ( p , a , b ) ) , Store , EXTRA ); |
| 9309 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9310 | p->error_indicator = 1; |
| 9311 | return NULL; |
| 9312 | } |
| 9313 | goto done; |
| 9314 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9315 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9316 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9317 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9318 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9319 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9320 | } |
| 9321 | |
| 9322 | // star_targets_seq: ','.star_target+ ','? |
| 9323 | static asdl_seq* |
| 9324 | star_targets_seq_rule(Parser *p) |
| 9325 | { |
| 9326 | if (p->error_indicator) { |
| 9327 | return NULL; |
| 9328 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9329 | asdl_seq* _res = NULL; |
| 9330 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9331 | { // ','.star_target+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9332 | void *_opt_var; |
| 9333 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9334 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9335 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9336 | (a = _gather_118_rule(p)) // ','.star_target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9337 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9338 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9339 | ) |
| 9340 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9341 | _res = a; |
| 9342 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9343 | p->error_indicator = 1; |
| 9344 | return NULL; |
| 9345 | } |
| 9346 | goto done; |
| 9347 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9348 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9349 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9350 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9351 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9352 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9353 | } |
| 9354 | |
| 9355 | // star_target: |
| 9356 | // | '*' (!'*' star_target) |
| 9357 | // | t_primary '.' NAME !t_lookahead |
| 9358 | // | t_primary '[' slices ']' !t_lookahead |
| 9359 | // | star_atom |
| 9360 | static expr_ty |
| 9361 | star_target_rule(Parser *p) |
| 9362 | { |
| 9363 | if (p->error_indicator) { |
| 9364 | return NULL; |
| 9365 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9366 | expr_ty _res = NULL; |
| 9367 | if (_PyPegen_is_memoized(p, star_target_type, &_res)) |
| 9368 | return _res; |
| 9369 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9370 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9371 | p->error_indicator = 1; |
| 9372 | return NULL; |
| 9373 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9374 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9375 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9376 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9377 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9378 | { // '*' (!'*' star_target) |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9379 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9380 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9381 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9382 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9383 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9384 | (a = _tmp_120_rule(p)) // !'*' star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9385 | ) |
| 9386 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9387 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9388 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9389 | return NULL; |
| 9390 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9391 | int _end_lineno = _token->end_lineno; |
| 9392 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9393 | int _end_col_offset = _token->end_col_offset; |
| 9394 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9395 | _res = _Py_Starred ( CHECK ( _PyPegen_set_expr_context ( p , a , Store ) ) , Store , EXTRA ); |
| 9396 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9397 | p->error_indicator = 1; |
| 9398 | return NULL; |
| 9399 | } |
| 9400 | goto done; |
| 9401 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9402 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9403 | } |
| 9404 | { // t_primary '.' NAME !t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9405 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9406 | expr_ty a; |
| 9407 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9408 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9409 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9410 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9411 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9412 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9413 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9414 | && |
| 9415 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9416 | ) |
| 9417 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9418 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9419 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9420 | return NULL; |
| 9421 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9422 | int _end_lineno = _token->end_lineno; |
| 9423 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9424 | int _end_col_offset = _token->end_col_offset; |
| 9425 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9426 | _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 9427 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9428 | p->error_indicator = 1; |
| 9429 | return NULL; |
| 9430 | } |
| 9431 | goto done; |
| 9432 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9433 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9434 | } |
| 9435 | { // t_primary '[' slices ']' !t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9436 | Token * _literal; |
| 9437 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9438 | expr_ty a; |
| 9439 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9440 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9441 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9442 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9443 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9444 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9445 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9446 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9447 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9448 | && |
| 9449 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9450 | ) |
| 9451 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9452 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9453 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9454 | return NULL; |
| 9455 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9456 | int _end_lineno = _token->end_lineno; |
| 9457 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9458 | int _end_col_offset = _token->end_col_offset; |
| 9459 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9460 | _res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 9461 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9462 | p->error_indicator = 1; |
| 9463 | return NULL; |
| 9464 | } |
| 9465 | goto done; |
| 9466 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9467 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9468 | } |
| 9469 | { // star_atom |
| 9470 | expr_ty star_atom_var; |
| 9471 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9472 | (star_atom_var = star_atom_rule(p)) // star_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9473 | ) |
| 9474 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9475 | _res = star_atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9476 | goto done; |
| 9477 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9478 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9479 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9480 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9481 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9482 | _PyPegen_insert_memo(p, _mark, star_target_type, _res); |
| 9483 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9484 | } |
| 9485 | |
| 9486 | // star_atom: |
| 9487 | // | NAME |
| 9488 | // | '(' star_target ')' |
| 9489 | // | '(' star_targets_seq? ')' |
| 9490 | // | '[' star_targets_seq? ']' |
| 9491 | static expr_ty |
| 9492 | star_atom_rule(Parser *p) |
| 9493 | { |
| 9494 | if (p->error_indicator) { |
| 9495 | return NULL; |
| 9496 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9497 | expr_ty _res = NULL; |
| 9498 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9499 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9500 | p->error_indicator = 1; |
| 9501 | return NULL; |
| 9502 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9503 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9504 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9505 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9506 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9507 | { // NAME |
| 9508 | expr_ty a; |
| 9509 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9510 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9511 | ) |
| 9512 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9513 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9514 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9515 | p->error_indicator = 1; |
| 9516 | return NULL; |
| 9517 | } |
| 9518 | goto done; |
| 9519 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9520 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9521 | } |
| 9522 | { // '(' star_target ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9523 | Token * _literal; |
| 9524 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9525 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9526 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9527 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9528 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9529 | (a = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9530 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9531 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9532 | ) |
| 9533 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9534 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9535 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9536 | p->error_indicator = 1; |
| 9537 | return NULL; |
| 9538 | } |
| 9539 | goto done; |
| 9540 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9541 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9542 | } |
| 9543 | { // '(' star_targets_seq? ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9544 | Token * _literal; |
| 9545 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9546 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9547 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9548 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9549 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9550 | (a = star_targets_seq_rule(p), 1) // star_targets_seq? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9551 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9552 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9553 | ) |
| 9554 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9555 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9556 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9557 | return NULL; |
| 9558 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9559 | int _end_lineno = _token->end_lineno; |
| 9560 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9561 | int _end_col_offset = _token->end_col_offset; |
| 9562 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9563 | _res = _Py_Tuple ( a , Store , EXTRA ); |
| 9564 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9565 | p->error_indicator = 1; |
| 9566 | return NULL; |
| 9567 | } |
| 9568 | goto done; |
| 9569 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9570 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9571 | } |
| 9572 | { // '[' star_targets_seq? ']' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9573 | Token * _literal; |
| 9574 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9575 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9576 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9577 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9578 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9579 | (a = star_targets_seq_rule(p), 1) // star_targets_seq? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9580 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9581 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9582 | ) |
| 9583 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9584 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9585 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9586 | return NULL; |
| 9587 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9588 | int _end_lineno = _token->end_lineno; |
| 9589 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9590 | int _end_col_offset = _token->end_col_offset; |
| 9591 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9592 | _res = _Py_List ( a , Store , EXTRA ); |
| 9593 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9594 | p->error_indicator = 1; |
| 9595 | return NULL; |
| 9596 | } |
| 9597 | goto done; |
| 9598 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9599 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9600 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9601 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9602 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9603 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9604 | } |
| 9605 | |
| 9606 | // inside_paren_ann_assign_target: |
| 9607 | // | ann_assign_subscript_attribute_target |
| 9608 | // | NAME |
| 9609 | // | '(' inside_paren_ann_assign_target ')' |
| 9610 | static expr_ty |
| 9611 | inside_paren_ann_assign_target_rule(Parser *p) |
| 9612 | { |
| 9613 | if (p->error_indicator) { |
| 9614 | return NULL; |
| 9615 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9616 | expr_ty _res = NULL; |
| 9617 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9618 | { // ann_assign_subscript_attribute_target |
| 9619 | expr_ty ann_assign_subscript_attribute_target_var; |
| 9620 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9621 | (ann_assign_subscript_attribute_target_var = ann_assign_subscript_attribute_target_rule(p)) // ann_assign_subscript_attribute_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9622 | ) |
| 9623 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9624 | _res = ann_assign_subscript_attribute_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9625 | goto done; |
| 9626 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9627 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9628 | } |
| 9629 | { // NAME |
| 9630 | expr_ty a; |
| 9631 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9632 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9633 | ) |
| 9634 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9635 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 9636 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9637 | p->error_indicator = 1; |
| 9638 | return NULL; |
| 9639 | } |
| 9640 | goto done; |
| 9641 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9642 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9643 | } |
| 9644 | { // '(' inside_paren_ann_assign_target ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9645 | Token * _literal; |
| 9646 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9647 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9648 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9649 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9650 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9651 | (a = inside_paren_ann_assign_target_rule(p)) // inside_paren_ann_assign_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9652 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9653 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9654 | ) |
| 9655 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9656 | _res = a; |
| 9657 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9658 | p->error_indicator = 1; |
| 9659 | return NULL; |
| 9660 | } |
| 9661 | goto done; |
| 9662 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9663 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9664 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9665 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9666 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9667 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9668 | } |
| 9669 | |
| 9670 | // ann_assign_subscript_attribute_target: |
| 9671 | // | t_primary '.' NAME !t_lookahead |
| 9672 | // | t_primary '[' slices ']' !t_lookahead |
| 9673 | static expr_ty |
| 9674 | ann_assign_subscript_attribute_target_rule(Parser *p) |
| 9675 | { |
| 9676 | if (p->error_indicator) { |
| 9677 | return NULL; |
| 9678 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9679 | expr_ty _res = NULL; |
| 9680 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9681 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9682 | p->error_indicator = 1; |
| 9683 | return NULL; |
| 9684 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9685 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9686 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9687 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9688 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9689 | { // t_primary '.' NAME !t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9690 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9691 | expr_ty a; |
| 9692 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9693 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9694 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9695 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9696 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9697 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9698 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9699 | && |
| 9700 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9701 | ) |
| 9702 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9703 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9704 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9705 | return NULL; |
| 9706 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9707 | int _end_lineno = _token->end_lineno; |
| 9708 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9709 | int _end_col_offset = _token->end_col_offset; |
| 9710 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9711 | _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 9712 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9713 | p->error_indicator = 1; |
| 9714 | return NULL; |
| 9715 | } |
| 9716 | goto done; |
| 9717 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9718 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9719 | } |
| 9720 | { // t_primary '[' slices ']' !t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9721 | Token * _literal; |
| 9722 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9723 | expr_ty a; |
| 9724 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9725 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9726 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9727 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9728 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9729 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9730 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9731 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9732 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9733 | && |
| 9734 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 9735 | ) |
| 9736 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9737 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9738 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9739 | return NULL; |
| 9740 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9741 | int _end_lineno = _token->end_lineno; |
| 9742 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9743 | int _end_col_offset = _token->end_col_offset; |
| 9744 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9745 | _res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 9746 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9747 | p->error_indicator = 1; |
| 9748 | return NULL; |
| 9749 | } |
| 9750 | goto done; |
| 9751 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9752 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9753 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9754 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9755 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9756 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9757 | } |
| 9758 | |
| 9759 | // del_targets: ','.del_target+ ','? |
| 9760 | static asdl_seq* |
| 9761 | del_targets_rule(Parser *p) |
| 9762 | { |
| 9763 | if (p->error_indicator) { |
| 9764 | return NULL; |
| 9765 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9766 | asdl_seq* _res = NULL; |
| 9767 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9768 | { // ','.del_target+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9769 | void *_opt_var; |
| 9770 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9771 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9772 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9773 | (a = _gather_121_rule(p)) // ','.del_target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9774 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9775 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9776 | ) |
| 9777 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9778 | _res = a; |
| 9779 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9780 | p->error_indicator = 1; |
| 9781 | return NULL; |
| 9782 | } |
| 9783 | goto done; |
| 9784 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9785 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9786 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9787 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9788 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9789 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9790 | } |
| 9791 | |
| 9792 | // del_target: |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9793 | // | t_primary '.' NAME &del_target_end |
| 9794 | // | t_primary '[' slices ']' &del_target_end |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9795 | // | del_t_atom |
| 9796 | static expr_ty |
| 9797 | del_target_rule(Parser *p) |
| 9798 | { |
| 9799 | if (p->error_indicator) { |
| 9800 | return NULL; |
| 9801 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9802 | expr_ty _res = NULL; |
| 9803 | if (_PyPegen_is_memoized(p, del_target_type, &_res)) |
| 9804 | return _res; |
| 9805 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9806 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9807 | p->error_indicator = 1; |
| 9808 | return NULL; |
| 9809 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9810 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9811 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9812 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9813 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9814 | { // t_primary '.' NAME &del_target_end |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9815 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9816 | expr_ty a; |
| 9817 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9818 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9819 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9820 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9821 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9822 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9823 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9824 | && |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9825 | _PyPegen_lookahead(1, del_target_end_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9826 | ) |
| 9827 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9828 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9829 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9830 | return NULL; |
| 9831 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9832 | int _end_lineno = _token->end_lineno; |
| 9833 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9834 | int _end_col_offset = _token->end_col_offset; |
| 9835 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9836 | _res = _Py_Attribute ( a , b -> v . Name . id , Del , EXTRA ); |
| 9837 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9838 | p->error_indicator = 1; |
| 9839 | return NULL; |
| 9840 | } |
| 9841 | goto done; |
| 9842 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9843 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9844 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9845 | { // t_primary '[' slices ']' &del_target_end |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9846 | Token * _literal; |
| 9847 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9848 | expr_ty a; |
| 9849 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9850 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9851 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9852 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9853 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9854 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9855 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9856 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9857 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9858 | && |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9859 | _PyPegen_lookahead(1, del_target_end_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9860 | ) |
| 9861 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9862 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9863 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9864 | return NULL; |
| 9865 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9866 | int _end_lineno = _token->end_lineno; |
| 9867 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9868 | int _end_col_offset = _token->end_col_offset; |
| 9869 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9870 | _res = _Py_Subscript ( a , b , Del , EXTRA ); |
| 9871 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9872 | p->error_indicator = 1; |
| 9873 | return NULL; |
| 9874 | } |
| 9875 | goto done; |
| 9876 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9877 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9878 | } |
| 9879 | { // del_t_atom |
| 9880 | expr_ty del_t_atom_var; |
| 9881 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9882 | (del_t_atom_var = del_t_atom_rule(p)) // del_t_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9883 | ) |
| 9884 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9885 | _res = del_t_atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9886 | goto done; |
| 9887 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9888 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9889 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9890 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9891 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9892 | _PyPegen_insert_memo(p, _mark, del_target_type, _res); |
| 9893 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9894 | } |
| 9895 | |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9896 | // del_t_atom: |
| 9897 | // | NAME &del_target_end |
| 9898 | // | '(' del_target ')' |
| 9899 | // | '(' del_targets? ')' |
| 9900 | // | '[' del_targets? ']' |
| 9901 | // | invalid_del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9902 | static expr_ty |
| 9903 | del_t_atom_rule(Parser *p) |
| 9904 | { |
| 9905 | if (p->error_indicator) { |
| 9906 | return NULL; |
| 9907 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9908 | expr_ty _res = NULL; |
| 9909 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9910 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 9911 | p->error_indicator = 1; |
| 9912 | return NULL; |
| 9913 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9914 | int _start_lineno = p->tokens[_mark]->lineno; |
| 9915 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 9916 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 9917 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9918 | { // NAME &del_target_end |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9919 | expr_ty a; |
| 9920 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9921 | (a = _PyPegen_name_token(p)) // NAME |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 9922 | && |
| 9923 | _PyPegen_lookahead(1, del_target_end_rule, p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9924 | ) |
| 9925 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9926 | _res = _PyPegen_set_expr_context ( p , a , Del ); |
| 9927 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9928 | p->error_indicator = 1; |
| 9929 | return NULL; |
| 9930 | } |
| 9931 | goto done; |
| 9932 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9933 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9934 | } |
| 9935 | { // '(' del_target ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9936 | Token * _literal; |
| 9937 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9938 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9939 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9940 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9941 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9942 | (a = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9943 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9944 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9945 | ) |
| 9946 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9947 | _res = _PyPegen_set_expr_context ( p , a , Del ); |
| 9948 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9949 | p->error_indicator = 1; |
| 9950 | return NULL; |
| 9951 | } |
| 9952 | goto done; |
| 9953 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9954 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9955 | } |
| 9956 | { // '(' del_targets? ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9957 | Token * _literal; |
| 9958 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9959 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9960 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9961 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9962 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9963 | (a = del_targets_rule(p), 1) // del_targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9964 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9965 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9966 | ) |
| 9967 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9968 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9969 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9970 | return NULL; |
| 9971 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9972 | int _end_lineno = _token->end_lineno; |
| 9973 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 9974 | int _end_col_offset = _token->end_col_offset; |
| 9975 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 9976 | _res = _Py_Tuple ( a , Del , EXTRA ); |
| 9977 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9978 | p->error_indicator = 1; |
| 9979 | return NULL; |
| 9980 | } |
| 9981 | goto done; |
| 9982 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9983 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9984 | } |
| 9985 | { // '[' del_targets? ']' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9986 | Token * _literal; |
| 9987 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9988 | void *a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9989 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9990 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9991 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 9992 | (a = del_targets_rule(p), 1) // del_targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9993 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9994 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9995 | ) |
| 9996 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 9997 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 9998 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 9999 | return NULL; |
| 10000 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10001 | int _end_lineno = _token->end_lineno; |
| 10002 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10003 | int _end_col_offset = _token->end_col_offset; |
| 10004 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10005 | _res = _Py_List ( a , Del , EXTRA ); |
| 10006 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10007 | p->error_indicator = 1; |
| 10008 | return NULL; |
| 10009 | } |
| 10010 | goto done; |
| 10011 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10012 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10013 | } |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 10014 | { // invalid_del_target |
| 10015 | void *invalid_del_target_var; |
| 10016 | if ( |
| 10017 | (invalid_del_target_var = invalid_del_target_rule(p)) // invalid_del_target |
| 10018 | ) |
| 10019 | { |
| 10020 | _res = invalid_del_target_var; |
| 10021 | goto done; |
| 10022 | } |
| 10023 | p->mark = _mark; |
| 10024 | } |
| 10025 | _res = NULL; |
| 10026 | done: |
| 10027 | return _res; |
| 10028 | } |
| 10029 | |
| 10030 | // del_target_end: ')' | ']' | ',' | ';' | NEWLINE |
| 10031 | static void * |
| 10032 | del_target_end_rule(Parser *p) |
| 10033 | { |
| 10034 | if (p->error_indicator) { |
| 10035 | return NULL; |
| 10036 | } |
| 10037 | void * _res = NULL; |
| 10038 | int _mark = p->mark; |
| 10039 | { // ')' |
| 10040 | Token * _literal; |
| 10041 | if ( |
| 10042 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
| 10043 | ) |
| 10044 | { |
| 10045 | _res = _literal; |
| 10046 | goto done; |
| 10047 | } |
| 10048 | p->mark = _mark; |
| 10049 | } |
| 10050 | { // ']' |
| 10051 | Token * _literal; |
| 10052 | if ( |
| 10053 | (_literal = _PyPegen_expect_token(p, 10)) // token=']' |
| 10054 | ) |
| 10055 | { |
| 10056 | _res = _literal; |
| 10057 | goto done; |
| 10058 | } |
| 10059 | p->mark = _mark; |
| 10060 | } |
| 10061 | { // ',' |
| 10062 | Token * _literal; |
| 10063 | if ( |
| 10064 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
| 10065 | ) |
| 10066 | { |
| 10067 | _res = _literal; |
| 10068 | goto done; |
| 10069 | } |
| 10070 | p->mark = _mark; |
| 10071 | } |
| 10072 | { // ';' |
| 10073 | Token * _literal; |
| 10074 | if ( |
| 10075 | (_literal = _PyPegen_expect_token(p, 13)) // token=';' |
| 10076 | ) |
| 10077 | { |
| 10078 | _res = _literal; |
| 10079 | goto done; |
| 10080 | } |
| 10081 | p->mark = _mark; |
| 10082 | } |
| 10083 | { // NEWLINE |
| 10084 | Token * newline_var; |
| 10085 | if ( |
| 10086 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
| 10087 | ) |
| 10088 | { |
| 10089 | _res = newline_var; |
| 10090 | goto done; |
| 10091 | } |
| 10092 | p->mark = _mark; |
| 10093 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10094 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10095 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10096 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10097 | } |
| 10098 | |
| 10099 | // targets: ','.target+ ','? |
| 10100 | static asdl_seq* |
| 10101 | targets_rule(Parser *p) |
| 10102 | { |
| 10103 | if (p->error_indicator) { |
| 10104 | return NULL; |
| 10105 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10106 | asdl_seq* _res = NULL; |
| 10107 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10108 | { // ','.target+ ','? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10109 | void *_opt_var; |
| 10110 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10111 | asdl_seq * a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10112 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10113 | (a = _gather_123_rule(p)) // ','.target+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10114 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10115 | (_opt_var = _PyPegen_expect_token(p, 12), 1) // ','? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10116 | ) |
| 10117 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10118 | _res = a; |
| 10119 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10120 | p->error_indicator = 1; |
| 10121 | return NULL; |
| 10122 | } |
| 10123 | goto done; |
| 10124 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10125 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10126 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10127 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10128 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10129 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10130 | } |
| 10131 | |
| 10132 | // target: |
| 10133 | // | t_primary '.' NAME !t_lookahead |
| 10134 | // | t_primary '[' slices ']' !t_lookahead |
| 10135 | // | t_atom |
| 10136 | static expr_ty |
| 10137 | target_rule(Parser *p) |
| 10138 | { |
| 10139 | if (p->error_indicator) { |
| 10140 | return NULL; |
| 10141 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10142 | expr_ty _res = NULL; |
| 10143 | if (_PyPegen_is_memoized(p, target_type, &_res)) |
| 10144 | return _res; |
| 10145 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10146 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10147 | p->error_indicator = 1; |
| 10148 | return NULL; |
| 10149 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10150 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10151 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10152 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10153 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10154 | { // t_primary '.' NAME !t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10155 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10156 | expr_ty a; |
| 10157 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10158 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10159 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10160 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10161 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10162 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10163 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10164 | && |
| 10165 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 10166 | ) |
| 10167 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10168 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10169 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10170 | return NULL; |
| 10171 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10172 | int _end_lineno = _token->end_lineno; |
| 10173 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10174 | int _end_col_offset = _token->end_col_offset; |
| 10175 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10176 | _res = _Py_Attribute ( a , b -> v . Name . id , Store , EXTRA ); |
| 10177 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10178 | p->error_indicator = 1; |
| 10179 | return NULL; |
| 10180 | } |
| 10181 | goto done; |
| 10182 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10183 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10184 | } |
| 10185 | { // t_primary '[' slices ']' !t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10186 | Token * _literal; |
| 10187 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10188 | expr_ty a; |
| 10189 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10190 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10191 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10192 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10193 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10194 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10195 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10196 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10197 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10198 | && |
| 10199 | _PyPegen_lookahead(0, t_lookahead_rule, p) |
| 10200 | ) |
| 10201 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10202 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10203 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10204 | return NULL; |
| 10205 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10206 | int _end_lineno = _token->end_lineno; |
| 10207 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10208 | int _end_col_offset = _token->end_col_offset; |
| 10209 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10210 | _res = _Py_Subscript ( a , b , Store , EXTRA ); |
| 10211 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10212 | p->error_indicator = 1; |
| 10213 | return NULL; |
| 10214 | } |
| 10215 | goto done; |
| 10216 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10217 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10218 | } |
| 10219 | { // t_atom |
| 10220 | expr_ty t_atom_var; |
| 10221 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10222 | (t_atom_var = t_atom_rule(p)) // t_atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10223 | ) |
| 10224 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10225 | _res = t_atom_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10226 | goto done; |
| 10227 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10228 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10229 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10230 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10231 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10232 | _PyPegen_insert_memo(p, _mark, target_type, _res); |
| 10233 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10234 | } |
| 10235 | |
| 10236 | // Left-recursive |
| 10237 | // t_primary: |
| 10238 | // | t_primary '.' NAME &t_lookahead |
| 10239 | // | t_primary '[' slices ']' &t_lookahead |
| 10240 | // | t_primary genexp &t_lookahead |
| 10241 | // | t_primary '(' arguments? ')' &t_lookahead |
| 10242 | // | atom &t_lookahead |
| 10243 | static expr_ty t_primary_raw(Parser *); |
| 10244 | static expr_ty |
| 10245 | t_primary_rule(Parser *p) |
| 10246 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10247 | expr_ty _res = NULL; |
| 10248 | if (_PyPegen_is_memoized(p, t_primary_type, &_res)) |
| 10249 | return _res; |
| 10250 | int _mark = p->mark; |
| 10251 | int _resmark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10252 | while (1) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10253 | int tmpvar_8 = _PyPegen_update_memo(p, _mark, t_primary_type, _res); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10254 | if (tmpvar_8) { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10255 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10256 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10257 | p->mark = _mark; |
| 10258 | void *_raw = t_primary_raw(p); |
| 10259 | if (_raw == NULL || p->mark <= _resmark) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10260 | break; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10261 | _resmark = p->mark; |
| 10262 | _res = _raw; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10263 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10264 | p->mark = _resmark; |
| 10265 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10266 | } |
| 10267 | static expr_ty |
| 10268 | t_primary_raw(Parser *p) |
| 10269 | { |
| 10270 | if (p->error_indicator) { |
| 10271 | return NULL; |
| 10272 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10273 | expr_ty _res = NULL; |
| 10274 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10275 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10276 | p->error_indicator = 1; |
| 10277 | return NULL; |
| 10278 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10279 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10280 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10281 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10282 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10283 | { // t_primary '.' NAME &t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10284 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10285 | expr_ty a; |
| 10286 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10287 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10288 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10289 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10290 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10291 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10292 | (b = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10293 | && |
| 10294 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10295 | ) |
| 10296 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10297 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10298 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10299 | return NULL; |
| 10300 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10301 | int _end_lineno = _token->end_lineno; |
| 10302 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10303 | int _end_col_offset = _token->end_col_offset; |
| 10304 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10305 | _res = _Py_Attribute ( a , b -> v . Name . id , Load , EXTRA ); |
| 10306 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10307 | p->error_indicator = 1; |
| 10308 | return NULL; |
| 10309 | } |
| 10310 | goto done; |
| 10311 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10312 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10313 | } |
| 10314 | { // t_primary '[' slices ']' &t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10315 | Token * _literal; |
| 10316 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10317 | expr_ty a; |
| 10318 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10319 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10320 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10321 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10322 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10323 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10324 | (b = slices_rule(p)) // slices |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10325 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10326 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10327 | && |
| 10328 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10329 | ) |
| 10330 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10331 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10332 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10333 | return NULL; |
| 10334 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10335 | int _end_lineno = _token->end_lineno; |
| 10336 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10337 | int _end_col_offset = _token->end_col_offset; |
| 10338 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10339 | _res = _Py_Subscript ( a , b , Load , EXTRA ); |
| 10340 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10341 | p->error_indicator = 1; |
| 10342 | return NULL; |
| 10343 | } |
| 10344 | goto done; |
| 10345 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10346 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10347 | } |
| 10348 | { // t_primary genexp &t_lookahead |
| 10349 | expr_ty a; |
| 10350 | expr_ty b; |
| 10351 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10352 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10353 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10354 | (b = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10355 | && |
| 10356 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10357 | ) |
| 10358 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10359 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10360 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10361 | return NULL; |
| 10362 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10363 | int _end_lineno = _token->end_lineno; |
| 10364 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10365 | int _end_col_offset = _token->end_col_offset; |
| 10366 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10367 | _res = _Py_Call ( a , CHECK ( _PyPegen_singleton_seq ( p , b ) ) , NULL , EXTRA ); |
| 10368 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10369 | p->error_indicator = 1; |
| 10370 | return NULL; |
| 10371 | } |
| 10372 | goto done; |
| 10373 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10374 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10375 | } |
| 10376 | { // t_primary '(' arguments? ')' &t_lookahead |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10377 | Token * _literal; |
| 10378 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10379 | expr_ty a; |
| 10380 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10381 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10382 | (a = t_primary_rule(p)) // t_primary |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10383 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10384 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10385 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10386 | (b = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10387 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10388 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10389 | && |
| 10390 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10391 | ) |
| 10392 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10393 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10394 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10395 | return NULL; |
| 10396 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10397 | int _end_lineno = _token->end_lineno; |
| 10398 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10399 | int _end_col_offset = _token->end_col_offset; |
| 10400 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10401 | _res = _Py_Call ( a , ( b ) ? ( ( expr_ty ) b ) -> v . Call . args : NULL , ( b ) ? ( ( expr_ty ) b ) -> v . Call . keywords : NULL , EXTRA ); |
| 10402 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10403 | p->error_indicator = 1; |
| 10404 | return NULL; |
| 10405 | } |
| 10406 | goto done; |
| 10407 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10408 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10409 | } |
| 10410 | { // atom &t_lookahead |
| 10411 | expr_ty a; |
| 10412 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10413 | (a = atom_rule(p)) // atom |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10414 | && |
| 10415 | _PyPegen_lookahead(1, t_lookahead_rule, p) |
| 10416 | ) |
| 10417 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10418 | _res = a; |
| 10419 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10420 | p->error_indicator = 1; |
| 10421 | return NULL; |
| 10422 | } |
| 10423 | goto done; |
| 10424 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10425 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10426 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10427 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10428 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10429 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10430 | } |
| 10431 | |
| 10432 | // t_lookahead: '(' | '[' | '.' |
| 10433 | static void * |
| 10434 | t_lookahead_rule(Parser *p) |
| 10435 | { |
| 10436 | if (p->error_indicator) { |
| 10437 | return NULL; |
| 10438 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10439 | void * _res = NULL; |
| 10440 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10441 | { // '(' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10442 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10443 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10444 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10445 | ) |
| 10446 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10447 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10448 | goto done; |
| 10449 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10450 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10451 | } |
| 10452 | { // '[' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10453 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10454 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10455 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10456 | ) |
| 10457 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10458 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10459 | goto done; |
| 10460 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10461 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10462 | } |
| 10463 | { // '.' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10464 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10465 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10466 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10467 | ) |
| 10468 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10469 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10470 | goto done; |
| 10471 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10472 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10473 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10474 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10475 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10476 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10477 | } |
| 10478 | |
| 10479 | // t_atom: NAME | '(' target ')' | '(' targets? ')' | '[' targets? ']' |
| 10480 | static expr_ty |
| 10481 | t_atom_rule(Parser *p) |
| 10482 | { |
| 10483 | if (p->error_indicator) { |
| 10484 | return NULL; |
| 10485 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10486 | expr_ty _res = NULL; |
| 10487 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10488 | if (p->mark == p->fill && _PyPegen_fill_token(p) < 0) { |
| 10489 | p->error_indicator = 1; |
| 10490 | return NULL; |
| 10491 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10492 | int _start_lineno = p->tokens[_mark]->lineno; |
| 10493 | UNUSED(_start_lineno); // Only used by EXTRA macro |
| 10494 | int _start_col_offset = p->tokens[_mark]->col_offset; |
| 10495 | UNUSED(_start_col_offset); // Only used by EXTRA macro |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10496 | { // NAME |
| 10497 | expr_ty a; |
| 10498 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10499 | (a = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10500 | ) |
| 10501 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10502 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 10503 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10504 | p->error_indicator = 1; |
| 10505 | return NULL; |
| 10506 | } |
| 10507 | goto done; |
| 10508 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10509 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10510 | } |
| 10511 | { // '(' target ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10512 | Token * _literal; |
| 10513 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10514 | expr_ty a; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10515 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10516 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10517 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10518 | (a = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10519 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10520 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10521 | ) |
| 10522 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10523 | _res = _PyPegen_set_expr_context ( p , a , Store ); |
| 10524 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10525 | p->error_indicator = 1; |
| 10526 | return NULL; |
| 10527 | } |
| 10528 | goto done; |
| 10529 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10530 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10531 | } |
| 10532 | { // '(' targets? ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10533 | Token * _literal; |
| 10534 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10535 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10536 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10537 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10538 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10539 | (b = targets_rule(p), 1) // targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10540 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10541 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10542 | ) |
| 10543 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10544 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10545 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10546 | return NULL; |
| 10547 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10548 | int _end_lineno = _token->end_lineno; |
| 10549 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10550 | int _end_col_offset = _token->end_col_offset; |
| 10551 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10552 | _res = _Py_Tuple ( b , Store , EXTRA ); |
| 10553 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10554 | p->error_indicator = 1; |
| 10555 | return NULL; |
| 10556 | } |
| 10557 | goto done; |
| 10558 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10559 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10560 | } |
| 10561 | { // '[' targets? ']' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10562 | Token * _literal; |
| 10563 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10564 | void *b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10565 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10566 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10567 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10568 | (b = targets_rule(p), 1) // targets? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10569 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10570 | (_literal_1 = _PyPegen_expect_token(p, 10)) // token=']' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10571 | ) |
| 10572 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10573 | Token *_token = _PyPegen_get_last_nonnwhitespace_token(p); |
| 10574 | if (_token == NULL) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10575 | return NULL; |
| 10576 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10577 | int _end_lineno = _token->end_lineno; |
| 10578 | UNUSED(_end_lineno); // Only used by EXTRA macro |
| 10579 | int _end_col_offset = _token->end_col_offset; |
| 10580 | UNUSED(_end_col_offset); // Only used by EXTRA macro |
| 10581 | _res = _Py_List ( b , Store , EXTRA ); |
| 10582 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10583 | p->error_indicator = 1; |
| 10584 | return NULL; |
| 10585 | } |
| 10586 | goto done; |
| 10587 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10588 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10589 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10590 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10591 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10592 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10593 | } |
| 10594 | |
| 10595 | // incorrect_arguments: |
| 10596 | // | args ',' '*' |
| 10597 | // | expression for_if_clauses ',' [args | expression for_if_clauses] |
| 10598 | // | args ',' args |
| 10599 | static void * |
| 10600 | incorrect_arguments_rule(Parser *p) |
| 10601 | { |
| 10602 | if (p->error_indicator) { |
| 10603 | return NULL; |
| 10604 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10605 | void * _res = NULL; |
| 10606 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10607 | { // args ',' '*' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10608 | Token * _literal; |
| 10609 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10610 | expr_ty args_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10611 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10612 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10613 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10614 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10615 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10616 | (_literal_1 = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10617 | ) |
| 10618 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10619 | _res = RAISE_SYNTAX_ERROR ( "iterable argument unpacking follows keyword argument unpacking" ); |
| 10620 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10621 | p->error_indicator = 1; |
| 10622 | return NULL; |
| 10623 | } |
| 10624 | goto done; |
| 10625 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10626 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10627 | } |
| 10628 | { // expression for_if_clauses ',' [args | expression for_if_clauses] |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10629 | Token * _literal; |
| 10630 | void *_opt_var; |
| 10631 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10632 | expr_ty expression_var; |
| 10633 | asdl_seq* for_if_clauses_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10634 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10635 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10636 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10637 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10638 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10639 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10640 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10641 | (_opt_var = _tmp_125_rule(p), 1) // [args | expression for_if_clauses] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10642 | ) |
| 10643 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10644 | _res = RAISE_SYNTAX_ERROR ( "Generator expression must be parenthesized" ); |
| 10645 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10646 | p->error_indicator = 1; |
| 10647 | return NULL; |
| 10648 | } |
| 10649 | goto done; |
| 10650 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10651 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10652 | } |
| 10653 | { // args ',' args |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10654 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10655 | expr_ty a; |
| 10656 | expr_ty args_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10657 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10658 | (a = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10659 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10660 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10661 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10662 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10663 | ) |
| 10664 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10665 | _res = _PyPegen_arguments_parsing_error ( p , a ); |
| 10666 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10667 | p->error_indicator = 1; |
| 10668 | return NULL; |
| 10669 | } |
| 10670 | goto done; |
| 10671 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10672 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10673 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10674 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10675 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10676 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10677 | } |
| 10678 | |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10679 | // invalid_kwarg: expression '=' |
| 10680 | static void * |
| 10681 | invalid_kwarg_rule(Parser *p) |
| 10682 | { |
| 10683 | if (p->error_indicator) { |
| 10684 | return NULL; |
| 10685 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10686 | void * _res = NULL; |
| 10687 | int _mark = p->mark; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10688 | { // expression '=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10689 | Token * _literal; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10690 | expr_ty expression_var; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10691 | if ( |
| 10692 | (expression_var = expression_rule(p)) // expression |
| 10693 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10694 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10695 | ) |
| 10696 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10697 | _res = RAISE_SYNTAX_ERROR ( "expression cannot contain assignment, perhaps you meant \"==\"?" ); |
| 10698 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10699 | p->error_indicator = 1; |
| 10700 | return NULL; |
| 10701 | } |
| 10702 | goto done; |
| 10703 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10704 | p->mark = _mark; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10705 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10706 | _res = NULL; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10707 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10708 | return _res; |
Lysandros Nikolaou | 4638c64 | 2020-05-07 13:44:06 +0300 | [diff] [blame] | 10709 | } |
| 10710 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10711 | // invalid_named_expression: expression ':=' expression |
| 10712 | static void * |
| 10713 | invalid_named_expression_rule(Parser *p) |
| 10714 | { |
| 10715 | if (p->error_indicator) { |
| 10716 | return NULL; |
| 10717 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10718 | void * _res = NULL; |
| 10719 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10720 | { // expression ':=' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10721 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10722 | expr_ty a; |
| 10723 | expr_ty expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10724 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10725 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10726 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10727 | (_literal = _PyPegen_expect_token(p, 53)) // token=':=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10728 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10729 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10730 | ) |
| 10731 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10732 | _res = RAISE_SYNTAX_ERROR ( "cannot use assignment expressions with %s" , _PyPegen_get_expr_name ( a ) ); |
| 10733 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10734 | p->error_indicator = 1; |
| 10735 | return NULL; |
| 10736 | } |
| 10737 | goto done; |
| 10738 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10739 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10740 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10741 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10742 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10743 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10744 | } |
| 10745 | |
| 10746 | // invalid_assignment: |
| 10747 | // | list ':' |
| 10748 | // | tuple ':' |
| 10749 | // | expression ':' expression ['=' annotated_rhs] |
| 10750 | // | expression ('=' | augassign) (yield_expr | star_expressions) |
| 10751 | static void * |
| 10752 | invalid_assignment_rule(Parser *p) |
| 10753 | { |
| 10754 | if (p->error_indicator) { |
| 10755 | return NULL; |
| 10756 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10757 | void * _res = NULL; |
| 10758 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10759 | { // list ':' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10760 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10761 | expr_ty list_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10762 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10763 | (list_var = list_rule(p)) // list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10764 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10765 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10766 | ) |
| 10767 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10768 | _res = RAISE_SYNTAX_ERROR ( "only single target (not list) can be annotated" ); |
| 10769 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10770 | p->error_indicator = 1; |
| 10771 | return NULL; |
| 10772 | } |
| 10773 | goto done; |
| 10774 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10775 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10776 | } |
| 10777 | { // tuple ':' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10778 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10779 | expr_ty tuple_var; |
| 10780 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10781 | (tuple_var = tuple_rule(p)) // tuple |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10782 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10783 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10784 | ) |
| 10785 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10786 | _res = RAISE_SYNTAX_ERROR ( "only single target (not tuple) can be annotated" ); |
| 10787 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10788 | p->error_indicator = 1; |
| 10789 | return NULL; |
| 10790 | } |
| 10791 | goto done; |
| 10792 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10793 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10794 | } |
| 10795 | { // expression ':' expression ['=' annotated_rhs] |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10796 | Token * _literal; |
| 10797 | void *_opt_var; |
| 10798 | UNUSED(_opt_var); // Silence compiler warnings |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10799 | expr_ty expression_var; |
| 10800 | expr_ty expression_var_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10801 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10802 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10803 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10804 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10805 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10806 | (expression_var_1 = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10807 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10808 | (_opt_var = _tmp_126_rule(p), 1) // ['=' annotated_rhs] |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10809 | ) |
| 10810 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10811 | _res = RAISE_SYNTAX_ERROR ( "illegal target for annotation" ); |
| 10812 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10813 | p->error_indicator = 1; |
| 10814 | return NULL; |
| 10815 | } |
| 10816 | goto done; |
| 10817 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10818 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10819 | } |
| 10820 | { // expression ('=' | augassign) (yield_expr | star_expressions) |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10821 | void *_tmp_127_var; |
| 10822 | void *_tmp_128_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10823 | expr_ty a; |
| 10824 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10825 | (a = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10826 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10827 | (_tmp_127_var = _tmp_127_rule(p)) // '=' | augassign |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 10828 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10829 | (_tmp_128_var = _tmp_128_rule(p)) // yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10830 | ) |
| 10831 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10832 | _res = RAISE_SYNTAX_ERROR_NO_COL_OFFSET ( "cannot assign to %s" , _PyPegen_get_expr_name ( a ) ); |
| 10833 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10834 | p->error_indicator = 1; |
| 10835 | return NULL; |
| 10836 | } |
| 10837 | goto done; |
| 10838 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10839 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10840 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10841 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10842 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10843 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10844 | } |
| 10845 | |
| 10846 | // invalid_block: NEWLINE !INDENT |
| 10847 | static void * |
| 10848 | invalid_block_rule(Parser *p) |
| 10849 | { |
| 10850 | if (p->error_indicator) { |
| 10851 | return NULL; |
| 10852 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10853 | void * _res = NULL; |
| 10854 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10855 | { // NEWLINE !INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 10856 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10857 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10858 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10859 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10860 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, INDENT) // token=INDENT |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10861 | ) |
| 10862 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10863 | _res = RAISE_INDENTATION_ERROR ( "expected an indented block" ); |
| 10864 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10865 | p->error_indicator = 1; |
| 10866 | return NULL; |
| 10867 | } |
| 10868 | goto done; |
| 10869 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10870 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10871 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10872 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10873 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10874 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10875 | } |
| 10876 | |
| 10877 | // invalid_comprehension: ('[' | '(' | '{') '*' expression for_if_clauses |
| 10878 | static void * |
| 10879 | invalid_comprehension_rule(Parser *p) |
| 10880 | { |
| 10881 | if (p->error_indicator) { |
| 10882 | return NULL; |
| 10883 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10884 | void * _res = NULL; |
| 10885 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10886 | { // ('[' | '(' | '{') '*' expression for_if_clauses |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10887 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 10888 | void *_tmp_129_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10889 | expr_ty expression_var; |
| 10890 | asdl_seq* for_if_clauses_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10891 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10892 | (_tmp_129_var = _tmp_129_rule(p)) // '[' | '(' | '{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10893 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10894 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10895 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10896 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10897 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10898 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10899 | ) |
| 10900 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10901 | _res = RAISE_SYNTAX_ERROR ( "iterable unpacking cannot be used in comprehension" ); |
| 10902 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10903 | p->error_indicator = 1; |
| 10904 | return NULL; |
| 10905 | } |
| 10906 | goto done; |
| 10907 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10908 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10909 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10910 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10911 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10912 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10913 | } |
| 10914 | |
| 10915 | // invalid_parameters: |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10916 | // | param_no_default* (slash_with_default | param_with_default+) param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10917 | static void * |
| 10918 | invalid_parameters_rule(Parser *p) |
| 10919 | { |
| 10920 | if (p->error_indicator) { |
| 10921 | return NULL; |
| 10922 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10923 | void * _res = NULL; |
| 10924 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10925 | { // 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] | 10926 | asdl_seq * _loop0_130_var; |
| 10927 | void *_tmp_131_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 10928 | arg_ty param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10929 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10930 | (_loop0_130_var = _loop0_130_rule(p)) // param_no_default* |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10931 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10932 | (_tmp_131_var = _tmp_131_rule(p)) // slash_with_default | param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10933 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10934 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10935 | ) |
| 10936 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10937 | _res = RAISE_SYNTAX_ERROR ( "non-default argument follows default argument" ); |
| 10938 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10939 | p->error_indicator = 1; |
| 10940 | return NULL; |
| 10941 | } |
| 10942 | goto done; |
| 10943 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10944 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10945 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10946 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10947 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10948 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 10949 | } |
| 10950 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10951 | // invalid_star_etc: '*' (')' | ',' (')' | '**')) |
| 10952 | static void * |
| 10953 | invalid_star_etc_rule(Parser *p) |
| 10954 | { |
| 10955 | if (p->error_indicator) { |
| 10956 | return NULL; |
| 10957 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10958 | void * _res = NULL; |
| 10959 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10960 | { // '*' (')' | ',' (')' | '**')) |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10961 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10962 | void *_tmp_132_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10963 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10964 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10965 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10966 | (_tmp_132_var = _tmp_132_rule(p)) // ')' | ',' (')' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10967 | ) |
| 10968 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10969 | _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); |
| 10970 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10971 | p->error_indicator = 1; |
| 10972 | return NULL; |
| 10973 | } |
| 10974 | goto done; |
| 10975 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10976 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10977 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10978 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10979 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10980 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10981 | } |
| 10982 | |
| 10983 | // invalid_lambda_star_etc: '*' (':' | ',' (':' | '**')) |
| 10984 | static void * |
| 10985 | invalid_lambda_star_etc_rule(Parser *p) |
| 10986 | { |
| 10987 | if (p->error_indicator) { |
| 10988 | return NULL; |
| 10989 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10990 | void * _res = NULL; |
| 10991 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10992 | { // '*' (':' | ',' (':' | '**')) |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10993 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10994 | void *_tmp_133_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10995 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 10996 | (_literal = _PyPegen_expect_token(p, 16)) // token='*' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10997 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 10998 | (_tmp_133_var = _tmp_133_rule(p)) // ':' | ',' (':' | '**') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 10999 | ) |
| 11000 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11001 | _res = RAISE_SYNTAX_ERROR ( "named arguments must follow bare *" ); |
| 11002 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11003 | p->error_indicator = 1; |
| 11004 | return NULL; |
| 11005 | } |
| 11006 | goto done; |
| 11007 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11008 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11009 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11010 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11011 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11012 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11013 | } |
| 11014 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11015 | // invalid_double_type_comments: TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
| 11016 | static void * |
| 11017 | invalid_double_type_comments_rule(Parser *p) |
| 11018 | { |
| 11019 | if (p->error_indicator) { |
| 11020 | return NULL; |
| 11021 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11022 | void * _res = NULL; |
| 11023 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11024 | { // TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11025 | Token * indent_var; |
| 11026 | Token * newline_var; |
| 11027 | Token * newline_var_1; |
| 11028 | Token * type_comment_var; |
| 11029 | Token * type_comment_var_1; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11030 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11031 | (type_comment_var = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11032 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11033 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11034 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11035 | (type_comment_var_1 = _PyPegen_expect_token(p, TYPE_COMMENT)) // token='TYPE_COMMENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11036 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11037 | (newline_var_1 = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11038 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11039 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11040 | ) |
| 11041 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11042 | _res = RAISE_SYNTAX_ERROR ( "Cannot have two type comments on def" ); |
| 11043 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11044 | p->error_indicator = 1; |
| 11045 | return NULL; |
| 11046 | } |
| 11047 | goto done; |
| 11048 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11049 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11050 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11051 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11052 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11053 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11054 | } |
| 11055 | |
Shantanu | 27c0d9b | 2020-05-11 14:53:58 -0700 | [diff] [blame] | 11056 | // invalid_del_target: star_expression &del_target_end |
| 11057 | static void * |
| 11058 | invalid_del_target_rule(Parser *p) |
| 11059 | { |
| 11060 | if (p->error_indicator) { |
| 11061 | return NULL; |
| 11062 | } |
| 11063 | void * _res = NULL; |
| 11064 | int _mark = p->mark; |
| 11065 | { // star_expression &del_target_end |
| 11066 | expr_ty a; |
| 11067 | if ( |
| 11068 | (a = star_expression_rule(p)) // star_expression |
| 11069 | && |
| 11070 | _PyPegen_lookahead(1, del_target_end_rule, p) |
| 11071 | ) |
| 11072 | { |
| 11073 | _res = RAISE_SYNTAX_ERROR ( "cannot delete %s" , _PyPegen_get_expr_name ( a ) ); |
| 11074 | if (_res == NULL && PyErr_Occurred()) { |
| 11075 | p->error_indicator = 1; |
| 11076 | return NULL; |
| 11077 | } |
| 11078 | goto done; |
| 11079 | } |
| 11080 | p->mark = _mark; |
| 11081 | } |
| 11082 | _res = NULL; |
| 11083 | done: |
| 11084 | return _res; |
| 11085 | } |
| 11086 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11087 | // _loop0_1: NEWLINE |
| 11088 | static asdl_seq * |
| 11089 | _loop0_1_rule(Parser *p) |
| 11090 | { |
| 11091 | if (p->error_indicator) { |
| 11092 | return NULL; |
| 11093 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11094 | void *_res = NULL; |
| 11095 | int _mark = p->mark; |
| 11096 | int _start_mark = p->mark; |
| 11097 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11098 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11099 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11100 | return NULL; |
| 11101 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11102 | ssize_t _children_capacity = 1; |
| 11103 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11104 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11105 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11106 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11107 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11108 | ) |
| 11109 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11110 | _res = newline_var; |
| 11111 | if (_n == _children_capacity) { |
| 11112 | _children_capacity *= 2; |
| 11113 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11114 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11115 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11116 | return NULL; |
| 11117 | } |
| 11118 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11119 | _children[_n++] = _res; |
| 11120 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11121 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11122 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11123 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11124 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11125 | if (!_seq) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11126 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_1"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11127 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11128 | return NULL; |
| 11129 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11130 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11131 | PyMem_Free(_children); |
| 11132 | _PyPegen_insert_memo(p, _start_mark, _loop0_1_type, _seq); |
| 11133 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11134 | } |
| 11135 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11136 | // _loop0_2: NEWLINE |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11137 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11138 | _loop0_2_rule(Parser *p) |
| 11139 | { |
| 11140 | if (p->error_indicator) { |
| 11141 | return NULL; |
| 11142 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11143 | void *_res = NULL; |
| 11144 | int _mark = p->mark; |
| 11145 | int _start_mark = p->mark; |
| 11146 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11147 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11148 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11149 | return NULL; |
| 11150 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11151 | ssize_t _children_capacity = 1; |
| 11152 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11153 | { // NEWLINE |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11154 | Token * newline_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11155 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11156 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11157 | ) |
| 11158 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11159 | _res = newline_var; |
| 11160 | if (_n == _children_capacity) { |
| 11161 | _children_capacity *= 2; |
| 11162 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11163 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11164 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11165 | return NULL; |
| 11166 | } |
| 11167 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11168 | _children[_n++] = _res; |
| 11169 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11170 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11171 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11172 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11173 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11174 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11175 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_2"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11176 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11177 | return NULL; |
| 11178 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11179 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11180 | PyMem_Free(_children); |
| 11181 | _PyPegen_insert_memo(p, _start_mark, _loop0_2_type, _seq); |
| 11182 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11183 | } |
| 11184 | |
| 11185 | // _loop0_4: ',' expression |
| 11186 | static asdl_seq * |
| 11187 | _loop0_4_rule(Parser *p) |
| 11188 | { |
| 11189 | if (p->error_indicator) { |
| 11190 | return NULL; |
| 11191 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11192 | void *_res = NULL; |
| 11193 | int _mark = p->mark; |
| 11194 | int _start_mark = p->mark; |
| 11195 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11196 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11197 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11198 | return NULL; |
| 11199 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11200 | ssize_t _children_capacity = 1; |
| 11201 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11202 | { // ',' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11203 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11204 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11205 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11206 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11207 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11208 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11209 | ) |
| 11210 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11211 | _res = elem; |
| 11212 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11213 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11214 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11215 | return NULL; |
| 11216 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11217 | if (_n == _children_capacity) { |
| 11218 | _children_capacity *= 2; |
| 11219 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11220 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11221 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11222 | return NULL; |
| 11223 | } |
| 11224 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11225 | _children[_n++] = _res; |
| 11226 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11227 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11228 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11229 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11230 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11231 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11232 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_4"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11233 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11234 | return NULL; |
| 11235 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11236 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11237 | PyMem_Free(_children); |
| 11238 | _PyPegen_insert_memo(p, _start_mark, _loop0_4_type, _seq); |
| 11239 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11240 | } |
| 11241 | |
| 11242 | // _gather_3: expression _loop0_4 |
| 11243 | static asdl_seq * |
| 11244 | _gather_3_rule(Parser *p) |
| 11245 | { |
| 11246 | if (p->error_indicator) { |
| 11247 | return NULL; |
| 11248 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11249 | asdl_seq * _res = NULL; |
| 11250 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11251 | { // expression _loop0_4 |
| 11252 | expr_ty elem; |
| 11253 | asdl_seq * seq; |
| 11254 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11255 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11256 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11257 | (seq = _loop0_4_rule(p)) // _loop0_4 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11258 | ) |
| 11259 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11260 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11261 | goto done; |
| 11262 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11263 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11264 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11265 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11266 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11267 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11268 | } |
| 11269 | |
| 11270 | // _loop0_6: ',' expression |
| 11271 | static asdl_seq * |
| 11272 | _loop0_6_rule(Parser *p) |
| 11273 | { |
| 11274 | if (p->error_indicator) { |
| 11275 | return NULL; |
| 11276 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11277 | void *_res = NULL; |
| 11278 | int _mark = p->mark; |
| 11279 | int _start_mark = p->mark; |
| 11280 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11281 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11282 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11283 | return NULL; |
| 11284 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11285 | ssize_t _children_capacity = 1; |
| 11286 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11287 | { // ',' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11288 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11289 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11290 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11291 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11292 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11293 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11294 | ) |
| 11295 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11296 | _res = elem; |
| 11297 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11298 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11299 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11300 | return NULL; |
| 11301 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11302 | if (_n == _children_capacity) { |
| 11303 | _children_capacity *= 2; |
| 11304 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11305 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11306 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11307 | return NULL; |
| 11308 | } |
| 11309 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11310 | _children[_n++] = _res; |
| 11311 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11312 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11313 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11314 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11315 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11316 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11317 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_6"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11318 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11319 | return NULL; |
| 11320 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11321 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11322 | PyMem_Free(_children); |
| 11323 | _PyPegen_insert_memo(p, _start_mark, _loop0_6_type, _seq); |
| 11324 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11325 | } |
| 11326 | |
| 11327 | // _gather_5: expression _loop0_6 |
| 11328 | static asdl_seq * |
| 11329 | _gather_5_rule(Parser *p) |
| 11330 | { |
| 11331 | if (p->error_indicator) { |
| 11332 | return NULL; |
| 11333 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11334 | asdl_seq * _res = NULL; |
| 11335 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11336 | { // expression _loop0_6 |
| 11337 | expr_ty elem; |
| 11338 | asdl_seq * seq; |
| 11339 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11340 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11341 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11342 | (seq = _loop0_6_rule(p)) // _loop0_6 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11343 | ) |
| 11344 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11345 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11346 | goto done; |
| 11347 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11348 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11349 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11350 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11351 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11352 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11353 | } |
| 11354 | |
| 11355 | // _loop0_8: ',' expression |
| 11356 | static asdl_seq * |
| 11357 | _loop0_8_rule(Parser *p) |
| 11358 | { |
| 11359 | if (p->error_indicator) { |
| 11360 | return NULL; |
| 11361 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11362 | void *_res = NULL; |
| 11363 | int _mark = p->mark; |
| 11364 | int _start_mark = p->mark; |
| 11365 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11366 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11367 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11368 | return NULL; |
| 11369 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11370 | ssize_t _children_capacity = 1; |
| 11371 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11372 | { // ',' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11373 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11374 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11375 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11376 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11377 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11378 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11379 | ) |
| 11380 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11381 | _res = elem; |
| 11382 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11383 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11384 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11385 | return NULL; |
| 11386 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11387 | if (_n == _children_capacity) { |
| 11388 | _children_capacity *= 2; |
| 11389 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11390 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11391 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11392 | return NULL; |
| 11393 | } |
| 11394 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11395 | _children[_n++] = _res; |
| 11396 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11397 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11398 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11399 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11400 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11401 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11402 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_8"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11403 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11404 | return NULL; |
| 11405 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11406 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11407 | PyMem_Free(_children); |
| 11408 | _PyPegen_insert_memo(p, _start_mark, _loop0_8_type, _seq); |
| 11409 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11410 | } |
| 11411 | |
| 11412 | // _gather_7: expression _loop0_8 |
| 11413 | static asdl_seq * |
| 11414 | _gather_7_rule(Parser *p) |
| 11415 | { |
| 11416 | if (p->error_indicator) { |
| 11417 | return NULL; |
| 11418 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11419 | asdl_seq * _res = NULL; |
| 11420 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11421 | { // expression _loop0_8 |
| 11422 | expr_ty elem; |
| 11423 | asdl_seq * seq; |
| 11424 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11425 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11426 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11427 | (seq = _loop0_8_rule(p)) // _loop0_8 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11428 | ) |
| 11429 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11430 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11431 | goto done; |
| 11432 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11433 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11434 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11435 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11436 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11437 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11438 | } |
| 11439 | |
| 11440 | // _loop0_10: ',' expression |
| 11441 | static asdl_seq * |
| 11442 | _loop0_10_rule(Parser *p) |
| 11443 | { |
| 11444 | if (p->error_indicator) { |
| 11445 | return NULL; |
| 11446 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11447 | void *_res = NULL; |
| 11448 | int _mark = p->mark; |
| 11449 | int _start_mark = p->mark; |
| 11450 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11451 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11452 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11453 | return NULL; |
| 11454 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11455 | ssize_t _children_capacity = 1; |
| 11456 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11457 | { // ',' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11458 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11459 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11460 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11461 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11462 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11463 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11464 | ) |
| 11465 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11466 | _res = elem; |
| 11467 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11468 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11469 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11470 | return NULL; |
| 11471 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11472 | if (_n == _children_capacity) { |
| 11473 | _children_capacity *= 2; |
| 11474 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11475 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11476 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11477 | return NULL; |
| 11478 | } |
| 11479 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11480 | _children[_n++] = _res; |
| 11481 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11482 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11483 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11484 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11485 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11486 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11487 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_10"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11488 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11489 | return NULL; |
| 11490 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11491 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11492 | PyMem_Free(_children); |
| 11493 | _PyPegen_insert_memo(p, _start_mark, _loop0_10_type, _seq); |
| 11494 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11495 | } |
| 11496 | |
| 11497 | // _gather_9: expression _loop0_10 |
| 11498 | static asdl_seq * |
| 11499 | _gather_9_rule(Parser *p) |
| 11500 | { |
| 11501 | if (p->error_indicator) { |
| 11502 | return NULL; |
| 11503 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11504 | asdl_seq * _res = NULL; |
| 11505 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11506 | { // expression _loop0_10 |
| 11507 | expr_ty elem; |
| 11508 | asdl_seq * seq; |
| 11509 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11510 | (elem = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11511 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11512 | (seq = _loop0_10_rule(p)) // _loop0_10 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11513 | ) |
| 11514 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11515 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11516 | goto done; |
| 11517 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11518 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11519 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11520 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11521 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11522 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11523 | } |
| 11524 | |
| 11525 | // _loop1_11: statement |
| 11526 | static asdl_seq * |
| 11527 | _loop1_11_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11528 | { |
| 11529 | if (p->error_indicator) { |
| 11530 | return NULL; |
| 11531 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11532 | void *_res = NULL; |
| 11533 | int _mark = p->mark; |
| 11534 | int _start_mark = p->mark; |
| 11535 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11536 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11537 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11538 | return NULL; |
| 11539 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11540 | ssize_t _children_capacity = 1; |
| 11541 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11542 | { // statement |
| 11543 | asdl_seq* statement_var; |
| 11544 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11545 | (statement_var = statement_rule(p)) // statement |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11546 | ) |
| 11547 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11548 | _res = statement_var; |
| 11549 | if (_n == _children_capacity) { |
| 11550 | _children_capacity *= 2; |
| 11551 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11552 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11553 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11554 | return NULL; |
| 11555 | } |
| 11556 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11557 | _children[_n++] = _res; |
| 11558 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11559 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11560 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11561 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11562 | if (_n == 0 || p->error_indicator) { |
| 11563 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11564 | return NULL; |
| 11565 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11566 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11567 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11568 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_11"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11569 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11570 | return NULL; |
| 11571 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11572 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11573 | PyMem_Free(_children); |
| 11574 | _PyPegen_insert_memo(p, _start_mark, _loop1_11_type, _seq); |
| 11575 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11576 | } |
| 11577 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11578 | // _loop0_13: ';' small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11579 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11580 | _loop0_13_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11581 | { |
| 11582 | if (p->error_indicator) { |
| 11583 | return NULL; |
| 11584 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11585 | void *_res = NULL; |
| 11586 | int _mark = p->mark; |
| 11587 | int _start_mark = p->mark; |
| 11588 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11589 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11590 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11591 | return NULL; |
| 11592 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11593 | ssize_t _children_capacity = 1; |
| 11594 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11595 | { // ';' small_stmt |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11596 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11597 | stmt_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11598 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11599 | (_literal = _PyPegen_expect_token(p, 13)) // token=';' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11600 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11601 | (elem = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11602 | ) |
| 11603 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11604 | _res = elem; |
| 11605 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11606 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11607 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11608 | return NULL; |
| 11609 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11610 | if (_n == _children_capacity) { |
| 11611 | _children_capacity *= 2; |
| 11612 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11613 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11614 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11615 | return NULL; |
| 11616 | } |
| 11617 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11618 | _children[_n++] = _res; |
| 11619 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11620 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11621 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11622 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11623 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 11624 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11625 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_13"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11626 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11627 | return NULL; |
| 11628 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11629 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 11630 | PyMem_Free(_children); |
| 11631 | _PyPegen_insert_memo(p, _start_mark, _loop0_13_type, _seq); |
| 11632 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11633 | } |
| 11634 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11635 | // _gather_12: small_stmt _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11636 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11637 | _gather_12_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11638 | { |
| 11639 | if (p->error_indicator) { |
| 11640 | return NULL; |
| 11641 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11642 | asdl_seq * _res = NULL; |
| 11643 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11644 | { // small_stmt _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11645 | stmt_ty elem; |
| 11646 | asdl_seq * seq; |
| 11647 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11648 | (elem = small_stmt_rule(p)) // small_stmt |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11649 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11650 | (seq = _loop0_13_rule(p)) // _loop0_13 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11651 | ) |
| 11652 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11653 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11654 | goto done; |
| 11655 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11656 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11657 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11658 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11659 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11660 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11661 | } |
| 11662 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11663 | // _tmp_14: 'import' | 'from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11664 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11665 | _tmp_14_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11666 | { |
| 11667 | if (p->error_indicator) { |
| 11668 | return NULL; |
| 11669 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11670 | void * _res = NULL; |
| 11671 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11672 | { // 'import' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11673 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11674 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11675 | (_keyword = _PyPegen_expect_token(p, 513)) // token='import' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11676 | ) |
| 11677 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11678 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11679 | goto done; |
| 11680 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11681 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11682 | } |
| 11683 | { // 'from' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11684 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11685 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11686 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11687 | ) |
| 11688 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11689 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11690 | goto done; |
| 11691 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11692 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11693 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11694 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11695 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11696 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11697 | } |
| 11698 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11699 | // _tmp_15: 'def' | '@' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11700 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11701 | _tmp_15_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11702 | { |
| 11703 | if (p->error_indicator) { |
| 11704 | return NULL; |
| 11705 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11706 | void * _res = NULL; |
| 11707 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11708 | { // 'def' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11709 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11710 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11711 | (_keyword = _PyPegen_expect_token(p, 522)) // token='def' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11712 | ) |
| 11713 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11714 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11715 | goto done; |
| 11716 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11717 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11718 | } |
| 11719 | { // '@' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11720 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11721 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11722 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11723 | ) |
| 11724 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11725 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11726 | goto done; |
| 11727 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11728 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11729 | } |
| 11730 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11731 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11732 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11733 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11734 | ) |
| 11735 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11736 | _res = async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11737 | goto done; |
| 11738 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11739 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11740 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11741 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11742 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11743 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11744 | } |
| 11745 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11746 | // _tmp_16: 'class' | '@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11747 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11748 | _tmp_16_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11749 | { |
| 11750 | if (p->error_indicator) { |
| 11751 | return NULL; |
| 11752 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11753 | void * _res = NULL; |
| 11754 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11755 | { // 'class' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11756 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11757 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11758 | (_keyword = _PyPegen_expect_token(p, 523)) // token='class' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11759 | ) |
| 11760 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11761 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11762 | goto done; |
| 11763 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11764 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11765 | } |
| 11766 | { // '@' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11767 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11768 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11769 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11770 | ) |
| 11771 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11772 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11773 | goto done; |
| 11774 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11775 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11776 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11777 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11778 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11779 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11780 | } |
| 11781 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11782 | // _tmp_17: 'with' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11783 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11784 | _tmp_17_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11785 | { |
| 11786 | if (p->error_indicator) { |
| 11787 | return NULL; |
| 11788 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11789 | void * _res = NULL; |
| 11790 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11791 | { // 'with' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11792 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11793 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11794 | (_keyword = _PyPegen_expect_token(p, 519)) // token='with' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11795 | ) |
| 11796 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11797 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11798 | goto done; |
| 11799 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11800 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11801 | } |
| 11802 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11803 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11804 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11805 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11806 | ) |
| 11807 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11808 | _res = async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11809 | goto done; |
| 11810 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11811 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11812 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11813 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11814 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11815 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11816 | } |
| 11817 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11818 | // _tmp_18: 'for' | ASYNC |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11819 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11820 | _tmp_18_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11821 | { |
| 11822 | if (p->error_indicator) { |
| 11823 | return NULL; |
| 11824 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11825 | void * _res = NULL; |
| 11826 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11827 | { // 'for' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11828 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11829 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11830 | (_keyword = _PyPegen_expect_token(p, 517)) // token='for' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11831 | ) |
| 11832 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11833 | _res = _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11834 | goto done; |
| 11835 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11836 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11837 | } |
| 11838 | { // ASYNC |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 11839 | Token * async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11840 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11841 | (async_var = _PyPegen_expect_token(p, ASYNC)) // token='ASYNC' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11842 | ) |
| 11843 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11844 | _res = async_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11845 | goto done; |
| 11846 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11847 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11848 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11849 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11850 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11851 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11852 | } |
| 11853 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11854 | // _tmp_19: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11855 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11856 | _tmp_19_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11857 | { |
| 11858 | if (p->error_indicator) { |
| 11859 | return NULL; |
| 11860 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11861 | void * _res = NULL; |
| 11862 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11863 | { // '=' annotated_rhs |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11864 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11865 | expr_ty d; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11866 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11867 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11868 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11869 | (d = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11870 | ) |
| 11871 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11872 | _res = d; |
| 11873 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11874 | p->error_indicator = 1; |
| 11875 | return NULL; |
| 11876 | } |
| 11877 | goto done; |
| 11878 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11879 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11880 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11881 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11882 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11883 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11884 | } |
| 11885 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11886 | // _tmp_20: '(' inside_paren_ann_assign_target ')' | ann_assign_subscript_attribute_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11887 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11888 | _tmp_20_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11889 | { |
| 11890 | if (p->error_indicator) { |
| 11891 | return NULL; |
| 11892 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11893 | void * _res = NULL; |
| 11894 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11895 | { // '(' inside_paren_ann_assign_target ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11896 | Token * _literal; |
| 11897 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11898 | expr_ty b; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11899 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11900 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11901 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11902 | (b = inside_paren_ann_assign_target_rule(p)) // inside_paren_ann_assign_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11903 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11904 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11905 | ) |
| 11906 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11907 | _res = b; |
| 11908 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11909 | p->error_indicator = 1; |
| 11910 | return NULL; |
| 11911 | } |
| 11912 | goto done; |
| 11913 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11914 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11915 | } |
| 11916 | { // ann_assign_subscript_attribute_target |
| 11917 | expr_ty ann_assign_subscript_attribute_target_var; |
| 11918 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11919 | (ann_assign_subscript_attribute_target_var = ann_assign_subscript_attribute_target_rule(p)) // ann_assign_subscript_attribute_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11920 | ) |
| 11921 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11922 | _res = ann_assign_subscript_attribute_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11923 | goto done; |
| 11924 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11925 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11926 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11927 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11928 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11929 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11930 | } |
| 11931 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11932 | // _tmp_21: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11933 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11934 | _tmp_21_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11935 | { |
| 11936 | if (p->error_indicator) { |
| 11937 | return NULL; |
| 11938 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11939 | void * _res = NULL; |
| 11940 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11941 | { // '=' annotated_rhs |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11942 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11943 | expr_ty d; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11944 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11945 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11946 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11947 | (d = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11948 | ) |
| 11949 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11950 | _res = d; |
| 11951 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11952 | p->error_indicator = 1; |
| 11953 | return NULL; |
| 11954 | } |
| 11955 | goto done; |
| 11956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11957 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11958 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11959 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11960 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11961 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11962 | } |
| 11963 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11964 | // _loop1_22: (star_targets '=') |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11965 | static asdl_seq * |
| 11966 | _loop1_22_rule(Parser *p) |
| 11967 | { |
| 11968 | if (p->error_indicator) { |
| 11969 | return NULL; |
| 11970 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11971 | void *_res = NULL; |
| 11972 | int _mark = p->mark; |
| 11973 | int _start_mark = p->mark; |
| 11974 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 11975 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11976 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 11977 | return NULL; |
| 11978 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11979 | ssize_t _children_capacity = 1; |
| 11980 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 11981 | { // (star_targets '=') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 11982 | void *_tmp_134_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11983 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 11984 | (_tmp_134_var = _tmp_134_rule(p)) // star_targets '=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11985 | ) |
| 11986 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11987 | _res = _tmp_134_var; |
| 11988 | if (_n == _children_capacity) { |
| 11989 | _children_capacity *= 2; |
| 11990 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 11991 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11992 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 11993 | return NULL; |
| 11994 | } |
| 11995 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11996 | _children[_n++] = _res; |
| 11997 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 11998 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 11999 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12000 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12001 | if (_n == 0 || p->error_indicator) { |
| 12002 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12003 | return NULL; |
| 12004 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12005 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12006 | if (!_seq) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12007 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_22"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12008 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12009 | return NULL; |
| 12010 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12011 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12012 | PyMem_Free(_children); |
| 12013 | _PyPegen_insert_memo(p, _start_mark, _loop1_22_type, _seq); |
| 12014 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12015 | } |
| 12016 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12017 | // _tmp_23: yield_expr | star_expressions |
| 12018 | static void * |
| 12019 | _tmp_23_rule(Parser *p) |
| 12020 | { |
| 12021 | if (p->error_indicator) { |
| 12022 | return NULL; |
| 12023 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12024 | void * _res = NULL; |
| 12025 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12026 | { // yield_expr |
| 12027 | expr_ty yield_expr_var; |
| 12028 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12029 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12030 | ) |
| 12031 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12032 | _res = yield_expr_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12033 | goto done; |
| 12034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12035 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12036 | } |
| 12037 | { // star_expressions |
| 12038 | expr_ty star_expressions_var; |
| 12039 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12040 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12041 | ) |
| 12042 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12043 | _res = star_expressions_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12044 | goto done; |
| 12045 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12046 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12047 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12048 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12049 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12050 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12051 | } |
| 12052 | |
| 12053 | // _tmp_24: yield_expr | star_expressions |
| 12054 | static void * |
| 12055 | _tmp_24_rule(Parser *p) |
| 12056 | { |
| 12057 | if (p->error_indicator) { |
| 12058 | return NULL; |
| 12059 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12060 | void * _res = NULL; |
| 12061 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12062 | { // yield_expr |
| 12063 | expr_ty yield_expr_var; |
| 12064 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12065 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12066 | ) |
| 12067 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12068 | _res = yield_expr_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12069 | goto done; |
| 12070 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12071 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12072 | } |
| 12073 | { // star_expressions |
| 12074 | expr_ty star_expressions_var; |
| 12075 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12076 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12077 | ) |
| 12078 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12079 | _res = star_expressions_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12080 | goto done; |
| 12081 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12082 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12083 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12084 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12085 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12086 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12087 | } |
| 12088 | |
| 12089 | // _loop0_26: ',' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12090 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12091 | _loop0_26_rule(Parser *p) |
| 12092 | { |
| 12093 | if (p->error_indicator) { |
| 12094 | return NULL; |
| 12095 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12096 | void *_res = NULL; |
| 12097 | int _mark = p->mark; |
| 12098 | int _start_mark = p->mark; |
| 12099 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12100 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12101 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12102 | return NULL; |
| 12103 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12104 | ssize_t _children_capacity = 1; |
| 12105 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12106 | { // ',' NAME |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12107 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12108 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12109 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12110 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12111 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12112 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12113 | ) |
| 12114 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12115 | _res = elem; |
| 12116 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12117 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12118 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12119 | return NULL; |
| 12120 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12121 | if (_n == _children_capacity) { |
| 12122 | _children_capacity *= 2; |
| 12123 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12124 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12125 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12126 | return NULL; |
| 12127 | } |
| 12128 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12129 | _children[_n++] = _res; |
| 12130 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12131 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12132 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12133 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12134 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12135 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12136 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_26"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12137 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12138 | return NULL; |
| 12139 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12140 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12141 | PyMem_Free(_children); |
| 12142 | _PyPegen_insert_memo(p, _start_mark, _loop0_26_type, _seq); |
| 12143 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12144 | } |
| 12145 | |
| 12146 | // _gather_25: NAME _loop0_26 |
| 12147 | static asdl_seq * |
| 12148 | _gather_25_rule(Parser *p) |
| 12149 | { |
| 12150 | if (p->error_indicator) { |
| 12151 | return NULL; |
| 12152 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12153 | asdl_seq * _res = NULL; |
| 12154 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12155 | { // NAME _loop0_26 |
| 12156 | expr_ty elem; |
| 12157 | asdl_seq * seq; |
| 12158 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12159 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12160 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12161 | (seq = _loop0_26_rule(p)) // _loop0_26 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12162 | ) |
| 12163 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12164 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12165 | goto done; |
| 12166 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12167 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12168 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12169 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12170 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12171 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12172 | } |
| 12173 | |
| 12174 | // _loop0_28: ',' NAME |
| 12175 | static asdl_seq * |
| 12176 | _loop0_28_rule(Parser *p) |
| 12177 | { |
| 12178 | if (p->error_indicator) { |
| 12179 | return NULL; |
| 12180 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12181 | void *_res = NULL; |
| 12182 | int _mark = p->mark; |
| 12183 | int _start_mark = p->mark; |
| 12184 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12185 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12186 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12187 | return NULL; |
| 12188 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12189 | ssize_t _children_capacity = 1; |
| 12190 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12191 | { // ',' NAME |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12192 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12193 | expr_ty elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12194 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12195 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12196 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12197 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12198 | ) |
| 12199 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12200 | _res = elem; |
| 12201 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12202 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12203 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12204 | return NULL; |
| 12205 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12206 | if (_n == _children_capacity) { |
| 12207 | _children_capacity *= 2; |
| 12208 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12209 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12210 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12211 | return NULL; |
| 12212 | } |
| 12213 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12214 | _children[_n++] = _res; |
| 12215 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12216 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12217 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12218 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12219 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12220 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12221 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_28"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12222 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12223 | return NULL; |
| 12224 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12225 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12226 | PyMem_Free(_children); |
| 12227 | _PyPegen_insert_memo(p, _start_mark, _loop0_28_type, _seq); |
| 12228 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12229 | } |
| 12230 | |
| 12231 | // _gather_27: NAME _loop0_28 |
| 12232 | static asdl_seq * |
| 12233 | _gather_27_rule(Parser *p) |
| 12234 | { |
| 12235 | if (p->error_indicator) { |
| 12236 | return NULL; |
| 12237 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12238 | asdl_seq * _res = NULL; |
| 12239 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12240 | { // NAME _loop0_28 |
| 12241 | expr_ty elem; |
| 12242 | asdl_seq * seq; |
| 12243 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12244 | (elem = _PyPegen_name_token(p)) // NAME |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12245 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12246 | (seq = _loop0_28_rule(p)) // _loop0_28 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12247 | ) |
| 12248 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12249 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12250 | goto done; |
| 12251 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12252 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12253 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12254 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12255 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12256 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12257 | } |
| 12258 | |
| 12259 | // _tmp_29: ',' expression |
| 12260 | static void * |
| 12261 | _tmp_29_rule(Parser *p) |
| 12262 | { |
| 12263 | if (p->error_indicator) { |
| 12264 | return NULL; |
| 12265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12266 | void * _res = NULL; |
| 12267 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12268 | { // ',' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12269 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12270 | expr_ty z; |
| 12271 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12272 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12273 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12274 | (z = expression_rule(p)) // expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12275 | ) |
| 12276 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12277 | _res = z; |
| 12278 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12279 | p->error_indicator = 1; |
| 12280 | return NULL; |
| 12281 | } |
| 12282 | goto done; |
| 12283 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12284 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12285 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12286 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12287 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12288 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12289 | } |
| 12290 | |
| 12291 | // _loop0_30: ('.' | '...') |
| 12292 | static asdl_seq * |
| 12293 | _loop0_30_rule(Parser *p) |
| 12294 | { |
| 12295 | if (p->error_indicator) { |
| 12296 | return NULL; |
| 12297 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12298 | void *_res = NULL; |
| 12299 | int _mark = p->mark; |
| 12300 | int _start_mark = p->mark; |
| 12301 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12302 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12303 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12304 | return NULL; |
| 12305 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12306 | ssize_t _children_capacity = 1; |
| 12307 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12308 | { // ('.' | '...') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12309 | void *_tmp_135_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12310 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12311 | (_tmp_135_var = _tmp_135_rule(p)) // '.' | '...' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12312 | ) |
| 12313 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12314 | _res = _tmp_135_var; |
| 12315 | if (_n == _children_capacity) { |
| 12316 | _children_capacity *= 2; |
| 12317 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12318 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12319 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12320 | return NULL; |
| 12321 | } |
| 12322 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12323 | _children[_n++] = _res; |
| 12324 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12325 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12326 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12327 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12328 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12329 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12330 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_30"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12331 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12332 | return NULL; |
| 12333 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12334 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12335 | PyMem_Free(_children); |
| 12336 | _PyPegen_insert_memo(p, _start_mark, _loop0_30_type, _seq); |
| 12337 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12338 | } |
| 12339 | |
| 12340 | // _loop1_31: ('.' | '...') |
| 12341 | static asdl_seq * |
| 12342 | _loop1_31_rule(Parser *p) |
| 12343 | { |
| 12344 | if (p->error_indicator) { |
| 12345 | return NULL; |
| 12346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12347 | void *_res = NULL; |
| 12348 | int _mark = p->mark; |
| 12349 | int _start_mark = p->mark; |
| 12350 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12351 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12352 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12353 | return NULL; |
| 12354 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12355 | ssize_t _children_capacity = 1; |
| 12356 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12357 | { // ('.' | '...') |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 12358 | void *_tmp_136_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12359 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12360 | (_tmp_136_var = _tmp_136_rule(p)) // '.' | '...' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12361 | ) |
| 12362 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12363 | _res = _tmp_136_var; |
| 12364 | if (_n == _children_capacity) { |
| 12365 | _children_capacity *= 2; |
| 12366 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12367 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12368 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12369 | return NULL; |
| 12370 | } |
| 12371 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12372 | _children[_n++] = _res; |
| 12373 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12374 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12375 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12376 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12377 | if (_n == 0 || p->error_indicator) { |
| 12378 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12379 | return NULL; |
| 12380 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12381 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12382 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12383 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_31"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12384 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12385 | return NULL; |
| 12386 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12387 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12388 | PyMem_Free(_children); |
| 12389 | _PyPegen_insert_memo(p, _start_mark, _loop1_31_type, _seq); |
| 12390 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12391 | } |
| 12392 | |
| 12393 | // _loop0_33: ',' import_from_as_name |
| 12394 | static asdl_seq * |
| 12395 | _loop0_33_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12396 | { |
| 12397 | if (p->error_indicator) { |
| 12398 | return NULL; |
| 12399 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12400 | void *_res = NULL; |
| 12401 | int _mark = p->mark; |
| 12402 | int _start_mark = p->mark; |
| 12403 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12404 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12405 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12406 | return NULL; |
| 12407 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12408 | ssize_t _children_capacity = 1; |
| 12409 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12410 | { // ',' import_from_as_name |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12411 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12412 | alias_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12413 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12414 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12415 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12416 | (elem = import_from_as_name_rule(p)) // import_from_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12417 | ) |
| 12418 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12419 | _res = elem; |
| 12420 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12421 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12422 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12423 | return NULL; |
| 12424 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12425 | if (_n == _children_capacity) { |
| 12426 | _children_capacity *= 2; |
| 12427 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12428 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12429 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12430 | return NULL; |
| 12431 | } |
| 12432 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12433 | _children[_n++] = _res; |
| 12434 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12435 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12436 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12437 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12438 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12439 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12440 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_33"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12441 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12442 | return NULL; |
| 12443 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12444 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12445 | PyMem_Free(_children); |
| 12446 | _PyPegen_insert_memo(p, _start_mark, _loop0_33_type, _seq); |
| 12447 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12448 | } |
| 12449 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12450 | // _gather_32: import_from_as_name _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12451 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12452 | _gather_32_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12453 | { |
| 12454 | if (p->error_indicator) { |
| 12455 | return NULL; |
| 12456 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12457 | asdl_seq * _res = NULL; |
| 12458 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12459 | { // import_from_as_name _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12460 | alias_ty elem; |
| 12461 | asdl_seq * seq; |
| 12462 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12463 | (elem = import_from_as_name_rule(p)) // import_from_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12464 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12465 | (seq = _loop0_33_rule(p)) // _loop0_33 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12466 | ) |
| 12467 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12468 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12469 | goto done; |
| 12470 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12471 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12472 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12473 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12474 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12475 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12476 | } |
| 12477 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12478 | // _tmp_34: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12479 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12480 | _tmp_34_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12481 | { |
| 12482 | if (p->error_indicator) { |
| 12483 | return NULL; |
| 12484 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12485 | void * _res = NULL; |
| 12486 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12487 | { // 'as' NAME |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12488 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12489 | expr_ty z; |
| 12490 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12491 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12492 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12493 | (z = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12494 | ) |
| 12495 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12496 | _res = z; |
| 12497 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12498 | p->error_indicator = 1; |
| 12499 | return NULL; |
| 12500 | } |
| 12501 | goto done; |
| 12502 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12503 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12504 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12505 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12506 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12507 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12508 | } |
| 12509 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12510 | // _loop0_36: ',' dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12511 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12512 | _loop0_36_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12513 | { |
| 12514 | if (p->error_indicator) { |
| 12515 | return NULL; |
| 12516 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12517 | void *_res = NULL; |
| 12518 | int _mark = p->mark; |
| 12519 | int _start_mark = p->mark; |
| 12520 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12521 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12522 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12523 | return NULL; |
| 12524 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12525 | ssize_t _children_capacity = 1; |
| 12526 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12527 | { // ',' dotted_as_name |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12528 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12529 | alias_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12530 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12531 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12532 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12533 | (elem = dotted_as_name_rule(p)) // dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12534 | ) |
| 12535 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12536 | _res = elem; |
| 12537 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12538 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12539 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12540 | return NULL; |
| 12541 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12542 | if (_n == _children_capacity) { |
| 12543 | _children_capacity *= 2; |
| 12544 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12545 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12546 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12547 | return NULL; |
| 12548 | } |
| 12549 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12550 | _children[_n++] = _res; |
| 12551 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12552 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12553 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12554 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12555 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12556 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12557 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_36"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12558 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12559 | return NULL; |
| 12560 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12561 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12562 | PyMem_Free(_children); |
| 12563 | _PyPegen_insert_memo(p, _start_mark, _loop0_36_type, _seq); |
| 12564 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12565 | } |
| 12566 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12567 | // _gather_35: dotted_as_name _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12568 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12569 | _gather_35_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12570 | { |
| 12571 | if (p->error_indicator) { |
| 12572 | return NULL; |
| 12573 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12574 | asdl_seq * _res = NULL; |
| 12575 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12576 | { // dotted_as_name _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12577 | alias_ty elem; |
| 12578 | asdl_seq * seq; |
| 12579 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12580 | (elem = dotted_as_name_rule(p)) // dotted_as_name |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12581 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12582 | (seq = _loop0_36_rule(p)) // _loop0_36 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12583 | ) |
| 12584 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12585 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12586 | goto done; |
| 12587 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12588 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12589 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12590 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12591 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12592 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12593 | } |
| 12594 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12595 | // _tmp_37: 'as' NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12596 | static void * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12597 | _tmp_37_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12598 | { |
| 12599 | if (p->error_indicator) { |
| 12600 | return NULL; |
| 12601 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12602 | void * _res = NULL; |
| 12603 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12604 | { // 'as' NAME |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12605 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12606 | expr_ty z; |
| 12607 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12608 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12609 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12610 | (z = _PyPegen_name_token(p)) // NAME |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12611 | ) |
| 12612 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12613 | _res = z; |
| 12614 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12615 | p->error_indicator = 1; |
| 12616 | return NULL; |
| 12617 | } |
| 12618 | goto done; |
| 12619 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12620 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12621 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12622 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12623 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12624 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12625 | } |
| 12626 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12627 | // _loop0_39: ',' with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12628 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12629 | _loop0_39_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12630 | { |
| 12631 | if (p->error_indicator) { |
| 12632 | return NULL; |
| 12633 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12634 | void *_res = NULL; |
| 12635 | int _mark = p->mark; |
| 12636 | int _start_mark = p->mark; |
| 12637 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12638 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12639 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12640 | return NULL; |
| 12641 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12642 | ssize_t _children_capacity = 1; |
| 12643 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12644 | { // ',' with_item |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12645 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12646 | withitem_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12647 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12648 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12649 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12650 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12651 | ) |
| 12652 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12653 | _res = elem; |
| 12654 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12655 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12656 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12657 | return NULL; |
| 12658 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12659 | if (_n == _children_capacity) { |
| 12660 | _children_capacity *= 2; |
| 12661 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12662 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12663 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12664 | return NULL; |
| 12665 | } |
| 12666 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12667 | _children[_n++] = _res; |
| 12668 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12669 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12670 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12671 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12672 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12673 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12674 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_39"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12675 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12676 | return NULL; |
| 12677 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12678 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12679 | PyMem_Free(_children); |
| 12680 | _PyPegen_insert_memo(p, _start_mark, _loop0_39_type, _seq); |
| 12681 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12682 | } |
| 12683 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12684 | // _gather_38: with_item _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12685 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12686 | _gather_38_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12687 | { |
| 12688 | if (p->error_indicator) { |
| 12689 | return NULL; |
| 12690 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12691 | asdl_seq * _res = NULL; |
| 12692 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12693 | { // with_item _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12694 | withitem_ty elem; |
| 12695 | asdl_seq * seq; |
| 12696 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12697 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12698 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12699 | (seq = _loop0_39_rule(p)) // _loop0_39 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12700 | ) |
| 12701 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12702 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12703 | goto done; |
| 12704 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12705 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12706 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12707 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12708 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12709 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12710 | } |
| 12711 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12712 | // _loop0_41: ',' with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12713 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12714 | _loop0_41_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12715 | { |
| 12716 | if (p->error_indicator) { |
| 12717 | return NULL; |
| 12718 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12719 | void *_res = NULL; |
| 12720 | int _mark = p->mark; |
| 12721 | int _start_mark = p->mark; |
| 12722 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12723 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12724 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12725 | return NULL; |
| 12726 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12727 | ssize_t _children_capacity = 1; |
| 12728 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12729 | { // ',' with_item |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12730 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12731 | withitem_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12732 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12733 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12734 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12735 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12736 | ) |
| 12737 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12738 | _res = elem; |
| 12739 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12740 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12741 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12742 | return NULL; |
| 12743 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12744 | if (_n == _children_capacity) { |
| 12745 | _children_capacity *= 2; |
| 12746 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12747 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12748 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12749 | return NULL; |
| 12750 | } |
| 12751 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12752 | _children[_n++] = _res; |
| 12753 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12754 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12755 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12756 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12757 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12758 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12759 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_41"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12760 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12761 | return NULL; |
| 12762 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12763 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12764 | PyMem_Free(_children); |
| 12765 | _PyPegen_insert_memo(p, _start_mark, _loop0_41_type, _seq); |
| 12766 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12767 | } |
| 12768 | |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12769 | // _gather_40: with_item _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12770 | static asdl_seq * |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12771 | _gather_40_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12772 | { |
| 12773 | if (p->error_indicator) { |
| 12774 | return NULL; |
| 12775 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12776 | asdl_seq * _res = NULL; |
| 12777 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 12778 | { // with_item _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12779 | withitem_ty elem; |
| 12780 | asdl_seq * seq; |
| 12781 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12782 | (elem = with_item_rule(p)) // with_item |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12783 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12784 | (seq = _loop0_41_rule(p)) // _loop0_41 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12785 | ) |
| 12786 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12787 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12788 | goto done; |
| 12789 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12790 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12791 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12792 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12793 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12794 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12795 | } |
| 12796 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12797 | // _loop0_43: ',' with_item |
| 12798 | static asdl_seq * |
| 12799 | _loop0_43_rule(Parser *p) |
| 12800 | { |
| 12801 | if (p->error_indicator) { |
| 12802 | return NULL; |
| 12803 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12804 | void *_res = NULL; |
| 12805 | int _mark = p->mark; |
| 12806 | int _start_mark = p->mark; |
| 12807 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12808 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12809 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12810 | return NULL; |
| 12811 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12812 | ssize_t _children_capacity = 1; |
| 12813 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12814 | { // ',' with_item |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12815 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12816 | withitem_ty elem; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12817 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12818 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12819 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12820 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12821 | ) |
| 12822 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12823 | _res = elem; |
| 12824 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12825 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12826 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12827 | return NULL; |
| 12828 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12829 | if (_n == _children_capacity) { |
| 12830 | _children_capacity *= 2; |
| 12831 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12832 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12833 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12834 | return NULL; |
| 12835 | } |
| 12836 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12837 | _children[_n++] = _res; |
| 12838 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12839 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12840 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12841 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12842 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12843 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12844 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_43"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12845 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12846 | return NULL; |
| 12847 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12848 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12849 | PyMem_Free(_children); |
| 12850 | _PyPegen_insert_memo(p, _start_mark, _loop0_43_type, _seq); |
| 12851 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12852 | } |
| 12853 | |
| 12854 | // _gather_42: with_item _loop0_43 |
| 12855 | static asdl_seq * |
| 12856 | _gather_42_rule(Parser *p) |
| 12857 | { |
| 12858 | if (p->error_indicator) { |
| 12859 | return NULL; |
| 12860 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12861 | asdl_seq * _res = NULL; |
| 12862 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12863 | { // with_item _loop0_43 |
| 12864 | withitem_ty elem; |
| 12865 | asdl_seq * seq; |
| 12866 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12867 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12868 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12869 | (seq = _loop0_43_rule(p)) // _loop0_43 |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12870 | ) |
| 12871 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12872 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12873 | goto done; |
| 12874 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12875 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12876 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12877 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12878 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12879 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12880 | } |
| 12881 | |
| 12882 | // _loop0_45: ',' with_item |
| 12883 | static asdl_seq * |
| 12884 | _loop0_45_rule(Parser *p) |
| 12885 | { |
| 12886 | if (p->error_indicator) { |
| 12887 | return NULL; |
| 12888 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12889 | void *_res = NULL; |
| 12890 | int _mark = p->mark; |
| 12891 | int _start_mark = p->mark; |
| 12892 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 12893 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12894 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 12895 | return NULL; |
| 12896 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12897 | ssize_t _children_capacity = 1; |
| 12898 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12899 | { // ',' with_item |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12900 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12901 | withitem_ty elem; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12902 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12903 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12904 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12905 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12906 | ) |
| 12907 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12908 | _res = elem; |
| 12909 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12910 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12911 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12912 | return NULL; |
| 12913 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12914 | if (_n == _children_capacity) { |
| 12915 | _children_capacity *= 2; |
| 12916 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 12917 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12918 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 12919 | return NULL; |
| 12920 | } |
| 12921 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12922 | _children[_n++] = _res; |
| 12923 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12924 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12925 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12926 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12927 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 12928 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12929 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_45"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12930 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12931 | return NULL; |
| 12932 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12933 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 12934 | PyMem_Free(_children); |
| 12935 | _PyPegen_insert_memo(p, _start_mark, _loop0_45_type, _seq); |
| 12936 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12937 | } |
| 12938 | |
| 12939 | // _gather_44: with_item _loop0_45 |
| 12940 | static asdl_seq * |
| 12941 | _gather_44_rule(Parser *p) |
| 12942 | { |
| 12943 | if (p->error_indicator) { |
| 12944 | return NULL; |
| 12945 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12946 | asdl_seq * _res = NULL; |
| 12947 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12948 | { // with_item _loop0_45 |
| 12949 | withitem_ty elem; |
| 12950 | asdl_seq * seq; |
| 12951 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12952 | (elem = with_item_rule(p)) // with_item |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12953 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12954 | (seq = _loop0_45_rule(p)) // _loop0_45 |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12955 | ) |
| 12956 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12957 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12958 | goto done; |
| 12959 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12960 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12961 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12962 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12963 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12964 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12965 | } |
| 12966 | |
| 12967 | // _tmp_46: 'as' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12968 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12969 | _tmp_46_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12970 | { |
| 12971 | if (p->error_indicator) { |
| 12972 | return NULL; |
| 12973 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12974 | void * _res = NULL; |
| 12975 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12976 | { // 'as' target |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12977 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12978 | expr_ty t; |
| 12979 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12980 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12981 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 12982 | (t = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12983 | ) |
| 12984 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12985 | _res = t; |
| 12986 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12987 | p->error_indicator = 1; |
| 12988 | return NULL; |
| 12989 | } |
| 12990 | goto done; |
| 12991 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12992 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12993 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12994 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12995 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 12996 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 12997 | } |
| 12998 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 12999 | // _loop1_47: except_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13000 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13001 | _loop1_47_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13002 | { |
| 13003 | if (p->error_indicator) { |
| 13004 | return NULL; |
| 13005 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13006 | void *_res = NULL; |
| 13007 | int _mark = p->mark; |
| 13008 | int _start_mark = p->mark; |
| 13009 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13010 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13011 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13012 | return NULL; |
| 13013 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13014 | ssize_t _children_capacity = 1; |
| 13015 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13016 | { // except_block |
| 13017 | excepthandler_ty except_block_var; |
| 13018 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13019 | (except_block_var = except_block_rule(p)) // except_block |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13020 | ) |
| 13021 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13022 | _res = except_block_var; |
| 13023 | if (_n == _children_capacity) { |
| 13024 | _children_capacity *= 2; |
| 13025 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13026 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13027 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13028 | return NULL; |
| 13029 | } |
| 13030 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13031 | _children[_n++] = _res; |
| 13032 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13033 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13034 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13035 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13036 | if (_n == 0 || p->error_indicator) { |
| 13037 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13038 | return NULL; |
| 13039 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13040 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13041 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13042 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_47"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13043 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13044 | return NULL; |
| 13045 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13046 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13047 | PyMem_Free(_children); |
| 13048 | _PyPegen_insert_memo(p, _start_mark, _loop1_47_type, _seq); |
| 13049 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13050 | } |
| 13051 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13052 | // _tmp_48: 'as' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13053 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13054 | _tmp_48_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13055 | { |
| 13056 | if (p->error_indicator) { |
| 13057 | return NULL; |
| 13058 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13059 | void * _res = NULL; |
| 13060 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13061 | { // 'as' target |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13062 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13063 | expr_ty z; |
| 13064 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13065 | (_keyword = _PyPegen_expect_token(p, 531)) // token='as' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13066 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13067 | (z = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13068 | ) |
| 13069 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13070 | _res = z; |
| 13071 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13072 | p->error_indicator = 1; |
| 13073 | return NULL; |
| 13074 | } |
| 13075 | goto done; |
| 13076 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13077 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13078 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13079 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13080 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13081 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13082 | } |
| 13083 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13084 | // _tmp_49: 'from' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13085 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13086 | _tmp_49_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13087 | { |
| 13088 | if (p->error_indicator) { |
| 13089 | return NULL; |
| 13090 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13091 | void * _res = NULL; |
| 13092 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13093 | { // 'from' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13094 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13095 | expr_ty z; |
| 13096 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13097 | (_keyword = _PyPegen_expect_token(p, 514)) // token='from' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13098 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13099 | (z = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13100 | ) |
| 13101 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13102 | _res = z; |
| 13103 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13104 | p->error_indicator = 1; |
| 13105 | return NULL; |
| 13106 | } |
| 13107 | goto done; |
| 13108 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13109 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13110 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13111 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13112 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13113 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13114 | } |
| 13115 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13116 | // _tmp_50: '->' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13117 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13118 | _tmp_50_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13119 | { |
| 13120 | if (p->error_indicator) { |
| 13121 | return NULL; |
| 13122 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13123 | void * _res = NULL; |
| 13124 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13125 | { // '->' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13126 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13127 | expr_ty z; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13128 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13129 | (_literal = _PyPegen_expect_token(p, 51)) // token='->' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13130 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13131 | (z = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13132 | ) |
| 13133 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13134 | _res = z; |
| 13135 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13136 | p->error_indicator = 1; |
| 13137 | return NULL; |
| 13138 | } |
| 13139 | goto done; |
| 13140 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13141 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13142 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13143 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13144 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13145 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13146 | } |
| 13147 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13148 | // _tmp_51: '->' expression |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13149 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13150 | _tmp_51_rule(Parser *p) |
| 13151 | { |
| 13152 | if (p->error_indicator) { |
| 13153 | return NULL; |
| 13154 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13155 | void * _res = NULL; |
| 13156 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13157 | { // '->' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13158 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13159 | expr_ty z; |
| 13160 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13161 | (_literal = _PyPegen_expect_token(p, 51)) // token='->' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13162 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13163 | (z = expression_rule(p)) // expression |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13164 | ) |
| 13165 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13166 | _res = z; |
| 13167 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13168 | p->error_indicator = 1; |
| 13169 | return NULL; |
| 13170 | } |
| 13171 | goto done; |
| 13172 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13173 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13174 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13175 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13176 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13177 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13178 | } |
| 13179 | |
| 13180 | // _tmp_52: NEWLINE INDENT |
| 13181 | static void * |
| 13182 | _tmp_52_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13183 | { |
| 13184 | if (p->error_indicator) { |
| 13185 | return NULL; |
| 13186 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13187 | void * _res = NULL; |
| 13188 | int _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13189 | { // NEWLINE INDENT |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 13190 | Token * indent_var; |
| 13191 | Token * newline_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13192 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13193 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13194 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13195 | (indent_var = _PyPegen_expect_token(p, INDENT)) // token='INDENT' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13196 | ) |
| 13197 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13198 | _res = _PyPegen_dummy_name(p, newline_var, indent_var); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13199 | goto done; |
| 13200 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13201 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13202 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13203 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13204 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13205 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13206 | } |
| 13207 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13208 | // _loop0_53: param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13209 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13210 | _loop0_53_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13211 | { |
| 13212 | if (p->error_indicator) { |
| 13213 | return NULL; |
| 13214 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13215 | void *_res = NULL; |
| 13216 | int _mark = p->mark; |
| 13217 | int _start_mark = p->mark; |
| 13218 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13219 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13220 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13221 | return NULL; |
| 13222 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13223 | ssize_t _children_capacity = 1; |
| 13224 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13225 | { // param_no_default |
| 13226 | arg_ty param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13227 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13228 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13229 | ) |
| 13230 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13231 | _res = param_no_default_var; |
| 13232 | if (_n == _children_capacity) { |
| 13233 | _children_capacity *= 2; |
| 13234 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13235 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13236 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13237 | return NULL; |
| 13238 | } |
| 13239 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13240 | _children[_n++] = _res; |
| 13241 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13242 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13243 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13244 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13245 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13246 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13247 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_53"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13248 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13249 | return NULL; |
| 13250 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13251 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13252 | PyMem_Free(_children); |
| 13253 | _PyPegen_insert_memo(p, _start_mark, _loop0_53_type, _seq); |
| 13254 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13255 | } |
| 13256 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13257 | // _loop0_54: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13258 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13259 | _loop0_54_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13260 | { |
| 13261 | if (p->error_indicator) { |
| 13262 | return NULL; |
| 13263 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13264 | void *_res = NULL; |
| 13265 | int _mark = p->mark; |
| 13266 | int _start_mark = p->mark; |
| 13267 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13268 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13269 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13270 | return NULL; |
| 13271 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13272 | ssize_t _children_capacity = 1; |
| 13273 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13274 | { // param_with_default |
| 13275 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13276 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13277 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13278 | ) |
| 13279 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13280 | _res = param_with_default_var; |
| 13281 | if (_n == _children_capacity) { |
| 13282 | _children_capacity *= 2; |
| 13283 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13284 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13285 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13286 | return NULL; |
| 13287 | } |
| 13288 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13289 | _children[_n++] = _res; |
| 13290 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13291 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13292 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13293 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13294 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13295 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13296 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_54"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13297 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13298 | return NULL; |
| 13299 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13300 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13301 | PyMem_Free(_children); |
| 13302 | _PyPegen_insert_memo(p, _start_mark, _loop0_54_type, _seq); |
| 13303 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13304 | } |
| 13305 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13306 | // _loop0_55: param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13307 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13308 | _loop0_55_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13309 | { |
| 13310 | if (p->error_indicator) { |
| 13311 | return NULL; |
| 13312 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13313 | void *_res = NULL; |
| 13314 | int _mark = p->mark; |
| 13315 | int _start_mark = p->mark; |
| 13316 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13317 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13318 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13319 | return NULL; |
| 13320 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13321 | ssize_t _children_capacity = 1; |
| 13322 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13323 | { // param_with_default |
| 13324 | NameDefaultPair* param_with_default_var; |
| 13325 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13326 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13327 | ) |
| 13328 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13329 | _res = param_with_default_var; |
| 13330 | if (_n == _children_capacity) { |
| 13331 | _children_capacity *= 2; |
| 13332 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13333 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13334 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13335 | return NULL; |
| 13336 | } |
| 13337 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13338 | _children[_n++] = _res; |
| 13339 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13340 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13341 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13342 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13343 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13344 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13345 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_55"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13346 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13347 | return NULL; |
| 13348 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13349 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13350 | PyMem_Free(_children); |
| 13351 | _PyPegen_insert_memo(p, _start_mark, _loop0_55_type, _seq); |
| 13352 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13353 | } |
| 13354 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13355 | // _loop1_56: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13356 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13357 | _loop1_56_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13358 | { |
| 13359 | if (p->error_indicator) { |
| 13360 | return NULL; |
| 13361 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13362 | void *_res = NULL; |
| 13363 | int _mark = p->mark; |
| 13364 | int _start_mark = p->mark; |
| 13365 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13366 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13367 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13368 | return NULL; |
| 13369 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13370 | ssize_t _children_capacity = 1; |
| 13371 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13372 | { // param_no_default |
| 13373 | arg_ty param_no_default_var; |
| 13374 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13375 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13376 | ) |
| 13377 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13378 | _res = param_no_default_var; |
| 13379 | if (_n == _children_capacity) { |
| 13380 | _children_capacity *= 2; |
| 13381 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13382 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13383 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13384 | return NULL; |
| 13385 | } |
| 13386 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13387 | _children[_n++] = _res; |
| 13388 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13389 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13390 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13391 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13392 | if (_n == 0 || p->error_indicator) { |
| 13393 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13394 | return NULL; |
| 13395 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13396 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13397 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13398 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_56"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13399 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13400 | return NULL; |
| 13401 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13402 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13403 | PyMem_Free(_children); |
| 13404 | _PyPegen_insert_memo(p, _start_mark, _loop1_56_type, _seq); |
| 13405 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13406 | } |
| 13407 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13408 | // _loop0_57: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13409 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13410 | _loop0_57_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13411 | { |
| 13412 | if (p->error_indicator) { |
| 13413 | return NULL; |
| 13414 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13415 | void *_res = NULL; |
| 13416 | int _mark = p->mark; |
| 13417 | int _start_mark = p->mark; |
| 13418 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13419 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13420 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13421 | return NULL; |
| 13422 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13423 | ssize_t _children_capacity = 1; |
| 13424 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13425 | { // param_with_default |
| 13426 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13427 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13428 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13429 | ) |
| 13430 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13431 | _res = param_with_default_var; |
| 13432 | if (_n == _children_capacity) { |
| 13433 | _children_capacity *= 2; |
| 13434 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13435 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13436 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13437 | return NULL; |
| 13438 | } |
| 13439 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13440 | _children[_n++] = _res; |
| 13441 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13442 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13443 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13444 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13445 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13446 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13447 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_57"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13448 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13449 | return NULL; |
| 13450 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13451 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13452 | PyMem_Free(_children); |
| 13453 | _PyPegen_insert_memo(p, _start_mark, _loop0_57_type, _seq); |
| 13454 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13455 | } |
| 13456 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13457 | // _loop1_58: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13458 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13459 | _loop1_58_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13460 | { |
| 13461 | if (p->error_indicator) { |
| 13462 | return NULL; |
| 13463 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13464 | void *_res = NULL; |
| 13465 | int _mark = p->mark; |
| 13466 | int _start_mark = p->mark; |
| 13467 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13468 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13469 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13470 | return NULL; |
| 13471 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13472 | ssize_t _children_capacity = 1; |
| 13473 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13474 | { // param_with_default |
| 13475 | NameDefaultPair* param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13476 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13477 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13478 | ) |
| 13479 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13480 | _res = param_with_default_var; |
| 13481 | if (_n == _children_capacity) { |
| 13482 | _children_capacity *= 2; |
| 13483 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13484 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13485 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13486 | return NULL; |
| 13487 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13488 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13489 | _children[_n++] = _res; |
| 13490 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13491 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13492 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13493 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13494 | if (_n == 0 || p->error_indicator) { |
| 13495 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13496 | return NULL; |
| 13497 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13498 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13499 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13500 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_58"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13501 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13502 | return NULL; |
| 13503 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13504 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13505 | PyMem_Free(_children); |
| 13506 | _PyPegen_insert_memo(p, _start_mark, _loop1_58_type, _seq); |
| 13507 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13508 | } |
| 13509 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13510 | // _loop1_59: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13511 | static asdl_seq * |
| 13512 | _loop1_59_rule(Parser *p) |
| 13513 | { |
| 13514 | if (p->error_indicator) { |
| 13515 | return NULL; |
| 13516 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13517 | void *_res = NULL; |
| 13518 | int _mark = p->mark; |
| 13519 | int _start_mark = p->mark; |
| 13520 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13521 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13522 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13523 | return NULL; |
| 13524 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13525 | ssize_t _children_capacity = 1; |
| 13526 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13527 | { // param_no_default |
| 13528 | arg_ty param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13529 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13530 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13531 | ) |
| 13532 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13533 | _res = param_no_default_var; |
| 13534 | if (_n == _children_capacity) { |
| 13535 | _children_capacity *= 2; |
| 13536 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13537 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13538 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13539 | return NULL; |
| 13540 | } |
| 13541 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13542 | _children[_n++] = _res; |
| 13543 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13544 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13545 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13546 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13547 | if (_n == 0 || p->error_indicator) { |
| 13548 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13549 | return NULL; |
| 13550 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13551 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13552 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13553 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_59"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13554 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13555 | return NULL; |
| 13556 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13557 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13558 | PyMem_Free(_children); |
| 13559 | _PyPegen_insert_memo(p, _start_mark, _loop1_59_type, _seq); |
| 13560 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13561 | } |
| 13562 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13563 | // _loop1_60: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13564 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13565 | _loop1_60_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13566 | { |
| 13567 | if (p->error_indicator) { |
| 13568 | return NULL; |
| 13569 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13570 | void *_res = NULL; |
| 13571 | int _mark = p->mark; |
| 13572 | int _start_mark = p->mark; |
| 13573 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13574 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13575 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13576 | return NULL; |
| 13577 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13578 | ssize_t _children_capacity = 1; |
| 13579 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13580 | { // param_no_default |
| 13581 | arg_ty param_no_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13582 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13583 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13584 | ) |
| 13585 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13586 | _res = param_no_default_var; |
| 13587 | if (_n == _children_capacity) { |
| 13588 | _children_capacity *= 2; |
| 13589 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13590 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13591 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13592 | return NULL; |
| 13593 | } |
| 13594 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13595 | _children[_n++] = _res; |
| 13596 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13597 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13598 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13599 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13600 | if (_n == 0 || p->error_indicator) { |
| 13601 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13602 | return NULL; |
| 13603 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13604 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13605 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13606 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_60"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13607 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13608 | return NULL; |
| 13609 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13610 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13611 | PyMem_Free(_children); |
| 13612 | _PyPegen_insert_memo(p, _start_mark, _loop1_60_type, _seq); |
| 13613 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13614 | } |
| 13615 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13616 | // _loop0_61: param_no_default |
| 13617 | static asdl_seq * |
| 13618 | _loop0_61_rule(Parser *p) |
| 13619 | { |
| 13620 | if (p->error_indicator) { |
| 13621 | return NULL; |
| 13622 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13623 | void *_res = NULL; |
| 13624 | int _mark = p->mark; |
| 13625 | int _start_mark = p->mark; |
| 13626 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13627 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13628 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13629 | return NULL; |
| 13630 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13631 | ssize_t _children_capacity = 1; |
| 13632 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13633 | { // param_no_default |
| 13634 | arg_ty param_no_default_var; |
| 13635 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13636 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13637 | ) |
| 13638 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13639 | _res = param_no_default_var; |
| 13640 | if (_n == _children_capacity) { |
| 13641 | _children_capacity *= 2; |
| 13642 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13643 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13644 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13645 | return NULL; |
| 13646 | } |
| 13647 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13648 | _children[_n++] = _res; |
| 13649 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13650 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13651 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13652 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13653 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13654 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13655 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_61"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13656 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13657 | return NULL; |
| 13658 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13659 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13660 | PyMem_Free(_children); |
| 13661 | _PyPegen_insert_memo(p, _start_mark, _loop0_61_type, _seq); |
| 13662 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13663 | } |
| 13664 | |
| 13665 | // _loop1_62: param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13666 | static asdl_seq * |
| 13667 | _loop1_62_rule(Parser *p) |
| 13668 | { |
| 13669 | if (p->error_indicator) { |
| 13670 | return NULL; |
| 13671 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13672 | void *_res = NULL; |
| 13673 | int _mark = p->mark; |
| 13674 | int _start_mark = p->mark; |
| 13675 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13676 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13677 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13678 | return NULL; |
| 13679 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13680 | ssize_t _children_capacity = 1; |
| 13681 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13682 | { // param_with_default |
| 13683 | NameDefaultPair* param_with_default_var; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13684 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13685 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13686 | ) |
| 13687 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13688 | _res = param_with_default_var; |
| 13689 | if (_n == _children_capacity) { |
| 13690 | _children_capacity *= 2; |
| 13691 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13692 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13693 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13694 | return NULL; |
| 13695 | } |
| 13696 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13697 | _children[_n++] = _res; |
| 13698 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13699 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13700 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13701 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13702 | if (_n == 0 || p->error_indicator) { |
| 13703 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13704 | return NULL; |
| 13705 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13706 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13707 | if (!_seq) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13708 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_62"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13709 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13710 | return NULL; |
| 13711 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13712 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13713 | PyMem_Free(_children); |
| 13714 | _PyPegen_insert_memo(p, _start_mark, _loop1_62_type, _seq); |
| 13715 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 13716 | } |
| 13717 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13718 | // _loop0_63: param_no_default |
| 13719 | static asdl_seq * |
| 13720 | _loop0_63_rule(Parser *p) |
| 13721 | { |
| 13722 | if (p->error_indicator) { |
| 13723 | return NULL; |
| 13724 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13725 | void *_res = NULL; |
| 13726 | int _mark = p->mark; |
| 13727 | int _start_mark = p->mark; |
| 13728 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13729 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13730 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13731 | return NULL; |
| 13732 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13733 | ssize_t _children_capacity = 1; |
| 13734 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13735 | { // param_no_default |
| 13736 | arg_ty param_no_default_var; |
| 13737 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13738 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13739 | ) |
| 13740 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13741 | _res = param_no_default_var; |
| 13742 | if (_n == _children_capacity) { |
| 13743 | _children_capacity *= 2; |
| 13744 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13745 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13746 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13747 | return NULL; |
| 13748 | } |
| 13749 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13750 | _children[_n++] = _res; |
| 13751 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13752 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13753 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13754 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13755 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13756 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13757 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_63"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13758 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13759 | return NULL; |
| 13760 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13761 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13762 | PyMem_Free(_children); |
| 13763 | _PyPegen_insert_memo(p, _start_mark, _loop0_63_type, _seq); |
| 13764 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13765 | } |
| 13766 | |
| 13767 | // _loop1_64: param_with_default |
| 13768 | static asdl_seq * |
| 13769 | _loop1_64_rule(Parser *p) |
| 13770 | { |
| 13771 | if (p->error_indicator) { |
| 13772 | return NULL; |
| 13773 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13774 | void *_res = NULL; |
| 13775 | int _mark = p->mark; |
| 13776 | int _start_mark = p->mark; |
| 13777 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13778 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13779 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13780 | return NULL; |
| 13781 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13782 | ssize_t _children_capacity = 1; |
| 13783 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13784 | { // param_with_default |
| 13785 | NameDefaultPair* param_with_default_var; |
| 13786 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13787 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13788 | ) |
| 13789 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13790 | _res = param_with_default_var; |
| 13791 | if (_n == _children_capacity) { |
| 13792 | _children_capacity *= 2; |
| 13793 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13794 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13795 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13796 | return NULL; |
| 13797 | } |
| 13798 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13799 | _children[_n++] = _res; |
| 13800 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13801 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13802 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13803 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13804 | if (_n == 0 || p->error_indicator) { |
| 13805 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13806 | return NULL; |
| 13807 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13808 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13809 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13810 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_64"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13811 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13812 | return NULL; |
| 13813 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13814 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13815 | PyMem_Free(_children); |
| 13816 | _PyPegen_insert_memo(p, _start_mark, _loop1_64_type, _seq); |
| 13817 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13818 | } |
| 13819 | |
| 13820 | // _loop0_65: param_maybe_default |
| 13821 | static asdl_seq * |
| 13822 | _loop0_65_rule(Parser *p) |
| 13823 | { |
| 13824 | if (p->error_indicator) { |
| 13825 | return NULL; |
| 13826 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13827 | void *_res = NULL; |
| 13828 | int _mark = p->mark; |
| 13829 | int _start_mark = p->mark; |
| 13830 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13831 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13832 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13833 | return NULL; |
| 13834 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13835 | ssize_t _children_capacity = 1; |
| 13836 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13837 | { // param_maybe_default |
| 13838 | NameDefaultPair* param_maybe_default_var; |
| 13839 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13840 | (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13841 | ) |
| 13842 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13843 | _res = param_maybe_default_var; |
| 13844 | if (_n == _children_capacity) { |
| 13845 | _children_capacity *= 2; |
| 13846 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13847 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13848 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13849 | return NULL; |
| 13850 | } |
| 13851 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13852 | _children[_n++] = _res; |
| 13853 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13854 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13855 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13856 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13857 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13858 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13859 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_65"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13860 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13861 | return NULL; |
| 13862 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13863 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13864 | PyMem_Free(_children); |
| 13865 | _PyPegen_insert_memo(p, _start_mark, _loop0_65_type, _seq); |
| 13866 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13867 | } |
| 13868 | |
| 13869 | // _loop1_66: param_maybe_default |
| 13870 | static asdl_seq * |
| 13871 | _loop1_66_rule(Parser *p) |
| 13872 | { |
| 13873 | if (p->error_indicator) { |
| 13874 | return NULL; |
| 13875 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13876 | void *_res = NULL; |
| 13877 | int _mark = p->mark; |
| 13878 | int _start_mark = p->mark; |
| 13879 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13880 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13881 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13882 | return NULL; |
| 13883 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13884 | ssize_t _children_capacity = 1; |
| 13885 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13886 | { // param_maybe_default |
| 13887 | NameDefaultPair* param_maybe_default_var; |
| 13888 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13889 | (param_maybe_default_var = param_maybe_default_rule(p)) // param_maybe_default |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13890 | ) |
| 13891 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13892 | _res = param_maybe_default_var; |
| 13893 | if (_n == _children_capacity) { |
| 13894 | _children_capacity *= 2; |
| 13895 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13896 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13897 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13898 | return NULL; |
| 13899 | } |
| 13900 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13901 | _children[_n++] = _res; |
| 13902 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13903 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13904 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13905 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13906 | if (_n == 0 || p->error_indicator) { |
| 13907 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13908 | return NULL; |
| 13909 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13910 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13911 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13912 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_66"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13913 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13914 | return NULL; |
| 13915 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13916 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13917 | PyMem_Free(_children); |
| 13918 | _PyPegen_insert_memo(p, _start_mark, _loop1_66_type, _seq); |
| 13919 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13920 | } |
| 13921 | |
| 13922 | // _loop1_67: ('@' named_expression NEWLINE) |
| 13923 | static asdl_seq * |
| 13924 | _loop1_67_rule(Parser *p) |
| 13925 | { |
| 13926 | if (p->error_indicator) { |
| 13927 | return NULL; |
| 13928 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13929 | void *_res = NULL; |
| 13930 | int _mark = p->mark; |
| 13931 | int _start_mark = p->mark; |
| 13932 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 13933 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13934 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 13935 | return NULL; |
| 13936 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13937 | ssize_t _children_capacity = 1; |
| 13938 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13939 | { // ('@' named_expression NEWLINE) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 13940 | void *_tmp_137_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13941 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13942 | (_tmp_137_var = _tmp_137_rule(p)) // '@' named_expression NEWLINE |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13943 | ) |
| 13944 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13945 | _res = _tmp_137_var; |
| 13946 | if (_n == _children_capacity) { |
| 13947 | _children_capacity *= 2; |
| 13948 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 13949 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13950 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 13951 | return NULL; |
| 13952 | } |
| 13953 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13954 | _children[_n++] = _res; |
| 13955 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13956 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13957 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13958 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13959 | if (_n == 0 || p->error_indicator) { |
| 13960 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13961 | return NULL; |
| 13962 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13963 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 13964 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13965 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_67"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13966 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13967 | return NULL; |
| 13968 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13969 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 13970 | PyMem_Free(_children); |
| 13971 | _PyPegen_insert_memo(p, _start_mark, _loop1_67_type, _seq); |
| 13972 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13973 | } |
| 13974 | |
| 13975 | // _tmp_68: '(' arguments? ')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13976 | static void * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 13977 | _tmp_68_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13978 | { |
| 13979 | if (p->error_indicator) { |
| 13980 | return NULL; |
| 13981 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13982 | void * _res = NULL; |
| 13983 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13984 | { // '(' arguments? ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13985 | Token * _literal; |
| 13986 | Token * _literal_1; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13987 | void *z; |
| 13988 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13989 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13990 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 13991 | (z = arguments_rule(p), 1) // arguments? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13992 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13993 | (_literal_1 = _PyPegen_expect_token(p, 8)) // token=')' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13994 | ) |
| 13995 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 13996 | _res = z; |
| 13997 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 13998 | p->error_indicator = 1; |
| 13999 | return NULL; |
| 14000 | } |
| 14001 | goto done; |
| 14002 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14003 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14004 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14005 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14006 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14007 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14008 | } |
| 14009 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14010 | // _loop0_70: ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14011 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14012 | _loop0_70_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14013 | { |
| 14014 | if (p->error_indicator) { |
| 14015 | return NULL; |
| 14016 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14017 | void *_res = NULL; |
| 14018 | int _mark = p->mark; |
| 14019 | int _start_mark = p->mark; |
| 14020 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14021 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14022 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14023 | return NULL; |
| 14024 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14025 | ssize_t _children_capacity = 1; |
| 14026 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14027 | { // ',' star_expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14028 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14029 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14030 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14031 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14032 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14033 | (elem = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14034 | ) |
| 14035 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14036 | _res = elem; |
| 14037 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14038 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14039 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14040 | return NULL; |
| 14041 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14042 | if (_n == _children_capacity) { |
| 14043 | _children_capacity *= 2; |
| 14044 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14045 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14046 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14047 | return NULL; |
| 14048 | } |
| 14049 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14050 | _children[_n++] = _res; |
| 14051 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14052 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14053 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14054 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14055 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14056 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14057 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_70"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14058 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14059 | return NULL; |
| 14060 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14061 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14062 | PyMem_Free(_children); |
| 14063 | _PyPegen_insert_memo(p, _start_mark, _loop0_70_type, _seq); |
| 14064 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14065 | } |
| 14066 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14067 | // _gather_69: star_expression _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14068 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14069 | _gather_69_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14070 | { |
| 14071 | if (p->error_indicator) { |
| 14072 | return NULL; |
| 14073 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14074 | asdl_seq * _res = NULL; |
| 14075 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14076 | { // star_expression _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14077 | expr_ty elem; |
| 14078 | asdl_seq * seq; |
| 14079 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14080 | (elem = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14081 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14082 | (seq = _loop0_70_rule(p)) // _loop0_70 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14083 | ) |
| 14084 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14085 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14086 | goto done; |
| 14087 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14088 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14089 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14090 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14091 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14092 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14093 | } |
| 14094 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14095 | // _loop1_71: (',' star_expression) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14096 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14097 | _loop1_71_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14098 | { |
| 14099 | if (p->error_indicator) { |
| 14100 | return NULL; |
| 14101 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14102 | void *_res = NULL; |
| 14103 | int _mark = p->mark; |
| 14104 | int _start_mark = p->mark; |
| 14105 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14106 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14107 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14108 | return NULL; |
| 14109 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14110 | ssize_t _children_capacity = 1; |
| 14111 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14112 | { // (',' star_expression) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 14113 | void *_tmp_138_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14114 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14115 | (_tmp_138_var = _tmp_138_rule(p)) // ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14116 | ) |
| 14117 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14118 | _res = _tmp_138_var; |
| 14119 | if (_n == _children_capacity) { |
| 14120 | _children_capacity *= 2; |
| 14121 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14122 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14123 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14124 | return NULL; |
| 14125 | } |
| 14126 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14127 | _children[_n++] = _res; |
| 14128 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14129 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14130 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14131 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14132 | if (_n == 0 || p->error_indicator) { |
| 14133 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14134 | return NULL; |
| 14135 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14136 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14137 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14138 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_71"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14139 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14140 | return NULL; |
| 14141 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14142 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14143 | PyMem_Free(_children); |
| 14144 | _PyPegen_insert_memo(p, _start_mark, _loop1_71_type, _seq); |
| 14145 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14146 | } |
| 14147 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14148 | // _loop0_73: ',' star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14149 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14150 | _loop0_73_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14151 | { |
| 14152 | if (p->error_indicator) { |
| 14153 | return NULL; |
| 14154 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14155 | void *_res = NULL; |
| 14156 | int _mark = p->mark; |
| 14157 | int _start_mark = p->mark; |
| 14158 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14159 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14160 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14161 | return NULL; |
| 14162 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14163 | ssize_t _children_capacity = 1; |
| 14164 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14165 | { // ',' star_named_expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14166 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14167 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14168 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14169 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14170 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14171 | (elem = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14172 | ) |
| 14173 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14174 | _res = elem; |
| 14175 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14176 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14177 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14178 | return NULL; |
| 14179 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14180 | if (_n == _children_capacity) { |
| 14181 | _children_capacity *= 2; |
| 14182 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14183 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14184 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14185 | return NULL; |
| 14186 | } |
| 14187 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14188 | _children[_n++] = _res; |
| 14189 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14190 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14191 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14192 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14193 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14194 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14195 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_73"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14196 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14197 | return NULL; |
| 14198 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14199 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14200 | PyMem_Free(_children); |
| 14201 | _PyPegen_insert_memo(p, _start_mark, _loop0_73_type, _seq); |
| 14202 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14203 | } |
| 14204 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14205 | // _gather_72: star_named_expression _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14206 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14207 | _gather_72_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14208 | { |
| 14209 | if (p->error_indicator) { |
| 14210 | return NULL; |
| 14211 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14212 | asdl_seq * _res = NULL; |
| 14213 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14214 | { // star_named_expression _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14215 | expr_ty elem; |
| 14216 | asdl_seq * seq; |
| 14217 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14218 | (elem = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14219 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14220 | (seq = _loop0_73_rule(p)) // _loop0_73 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14221 | ) |
| 14222 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14223 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14224 | goto done; |
| 14225 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14226 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14227 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14228 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14229 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14230 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14231 | } |
| 14232 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14233 | // _loop1_74: (',' expression) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14234 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14235 | _loop1_74_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14236 | { |
| 14237 | if (p->error_indicator) { |
| 14238 | return NULL; |
| 14239 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14240 | void *_res = NULL; |
| 14241 | int _mark = p->mark; |
| 14242 | int _start_mark = p->mark; |
| 14243 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14244 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14245 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14246 | return NULL; |
| 14247 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14248 | ssize_t _children_capacity = 1; |
| 14249 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14250 | { // (',' expression) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 14251 | void *_tmp_139_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14252 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14253 | (_tmp_139_var = _tmp_139_rule(p)) // ',' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14254 | ) |
| 14255 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14256 | _res = _tmp_139_var; |
| 14257 | if (_n == _children_capacity) { |
| 14258 | _children_capacity *= 2; |
| 14259 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14260 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14261 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14262 | return NULL; |
| 14263 | } |
| 14264 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14265 | _children[_n++] = _res; |
| 14266 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14267 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14268 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14269 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14270 | if (_n == 0 || p->error_indicator) { |
| 14271 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14272 | return NULL; |
| 14273 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14274 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14275 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14276 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_74"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14277 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14278 | return NULL; |
| 14279 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14280 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14281 | PyMem_Free(_children); |
| 14282 | _PyPegen_insert_memo(p, _start_mark, _loop1_74_type, _seq); |
| 14283 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14284 | } |
| 14285 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14286 | // _loop0_75: lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14287 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14288 | _loop0_75_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14289 | { |
| 14290 | if (p->error_indicator) { |
| 14291 | return NULL; |
| 14292 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14293 | void *_res = NULL; |
| 14294 | int _mark = p->mark; |
| 14295 | int _start_mark = p->mark; |
| 14296 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14297 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14298 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14299 | return NULL; |
| 14300 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14301 | ssize_t _children_capacity = 1; |
| 14302 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14303 | { // lambda_param_no_default |
| 14304 | arg_ty lambda_param_no_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14305 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14306 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14307 | ) |
| 14308 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14309 | _res = lambda_param_no_default_var; |
| 14310 | if (_n == _children_capacity) { |
| 14311 | _children_capacity *= 2; |
| 14312 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14313 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14314 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14315 | return NULL; |
| 14316 | } |
| 14317 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14318 | _children[_n++] = _res; |
| 14319 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14320 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14321 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14322 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14323 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14324 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14325 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_75"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14326 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14327 | return NULL; |
| 14328 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14329 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14330 | PyMem_Free(_children); |
| 14331 | _PyPegen_insert_memo(p, _start_mark, _loop0_75_type, _seq); |
| 14332 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14333 | } |
| 14334 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14335 | // _loop0_76: lambda_param_with_default |
| 14336 | static asdl_seq * |
| 14337 | _loop0_76_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14338 | { |
| 14339 | if (p->error_indicator) { |
| 14340 | return NULL; |
| 14341 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14342 | void *_res = NULL; |
| 14343 | int _mark = p->mark; |
| 14344 | int _start_mark = p->mark; |
| 14345 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14346 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14347 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14348 | return NULL; |
| 14349 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14350 | ssize_t _children_capacity = 1; |
| 14351 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14352 | { // lambda_param_with_default |
| 14353 | NameDefaultPair* lambda_param_with_default_var; |
| 14354 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14355 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14356 | ) |
| 14357 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14358 | _res = lambda_param_with_default_var; |
| 14359 | if (_n == _children_capacity) { |
| 14360 | _children_capacity *= 2; |
| 14361 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14362 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14363 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14364 | return NULL; |
| 14365 | } |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14366 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14367 | _children[_n++] = _res; |
| 14368 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14369 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14370 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14371 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14372 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14373 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14374 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_76"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14375 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14376 | return NULL; |
| 14377 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14378 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14379 | PyMem_Free(_children); |
| 14380 | _PyPegen_insert_memo(p, _start_mark, _loop0_76_type, _seq); |
| 14381 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14382 | } |
| 14383 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14384 | // _loop0_77: lambda_param_with_default |
| 14385 | static asdl_seq * |
| 14386 | _loop0_77_rule(Parser *p) |
| 14387 | { |
| 14388 | if (p->error_indicator) { |
| 14389 | return NULL; |
| 14390 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14391 | void *_res = NULL; |
| 14392 | int _mark = p->mark; |
| 14393 | int _start_mark = p->mark; |
| 14394 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14395 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14396 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14397 | return NULL; |
| 14398 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14399 | ssize_t _children_capacity = 1; |
| 14400 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14401 | { // lambda_param_with_default |
| 14402 | NameDefaultPair* lambda_param_with_default_var; |
| 14403 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14404 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14405 | ) |
| 14406 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14407 | _res = lambda_param_with_default_var; |
| 14408 | if (_n == _children_capacity) { |
| 14409 | _children_capacity *= 2; |
| 14410 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14411 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14412 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14413 | return NULL; |
| 14414 | } |
| 14415 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14416 | _children[_n++] = _res; |
| 14417 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14418 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14419 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14420 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14421 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14422 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14423 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_77"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14424 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14425 | return NULL; |
| 14426 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14427 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14428 | PyMem_Free(_children); |
| 14429 | _PyPegen_insert_memo(p, _start_mark, _loop0_77_type, _seq); |
| 14430 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14431 | } |
| 14432 | |
| 14433 | // _loop1_78: lambda_param_no_default |
| 14434 | static asdl_seq * |
| 14435 | _loop1_78_rule(Parser *p) |
| 14436 | { |
| 14437 | if (p->error_indicator) { |
| 14438 | return NULL; |
| 14439 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14440 | void *_res = NULL; |
| 14441 | int _mark = p->mark; |
| 14442 | int _start_mark = p->mark; |
| 14443 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14444 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14445 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14446 | return NULL; |
| 14447 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14448 | ssize_t _children_capacity = 1; |
| 14449 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14450 | { // lambda_param_no_default |
| 14451 | arg_ty lambda_param_no_default_var; |
| 14452 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14453 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14454 | ) |
| 14455 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14456 | _res = lambda_param_no_default_var; |
| 14457 | if (_n == _children_capacity) { |
| 14458 | _children_capacity *= 2; |
| 14459 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14460 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14461 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14462 | return NULL; |
| 14463 | } |
| 14464 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14465 | _children[_n++] = _res; |
| 14466 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14467 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14468 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14469 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14470 | if (_n == 0 || p->error_indicator) { |
| 14471 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14472 | return NULL; |
| 14473 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14474 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14475 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14476 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_78"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14477 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14478 | return NULL; |
| 14479 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14480 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14481 | PyMem_Free(_children); |
| 14482 | _PyPegen_insert_memo(p, _start_mark, _loop1_78_type, _seq); |
| 14483 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14484 | } |
| 14485 | |
| 14486 | // _loop0_79: lambda_param_with_default |
| 14487 | static asdl_seq * |
| 14488 | _loop0_79_rule(Parser *p) |
| 14489 | { |
| 14490 | if (p->error_indicator) { |
| 14491 | return NULL; |
| 14492 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14493 | void *_res = NULL; |
| 14494 | int _mark = p->mark; |
| 14495 | int _start_mark = p->mark; |
| 14496 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14497 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14498 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14499 | return NULL; |
| 14500 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14501 | ssize_t _children_capacity = 1; |
| 14502 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14503 | { // lambda_param_with_default |
| 14504 | NameDefaultPair* lambda_param_with_default_var; |
| 14505 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14506 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14507 | ) |
| 14508 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14509 | _res = lambda_param_with_default_var; |
| 14510 | if (_n == _children_capacity) { |
| 14511 | _children_capacity *= 2; |
| 14512 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14513 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14514 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14515 | return NULL; |
| 14516 | } |
| 14517 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14518 | _children[_n++] = _res; |
| 14519 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14520 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14521 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14522 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14523 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14524 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14525 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_79"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14526 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14527 | return NULL; |
| 14528 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14529 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14530 | PyMem_Free(_children); |
| 14531 | _PyPegen_insert_memo(p, _start_mark, _loop0_79_type, _seq); |
| 14532 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14533 | } |
| 14534 | |
| 14535 | // _loop1_80: lambda_param_with_default |
| 14536 | static asdl_seq * |
| 14537 | _loop1_80_rule(Parser *p) |
| 14538 | { |
| 14539 | if (p->error_indicator) { |
| 14540 | return NULL; |
| 14541 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14542 | void *_res = NULL; |
| 14543 | int _mark = p->mark; |
| 14544 | int _start_mark = p->mark; |
| 14545 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14546 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14547 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14548 | return NULL; |
| 14549 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14550 | ssize_t _children_capacity = 1; |
| 14551 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14552 | { // lambda_param_with_default |
| 14553 | NameDefaultPair* lambda_param_with_default_var; |
| 14554 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14555 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14556 | ) |
| 14557 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14558 | _res = lambda_param_with_default_var; |
| 14559 | if (_n == _children_capacity) { |
| 14560 | _children_capacity *= 2; |
| 14561 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14562 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14563 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14564 | return NULL; |
| 14565 | } |
| 14566 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14567 | _children[_n++] = _res; |
| 14568 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14569 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14570 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14571 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14572 | if (_n == 0 || p->error_indicator) { |
| 14573 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14574 | return NULL; |
| 14575 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14576 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14577 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14578 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_80"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14579 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14580 | return NULL; |
| 14581 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14582 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14583 | PyMem_Free(_children); |
| 14584 | _PyPegen_insert_memo(p, _start_mark, _loop1_80_type, _seq); |
| 14585 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14586 | } |
| 14587 | |
| 14588 | // _loop1_81: lambda_param_no_default |
| 14589 | static asdl_seq * |
| 14590 | _loop1_81_rule(Parser *p) |
| 14591 | { |
| 14592 | if (p->error_indicator) { |
| 14593 | return NULL; |
| 14594 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14595 | void *_res = NULL; |
| 14596 | int _mark = p->mark; |
| 14597 | int _start_mark = p->mark; |
| 14598 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14599 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14600 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14601 | return NULL; |
| 14602 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14603 | ssize_t _children_capacity = 1; |
| 14604 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14605 | { // lambda_param_no_default |
| 14606 | arg_ty lambda_param_no_default_var; |
| 14607 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14608 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14609 | ) |
| 14610 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14611 | _res = lambda_param_no_default_var; |
| 14612 | if (_n == _children_capacity) { |
| 14613 | _children_capacity *= 2; |
| 14614 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14615 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14616 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14617 | return NULL; |
| 14618 | } |
| 14619 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14620 | _children[_n++] = _res; |
| 14621 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14622 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14623 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14624 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14625 | if (_n == 0 || p->error_indicator) { |
| 14626 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14627 | return NULL; |
| 14628 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14629 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14630 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14631 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_81"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14632 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14633 | return NULL; |
| 14634 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14635 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14636 | PyMem_Free(_children); |
| 14637 | _PyPegen_insert_memo(p, _start_mark, _loop1_81_type, _seq); |
| 14638 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14639 | } |
| 14640 | |
| 14641 | // _loop1_82: lambda_param_no_default |
| 14642 | static asdl_seq * |
| 14643 | _loop1_82_rule(Parser *p) |
| 14644 | { |
| 14645 | if (p->error_indicator) { |
| 14646 | return NULL; |
| 14647 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14648 | void *_res = NULL; |
| 14649 | int _mark = p->mark; |
| 14650 | int _start_mark = p->mark; |
| 14651 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14652 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14653 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14654 | return NULL; |
| 14655 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14656 | ssize_t _children_capacity = 1; |
| 14657 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14658 | { // lambda_param_no_default |
| 14659 | arg_ty lambda_param_no_default_var; |
| 14660 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14661 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14662 | ) |
| 14663 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14664 | _res = lambda_param_no_default_var; |
| 14665 | if (_n == _children_capacity) { |
| 14666 | _children_capacity *= 2; |
| 14667 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14668 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14669 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14670 | return NULL; |
| 14671 | } |
| 14672 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14673 | _children[_n++] = _res; |
| 14674 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14675 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14676 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14677 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14678 | if (_n == 0 || p->error_indicator) { |
| 14679 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14680 | return NULL; |
| 14681 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14682 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14683 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14684 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_82"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14685 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14686 | return NULL; |
| 14687 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14688 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14689 | PyMem_Free(_children); |
| 14690 | _PyPegen_insert_memo(p, _start_mark, _loop1_82_type, _seq); |
| 14691 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14692 | } |
| 14693 | |
| 14694 | // _loop0_83: lambda_param_no_default |
| 14695 | static asdl_seq * |
| 14696 | _loop0_83_rule(Parser *p) |
| 14697 | { |
| 14698 | if (p->error_indicator) { |
| 14699 | return NULL; |
| 14700 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14701 | void *_res = NULL; |
| 14702 | int _mark = p->mark; |
| 14703 | int _start_mark = p->mark; |
| 14704 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14705 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14706 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14707 | return NULL; |
| 14708 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14709 | ssize_t _children_capacity = 1; |
| 14710 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14711 | { // lambda_param_no_default |
| 14712 | arg_ty lambda_param_no_default_var; |
| 14713 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14714 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14715 | ) |
| 14716 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14717 | _res = lambda_param_no_default_var; |
| 14718 | if (_n == _children_capacity) { |
| 14719 | _children_capacity *= 2; |
| 14720 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14721 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14722 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14723 | return NULL; |
| 14724 | } |
| 14725 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14726 | _children[_n++] = _res; |
| 14727 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14728 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14729 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14730 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14731 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14732 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14733 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_83"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14734 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14735 | return NULL; |
| 14736 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14737 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14738 | PyMem_Free(_children); |
| 14739 | _PyPegen_insert_memo(p, _start_mark, _loop0_83_type, _seq); |
| 14740 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14741 | } |
| 14742 | |
| 14743 | // _loop1_84: lambda_param_with_default |
| 14744 | static asdl_seq * |
| 14745 | _loop1_84_rule(Parser *p) |
| 14746 | { |
| 14747 | if (p->error_indicator) { |
| 14748 | return NULL; |
| 14749 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14750 | void *_res = NULL; |
| 14751 | int _mark = p->mark; |
| 14752 | int _start_mark = p->mark; |
| 14753 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14754 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14755 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14756 | return NULL; |
| 14757 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14758 | ssize_t _children_capacity = 1; |
| 14759 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14760 | { // lambda_param_with_default |
| 14761 | NameDefaultPair* lambda_param_with_default_var; |
| 14762 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14763 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14764 | ) |
| 14765 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14766 | _res = lambda_param_with_default_var; |
| 14767 | if (_n == _children_capacity) { |
| 14768 | _children_capacity *= 2; |
| 14769 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14770 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14771 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14772 | return NULL; |
| 14773 | } |
| 14774 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14775 | _children[_n++] = _res; |
| 14776 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14777 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14778 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14779 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14780 | if (_n == 0 || p->error_indicator) { |
| 14781 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14782 | return NULL; |
| 14783 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14784 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14785 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14786 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_84"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14787 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14788 | return NULL; |
| 14789 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14790 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14791 | PyMem_Free(_children); |
| 14792 | _PyPegen_insert_memo(p, _start_mark, _loop1_84_type, _seq); |
| 14793 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14794 | } |
| 14795 | |
| 14796 | // _loop0_85: lambda_param_no_default |
| 14797 | static asdl_seq * |
| 14798 | _loop0_85_rule(Parser *p) |
| 14799 | { |
| 14800 | if (p->error_indicator) { |
| 14801 | return NULL; |
| 14802 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14803 | void *_res = NULL; |
| 14804 | int _mark = p->mark; |
| 14805 | int _start_mark = p->mark; |
| 14806 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14807 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14808 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14809 | return NULL; |
| 14810 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14811 | ssize_t _children_capacity = 1; |
| 14812 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14813 | { // lambda_param_no_default |
| 14814 | arg_ty lambda_param_no_default_var; |
| 14815 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14816 | (lambda_param_no_default_var = lambda_param_no_default_rule(p)) // lambda_param_no_default |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14817 | ) |
| 14818 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14819 | _res = lambda_param_no_default_var; |
| 14820 | if (_n == _children_capacity) { |
| 14821 | _children_capacity *= 2; |
| 14822 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14823 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14824 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14825 | return NULL; |
| 14826 | } |
| 14827 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14828 | _children[_n++] = _res; |
| 14829 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14830 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14831 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14832 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14833 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14834 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14835 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_85"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14836 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14837 | return NULL; |
| 14838 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14839 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14840 | PyMem_Free(_children); |
| 14841 | _PyPegen_insert_memo(p, _start_mark, _loop0_85_type, _seq); |
| 14842 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14843 | } |
| 14844 | |
| 14845 | // _loop1_86: lambda_param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14846 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14847 | _loop1_86_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14848 | { |
| 14849 | if (p->error_indicator) { |
| 14850 | return NULL; |
| 14851 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14852 | void *_res = NULL; |
| 14853 | int _mark = p->mark; |
| 14854 | int _start_mark = p->mark; |
| 14855 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14856 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14857 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14858 | return NULL; |
| 14859 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14860 | ssize_t _children_capacity = 1; |
| 14861 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14862 | { // lambda_param_with_default |
| 14863 | NameDefaultPair* lambda_param_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14864 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14865 | (lambda_param_with_default_var = lambda_param_with_default_rule(p)) // lambda_param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14866 | ) |
| 14867 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14868 | _res = lambda_param_with_default_var; |
| 14869 | if (_n == _children_capacity) { |
| 14870 | _children_capacity *= 2; |
| 14871 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14872 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14873 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14874 | return NULL; |
| 14875 | } |
| 14876 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14877 | _children[_n++] = _res; |
| 14878 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14879 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14880 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14881 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14882 | if (_n == 0 || p->error_indicator) { |
| 14883 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14884 | return NULL; |
| 14885 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14886 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14887 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 14888 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_86"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14889 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14890 | return NULL; |
| 14891 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14892 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14893 | PyMem_Free(_children); |
| 14894 | _PyPegen_insert_memo(p, _start_mark, _loop1_86_type, _seq); |
| 14895 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14896 | } |
| 14897 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14898 | // _loop0_87: lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14899 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14900 | _loop0_87_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14901 | { |
| 14902 | if (p->error_indicator) { |
| 14903 | return NULL; |
| 14904 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14905 | void *_res = NULL; |
| 14906 | int _mark = p->mark; |
| 14907 | int _start_mark = p->mark; |
| 14908 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14909 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14910 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14911 | return NULL; |
| 14912 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14913 | ssize_t _children_capacity = 1; |
| 14914 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14915 | { // lambda_param_maybe_default |
| 14916 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14917 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14918 | (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14919 | ) |
| 14920 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14921 | _res = lambda_param_maybe_default_var; |
| 14922 | if (_n == _children_capacity) { |
| 14923 | _children_capacity *= 2; |
| 14924 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14925 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14926 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14927 | return NULL; |
| 14928 | } |
| 14929 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14930 | _children[_n++] = _res; |
| 14931 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14932 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14933 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14934 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14935 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14936 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14937 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_87"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14938 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14939 | return NULL; |
| 14940 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14941 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14942 | PyMem_Free(_children); |
| 14943 | _PyPegen_insert_memo(p, _start_mark, _loop0_87_type, _seq); |
| 14944 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14945 | } |
| 14946 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14947 | // _loop1_88: lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14948 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14949 | _loop1_88_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14950 | { |
| 14951 | if (p->error_indicator) { |
| 14952 | return NULL; |
| 14953 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14954 | void *_res = NULL; |
| 14955 | int _mark = p->mark; |
| 14956 | int _start_mark = p->mark; |
| 14957 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 14958 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14959 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 14960 | return NULL; |
| 14961 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14962 | ssize_t _children_capacity = 1; |
| 14963 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14964 | { // lambda_param_maybe_default |
| 14965 | NameDefaultPair* lambda_param_maybe_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14966 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 14967 | (lambda_param_maybe_default_var = lambda_param_maybe_default_rule(p)) // lambda_param_maybe_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14968 | ) |
| 14969 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14970 | _res = lambda_param_maybe_default_var; |
| 14971 | if (_n == _children_capacity) { |
| 14972 | _children_capacity *= 2; |
| 14973 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 14974 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14975 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 14976 | return NULL; |
| 14977 | } |
| 14978 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14979 | _children[_n++] = _res; |
| 14980 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14981 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14982 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14983 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14984 | if (_n == 0 || p->error_indicator) { |
| 14985 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14986 | return NULL; |
| 14987 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14988 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 14989 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 14990 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_88"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14991 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14992 | return NULL; |
| 14993 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 14994 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 14995 | PyMem_Free(_children); |
| 14996 | _PyPegen_insert_memo(p, _start_mark, _loop1_88_type, _seq); |
| 14997 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 14998 | } |
| 14999 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15000 | // _loop1_89: ('or' conjunction) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15001 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15002 | _loop1_89_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15003 | { |
| 15004 | if (p->error_indicator) { |
| 15005 | return NULL; |
| 15006 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15007 | void *_res = NULL; |
| 15008 | int _mark = p->mark; |
| 15009 | int _start_mark = p->mark; |
| 15010 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15011 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15012 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15013 | return NULL; |
| 15014 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15015 | ssize_t _children_capacity = 1; |
| 15016 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15017 | { // ('or' conjunction) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15018 | void *_tmp_140_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15019 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15020 | (_tmp_140_var = _tmp_140_rule(p)) // 'or' conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15021 | ) |
| 15022 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15023 | _res = _tmp_140_var; |
| 15024 | if (_n == _children_capacity) { |
| 15025 | _children_capacity *= 2; |
| 15026 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15027 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15028 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15029 | return NULL; |
| 15030 | } |
| 15031 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15032 | _children[_n++] = _res; |
| 15033 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15035 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15036 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15037 | if (_n == 0 || p->error_indicator) { |
| 15038 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15039 | return NULL; |
| 15040 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15041 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15042 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15043 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_89"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15044 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15045 | return NULL; |
| 15046 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15047 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15048 | PyMem_Free(_children); |
| 15049 | _PyPegen_insert_memo(p, _start_mark, _loop1_89_type, _seq); |
| 15050 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15051 | } |
| 15052 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15053 | // _loop1_90: ('and' inversion) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15054 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15055 | _loop1_90_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15056 | { |
| 15057 | if (p->error_indicator) { |
| 15058 | return NULL; |
| 15059 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15060 | void *_res = NULL; |
| 15061 | int _mark = p->mark; |
| 15062 | int _start_mark = p->mark; |
| 15063 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15064 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15065 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15066 | return NULL; |
| 15067 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15068 | ssize_t _children_capacity = 1; |
| 15069 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15070 | { // ('and' inversion) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15071 | void *_tmp_141_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15072 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15073 | (_tmp_141_var = _tmp_141_rule(p)) // 'and' inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15074 | ) |
| 15075 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15076 | _res = _tmp_141_var; |
| 15077 | if (_n == _children_capacity) { |
| 15078 | _children_capacity *= 2; |
| 15079 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15080 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15081 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15082 | return NULL; |
| 15083 | } |
| 15084 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15085 | _children[_n++] = _res; |
| 15086 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15087 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15088 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15089 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15090 | if (_n == 0 || p->error_indicator) { |
| 15091 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15092 | return NULL; |
| 15093 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15094 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15095 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15096 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_90"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15097 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15098 | return NULL; |
| 15099 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15100 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15101 | PyMem_Free(_children); |
| 15102 | _PyPegen_insert_memo(p, _start_mark, _loop1_90_type, _seq); |
| 15103 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15104 | } |
| 15105 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15106 | // _loop1_91: compare_op_bitwise_or_pair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15107 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15108 | _loop1_91_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15109 | { |
| 15110 | if (p->error_indicator) { |
| 15111 | return NULL; |
| 15112 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15113 | void *_res = NULL; |
| 15114 | int _mark = p->mark; |
| 15115 | int _start_mark = p->mark; |
| 15116 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15117 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15118 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15119 | return NULL; |
| 15120 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15121 | ssize_t _children_capacity = 1; |
| 15122 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15123 | { // compare_op_bitwise_or_pair |
| 15124 | CmpopExprPair* compare_op_bitwise_or_pair_var; |
| 15125 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15126 | (compare_op_bitwise_or_pair_var = compare_op_bitwise_or_pair_rule(p)) // compare_op_bitwise_or_pair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15127 | ) |
| 15128 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15129 | _res = compare_op_bitwise_or_pair_var; |
| 15130 | if (_n == _children_capacity) { |
| 15131 | _children_capacity *= 2; |
| 15132 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15133 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15134 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15135 | return NULL; |
| 15136 | } |
| 15137 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15138 | _children[_n++] = _res; |
| 15139 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15140 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15141 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15142 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15143 | if (_n == 0 || p->error_indicator) { |
| 15144 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15145 | return NULL; |
| 15146 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15147 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15148 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15149 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_91"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15150 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15151 | return NULL; |
| 15152 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15153 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15154 | PyMem_Free(_children); |
| 15155 | _PyPegen_insert_memo(p, _start_mark, _loop1_91_type, _seq); |
| 15156 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15157 | } |
| 15158 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15159 | // _tmp_92: '!=' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15160 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15161 | _tmp_92_rule(Parser *p) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15162 | { |
| 15163 | if (p->error_indicator) { |
| 15164 | return NULL; |
| 15165 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15166 | void * _res = NULL; |
| 15167 | int _mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15168 | { // '!=' |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 15169 | Token * tok; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15170 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15171 | (tok = _PyPegen_expect_token(p, 28)) // token='!=' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15172 | ) |
| 15173 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15174 | _res = _PyPegen_check_barry_as_flufl ( p ) ? NULL : tok; |
| 15175 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15176 | p->error_indicator = 1; |
| 15177 | return NULL; |
| 15178 | } |
| 15179 | goto done; |
| 15180 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15181 | p->mark = _mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15182 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15183 | _res = NULL; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15184 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15185 | return _res; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15186 | } |
| 15187 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15188 | // _loop0_94: ',' slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15189 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15190 | _loop0_94_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15191 | { |
| 15192 | if (p->error_indicator) { |
| 15193 | return NULL; |
| 15194 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15195 | void *_res = NULL; |
| 15196 | int _mark = p->mark; |
| 15197 | int _start_mark = p->mark; |
| 15198 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15199 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15200 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15201 | return NULL; |
| 15202 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15203 | ssize_t _children_capacity = 1; |
| 15204 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15205 | { // ',' slice |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15206 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15207 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15208 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15209 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15210 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15211 | (elem = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15212 | ) |
| 15213 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15214 | _res = elem; |
| 15215 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15216 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15217 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15218 | return NULL; |
| 15219 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15220 | if (_n == _children_capacity) { |
| 15221 | _children_capacity *= 2; |
| 15222 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15223 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15224 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15225 | return NULL; |
| 15226 | } |
| 15227 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15228 | _children[_n++] = _res; |
| 15229 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15230 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15231 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15232 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15233 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15234 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15235 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_94"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15236 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15237 | return NULL; |
| 15238 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15239 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15240 | PyMem_Free(_children); |
| 15241 | _PyPegen_insert_memo(p, _start_mark, _loop0_94_type, _seq); |
| 15242 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15243 | } |
| 15244 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15245 | // _gather_93: slice _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15246 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15247 | _gather_93_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15248 | { |
| 15249 | if (p->error_indicator) { |
| 15250 | return NULL; |
| 15251 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15252 | asdl_seq * _res = NULL; |
| 15253 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15254 | { // slice _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15255 | expr_ty elem; |
| 15256 | asdl_seq * seq; |
| 15257 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15258 | (elem = slice_rule(p)) // slice |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15259 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15260 | (seq = _loop0_94_rule(p)) // _loop0_94 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15261 | ) |
| 15262 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15263 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15264 | goto done; |
| 15265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15266 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15267 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15268 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15269 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15270 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15271 | } |
| 15272 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15273 | // _tmp_95: ':' expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15274 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15275 | _tmp_95_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15276 | { |
| 15277 | if (p->error_indicator) { |
| 15278 | return NULL; |
| 15279 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15280 | void * _res = NULL; |
| 15281 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15282 | { // ':' expression? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15283 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15284 | void *d; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15285 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15286 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15287 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15288 | (d = expression_rule(p), 1) // expression? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15289 | ) |
| 15290 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15291 | _res = d; |
| 15292 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15293 | p->error_indicator = 1; |
| 15294 | return NULL; |
| 15295 | } |
| 15296 | goto done; |
| 15297 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15298 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15299 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15300 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15301 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15302 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15303 | } |
| 15304 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15305 | // _tmp_96: tuple | group | genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15306 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15307 | _tmp_96_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15308 | { |
| 15309 | if (p->error_indicator) { |
| 15310 | return NULL; |
| 15311 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15312 | void * _res = NULL; |
| 15313 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15314 | { // tuple |
| 15315 | expr_ty tuple_var; |
| 15316 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15317 | (tuple_var = tuple_rule(p)) // tuple |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15318 | ) |
| 15319 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15320 | _res = tuple_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15321 | goto done; |
| 15322 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15323 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15324 | } |
| 15325 | { // group |
| 15326 | expr_ty group_var; |
| 15327 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15328 | (group_var = group_rule(p)) // group |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15329 | ) |
| 15330 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15331 | _res = group_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15332 | goto done; |
| 15333 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15334 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15335 | } |
| 15336 | { // genexp |
| 15337 | expr_ty genexp_var; |
| 15338 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15339 | (genexp_var = genexp_rule(p)) // genexp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15340 | ) |
| 15341 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15342 | _res = genexp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15343 | goto done; |
| 15344 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15345 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15346 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15347 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15348 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15349 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15350 | } |
| 15351 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15352 | // _tmp_97: list | listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15353 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15354 | _tmp_97_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15355 | { |
| 15356 | if (p->error_indicator) { |
| 15357 | return NULL; |
| 15358 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15359 | void * _res = NULL; |
| 15360 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15361 | { // list |
| 15362 | expr_ty list_var; |
| 15363 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15364 | (list_var = list_rule(p)) // list |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15365 | ) |
| 15366 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15367 | _res = list_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15368 | goto done; |
| 15369 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15370 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15371 | } |
| 15372 | { // listcomp |
| 15373 | expr_ty listcomp_var; |
| 15374 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15375 | (listcomp_var = listcomp_rule(p)) // listcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15376 | ) |
| 15377 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15378 | _res = listcomp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15379 | goto done; |
| 15380 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15381 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15382 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15383 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15384 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15385 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15386 | } |
| 15387 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15388 | // _tmp_98: dict | set | dictcomp | setcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15389 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15390 | _tmp_98_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15391 | { |
| 15392 | if (p->error_indicator) { |
| 15393 | return NULL; |
| 15394 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15395 | void * _res = NULL; |
| 15396 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15397 | { // dict |
| 15398 | expr_ty dict_var; |
| 15399 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15400 | (dict_var = dict_rule(p)) // dict |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15401 | ) |
| 15402 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15403 | _res = dict_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15404 | goto done; |
| 15405 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15406 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15407 | } |
| 15408 | { // set |
| 15409 | expr_ty set_var; |
| 15410 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15411 | (set_var = set_rule(p)) // set |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15412 | ) |
| 15413 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15414 | _res = set_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15415 | goto done; |
| 15416 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15417 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15418 | } |
| 15419 | { // dictcomp |
| 15420 | expr_ty dictcomp_var; |
| 15421 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15422 | (dictcomp_var = dictcomp_rule(p)) // dictcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15423 | ) |
| 15424 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15425 | _res = dictcomp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15426 | goto done; |
| 15427 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15428 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15429 | } |
| 15430 | { // setcomp |
| 15431 | expr_ty setcomp_var; |
| 15432 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15433 | (setcomp_var = setcomp_rule(p)) // setcomp |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15434 | ) |
| 15435 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15436 | _res = setcomp_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15437 | goto done; |
| 15438 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15439 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15440 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15441 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15442 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15443 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15444 | } |
| 15445 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15446 | // _loop1_99: STRING |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15447 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15448 | _loop1_99_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15449 | { |
| 15450 | if (p->error_indicator) { |
| 15451 | return NULL; |
| 15452 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15453 | void *_res = NULL; |
| 15454 | int _mark = p->mark; |
| 15455 | int _start_mark = p->mark; |
| 15456 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15457 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15458 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15459 | return NULL; |
| 15460 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15461 | ssize_t _children_capacity = 1; |
| 15462 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15463 | { // STRING |
| 15464 | expr_ty string_var; |
| 15465 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15466 | (string_var = _PyPegen_string_token(p)) // STRING |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15467 | ) |
| 15468 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15469 | _res = string_var; |
| 15470 | if (_n == _children_capacity) { |
| 15471 | _children_capacity *= 2; |
| 15472 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15473 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15474 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15475 | return NULL; |
| 15476 | } |
| 15477 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15478 | _children[_n++] = _res; |
| 15479 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15480 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15481 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15482 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15483 | if (_n == 0 || p->error_indicator) { |
| 15484 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15485 | return NULL; |
| 15486 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15487 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15488 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15489 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_99"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15490 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15491 | return NULL; |
| 15492 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15493 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15494 | PyMem_Free(_children); |
| 15495 | _PyPegen_insert_memo(p, _start_mark, _loop1_99_type, _seq); |
| 15496 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15497 | } |
| 15498 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15499 | // _tmp_100: star_named_expression ',' star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15500 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15501 | _tmp_100_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15502 | { |
| 15503 | if (p->error_indicator) { |
| 15504 | return NULL; |
| 15505 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15506 | void * _res = NULL; |
| 15507 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15508 | { // star_named_expression ',' star_named_expressions? |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15509 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15510 | expr_ty y; |
| 15511 | void *z; |
| 15512 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15513 | (y = star_named_expression_rule(p)) // star_named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15514 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15515 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15516 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15517 | (z = star_named_expressions_rule(p), 1) // star_named_expressions? |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15518 | ) |
| 15519 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15520 | _res = _PyPegen_seq_insert_in_front ( p , y , z ); |
| 15521 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15522 | p->error_indicator = 1; |
| 15523 | return NULL; |
| 15524 | } |
| 15525 | goto done; |
| 15526 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15527 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15528 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15529 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15530 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15531 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15532 | } |
| 15533 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15534 | // _tmp_101: yield_expr | named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15535 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15536 | _tmp_101_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15537 | { |
| 15538 | if (p->error_indicator) { |
| 15539 | return NULL; |
| 15540 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15541 | void * _res = NULL; |
| 15542 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15543 | { // yield_expr |
| 15544 | expr_ty yield_expr_var; |
| 15545 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15546 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15547 | ) |
| 15548 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15549 | _res = yield_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15550 | goto done; |
| 15551 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15552 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15553 | } |
| 15554 | { // named_expression |
| 15555 | expr_ty named_expression_var; |
| 15556 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15557 | (named_expression_var = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15558 | ) |
| 15559 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15560 | _res = named_expression_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15561 | goto done; |
| 15562 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15563 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15564 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15565 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15566 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15567 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15568 | } |
| 15569 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15570 | // _loop0_103: ',' kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15571 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15572 | _loop0_103_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15573 | { |
| 15574 | if (p->error_indicator) { |
| 15575 | return NULL; |
| 15576 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15577 | void *_res = NULL; |
| 15578 | int _mark = p->mark; |
| 15579 | int _start_mark = p->mark; |
| 15580 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15581 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15582 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15583 | return NULL; |
| 15584 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15585 | ssize_t _children_capacity = 1; |
| 15586 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15587 | { // ',' kvpair |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15588 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15589 | KeyValuePair* elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15590 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15591 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15592 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15593 | (elem = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15594 | ) |
| 15595 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15596 | _res = elem; |
| 15597 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15598 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15599 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15600 | return NULL; |
| 15601 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15602 | if (_n == _children_capacity) { |
| 15603 | _children_capacity *= 2; |
| 15604 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15605 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15606 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15607 | return NULL; |
| 15608 | } |
| 15609 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15610 | _children[_n++] = _res; |
| 15611 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15612 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15613 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15614 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15615 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15616 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15617 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_103"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15618 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15619 | return NULL; |
| 15620 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15621 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15622 | PyMem_Free(_children); |
| 15623 | _PyPegen_insert_memo(p, _start_mark, _loop0_103_type, _seq); |
| 15624 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15625 | } |
| 15626 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15627 | // _gather_102: kvpair _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15628 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15629 | _gather_102_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15630 | { |
| 15631 | if (p->error_indicator) { |
| 15632 | return NULL; |
| 15633 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15634 | asdl_seq * _res = NULL; |
| 15635 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15636 | { // kvpair _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15637 | KeyValuePair* elem; |
| 15638 | asdl_seq * seq; |
| 15639 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15640 | (elem = kvpair_rule(p)) // kvpair |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15641 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15642 | (seq = _loop0_103_rule(p)) // _loop0_103 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15643 | ) |
| 15644 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15645 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15646 | goto done; |
| 15647 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15648 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15649 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15650 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15651 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15652 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15653 | } |
| 15654 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15655 | // _loop1_104: for_if_clause |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15656 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15657 | _loop1_104_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15658 | { |
| 15659 | if (p->error_indicator) { |
| 15660 | return NULL; |
| 15661 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15662 | void *_res = NULL; |
| 15663 | int _mark = p->mark; |
| 15664 | int _start_mark = p->mark; |
| 15665 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15666 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15667 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15668 | return NULL; |
| 15669 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15670 | ssize_t _children_capacity = 1; |
| 15671 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15672 | { // for_if_clause |
| 15673 | comprehension_ty for_if_clause_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15674 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15675 | (for_if_clause_var = for_if_clause_rule(p)) // for_if_clause |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15676 | ) |
| 15677 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15678 | _res = for_if_clause_var; |
| 15679 | if (_n == _children_capacity) { |
| 15680 | _children_capacity *= 2; |
| 15681 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15682 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15683 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15684 | return NULL; |
| 15685 | } |
| 15686 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15687 | _children[_n++] = _res; |
| 15688 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15689 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15690 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15691 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15692 | if (_n == 0 || p->error_indicator) { |
| 15693 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15694 | return NULL; |
| 15695 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15696 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15697 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15698 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_104"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15699 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15700 | return NULL; |
| 15701 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15702 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15703 | PyMem_Free(_children); |
| 15704 | _PyPegen_insert_memo(p, _start_mark, _loop1_104_type, _seq); |
| 15705 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 15706 | } |
| 15707 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15708 | // _loop0_105: ('if' disjunction) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15709 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15710 | _loop0_105_rule(Parser *p) |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15711 | { |
| 15712 | if (p->error_indicator) { |
| 15713 | return NULL; |
| 15714 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15715 | void *_res = NULL; |
| 15716 | int _mark = p->mark; |
| 15717 | int _start_mark = p->mark; |
| 15718 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15719 | if (!_children) { |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15720 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15721 | return NULL; |
| 15722 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15723 | ssize_t _children_capacity = 1; |
| 15724 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15725 | { // ('if' disjunction) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15726 | void *_tmp_142_var; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15727 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15728 | (_tmp_142_var = _tmp_142_rule(p)) // 'if' disjunction |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15729 | ) |
| 15730 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15731 | _res = _tmp_142_var; |
| 15732 | if (_n == _children_capacity) { |
| 15733 | _children_capacity *= 2; |
| 15734 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15735 | if (!_children) { |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15736 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15737 | return NULL; |
| 15738 | } |
| 15739 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15740 | _children[_n++] = _res; |
| 15741 | _mark = p->mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15742 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15743 | p->mark = _mark; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15744 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15745 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15746 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15747 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_105"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15748 | PyMem_Free(_children); |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15749 | return NULL; |
| 15750 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15751 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15752 | PyMem_Free(_children); |
| 15753 | _PyPegen_insert_memo(p, _start_mark, _loop0_105_type, _seq); |
| 15754 | return _seq; |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 15755 | } |
| 15756 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15757 | // _loop0_106: ('if' disjunction) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15758 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15759 | _loop0_106_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15760 | { |
| 15761 | if (p->error_indicator) { |
| 15762 | return NULL; |
| 15763 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15764 | void *_res = NULL; |
| 15765 | int _mark = p->mark; |
| 15766 | int _start_mark = p->mark; |
| 15767 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15768 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15769 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15770 | return NULL; |
| 15771 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15772 | ssize_t _children_capacity = 1; |
| 15773 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15774 | { // ('if' disjunction) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 15775 | void *_tmp_143_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15776 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15777 | (_tmp_143_var = _tmp_143_rule(p)) // 'if' disjunction |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15778 | ) |
| 15779 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15780 | _res = _tmp_143_var; |
| 15781 | if (_n == _children_capacity) { |
| 15782 | _children_capacity *= 2; |
| 15783 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15784 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15785 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15786 | return NULL; |
| 15787 | } |
| 15788 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15789 | _children[_n++] = _res; |
| 15790 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15791 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15792 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15793 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15794 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15795 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15796 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_106"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15797 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15798 | return NULL; |
| 15799 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15800 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15801 | PyMem_Free(_children); |
| 15802 | _PyPegen_insert_memo(p, _start_mark, _loop0_106_type, _seq); |
| 15803 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15804 | } |
| 15805 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15806 | // _tmp_107: ',' args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15807 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15808 | _tmp_107_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15809 | { |
| 15810 | if (p->error_indicator) { |
| 15811 | return NULL; |
| 15812 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15813 | void * _res = NULL; |
| 15814 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15815 | { // ',' args |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15816 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15817 | expr_ty c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15818 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15819 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15820 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15821 | (c = args_rule(p)) // args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15822 | ) |
| 15823 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15824 | _res = c; |
| 15825 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15826 | p->error_indicator = 1; |
| 15827 | return NULL; |
| 15828 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15829 | goto done; |
| 15830 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15831 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15832 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15833 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15834 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15835 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 15836 | } |
| 15837 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15838 | // _tmp_108: ',' args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15839 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15840 | _tmp_108_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15841 | { |
| 15842 | if (p->error_indicator) { |
| 15843 | return NULL; |
| 15844 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15845 | void * _res = NULL; |
| 15846 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15847 | { // ',' args |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15848 | Token * _literal; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15849 | expr_ty c; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15850 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15851 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15852 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15853 | (c = args_rule(p)) // args |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15854 | ) |
| 15855 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15856 | _res = c; |
| 15857 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15858 | p->error_indicator = 1; |
| 15859 | return NULL; |
| 15860 | } |
| 15861 | goto done; |
| 15862 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15863 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15864 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15865 | _res = NULL; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15866 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15867 | return _res; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 15868 | } |
| 15869 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15870 | // _loop0_110: ',' kwarg_or_starred |
| 15871 | static asdl_seq * |
| 15872 | _loop0_110_rule(Parser *p) |
| 15873 | { |
| 15874 | if (p->error_indicator) { |
| 15875 | return NULL; |
| 15876 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15877 | void *_res = NULL; |
| 15878 | int _mark = p->mark; |
| 15879 | int _start_mark = p->mark; |
| 15880 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15881 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15882 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15883 | return NULL; |
| 15884 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15885 | ssize_t _children_capacity = 1; |
| 15886 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15887 | { // ',' kwarg_or_starred |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15888 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15889 | KeywordOrStarred* elem; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15890 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15891 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15892 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15893 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15894 | ) |
| 15895 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15896 | _res = elem; |
| 15897 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15898 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15899 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15900 | return NULL; |
| 15901 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15902 | if (_n == _children_capacity) { |
| 15903 | _children_capacity *= 2; |
| 15904 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15905 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15906 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15907 | return NULL; |
| 15908 | } |
| 15909 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15910 | _children[_n++] = _res; |
| 15911 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15912 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15913 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15914 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15915 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 15916 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15917 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_110"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15918 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15919 | return NULL; |
| 15920 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15921 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 15922 | PyMem_Free(_children); |
| 15923 | _PyPegen_insert_memo(p, _start_mark, _loop0_110_type, _seq); |
| 15924 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15925 | } |
| 15926 | |
| 15927 | // _gather_109: kwarg_or_starred _loop0_110 |
| 15928 | static asdl_seq * |
| 15929 | _gather_109_rule(Parser *p) |
| 15930 | { |
| 15931 | if (p->error_indicator) { |
| 15932 | return NULL; |
| 15933 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15934 | asdl_seq * _res = NULL; |
| 15935 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15936 | { // kwarg_or_starred _loop0_110 |
| 15937 | KeywordOrStarred* elem; |
| 15938 | asdl_seq * seq; |
| 15939 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15940 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15941 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15942 | (seq = _loop0_110_rule(p)) // _loop0_110 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15943 | ) |
| 15944 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15945 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15946 | goto done; |
| 15947 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15948 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15949 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15950 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15951 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15952 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15953 | } |
| 15954 | |
| 15955 | // _loop0_112: ',' kwarg_or_double_starred |
| 15956 | static asdl_seq * |
| 15957 | _loop0_112_rule(Parser *p) |
| 15958 | { |
| 15959 | if (p->error_indicator) { |
| 15960 | return NULL; |
| 15961 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15962 | void *_res = NULL; |
| 15963 | int _mark = p->mark; |
| 15964 | int _start_mark = p->mark; |
| 15965 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 15966 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15967 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 15968 | return NULL; |
| 15969 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15970 | ssize_t _children_capacity = 1; |
| 15971 | ssize_t _n = 0; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15972 | { // ',' kwarg_or_double_starred |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15973 | Token * _literal; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15974 | KeywordOrStarred* elem; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15975 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15976 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15977 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 15978 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15979 | ) |
| 15980 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15981 | _res = elem; |
| 15982 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15983 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15984 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15985 | return NULL; |
| 15986 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15987 | if (_n == _children_capacity) { |
| 15988 | _children_capacity *= 2; |
| 15989 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 15990 | if (!_children) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15991 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 15992 | return NULL; |
| 15993 | } |
| 15994 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15995 | _children[_n++] = _res; |
| 15996 | _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15997 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 15998 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 15999 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16000 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16001 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16002 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_112"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16003 | PyMem_Free(_children); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16004 | return NULL; |
| 16005 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16006 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16007 | PyMem_Free(_children); |
| 16008 | _PyPegen_insert_memo(p, _start_mark, _loop0_112_type, _seq); |
| 16009 | return _seq; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16010 | } |
| 16011 | |
| 16012 | // _gather_111: kwarg_or_double_starred _loop0_112 |
| 16013 | static asdl_seq * |
| 16014 | _gather_111_rule(Parser *p) |
| 16015 | { |
| 16016 | if (p->error_indicator) { |
| 16017 | return NULL; |
| 16018 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16019 | asdl_seq * _res = NULL; |
| 16020 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16021 | { // kwarg_or_double_starred _loop0_112 |
| 16022 | KeywordOrStarred* elem; |
| 16023 | asdl_seq * seq; |
| 16024 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16025 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16026 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16027 | (seq = _loop0_112_rule(p)) // _loop0_112 |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16028 | ) |
| 16029 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16030 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16031 | goto done; |
| 16032 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16033 | p->mark = _mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16034 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16035 | _res = NULL; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16036 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16037 | return _res; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16038 | } |
| 16039 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16040 | // _loop0_114: ',' kwarg_or_starred |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16041 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16042 | _loop0_114_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16043 | { |
| 16044 | if (p->error_indicator) { |
| 16045 | return NULL; |
| 16046 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16047 | void *_res = NULL; |
| 16048 | int _mark = p->mark; |
| 16049 | int _start_mark = p->mark; |
| 16050 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16051 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16052 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16053 | return NULL; |
| 16054 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16055 | ssize_t _children_capacity = 1; |
| 16056 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16057 | { // ',' kwarg_or_starred |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16058 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16059 | KeywordOrStarred* elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16060 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16061 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16062 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16063 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16064 | ) |
| 16065 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16066 | _res = elem; |
| 16067 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16068 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16069 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16070 | return NULL; |
| 16071 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16072 | if (_n == _children_capacity) { |
| 16073 | _children_capacity *= 2; |
| 16074 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16075 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16076 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16077 | return NULL; |
| 16078 | } |
| 16079 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16080 | _children[_n++] = _res; |
| 16081 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16082 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16083 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16084 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16085 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16086 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16087 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_114"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16088 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16089 | return NULL; |
| 16090 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16091 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16092 | PyMem_Free(_children); |
| 16093 | _PyPegen_insert_memo(p, _start_mark, _loop0_114_type, _seq); |
| 16094 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16095 | } |
| 16096 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16097 | // _gather_113: kwarg_or_starred _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16098 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16099 | _gather_113_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16100 | { |
| 16101 | if (p->error_indicator) { |
| 16102 | return NULL; |
| 16103 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16104 | asdl_seq * _res = NULL; |
| 16105 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16106 | { // kwarg_or_starred _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16107 | KeywordOrStarred* elem; |
| 16108 | asdl_seq * seq; |
| 16109 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16110 | (elem = kwarg_or_starred_rule(p)) // kwarg_or_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16111 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16112 | (seq = _loop0_114_rule(p)) // _loop0_114 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16113 | ) |
| 16114 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16115 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16116 | goto done; |
| 16117 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16118 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16119 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16120 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16121 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16122 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16123 | } |
| 16124 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16125 | // _loop0_116: ',' kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16126 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16127 | _loop0_116_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16128 | { |
| 16129 | if (p->error_indicator) { |
| 16130 | return NULL; |
| 16131 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16132 | void *_res = NULL; |
| 16133 | int _mark = p->mark; |
| 16134 | int _start_mark = p->mark; |
| 16135 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16136 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16137 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16138 | return NULL; |
| 16139 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16140 | ssize_t _children_capacity = 1; |
| 16141 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16142 | { // ',' kwarg_or_double_starred |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16143 | Token * _literal; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16144 | KeywordOrStarred* elem; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16145 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16146 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16147 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16148 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16149 | ) |
| 16150 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16151 | _res = elem; |
| 16152 | if (_res == NULL && PyErr_Occurred()) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16153 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16154 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16155 | return NULL; |
| 16156 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16157 | if (_n == _children_capacity) { |
| 16158 | _children_capacity *= 2; |
| 16159 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16160 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16161 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16162 | return NULL; |
| 16163 | } |
| 16164 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16165 | _children[_n++] = _res; |
| 16166 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16167 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16168 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16169 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16170 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16171 | if (!_seq) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16172 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_116"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16173 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16174 | return NULL; |
| 16175 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16176 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16177 | PyMem_Free(_children); |
| 16178 | _PyPegen_insert_memo(p, _start_mark, _loop0_116_type, _seq); |
| 16179 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16180 | } |
| 16181 | |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16182 | // _gather_115: kwarg_or_double_starred _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16183 | static asdl_seq * |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16184 | _gather_115_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16185 | { |
| 16186 | if (p->error_indicator) { |
| 16187 | return NULL; |
| 16188 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16189 | asdl_seq * _res = NULL; |
| 16190 | int _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16191 | { // kwarg_or_double_starred _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16192 | KeywordOrStarred* elem; |
| 16193 | asdl_seq * seq; |
| 16194 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16195 | (elem = kwarg_or_double_starred_rule(p)) // kwarg_or_double_starred |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16196 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16197 | (seq = _loop0_116_rule(p)) // _loop0_116 |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16198 | ) |
| 16199 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16200 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16201 | goto done; |
| 16202 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16203 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16204 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16205 | _res = NULL; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16206 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16207 | return _res; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16208 | } |
| 16209 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16210 | // _loop0_117: (',' star_target) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16211 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16212 | _loop0_117_rule(Parser *p) |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16213 | { |
| 16214 | if (p->error_indicator) { |
| 16215 | return NULL; |
| 16216 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16217 | void *_res = NULL; |
| 16218 | int _mark = p->mark; |
| 16219 | int _start_mark = p->mark; |
| 16220 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16221 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16222 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16223 | return NULL; |
| 16224 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16225 | ssize_t _children_capacity = 1; |
| 16226 | ssize_t _n = 0; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16227 | { // (',' star_target) |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16228 | void *_tmp_144_var; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16229 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16230 | (_tmp_144_var = _tmp_144_rule(p)) // ',' star_target |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16231 | ) |
| 16232 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16233 | _res = _tmp_144_var; |
| 16234 | if (_n == _children_capacity) { |
| 16235 | _children_capacity *= 2; |
| 16236 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16237 | if (!_children) { |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16238 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16239 | return NULL; |
| 16240 | } |
| 16241 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16242 | _children[_n++] = _res; |
| 16243 | _mark = p->mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16244 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16245 | p->mark = _mark; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16246 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16247 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16248 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16249 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_117"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16250 | PyMem_Free(_children); |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16251 | return NULL; |
| 16252 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16253 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16254 | PyMem_Free(_children); |
| 16255 | _PyPegen_insert_memo(p, _start_mark, _loop0_117_type, _seq); |
| 16256 | return _seq; |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16257 | } |
| 16258 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16259 | // _loop0_119: ',' star_target |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 16260 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16261 | _loop0_119_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16262 | { |
| 16263 | if (p->error_indicator) { |
| 16264 | return NULL; |
| 16265 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16266 | void *_res = NULL; |
| 16267 | int _mark = p->mark; |
| 16268 | int _start_mark = p->mark; |
| 16269 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16270 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16271 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16272 | return NULL; |
| 16273 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16274 | ssize_t _children_capacity = 1; |
| 16275 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16276 | { // ',' star_target |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16277 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16278 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16279 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16280 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16281 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16282 | (elem = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16283 | ) |
| 16284 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16285 | _res = elem; |
| 16286 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16287 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16288 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16289 | return NULL; |
| 16290 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16291 | if (_n == _children_capacity) { |
| 16292 | _children_capacity *= 2; |
| 16293 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16294 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16295 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16296 | return NULL; |
| 16297 | } |
| 16298 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16299 | _children[_n++] = _res; |
| 16300 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16301 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16302 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16303 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16304 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16305 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16306 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_119"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16307 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16308 | return NULL; |
| 16309 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16310 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16311 | PyMem_Free(_children); |
| 16312 | _PyPegen_insert_memo(p, _start_mark, _loop0_119_type, _seq); |
| 16313 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16314 | } |
| 16315 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16316 | // _gather_118: star_target _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16317 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16318 | _gather_118_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16319 | { |
| 16320 | if (p->error_indicator) { |
| 16321 | return NULL; |
| 16322 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16323 | asdl_seq * _res = NULL; |
| 16324 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16325 | { // star_target _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16326 | expr_ty elem; |
| 16327 | asdl_seq * seq; |
| 16328 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16329 | (elem = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16330 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16331 | (seq = _loop0_119_rule(p)) // _loop0_119 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16332 | ) |
| 16333 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16334 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16335 | goto done; |
| 16336 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16337 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16338 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16339 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16340 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16341 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16342 | } |
| 16343 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16344 | // _tmp_120: !'*' star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16345 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16346 | _tmp_120_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16347 | { |
| 16348 | if (p->error_indicator) { |
| 16349 | return NULL; |
| 16350 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16351 | void * _res = NULL; |
| 16352 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16353 | { // !'*' star_target |
| 16354 | expr_ty star_target_var; |
| 16355 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16356 | _PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 16) // token='*' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16357 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16358 | (star_target_var = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16359 | ) |
| 16360 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16361 | _res = star_target_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16362 | goto done; |
| 16363 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16364 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16365 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16366 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16367 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16368 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16369 | } |
| 16370 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16371 | // _loop0_122: ',' del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16372 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16373 | _loop0_122_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16374 | { |
| 16375 | if (p->error_indicator) { |
| 16376 | return NULL; |
| 16377 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16378 | void *_res = NULL; |
| 16379 | int _mark = p->mark; |
| 16380 | int _start_mark = p->mark; |
| 16381 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16382 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16383 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16384 | return NULL; |
| 16385 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16386 | ssize_t _children_capacity = 1; |
| 16387 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16388 | { // ',' del_target |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16389 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16390 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16391 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16392 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16393 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16394 | (elem = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16395 | ) |
| 16396 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16397 | _res = elem; |
| 16398 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16399 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16400 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16401 | return NULL; |
| 16402 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16403 | if (_n == _children_capacity) { |
| 16404 | _children_capacity *= 2; |
| 16405 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16406 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16407 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16408 | return NULL; |
| 16409 | } |
| 16410 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16411 | _children[_n++] = _res; |
| 16412 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16413 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16414 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16415 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16416 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16417 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16418 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_122"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16419 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16420 | return NULL; |
| 16421 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16422 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16423 | PyMem_Free(_children); |
| 16424 | _PyPegen_insert_memo(p, _start_mark, _loop0_122_type, _seq); |
| 16425 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16426 | } |
| 16427 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16428 | // _gather_121: del_target _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16429 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16430 | _gather_121_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16431 | { |
| 16432 | if (p->error_indicator) { |
| 16433 | return NULL; |
| 16434 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16435 | asdl_seq * _res = NULL; |
| 16436 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16437 | { // del_target _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16438 | expr_ty elem; |
| 16439 | asdl_seq * seq; |
| 16440 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16441 | (elem = del_target_rule(p)) // del_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16442 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16443 | (seq = _loop0_122_rule(p)) // _loop0_122 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16444 | ) |
| 16445 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16446 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16447 | goto done; |
| 16448 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16449 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16450 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16451 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16452 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16453 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16454 | } |
| 16455 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16456 | // _loop0_124: ',' target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16457 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16458 | _loop0_124_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16459 | { |
| 16460 | if (p->error_indicator) { |
| 16461 | return NULL; |
| 16462 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16463 | void *_res = NULL; |
| 16464 | int _mark = p->mark; |
| 16465 | int _start_mark = p->mark; |
| 16466 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16467 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16468 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16469 | return NULL; |
| 16470 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16471 | ssize_t _children_capacity = 1; |
| 16472 | ssize_t _n = 0; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16473 | { // ',' target |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16474 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16475 | expr_ty elem; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16476 | while ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16477 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16478 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16479 | (elem = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16480 | ) |
| 16481 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16482 | _res = elem; |
| 16483 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16484 | p->error_indicator = 1; |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16485 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16486 | return NULL; |
| 16487 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16488 | if (_n == _children_capacity) { |
| 16489 | _children_capacity *= 2; |
| 16490 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16491 | if (!_children) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16492 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16493 | return NULL; |
| 16494 | } |
| 16495 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16496 | _children[_n++] = _res; |
| 16497 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16498 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16499 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16500 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16501 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16502 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16503 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_124"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16504 | PyMem_Free(_children); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16505 | return NULL; |
| 16506 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16507 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16508 | PyMem_Free(_children); |
| 16509 | _PyPegen_insert_memo(p, _start_mark, _loop0_124_type, _seq); |
| 16510 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16511 | } |
| 16512 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16513 | // _gather_123: target _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16514 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16515 | _gather_123_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16516 | { |
| 16517 | if (p->error_indicator) { |
| 16518 | return NULL; |
| 16519 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16520 | asdl_seq * _res = NULL; |
| 16521 | int _mark = p->mark; |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16522 | { // target _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16523 | expr_ty elem; |
| 16524 | asdl_seq * seq; |
| 16525 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16526 | (elem = target_rule(p)) // target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16527 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16528 | (seq = _loop0_124_rule(p)) // _loop0_124 |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16529 | ) |
| 16530 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16531 | _res = _PyPegen_seq_insert_in_front(p, elem, seq); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16532 | goto done; |
| 16533 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16534 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16535 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16536 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16537 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16538 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16539 | } |
| 16540 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16541 | // _tmp_125: args | expression for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16542 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16543 | _tmp_125_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16544 | { |
| 16545 | if (p->error_indicator) { |
| 16546 | return NULL; |
| 16547 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16548 | void * _res = NULL; |
| 16549 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16550 | { // args |
| 16551 | expr_ty args_var; |
| 16552 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16553 | (args_var = args_rule(p)) // args |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16554 | ) |
| 16555 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16556 | _res = args_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16557 | goto done; |
| 16558 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16559 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16560 | } |
| 16561 | { // expression for_if_clauses |
| 16562 | expr_ty expression_var; |
| 16563 | asdl_seq* for_if_clauses_var; |
| 16564 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16565 | (expression_var = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16566 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16567 | (for_if_clauses_var = for_if_clauses_rule(p)) // for_if_clauses |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16568 | ) |
| 16569 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16570 | _res = _PyPegen_dummy_name(p, expression_var, for_if_clauses_var); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16571 | goto done; |
| 16572 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16573 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16574 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16575 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16576 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16577 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16578 | } |
| 16579 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16580 | // _tmp_126: '=' annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16581 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16582 | _tmp_126_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16583 | { |
| 16584 | if (p->error_indicator) { |
| 16585 | return NULL; |
| 16586 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16587 | void * _res = NULL; |
| 16588 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16589 | { // '=' annotated_rhs |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16590 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16591 | expr_ty annotated_rhs_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16592 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16593 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16594 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16595 | (annotated_rhs_var = annotated_rhs_rule(p)) // annotated_rhs |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16596 | ) |
| 16597 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16598 | _res = _PyPegen_dummy_name(p, _literal, annotated_rhs_var); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16599 | goto done; |
| 16600 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16601 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16602 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16603 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16604 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16605 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16606 | } |
| 16607 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16608 | // _tmp_127: '=' | augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16609 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16610 | _tmp_127_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16611 | { |
| 16612 | if (p->error_indicator) { |
| 16613 | return NULL; |
| 16614 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16615 | void * _res = NULL; |
| 16616 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16617 | { // '=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16618 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16619 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16620 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16621 | ) |
| 16622 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16623 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16624 | goto done; |
| 16625 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16626 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16627 | } |
| 16628 | { // augassign |
| 16629 | AugOperator* augassign_var; |
| 16630 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16631 | (augassign_var = augassign_rule(p)) // augassign |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16632 | ) |
| 16633 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16634 | _res = augassign_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16635 | goto done; |
| 16636 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16637 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16638 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16639 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16640 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16641 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16642 | } |
| 16643 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16644 | // _tmp_128: yield_expr | star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16645 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16646 | _tmp_128_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16647 | { |
| 16648 | if (p->error_indicator) { |
| 16649 | return NULL; |
| 16650 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16651 | void * _res = NULL; |
| 16652 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16653 | { // yield_expr |
| 16654 | expr_ty yield_expr_var; |
| 16655 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16656 | (yield_expr_var = yield_expr_rule(p)) // yield_expr |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16657 | ) |
| 16658 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16659 | _res = yield_expr_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16660 | goto done; |
| 16661 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16662 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16663 | } |
| 16664 | { // star_expressions |
| 16665 | expr_ty star_expressions_var; |
| 16666 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16667 | (star_expressions_var = star_expressions_rule(p)) // star_expressions |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16668 | ) |
| 16669 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16670 | _res = star_expressions_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16671 | goto done; |
| 16672 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16673 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16674 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16675 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16676 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16677 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16678 | } |
| 16679 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16680 | // _tmp_129: '[' | '(' | '{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16681 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16682 | _tmp_129_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16683 | { |
| 16684 | if (p->error_indicator) { |
| 16685 | return NULL; |
| 16686 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16687 | void * _res = NULL; |
| 16688 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16689 | { // '[' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16690 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16691 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16692 | (_literal = _PyPegen_expect_token(p, 9)) // token='[' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16693 | ) |
| 16694 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16695 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16696 | goto done; |
| 16697 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16698 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16699 | } |
| 16700 | { // '(' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16701 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16702 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16703 | (_literal = _PyPegen_expect_token(p, 7)) // token='(' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16704 | ) |
| 16705 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16706 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16707 | goto done; |
| 16708 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16709 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16710 | } |
| 16711 | { // '{' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16712 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16713 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16714 | (_literal = _PyPegen_expect_token(p, 25)) // token='{' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16715 | ) |
| 16716 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16717 | _res = _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16718 | goto done; |
| 16719 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16720 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16721 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16722 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16723 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16724 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16725 | } |
| 16726 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16727 | // _loop0_130: param_no_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16728 | static asdl_seq * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16729 | _loop0_130_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16730 | { |
| 16731 | if (p->error_indicator) { |
| 16732 | return NULL; |
| 16733 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16734 | void *_res = NULL; |
| 16735 | int _mark = p->mark; |
| 16736 | int _start_mark = p->mark; |
| 16737 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 16738 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16739 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 16740 | return NULL; |
| 16741 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16742 | ssize_t _children_capacity = 1; |
| 16743 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16744 | { // param_no_default |
| 16745 | arg_ty param_no_default_var; |
| 16746 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16747 | (param_no_default_var = param_no_default_rule(p)) // param_no_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16748 | ) |
| 16749 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16750 | _res = param_no_default_var; |
| 16751 | if (_n == _children_capacity) { |
| 16752 | _children_capacity *= 2; |
| 16753 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 16754 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16755 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 16756 | return NULL; |
| 16757 | } |
| 16758 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16759 | _children[_n++] = _res; |
| 16760 | _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16761 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16762 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16763 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16764 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 16765 | if (!_seq) { |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16766 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop0_130"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16767 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16768 | return NULL; |
| 16769 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16770 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 16771 | PyMem_Free(_children); |
| 16772 | _PyPegen_insert_memo(p, _start_mark, _loop0_130_type, _seq); |
| 16773 | return _seq; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16774 | } |
| 16775 | |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16776 | // _tmp_131: slash_with_default | param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16777 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16778 | _tmp_131_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16779 | { |
| 16780 | if (p->error_indicator) { |
| 16781 | return NULL; |
| 16782 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16783 | void * _res = NULL; |
| 16784 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16785 | { // slash_with_default |
| 16786 | SlashWithDefault* slash_with_default_var; |
| 16787 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16788 | (slash_with_default_var = slash_with_default_rule(p)) // slash_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16789 | ) |
| 16790 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16791 | _res = slash_with_default_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16792 | goto done; |
| 16793 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16794 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16795 | } |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 16796 | { // param_with_default+ |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16797 | asdl_seq * _loop1_145_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16798 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16799 | (_loop1_145_var = _loop1_145_rule(p)) // param_with_default+ |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16800 | ) |
| 16801 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16802 | _res = _loop1_145_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16803 | goto done; |
| 16804 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16805 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16806 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16807 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16808 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16809 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16810 | } |
| 16811 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16812 | // _tmp_132: ')' | ',' (')' | '**') |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16813 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16814 | _tmp_132_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16815 | { |
| 16816 | if (p->error_indicator) { |
| 16817 | return NULL; |
| 16818 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16819 | void * _res = NULL; |
| 16820 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16821 | { // ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16822 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16823 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16824 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16825 | ) |
| 16826 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16827 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16828 | goto done; |
| 16829 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16830 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16831 | } |
| 16832 | { // ',' (')' | '**') |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16833 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16834 | void *_tmp_146_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16835 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16836 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16837 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16838 | (_tmp_146_var = _tmp_146_rule(p)) // ')' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16839 | ) |
| 16840 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16841 | _res = _PyPegen_dummy_name(p, _literal, _tmp_146_var); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16842 | goto done; |
| 16843 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16844 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16845 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16846 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16847 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16848 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16849 | } |
| 16850 | |
| 16851 | // _tmp_133: ':' | ',' (':' | '**') |
| 16852 | static void * |
| 16853 | _tmp_133_rule(Parser *p) |
| 16854 | { |
| 16855 | if (p->error_indicator) { |
| 16856 | return NULL; |
| 16857 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16858 | void * _res = NULL; |
| 16859 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16860 | { // ':' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16861 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16862 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16863 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16864 | ) |
| 16865 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16866 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16867 | goto done; |
| 16868 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16869 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16870 | } |
| 16871 | { // ',' (':' | '**') |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16872 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16873 | void *_tmp_147_var; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16874 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16875 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16876 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16877 | (_tmp_147_var = _tmp_147_rule(p)) // ':' | '**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16878 | ) |
| 16879 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16880 | _res = _PyPegen_dummy_name(p, _literal, _tmp_147_var); |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16881 | goto done; |
| 16882 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16883 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16884 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16885 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16886 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16887 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16888 | } |
| 16889 | |
| 16890 | // _tmp_134: star_targets '=' |
| 16891 | static void * |
| 16892 | _tmp_134_rule(Parser *p) |
| 16893 | { |
| 16894 | if (p->error_indicator) { |
| 16895 | return NULL; |
| 16896 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16897 | void * _res = NULL; |
| 16898 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16899 | { // star_targets '=' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16900 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16901 | expr_ty z; |
| 16902 | if ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 16903 | (z = star_targets_rule(p)) // star_targets |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16904 | && |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16905 | (_literal = _PyPegen_expect_token(p, 22)) // token='=' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16906 | ) |
| 16907 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16908 | _res = z; |
| 16909 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16910 | p->error_indicator = 1; |
| 16911 | return NULL; |
| 16912 | } |
| 16913 | goto done; |
| 16914 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16915 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16916 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16917 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16918 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16919 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16920 | } |
| 16921 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16922 | // _tmp_135: '.' | '...' |
Pablo Galindo | 2b74c83 | 2020-04-27 18:02:07 +0100 | [diff] [blame] | 16923 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 16924 | _tmp_135_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 16925 | { |
| 16926 | if (p->error_indicator) { |
| 16927 | return NULL; |
| 16928 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16929 | void * _res = NULL; |
| 16930 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16931 | { // '.' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16932 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16933 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16934 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16935 | ) |
| 16936 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16937 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16938 | goto done; |
| 16939 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16940 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16941 | } |
| 16942 | { // '...' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16943 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16944 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16945 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16946 | ) |
| 16947 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16948 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16949 | goto done; |
| 16950 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16951 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16952 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16953 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16954 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16955 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16956 | } |
| 16957 | |
| 16958 | // _tmp_136: '.' | '...' |
| 16959 | static void * |
| 16960 | _tmp_136_rule(Parser *p) |
| 16961 | { |
| 16962 | if (p->error_indicator) { |
| 16963 | return NULL; |
| 16964 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16965 | void * _res = NULL; |
| 16966 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16967 | { // '.' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16968 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16969 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16970 | (_literal = _PyPegen_expect_token(p, 23)) // token='.' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16971 | ) |
| 16972 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16973 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16974 | goto done; |
| 16975 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16976 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16977 | } |
| 16978 | { // '...' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16979 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16980 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16981 | (_literal = _PyPegen_expect_token(p, 52)) // token='...' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16982 | ) |
| 16983 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16984 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16985 | goto done; |
| 16986 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16987 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16988 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16989 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16990 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 16991 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 16992 | } |
| 16993 | |
| 16994 | // _tmp_137: '@' named_expression NEWLINE |
| 16995 | static void * |
| 16996 | _tmp_137_rule(Parser *p) |
| 16997 | { |
| 16998 | if (p->error_indicator) { |
| 16999 | return NULL; |
| 17000 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17001 | void * _res = NULL; |
| 17002 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17003 | { // '@' named_expression NEWLINE |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17004 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17005 | expr_ty f; |
Pablo Galindo | b796b3f | 2020-05-01 12:32:26 +0100 | [diff] [blame] | 17006 | Token * newline_var; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17007 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17008 | (_literal = _PyPegen_expect_token(p, 49)) // token='@' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17009 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17010 | (f = named_expression_rule(p)) // named_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17011 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17012 | (newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17013 | ) |
| 17014 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17015 | _res = f; |
| 17016 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17017 | p->error_indicator = 1; |
| 17018 | return NULL; |
| 17019 | } |
| 17020 | goto done; |
| 17021 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17022 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17023 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17024 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17025 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17026 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17027 | } |
| 17028 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17029 | // _tmp_138: ',' star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17030 | static void * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17031 | _tmp_138_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17032 | { |
| 17033 | if (p->error_indicator) { |
| 17034 | return NULL; |
| 17035 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17036 | void * _res = NULL; |
| 17037 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17038 | { // ',' star_expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17039 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17040 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17041 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17042 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17043 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17044 | (c = star_expression_rule(p)) // star_expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17045 | ) |
| 17046 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17047 | _res = c; |
| 17048 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17049 | p->error_indicator = 1; |
| 17050 | return NULL; |
| 17051 | } |
| 17052 | goto done; |
| 17053 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17054 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17055 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17056 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17057 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17058 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17059 | } |
| 17060 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17061 | // _tmp_139: ',' expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17062 | static void * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17063 | _tmp_139_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17064 | { |
| 17065 | if (p->error_indicator) { |
| 17066 | return NULL; |
| 17067 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17068 | void * _res = NULL; |
| 17069 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17070 | { // ',' expression |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17071 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17072 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17073 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17074 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17075 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17076 | (c = expression_rule(p)) // expression |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17077 | ) |
| 17078 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17079 | _res = c; |
| 17080 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17081 | p->error_indicator = 1; |
| 17082 | return NULL; |
| 17083 | } |
| 17084 | goto done; |
| 17085 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17086 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17087 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17088 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17089 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17090 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17091 | } |
| 17092 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17093 | // _tmp_140: 'or' conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17094 | static void * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17095 | _tmp_140_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17096 | { |
| 17097 | if (p->error_indicator) { |
| 17098 | return NULL; |
| 17099 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17100 | void * _res = NULL; |
| 17101 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17102 | { // 'or' conjunction |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17103 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17104 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17105 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17106 | (_keyword = _PyPegen_expect_token(p, 532)) // token='or' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17107 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17108 | (c = conjunction_rule(p)) // conjunction |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17109 | ) |
| 17110 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17111 | _res = c; |
| 17112 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17113 | p->error_indicator = 1; |
| 17114 | return NULL; |
| 17115 | } |
| 17116 | goto done; |
| 17117 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17118 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17119 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17120 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17121 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17122 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17123 | } |
| 17124 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17125 | // _tmp_141: 'and' inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17126 | static void * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17127 | _tmp_141_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17128 | { |
| 17129 | if (p->error_indicator) { |
| 17130 | return NULL; |
| 17131 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17132 | void * _res = NULL; |
| 17133 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17134 | { // 'and' inversion |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17135 | Token * _keyword; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17136 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17137 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17138 | (_keyword = _PyPegen_expect_token(p, 533)) // token='and' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17139 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17140 | (c = inversion_rule(p)) // inversion |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17141 | ) |
| 17142 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17143 | _res = c; |
| 17144 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17145 | p->error_indicator = 1; |
| 17146 | return NULL; |
| 17147 | } |
| 17148 | goto done; |
| 17149 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17150 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17151 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17152 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17153 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17154 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17155 | } |
| 17156 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17157 | // _tmp_142: 'if' disjunction |
Lysandros Nikolaou | 3e0a6f3 | 2020-05-01 06:27:52 +0300 | [diff] [blame] | 17158 | static void * |
Guido van Rossum | 3941d97 | 2020-05-01 09:42:03 -0700 | [diff] [blame] | 17159 | _tmp_142_rule(Parser *p) |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17160 | { |
| 17161 | if (p->error_indicator) { |
| 17162 | return NULL; |
| 17163 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17164 | void * _res = NULL; |
| 17165 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17166 | { // 'if' disjunction |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17167 | Token * _keyword; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17168 | expr_ty z; |
| 17169 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17170 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17171 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17172 | (z = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17173 | ) |
| 17174 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17175 | _res = z; |
| 17176 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17177 | p->error_indicator = 1; |
| 17178 | return NULL; |
| 17179 | } |
| 17180 | goto done; |
| 17181 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17182 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17183 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17184 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17185 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17186 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17187 | } |
| 17188 | |
| 17189 | // _tmp_143: 'if' disjunction |
| 17190 | static void * |
| 17191 | _tmp_143_rule(Parser *p) |
| 17192 | { |
| 17193 | if (p->error_indicator) { |
| 17194 | return NULL; |
| 17195 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17196 | void * _res = NULL; |
| 17197 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17198 | { // 'if' disjunction |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17199 | Token * _keyword; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17200 | expr_ty z; |
| 17201 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17202 | (_keyword = _PyPegen_expect_token(p, 510)) // token='if' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17203 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17204 | (z = disjunction_rule(p)) // disjunction |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17205 | ) |
| 17206 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17207 | _res = z; |
| 17208 | if (_res == NULL && PyErr_Occurred()) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17209 | p->error_indicator = 1; |
| 17210 | return NULL; |
| 17211 | } |
| 17212 | goto done; |
| 17213 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17214 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17215 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17216 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17217 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17218 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17219 | } |
| 17220 | |
| 17221 | // _tmp_144: ',' star_target |
| 17222 | static void * |
| 17223 | _tmp_144_rule(Parser *p) |
| 17224 | { |
| 17225 | if (p->error_indicator) { |
| 17226 | return NULL; |
| 17227 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17228 | void * _res = NULL; |
| 17229 | int _mark = p->mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17230 | { // ',' star_target |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17231 | Token * _literal; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17232 | expr_ty c; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17233 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17234 | (_literal = _PyPegen_expect_token(p, 12)) // token=',' |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17235 | && |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17236 | (c = star_target_rule(p)) // star_target |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17237 | ) |
| 17238 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17239 | _res = c; |
| 17240 | if (_res == NULL && PyErr_Occurred()) { |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17241 | p->error_indicator = 1; |
| 17242 | return NULL; |
| 17243 | } |
| 17244 | goto done; |
| 17245 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17246 | p->mark = _mark; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17247 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17248 | _res = NULL; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17249 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17250 | return _res; |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17251 | } |
| 17252 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17253 | // _loop1_145: param_with_default |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17254 | static asdl_seq * |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17255 | _loop1_145_rule(Parser *p) |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17256 | { |
| 17257 | if (p->error_indicator) { |
| 17258 | return NULL; |
| 17259 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17260 | void *_res = NULL; |
| 17261 | int _mark = p->mark; |
| 17262 | int _start_mark = p->mark; |
| 17263 | void **_children = PyMem_Malloc(sizeof(void *)); |
| 17264 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17265 | PyErr_Format(PyExc_MemoryError, "Parser out of memory"); |
| 17266 | return NULL; |
| 17267 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17268 | ssize_t _children_capacity = 1; |
| 17269 | ssize_t _n = 0; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17270 | { // param_with_default |
| 17271 | NameDefaultPair* param_with_default_var; |
| 17272 | while ( |
Pablo Galindo | 470aac4 | 2020-05-06 23:14:43 +0100 | [diff] [blame] | 17273 | (param_with_default_var = param_with_default_rule(p)) // param_with_default |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17274 | ) |
| 17275 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17276 | _res = param_with_default_var; |
| 17277 | if (_n == _children_capacity) { |
| 17278 | _children_capacity *= 2; |
| 17279 | _children = PyMem_Realloc(_children, _children_capacity*sizeof(void *)); |
| 17280 | if (!_children) { |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17281 | PyErr_Format(PyExc_MemoryError, "realloc None"); |
| 17282 | return NULL; |
| 17283 | } |
| 17284 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17285 | _children[_n++] = _res; |
| 17286 | _mark = p->mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17287 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17288 | p->mark = _mark; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17289 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17290 | if (_n == 0 || p->error_indicator) { |
| 17291 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17292 | return NULL; |
| 17293 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17294 | asdl_seq *_seq = _Py_asdl_seq_new(_n, p->arena); |
| 17295 | if (!_seq) { |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17296 | PyErr_Format(PyExc_MemoryError, "asdl_seq_new _loop1_145"); |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17297 | PyMem_Free(_children); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17298 | return NULL; |
| 17299 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17300 | for (int i = 0; i < _n; i++) asdl_seq_SET(_seq, i, _children[i]); |
| 17301 | PyMem_Free(_children); |
| 17302 | _PyPegen_insert_memo(p, _start_mark, _loop1_145_type, _seq); |
| 17303 | return _seq; |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17304 | } |
| 17305 | |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17306 | // _tmp_146: ')' | '**' |
| 17307 | static void * |
| 17308 | _tmp_146_rule(Parser *p) |
| 17309 | { |
| 17310 | if (p->error_indicator) { |
| 17311 | return NULL; |
| 17312 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17313 | void * _res = NULL; |
| 17314 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17315 | { // ')' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17316 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17317 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17318 | (_literal = _PyPegen_expect_token(p, 8)) // token=')' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17319 | ) |
| 17320 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17321 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17322 | goto done; |
| 17323 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17324 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17325 | } |
| 17326 | { // '**' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17327 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17328 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17329 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17330 | ) |
| 17331 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17332 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17333 | goto done; |
| 17334 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17335 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17336 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17337 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17338 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17339 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17340 | } |
| 17341 | |
| 17342 | // _tmp_147: ':' | '**' |
| 17343 | static void * |
| 17344 | _tmp_147_rule(Parser *p) |
| 17345 | { |
| 17346 | if (p->error_indicator) { |
| 17347 | return NULL; |
| 17348 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17349 | void * _res = NULL; |
| 17350 | int _mark = p->mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17351 | { // ':' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17352 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17353 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17354 | (_literal = _PyPegen_expect_token(p, 11)) // token=':' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17355 | ) |
| 17356 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17357 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17358 | goto done; |
| 17359 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17360 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17361 | } |
| 17362 | { // '**' |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17363 | Token * _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17364 | if ( |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17365 | (_literal = _PyPegen_expect_token(p, 35)) // token='**' |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17366 | ) |
| 17367 | { |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17368 | _res = _literal; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17369 | goto done; |
| 17370 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17371 | p->mark = _mark; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17372 | } |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17373 | _res = NULL; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17374 | done: |
Pablo Galindo | ac7a92c | 2020-05-10 05:34:50 +0100 | [diff] [blame] | 17375 | return _res; |
Lysandros Nikolaou | e10e7c7 | 2020-05-04 13:58:31 +0300 | [diff] [blame] | 17376 | } |
| 17377 | |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17378 | void * |
| 17379 | _PyPegen_parse(Parser *p) |
| 17380 | { |
| 17381 | // Initialize keywords |
| 17382 | p->keywords = reserved_keywords; |
| 17383 | p->n_keyword_lists = n_keyword_lists; |
| 17384 | |
| 17385 | // Run parser |
| 17386 | void *result = NULL; |
| 17387 | if (p->start_rule == Py_file_input) { |
| 17388 | result = file_rule(p); |
| 17389 | } else if (p->start_rule == Py_single_input) { |
| 17390 | result = interactive_rule(p); |
| 17391 | } else if (p->start_rule == Py_eval_input) { |
| 17392 | result = eval_rule(p); |
Guido van Rossum | c001c09 | 2020-04-30 12:12:19 -0700 | [diff] [blame] | 17393 | } else if (p->start_rule == Py_func_type_input) { |
| 17394 | result = func_type_rule(p); |
Pablo Galindo | c5fc156 | 2020-04-22 23:29:27 +0100 | [diff] [blame] | 17395 | } else if (p->start_rule == Py_fstring_input) { |
| 17396 | result = fstring_rule(p); |
| 17397 | } |
| 17398 | |
| 17399 | return result; |
| 17400 | } |
| 17401 | |
| 17402 | // The end |